hxp
5 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package Item_ResetAttrPoint
# @todo: Ï´µã¾íÖá
#
# @author: xdh
# @date 2017-12-15
# @version 1.0
#
#---------------------------------------------------------------------
#"""Version = 2017-12-15 17:40"""
#---------------------------------------------------------------------
 
import ChPlayer
import PlayerControl
import DataRecordPack
import IpyGameDataPY
import ItemCommon
import ChConfig
import SkillShell
 
##ÅúÁ¿Ê¹ÓÃÎïÆ·
# @param curPlayer: Íæ¼ÒʵÀý
# @param curRoleItem: ÎïÆ·ÊµÀý
# @param tick: Ê±¼ä´Á
# @param useCnt: Ê¹ÓøöÊý
# @return: 
def BatchUseItem(curPlayer, curRoleItem, tick, useCnt, exData):
    curEff = curRoleItem.GetEffectByIndex(0)
    effectID = curEff.GetEffectID()
    if effectID != ChConfig.Def_Effect_ResetAttrPoint:
        return
    resetID = curEff.GetEffectValue(0)
    if not resetID and exData:
        resetID = exData
    resetPoint = curEff.GetEffectValue(1) * useCnt
    if not DoResetAttrPoint(curPlayer, resetID, resetPoint, curRoleItem.GetItemTypeID()):
        return
    
    #¿Û³ýÎïÆ·
    ItemCommon.DelItem(curPlayer, curRoleItem, useCnt, True, ChConfig.ItemDel_ResetAttrPoint)
    return True, useCnt
 
def DoResetAttrPoint(curPlayer, resetID, resetPoint, useItemID=0):
    '''ÖØÖÃÁé¸ùÊôÐÔµã
    @param resetID: ÖØÖÃÊôÐÔID£¬0ÎªÖØÖÃÈ«²¿
    @param resetPoint: ÖØÖõãÊý£¬0ÎªÖØÖÃÈ«²¿
    '''
    
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    canResetIDList = [ipyDataMgr.GetRolePointByIndex(index).GetAttrID() for index in xrange(ipyDataMgr.GetRolePointCount())]
    if resetID == 0:
        resetIDList = canResetIDList
        resetValueList = [resetPoint for _ in xrange(len(canResetIDList))]
    elif resetID in canResetIDList:
        resetIDList = [resetID]
        resetValueList = [resetPoint]
    else:
        return
    
    resetPointTotal = 0
    for i, resetID in enumerate(resetIDList):
        resetPoint = resetValueList[i]
        curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AddPointValue % resetID)
        if not resetPoint:
            realResetPoint = curPoint
        else:
            realResetPoint = min(resetPoint, curPoint)
        if not realResetPoint:
            continue
        resetPointTotal += realResetPoint
        updPoint = max(curPoint - realResetPoint, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AddPointValue % resetID, updPoint)
        if useItemID:
            PlayerControl.NotifyCode(curPlayer, 'WashPoint2', [useItemID, resetID, realResetPoint, updPoint])
            
    freePoint = curPlayer.GetFreePoint()
    curPlayer.SetFreePoint(freePoint + resetPointTotal)
    ChPlayer.NotifyPlayerBasePoint(curPlayer, resetIDList)
    DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_ResetPoint, {'resetIDList':resetIDList, 'resetPointTotal':resetPointTotal})
    
    #Ë¢ÐÂÈËÎïËùÓÐ״̬
    playerControl = PlayerControl.PlayerControl(curPlayer)
    playerControl.RefreshPlayerAttrState()
    return True
 
## Âß¼­ÊµÏÖ //·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param curRoleItem µ±Ç°Ö÷½ÇʹÓõÄÎïÆ·
#  @param tick µ±Ç°Ê±¼ä
#  @return True or False ·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def UseItem(curPlayer, curRoleItem, tick):
    return BatchUseItem(curPlayer, curRoleItem, tick, 1, 0)