#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GM.Commands.AddLegendAttr
|
#
|
# @todo:Ìí¼Ó/ÖØÐÂÉú³É´«ÆæÊôÐÔ
|
# @author hxp
|
# @date 2017-08-23
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: Ìí¼Ó/ÖØÐÂÉú³É´«ÆæÊôÐÔ
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2017-08-23 23:00"""
|
#-------------------------------------------------------------------------------
|
|
import GameWorld
|
import ItemCommon
|
import ItemControler
|
import IPY_GameWorld
|
import IpyGameDataPY
|
import ShareDefine
|
import ChConfig
|
|
import random
|
|
#---------------------------------------------------------------------
|
#Â߼ʵÏÖ
|
## GMÃüÁîÖ´ÐÐÈë¿Ú
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param cmdList ²ÎÊýÁбí [index£¬attrIndexList]
|
# @return None
|
def OnExec(curPlayer, cmdList):
|
cmdlen = len(cmdList)
|
if cmdlen < 1:
|
GameWorld.DebugAnswer(curPlayer, "ÖØÐÂËæ»ú´«ÆæÊôÐÔ: AddLegendAttr ±³°ü¸ñ×ÓË÷Òý")
|
GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓÖ¸¶¨´«ÆæÊôÐÔ: AddLegendAttr ±³°ü¸ñ×ÓË÷Òý ÊôÐÔID1 ÊôÐÔID2 ...")
|
GameWorld.DebugAnswer(curPlayer, "Ìí¼ÓËùÓд«ÆæÊôÐÔ: AddLegendAttr ±³°ü¸ñ×ÓË÷Òý 0")
|
return
|
|
#»ñÈ¡ÎïÆ·
|
index = cmdList[0]
|
curItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem).GetAt(index)
|
if not ItemCommon.CheckItemIsEquip(curItem):
|
GameWorld.DebugAnswer(curPlayer, "·Ç×°±¸ÎÞ·¨»ñµÃ´«ÆæÊôÐÔ!")
|
return
|
|
attrIDList, attrValueList = [], [] # ÖØÐÂˢеÄÊôÐÔ
|
addAttrIDList, addAttrValueList = [], [] # Ìí¼ÓµÄÊôÐÔ
|
if curItem.GetType() == ChConfig.Def_ItemType_retWing:
|
attrInfo = __GetWingGMAddLegendAttrInfo(curPlayer, curItem, cmdList)
|
else:
|
attrInfo = __GetEquipGMAddLegendAttrInfo(curPlayer, curItem, cmdList)
|
|
if not attrInfo or (not attrInfo[0] and not attrInfo[1]):
|
GameWorld.DebugAnswer(curPlayer, "»ñÈ¡¸Ã×°±¸´«ÆæÊôÐÔʧ°Ü»òûÓд«ÆæÊôÐÔ!")
|
return
|
|
if attrInfo[0]:
|
attrIDList, attrValueList = attrInfo[0]
|
if attrInfo[1]:
|
addAttrIDList, addAttrValueList = attrInfo[1]
|
|
# ´«ÆæÊôÐÔ
|
if attrIDList and attrValueList and len(attrIDList) == len(attrValueList):
|
curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)
|
curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)
|
GameWorld.DebugLog("ˢд«ÆæÊôÐÔ: ID=%s,value=%s" % (attrIDList, attrValueList))
|
for i, attrID in enumerate(attrIDList):
|
curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, attrID)
|
curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, attrValueList[i])
|
|
# Ö±½ÓÌí¼ÓµÄ
|
if addAttrIDList and addAttrValueList and len(addAttrIDList) == len(addAttrValueList):
|
GameWorld.DebugLog("Ìí¼Ó´«ÆæÊôÐÔ: ID=%s,value=%s" % (addAttrIDList, addAttrValueList))
|
for i, attrID in enumerate(addAttrIDList):
|
curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, attrID)
|
curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, addAttrValueList[i])
|
|
idList = [curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i) \
|
for i in range(curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID))]
|
valueList = [curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i) \
|
for i in range(curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue))]
|
GameWorld.DebugLog("µ±Ç°´«ÆæÊôÐÔ: ID=%s,value=%s" % (idList, valueList))
|
|
return
|
|
def __GetEquipGMAddLegendAttrInfo(curPlayer, curItem, cmdList):
|
isAdd = False
|
cmdlen = len(cmdList)
|
equipPlace = curItem.GetEquipPlace()
|
itemColor = curItem.GetItemColor()
|
if cmdlen == 1:
|
return ItemControler.GetAddEquipLegendAttr(curItem), []
|
|
if cmdList[1] == 0:
|
legAttrRuleDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrRule")
|
if equipPlace not in legAttrRuleDict:
|
GameWorld.DebugAnswer(curPlayer, "¸Ã×°±¸Î»ÎÞ·¨»ñµÃ´«ÆæÊôÐÔ£¡equipPlace=%s" % equipPlace)
|
return
|
commAttrList, goodAttrList, specAttrList = legAttrRuleDict[equipPlace]
|
attrIDList = commAttrList + goodAttrList
|
if specAttrList:
|
if type(specAttrList) == int:
|
attrIDList.append(specAttrList)
|
else:
|
attrIDList += specAttrList
|
else:
|
isAdd = True
|
attrIDList = cmdList[1:]
|
|
legAttrIDList = []
|
legAttrValueList = []
|
|
legAttrValueDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValue")
|
for attrID in attrIDList:
|
if attrID not in legAttrValueDict:
|
GameWorld.DebugAnswer(curPlayer, "ûÓиô«ÆæÊôÐÔ: %s" % attrID)
|
continue
|
colorValueDict = legAttrValueDict[attrID]
|
if itemColor not in colorValueDict:
|
continue
|
legAttrIDList.append(attrID)
|
legAttrValueList.append(colorValueDict[itemColor])
|
|
if not legAttrIDList or not legAttrValueList:
|
return
|
return ([], [legAttrIDList, legAttrValueList]) if isAdd else ([legAttrIDList, legAttrValueList], [])
|
|
def __GetWingGMAddLegendAttrInfo(curPlayer, curItem, cmdList):
|
isAdd = False
|
cmdlen = len(cmdList)
|
if cmdlen == 1:
|
return ItemControler.GetAddEquipLegendAttr(curItem), []
|
|
itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
wingLegAttrValueDict = IpyGameDataPY.GetFuncEvalCfg("WingLegendAttrValue")
|
if itemClassLV not in wingLegAttrValueDict:
|
GameWorld.DebugAnswer(curPlayer, "¸Ã³á°ò½×¼¶ÎÞ·¨»ñµÃ´«ÆæÊôÐÔ£¡itemClassLV=%s" % itemClassLV)
|
return
|
curClassLVLegAttrDict = wingLegAttrValueDict[itemClassLV]
|
if cmdList[1] == 0:
|
attrIDList = curClassLVLegAttrDict.keys()
|
else:
|
isAdd = True
|
attrIDList = cmdList[1:]
|
|
legAttrIDList = []
|
legAttrValueList = []
|
for attrID in attrIDList:
|
if attrID not in curClassLVLegAttrDict:
|
GameWorld.DebugAnswer(curPlayer, "ûÓиóá°ò´«ÆæÊôÐÔ: %s" % attrID)
|
continue
|
legAttrIDList.append(attrID)
|
legAttrValueList.append(random.choice(curClassLVLegAttrDict[attrID]))
|
|
if not legAttrIDList or not legAttrValueList:
|
return
|
return ([], [legAttrIDList, legAttrValueList]) if isAdd else ([legAttrIDList, legAttrValueList], [])
|
|
|