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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.SetEquipWash
#
# @todo:ÉèÖÃ×°±¸Ï´Á·
# @author hxp
# @date 2017-08-09
# @version 1.0
#
# ÏêϸÃèÊö: ÉèÖÃ×°±¸Ï´Á·
#
#-------------------------------------------------------------------------------
#"""Version = 2017-08-09 15:00"""
#-------------------------------------------------------------------------------
import Operate_EquipWash
import PlayerControl
import ChConfig
import GameWorld
 
#---------------------------------------------------------------------
#Âß¼­ÊµÏÖ
## GMÃüÁîÖ´ÐÐÈë¿Ú
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param cmdList ²ÎÊýÁбí [packType, index, starLV]
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(curPlayer, cmdList):
    if not cmdList:
        GameWorld.DebugAnswer(curPlayer, "ÖØÖÃËùÓв¿Î»Ï´Á·ÐÅÏ¢: SetEquipWash 0")
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃËùÓв¿Î»Ï´Á·ÐÅÏ¢: SetEquipWash Ï´Á·µÈ¼¶ µ±Ç°µÈ¼¶Ï´Á·ÊôÐÔ°Ù·Ö±È")
        GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÖ¸¶¨²¿Î»Ï´Á·ÐÅÏ¢: SetEquipWash ×°±¸Î» Ï´Á·µÈ¼¶ µ±Ç°µÈ¼¶Ï´Á·ÊôÐÔ°Ù·Ö±È")
        return
    
    placeList = Operate_EquipWash.GetAllEquipWashPlace()
    syncPlace = -1
    if len(cmdList) == 1 and cmdList[0] == 0:
        for place in placeList:
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashLV % (place), 0)
            for attrNum in range(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1):
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValue % (place, attrNum), 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValueTemp % (place, attrNum), 0)
        GameWorld.DebugLog("ÖØÖÃËùÓÐÏ´Á·Êý¾Ý")
                
    elif len(cmdList) == 2:
        isSync = False
        washLV, attrPer = cmdList
        for place in placeList:
            maxWashLV = Operate_EquipWash.GetEquipWashMaxLV(curPlayer, place)
            if maxWashLV < 1:
                continue
            __SetEquipPlaceWashLV(curPlayer, place, washLV, attrPer, maxWashLV)
            isSync = True
        if not isSync:
            return
            
    elif len(cmdList) == 3:
        place, washLV, attrPer = cmdList
        if place not in placeList:
            return
        syncPlace = place
        maxWashLV = Operate_EquipWash.GetEquipWashMaxLV(curPlayer, place)
        if maxWashLV < 1:
            return
        __SetEquipPlaceWashLV(curPlayer, place, washLV, attrPer, maxWashLV)
        
    else:
        return
    
    Operate_EquipWash.RefreshEquipWashAttr(curPlayer)
    Operate_EquipWash.Sycn_EquipWashInfo(curPlayer, syncPlace)
    return
 
def __SetEquipPlaceWashLV(curPlayer, place, washLV, attrPer, maxWashLV):
    washLV = min(maxWashLV, washLV)
    washLV = max(1, washLV)
    attrPer = max(0, attrPer)
    attrPer = min(100, attrPer)
    
    washType = Operate_EquipWash.GetEquipWashType(place)
    washData = Operate_EquipWash.GetEquipWashData(washType, washLV)
    preWashData = None if washLV <= 1 else Operate_EquipWash.GetEquipWashData(washType, washLV - 1)
    
    #GameWorld.DebugLog("ÉèÖÃÏ´Á·: place=%s,washType=%s,washLV=%s,attrPer=%s" % (place, washType, washLV, attrPer))
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashLV % (place), washLV - 1)
    for attrNum in range(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1):
        preMaxValue = 0 if not preWashData else getattr(preWashData, "GetAttrMax%s" % attrNum)()
        curMaxValue = getattr(washData, "GetAttrMax%s" % attrNum)()
        value = preMaxValue + int((curMaxValue - preMaxValue) * attrPer / 100.0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValue % (place, attrNum), value)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValueTemp % (place, attrNum), 0)
        #GameWorld.DebugLog("    attrNum=%s,value=%s" % (attrNum, value))
        
    return