| | |
| | | import CrossPlayerData
|
| | | import GameFuncComm
|
| | | import ShareDefine
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import ItemCommon
|
| | |
|
| | | import time
|
| | | #-------------------------------------------------------------
|
| | |
| | | CrossPlayerData.OnDienstgradChange(curPlayer, dienstgradID, 1)
|
| | | if dienstgradID == IpyGameDataPY.GetFuncCfg("TitleAddPoint"):
|
| | | __DoTitleAddPoint(curPlayer)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TitleStar % dienstgradID, 1)
|
| | | SyncTitleStarInfo(curPlayer, dienstgradID)
|
| | | |
| | | #重新刷新角色属性
|
| | | if isRefreshAttr:
|
| | | CalcAllDienstgradAttr(curPlayer)
|
| | |
| | | curDienstgradMgr = curPlayer.GetDienstgradManager()
|
| | | curDienstgradMgr.Sync_AllDienstgrad()
|
| | | curDienstgradMgr.Notify_PlayerChangeDienstgrad(curDienstgradMgr.GetCurGradID())
|
| | | SyncTitleStarInfo(curPlayer)
|
| | | return
|
| | |
|
| | | #===============================================================================
|
| | | # //B2 01 使用称号(有属性不显示场景中) #tagPyCMUseDienstgrad
|
| | |
| | | FitOnDienstgrad(index, curGradID)
|
| | | else:
|
| | | TakeOffDienstgrad(index)
|
| | | |
| | | #// A5 36 称号升星 #tagCMTitleStarUp
|
| | | #
|
| | | #struct tagCMTitleStarUp
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD TitleID; //称号ID
|
| | | #};
|
| | | def OnTitleStarUp(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | titleID = clientData.TitleID
|
| | | |
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleStar % titleID) |
| | | ipyData = IpyGameDataPY.GetIpyGameData("TitleStarUp", titleID, curStar)
|
| | | if not ipyData:
|
| | | return
|
| | | nextStar = curStar + 1
|
| | | nextIpyData = IpyGameDataPY.GetIpyGameData("TitleStarUp", titleID, nextStar)
|
| | | needItemList = ipyData.GetStarUpNeedItemList()
|
| | | if not needItemList or not nextIpyData:
|
| | | GameWorld.DebugLog("称号已满星,无法升星. titleID=%s,curStar=%s" % (titleID, curStar), playerID)
|
| | | return
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack)
|
| | | if lackItemDict:
|
| | | GameWorld.DebugLog("称号升星所需物品不足! titleID=%s,curStar=%s,needItemList=%s,lackItemDict=%s" |
| | | % (titleID, curStar, needItemList, lackItemDict), playerID)
|
| | | return
|
| | | |
| | | ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "TitleStarUp")
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TitleStar % titleID, nextStar)
|
| | | |
| | | GameWorld.DebugLog("称号升星. titleID=%s,curStar=%s,nextStar=%s" % (titleID, curStar, nextStar), playerID)
|
| | | |
| | | CalcAllDienstgradAttr(curPlayer)
|
| | | playerControl = PlayerControl.PlayerControl(curPlayer)
|
| | | playerControl.RefreshPlayerAttrState()
|
| | | |
| | | SyncTitleStarInfo(curPlayer, titleID)
|
| | | return
|
| | |
|
| | | #-------------------------------------------------------------
|
| | | ## 获取已激活称号列表
|
| | |
| | | def CalcAllDienstgradAttr(curPlayer):
|
| | | # 计算全部称号属性
|
| | | allAttrList = [{} for i in range(4)]
|
| | | allAttrListStar = [{} for _ in range(4)]
|
| | | |
| | | dienstgradManager = curPlayer.GetDienstgradManager()
|
| | | gradCnt = dienstgradManager.GetCount()
|
| | | for i in xrange(gradCnt):
|
| | |
| | | for i, attrID in enumerate(attrTypeList):
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList)
|
| | |
|
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleStar % curGradID) |
| | | starIpyData = IpyGameDataPY.GetIpyGameData("TitleStarUp", curGradID, curStar)
|
| | | if starIpyData:
|
| | | starAttrType = starIpyData.GetStarAttrType()
|
| | | starAttrValue = starIpyData.GetStarAttrValue()
|
| | | for i, attrID in enumerate(starAttrType):
|
| | | attrValue = starAttrValue[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrListStar)
|
| | | |
| | | # 保存计算值
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Dienstgrad, allAttrList)
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_TitleStar, allAttrListStar)
|
| | | return
|
| | |
|
| | | ## 称号每日更新处理
|
| | |
| | | for dienstgradID in dienstgradIDList:
|
| | | PlayerAddDienstgrad(curPlayer, dienstgradID)
|
| | | #PlayerFitOnDienstgrad(curPlayer, dienstgradID)
|
| | | return |
| | | return
|
| | |
|
| | | def SyncTitleStarInfo(curPlayer, titleID=None):
|
| | | if titleID > 0:
|
| | | syncIDList = [titleID]
|
| | | else:
|
| | | syncIDList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetDienstgradCount()):
|
| | | ipyData = ipyDataMgr.GetDienstgradByIndex(index)
|
| | | syncIDList.append(ipyData.GetID())
|
| | | |
| | | if not syncIDList:
|
| | | return
|
| | | |
| | | titleStarList = []
|
| | | for titleID in syncIDList:
|
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleStar % titleID)
|
| | | if not curStar:
|
| | | continue
|
| | | starInfo = ChPyNetSendPack.tagMCTitleStar()
|
| | | starInfo.Clear()
|
| | | starInfo.TitleID = titleID
|
| | | starInfo.Star = curStar
|
| | | titleStarList.append(starInfo)
|
| | | |
| | | if not titleStarList:
|
| | | return
|
| | | |
| | | clientPack = ChPyNetSendPack.tagMCTitleStarInfo()
|
| | | clientPack.Clear()
|
| | | clientPack.TitleStarList = titleStarList
|
| | | clientPack.Count = len(clientPack.TitleStarList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|