#!/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  
 | 
import IpyGameDataPY  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#Â߼ʵÏÖ  
 | 
## GMÃüÁîÖ´ÐÐÈë¿Ú  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param cmdList ²ÎÊýÁбí [packType, index, starLV]  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def OnExec(curPlayer, cmdList):  
 | 
    if not cmdList:  
 | 
        __GMHelpAnswer(curPlayer)  
 | 
        return  
 | 
      
 | 
    classLV = 0  
 | 
    allIndexList = Operate_EquipWash.GetAllEquipWashPlace()  
 | 
    syncPlace = -1  
 | 
    if len(cmdList) == 1 and cmdList[0] == 0:  
 | 
        for index in allIndexList:  
 | 
            Operate_EquipWash.SetEquipWashLV(curPlayer, index, 0)  
 | 
            for attrNum in range(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1):  
 | 
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValue % (index, attrNum), 0)  
 | 
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValueTemp % (index, attrNum), 0)  
 | 
        GameWorld.DebugLog("ÖØÖÃËùÓÐÏ´Á·Êý¾Ý")  
 | 
                  
 | 
    elif len(cmdList) == 2:  
 | 
        isSync = False  
 | 
        washLV, attrPer = cmdList  
 | 
        for equipPackindex in allIndexList:  
 | 
            ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex':equipPackindex})  
 | 
            if not ipyData:  
 | 
                continue  
 | 
            equipPlace = ipyData.GetEquipPlace()  
 | 
            maxWashLV = Operate_EquipWash.GetEquipWashMaxLV(curPlayer, equipPackindex, equipPlace)  
 | 
            #if maxWashLV < 1:  
 | 
            #    continue  
 | 
            __SetEquipPlaceWashLV(curPlayer, equipPackindex, equipPlace, washLV, attrPer, maxWashLV)  
 | 
            isSync = True  
 | 
        if not isSync:  
 | 
            return  
 | 
              
 | 
    elif len(cmdList) == 4:  
 | 
        classLV, place, washLV, attrPer = cmdList  
 | 
        ipyData = IpyGameDataPY.GetIpyGameData('EquipPlaceIndexMap', classLV, place)  
 | 
        if not ipyData:  
 | 
            return  
 | 
          
 | 
        gridIndex = ipyData.GetGridIndex()  
 | 
        syncPlace = gridIndex  
 | 
        maxWashLV = Operate_EquipWash.GetEquipWashMaxLV(curPlayer, gridIndex, place)  
 | 
        #if maxWashLV < 1:  
 | 
        #    return  
 | 
        __SetEquipPlaceWashLV(curPlayer, gridIndex, place, washLV, attrPer, maxWashLV)  
 | 
          
 | 
    else:  
 | 
        __GMHelpAnswer(curPlayer)  
 | 
        return  
 | 
      
 | 
    Operate_EquipWash.RefreshEquipWashAttr(curPlayer, classLV)  
 | 
    Operate_EquipWash.Sycn_EquipWashInfo(curPlayer, syncPlace)  
 | 
    return  
 | 
  
 | 
def __SetEquipPlaceWashLV(curPlayer, equipPackindex, place, washLV, attrPer, maxWashLV):  
 | 
    washLV = min(maxWashLV, washLV)  
 | 
    washLV = max(0, washLV)  
 | 
    attrPer = max(0, attrPer)  
 | 
    attrPer = min(100, attrPer)  
 | 
      
 | 
    washType = Operate_EquipWash.GetEquipWashType(place)  
 | 
    washData = Operate_EquipWash.GetEquipWashData(washType, washLV)  
 | 
    preWashData = None if washLV <= 0 else Operate_EquipWash.GetEquipWashData(washType, washLV - 1)  
 | 
      
 | 
    #GameWorld.DebugLog("ÉèÖÃÏ´Á·: place=%s,washType=%s,washLV=%s,attrPer=%s" % (place, washType, washLV, attrPer))  
 | 
    Operate_EquipWash.SetEquipWashLV(curPlayer, equipPackindex, washLV)  
 | 
    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 % (equipPackindex, attrNum), value)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipWashValueTemp % (equipPackindex, attrNum), 0)  
 | 
        #GameWorld.DebugLog("    attrNum=%s,value=%s" % (attrNum, value))  
 | 
          
 | 
    return  
 | 
  
 | 
def __GMHelpAnswer(curPlayer):  
 | 
    GameWorld.DebugAnswer(curPlayer, "ÖØÖÃËùÓв¿Î»Ï´Á·: SetEquipWash 0")  
 | 
    GameWorld.DebugAnswer(curPlayer, "ÉèÖÃËùÓв¿Î»Ï´Á·: SetEquipWash µÈ¼¶ °Ù·Ö±È")  
 | 
    GameWorld.DebugAnswer(curPlayer, "ÉèÖÃÖ¸¶¨²¿Î»Ï´Á·: SetEquipWash ½×¼¶ ×°±¸Î» µÈ¼¶ °Ù·Ö±È")  
 | 
    return  
 | 
  
 | 
  
 |