| | |
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import GameWorld
|
| | | import ShareDefine
|
| | | import PlayerFamily
|
| | | import PlayerControl
|
| | | import IPY_GameWorld
|
| | | import ChPyNetSendPack
|
| | | import IpyGameDataPY
|
| | | import NetPackCommon
|
| | | import ItemCommon
|
| | | import PlayerHero
|
| | | import PlayerHJG
|
| | | import ChConfig
|
| | | import ObjPool
|
| | |
|
| | | import random
|
| | | import time
|
| | |
| | | for index in range(ipyDataMgr.GetPlayerFaceCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFaceByIndex(index)
|
| | | faceID = ipyData.GetFaceID()
|
| | | if ipyData.GetUnlockDefault():
|
| | | # 默认激活的不处理
|
| | | continue
|
| | | if ipyData.GetCustomPlayerID():
|
| | | # 玩家定制的不处理
|
| | | continue
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID):
|
| | | # 未激活的不处理
|
| | | continue
|
| | |
| | | for index in range(ipyDataMgr.GetPlayerFacePicCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFacePicByIndex(index)
|
| | | facePicID = ipyData.GetFacePicID()
|
| | | if ipyData.GetUnlockDefault():
|
| | | # 默认激活的不处理
|
| | | continue
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID):
|
| | | # 未激活的不处理
|
| | | continue
|
| | |
| | | RefreshFacePicAttr(curPlayer)
|
| | | return
|
| | |
|
| | | def AddFace(curPlayer, faceID, setExpireTimes=None):
|
| | | def AddFace(curPlayer, faceID, setExpireTimes=None, isFree=False):
|
| | | if faceID <= 0:
|
| | | return
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if not ipyData:
|
| | | return
|
| | | if ipyData.GetUnlockDefault():
|
| | | GameWorld.DebugLog("默认解锁的头像不用添加: faceID=%s" % (faceID), playerID)
|
| | | if ipyData.GetUnlockWay() != 2:
|
| | | GameWorld.DebugLog("非道具激活的不用添加: faceID=%s" % (faceID), playerID)
|
| | | return
|
| | | if ipyData.GetCustomPlayerID():
|
| | | GameWorld.DebugLog("玩家定制的头像不用添加: faceID=%s" % (faceID), playerID)
|
| | | return
|
| | | if not isFree:
|
| | | itemID = ipyData.GetUnlockValue()
|
| | | itemCount = ipyData.GetUnlockNeedCnt()
|
| | | if not itemID or not itemCount:
|
| | | return
|
| | | needItemList = [[itemID, itemCount]]
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack)
|
| | | if lackItemDict:
|
| | | GameWorld.DebugLog("激活所需物品不足! faceID=%s,lackItemDict=%s" % (faceID, lackItemDict), playerID)
|
| | | return
|
| | | ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "AddFace")
|
| | | |
| | | ipyExpireSeconds = ipyData.GetExpireMinutes() * 60
|
| | |
|
| | | curTime = int(time.time())
|
| | |
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if not ipyData:
|
| | | return
|
| | | if ipyData.GetUnlockDefault():
|
| | | return
|
| | | if ipyData.GetCustomPlayerID():
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID):
|
| | | return
|
| | | GameWorld.Log("删除头像: faceID=%s,notifyMail=%s" % (faceID, notifyMail), playerID)
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID, 0)
|
| | |
| | | randFace = random.choice(defaultFaceIDList) if defaultFaceIDList else 0
|
| | | curPlayer.SetFace(randFace)
|
| | | GameWorld.DebugLog("玩家佩戴的头像被删除,随机重置默认头像! randFace=%s" % randFace, playerID)
|
| | | PlayerFamily.RefreshFamilyMember(curPlayer)
|
| | |
|
| | | if isRefreshAttr:
|
| | | RefreshFaceAttr(curPlayer)
|
| | |
| | | for index in range(ipyDataMgr.GetPlayerFaceCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFaceByIndex(index)
|
| | | faceID = ipyData.GetFaceID()
|
| | | if not ipyData.GetUnlockDefault():
|
| | | if ipyData.GetUnlockWay() != 1:
|
| | | continue
|
| | | defaultFaceIDList.append(faceID)
|
| | | return defaultFaceIDList
|
| | |
|
| | | def GetDefaultFacePicIDList():
|
| | | defaultFacePicIDList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetPlayerFacePicCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFacePicByIndex(index)
|
| | | facePicID = ipyData.GetFacePicID()
|
| | | if not ipyData.GetUnlockDefault():
|
| | | continue
|
| | | defaultFacePicIDList.append(facePicID)
|
| | | return defaultFacePicIDList
|
| | | def IsFaceCanUse(curPlayer, faceID, ipyData=None):
|
| | | ## 头像是否可用
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID)
|
| | | if state:
|
| | | return True
|
| | | |
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if ipyData:
|
| | | unlockWay = ipyData.GetUnlockWay()
|
| | | unlockValue = ipyData.GetUnlockValue()
|
| | | if unlockWay == 1: # 默认激活的
|
| | | return True
|
| | | if unlockWay == 3: # 关联武将
|
| | | heroID = unlockValue
|
| | | return True if PlayerHero.GetHeroActivite(curPlayer, heroID) else False
|
| | | |
| | | return False
|
| | |
|
| | | def AddFacePic(curPlayer, facePicID, setExpireTimes=None):
|
| | | def RefreshFaceAttr(curPlayer):
|
| | | PlayerHJG.RefreshHJGAttr(curPlayer)
|
| | | return
|
| | |
|
| | | def OnUseFace(curPlayer, faceID):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if not IsFaceCanUse(curPlayer, faceID):
|
| | | GameWorld.DebugLog("该头像不可用! faceID=%s" % (faceID), playerID)
|
| | | return |
| | | GameWorld.DebugLog("头像幻化! faceID=%s" % (faceID), playerID)
|
| | | curPlayer.SetFace(faceID)
|
| | | PlayerFamily.RefreshFamilyMember(curPlayer)
|
| | | return
|
| | |
|
| | | def OnFaceStarUP(curPlayer, faceID):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if not IsFaceCanUse(curPlayer, faceID):
|
| | | GameWorld.DebugLog("该头像不可用! faceID=%s" % (faceID), playerID)
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if not ipyData:
|
| | | return
|
| | | starMax = ipyData.GetStarMax()
|
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID)
|
| | | if curStar >= starMax:
|
| | | GameWorld.DebugLog("头像星级已满! faceID=%s,curStar=%s >= %s" % (faceID, curStar, starMax), playerID)
|
| | | return
|
| | | if ipyData.GetUnlockWay() != 2:
|
| | | return
|
| | | itemID = ipyData.GetUnlockValue()
|
| | | itemCount = ipyData.GetUnlockNeedCnt()
|
| | | if not itemID or not itemCount:
|
| | | return
|
| | | needItemList = [[itemID, itemCount]]
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack)
|
| | | if lackItemDict:
|
| | | GameWorld.DebugLog("头像升星所需物品不足! faceID=%s,lackItemDict=%s" % (faceID, lackItemDict), playerID)
|
| | | return
|
| | | ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "FaceStarUP")
|
| | | |
| | | nextStar = curStar + 1
|
| | | GameWorld.DebugLog("头像升星! faceID=%s,nextStar=%s" % (faceID, nextStar), playerID)
|
| | | SetFaceStar(curPlayer, faceID, nextStar)
|
| | | return
|
| | |
|
| | | def SetFaceStar(curPlayer, faceID, setStar):
|
| | | if not IsFaceCanUse(curPlayer, faceID):
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if not ipyData:
|
| | | return
|
| | | setStar = min(setStar, ipyData.GetStarMax())
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceStar % faceID, setStar)
|
| | | RefreshFaceAttr(curPlayer)
|
| | | SyncFaceInfo(curPlayer, [faceID])
|
| | | return True
|
| | |
|
| | | def SyncFaceInfo(curPlayer, faceIDList=None):
|
| | | if faceIDList == None:
|
| | | syncIDList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetPlayerFaceCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFaceByIndex(index)
|
| | | syncIDList.append(ipyData.GetFaceID())
|
| | | else:
|
| | | syncIDList = faceIDList
|
| | | |
| | | faceList = []
|
| | | for faceID in syncIDList:
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID)
|
| | | if not state and faceIDList == None:
|
| | | continue
|
| | | face = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCFace)
|
| | | face.FaceID = faceID
|
| | | face.State = state
|
| | | face.EndTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % faceID)
|
| | | face.Star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID)
|
| | | faceList.append(face)
|
| | | |
| | | if not faceList:
|
| | | return
|
| | | |
| | | clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCFaceInfo)
|
| | | clientPack.FaceList = faceList
|
| | | clientPack.Count = len(clientPack.FaceList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | ## ------------------------------------------------------------------------------------------------
|
| | |
|
| | | def AddFacePic(curPlayer, facePicID, setExpireTimes=None, isFree=False):
|
| | | if facePicID <= 0:
|
| | | return
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if not ipyData:
|
| | | return
|
| | | if ipyData.GetUnlockDefault():
|
| | | GameWorld.DebugLog("默认解锁的头像框不用添加: facePicID=%s" % (facePicID), playerID)
|
| | | if ipyData.GetUnlockWay() != 2:
|
| | | GameWorld.DebugLog("非道具激活的不用添加: facePicID=%s" % (facePicID), playerID)
|
| | | return
|
| | | if not isFree:
|
| | | itemID = ipyData.GetUnlockValue()
|
| | | itemCount = ipyData.GetUnlockNeedCnt()
|
| | | if not itemID or not itemCount:
|
| | | return
|
| | | needItemList = [[itemID, itemCount]]
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack)
|
| | | if lackItemDict:
|
| | | GameWorld.DebugLog("激活所需物品不足! facePicID=%s,lackItemDict=%s" % (facePicID, lackItemDict), playerID)
|
| | | return
|
| | | ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "AddFacePic")
|
| | | |
| | | ipyExpireSeconds = ipyData.GetExpireMinutes() * 60
|
| | |
|
| | | curTime = int(time.time())
|
| | |
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if not ipyData:
|
| | | return
|
| | | if ipyData.GetUnlockDefault():
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID):
|
| | | return
|
| | | GameWorld.Log("删除头像框: facePicID=%s,notifyMail=%s" % (facePicID, notifyMail), playerID)
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID, 0)
|
| | |
| | | randFacePic = random.choice(defaultFacePicIDList) if defaultFacePicIDList else 0
|
| | | curPlayer.SetFacePic(randFacePic)
|
| | | GameWorld.DebugLog("玩家佩戴的头像框过期,随机重置默认头像框! randFacePic=%s" % randFacePic, playerID)
|
| | | PlayerFamily.RefreshFamilyMember(curPlayer)
|
| | |
|
| | | if isRefreshAttr:
|
| | | RefreshFacePicAttr(curPlayer)
|
| | |
| | | PlayerControl.SendMailByKey(notifyMail, [playerID], [], [facePicID])
|
| | | return True
|
| | |
|
| | | def IsFaceCanUse(curPlayer, faceID, ipyData=None):
|
| | | ## 头像是否可用
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID)
|
| | | if state:
|
| | | return True
|
| | | |
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if ipyData:
|
| | | if ipyData.GetUnlockDefault():
|
| | | return True
|
| | | if ipyData.GetCustomPlayerID() and ipyData.GetCustomPlayerID() == curPlayer.GetPlayerID():
|
| | | return True
|
| | | |
| | | return False
|
| | | def GetDefaultFacePicIDList():
|
| | | defaultFacePicIDList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetPlayerFacePicCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFacePicByIndex(index)
|
| | | facePicID = ipyData.GetFacePicID()
|
| | | if ipyData.GetUnlockWay() != 1:
|
| | | continue
|
| | | defaultFacePicIDList.append(facePicID)
|
| | | return defaultFacePicIDList
|
| | |
|
| | | def IsFacePicCanUse(curPlayer, facePicID, ipyData=None):
|
| | | ## 头像框是否可用
|
| | |
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if ipyData:
|
| | | if ipyData.GetUnlockDefault():
|
| | | unlockWay = ipyData.GetUnlockWay()
|
| | | if unlockWay == 1: # 默认激活的
|
| | | return True
|
| | |
|
| | | return False
|
| | |
|
| | | def RefreshFaceAttr(curPlayer):
|
| | | CalcFaceAttr(curPlayer)
|
| | | PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
|
| | | return
|
| | |
|
| | | def RefreshFacePicAttr(curPlayer):
|
| | | CalcFacePicAttr(curPlayer)
|
| | | PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
|
| | | PlayerHJG.RefreshHJGAttr(curPlayer)
|
| | | return
|
| | |
|
| | | def CalcFaceAttr(curPlayer):
|
| | | ## 计算头像属性
|
| | | |
| | | fightPowerEx = 0
|
| | | allAttrList = [{} for i in range(4)]
|
| | | |
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetPlayerFaceCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFaceByIndex(index)
|
| | | faceID = ipyData.GetFaceID()
|
| | | if not IsFaceCanUse(curPlayer, faceID, ipyData):
|
| | | continue
|
| | | |
| | | fightPowerEx += ipyData.GetLightFightPower()
|
| | | # 激活属性
|
| | | lightAttrType = ipyData.GetLightAttrType()
|
| | | lightAttrValue = ipyData.GetLightAttrValue()
|
| | | for i, attrID in enumerate(lightAttrType):
|
| | | attrValue = lightAttrValue[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
|
| | | |
| | | # 星级属性
|
| | | faceStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID)
|
| | | starIpyData = IpyGameDataPY.GetIpyGameDataNotLog("PlayerFaceStar", faceID, faceStar)
|
| | | if starIpyData:
|
| | | starAttrType = starIpyData.GetStarAttrType()
|
| | | starAttrValue = starIpyData.GetStarAttrValue()
|
| | | for i, attrID in enumerate(starAttrType):
|
| | | attrValue = starAttrValue[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
|
| | | |
| | | # 保存计算值
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Face, allAttrList)
|
| | | PlayerControl.SetMFPExFightPower(curPlayer, ShareDefine.Def_MFPType_Face, fightPowerEx)
|
| | | return
|
| | |
|
| | | def CalcFacePicAttr(curPlayer):
|
| | | ## 计算头像框属性
|
| | | |
| | | fightPowerEx = 0
|
| | | allAttrList = [{} for _ in range(4)]
|
| | | |
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetPlayerFacePicCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFacePicByIndex(index)
|
| | | facePicID = ipyData.GetFacePicID()
|
| | | if not IsFacePicCanUse(curPlayer, facePicID, ipyData):
|
| | | continue
|
| | | |
| | | fightPowerEx += ipyData.GetLightFightPower()
|
| | | # 激活属性
|
| | | lightAttrType = ipyData.GetLightAttrType()
|
| | | lightAttrValue = ipyData.GetLightAttrValue()
|
| | | for i, attrID in enumerate(lightAttrType):
|
| | | attrValue = lightAttrValue[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
|
| | | |
| | | # 星级属性
|
| | | facePicStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % facePicID)
|
| | | starIpyData = IpyGameDataPY.GetIpyGameDataNotLog("PlayerFacePicStar", facePicID, facePicStar)
|
| | | if starIpyData:
|
| | | starAttrType = starIpyData.GetStarAttrType()
|
| | | starAttrValue = starIpyData.GetStarAttrValue()
|
| | | for i, attrID in enumerate(starAttrType):
|
| | | attrValue = starAttrValue[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
|
| | | |
| | | # 保存计算值
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_FacePic, allAttrList)
|
| | | PlayerControl.SetMFPExFightPower(curPlayer, ShareDefine.Def_MFPType_FacePic, fightPowerEx)
|
| | | return
|
| | |
|
| | | #// B2 26 头像幻化 #tagCMFaceChange
|
| | | #
|
| | | #struct tagCMFaceChange
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD FaceID; // 幻化的ID
|
| | | #};
|
| | | def OnFaceChange(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | def OnUseFacePic(curPlayer, facePicID):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | faceID = clientData.FaceID
|
| | | |
| | | if not IsFaceCanUse(curPlayer, faceID):
|
| | | GameWorld.DebugLog("该头像不可用! faceID=%s" % (faceID), playerID)
|
| | | return |
| | | GameWorld.DebugLog("头像幻化! faceID=%s" % (faceID), playerID)
|
| | | curPlayer.SetFace(faceID)
|
| | | return
|
| | |
|
| | | #// B2 27 头像升星 #tagCMFaceStarUP
|
| | | #
|
| | | #struct tagCMFaceStarUP
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD FaceID;
|
| | | #};
|
| | | def OnFaceStarUP(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | faceID = clientData.FaceID
|
| | | |
| | | if not IsFaceCanUse(curPlayer, faceID):
|
| | | GameWorld.DebugLog("该头像不可用! faceID=%s" % (faceID), playerID)
|
| | | return
|
| | | |
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID) |
| | | nextStar = curStar + 1
|
| | | nextIpyData = IpyGameDataPY.GetIpyGameData("PlayerFaceStar", faceID, nextStar)
|
| | | if not nextIpyData:
|
| | | GameWorld.DebugLog("不存在该头像星级! faceID=%s,nextStar=%s" % (faceID, nextStar), playerID)
|
| | | return
|
| | | needItemList = nextIpyData.GetStarUpNeedItemList()
|
| | | if not needItemList:
|
| | | return
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack)
|
| | | if lackItemDict:
|
| | | GameWorld.DebugLog("头像升星所需物品不足! faceID=%s,nextStar=%s,needItemList=%s,lackItemDict=%s" |
| | | % (faceID, nextStar, needItemList, lackItemDict), playerID)
|
| | | return
|
| | | ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "FaceStarUP")
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceStar % faceID, nextStar)
|
| | | |
| | | GameWorld.DebugLog("头像升星! faceID=%s,curStar=%s,nextStar=%s" % (faceID, curStar, nextStar), playerID)
|
| | | |
| | | RefreshFaceAttr(curPlayer)
|
| | | SyncFaceInfo(curPlayer, [faceID])
|
| | | return
|
| | |
|
| | | def GMSetFaceStar(curPlayer, faceID, setValue=None):
|
| | | ## GM设置星级
|
| | | |
| | | if not IsFaceCanUse(curPlayer, faceID):
|
| | | return False, "The player has not activated the faceID(%s)" % faceID
|
| | | |
| | | if setValue == None:
|
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID)
|
| | | setStar = curStar + 1 # 没指定星级时默认升星
|
| | | else:
|
| | | setStar = setValue
|
| | | |
| | | if setStar > 0:
|
| | | if not IpyGameDataPY.GetIpyGameData("PlayerFaceStar", faceID, setStar):
|
| | | return False, "The faceID(%s) star(%s) is not exist." % (faceID, setStar)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceStar % faceID, setStar)
|
| | | GameWorld.Log("GM设置头像星级: faceID=%s,setStar=%s" % (faceID, setStar), curPlayer.GetPlayerID())
|
| | | |
| | | RefreshFaceAttr(curPlayer)
|
| | | SyncFaceInfo(curPlayer, [faceID])
|
| | | return True, ""
|
| | |
|
| | | #// B2 28 头像框幻化 #tagCMFacePicChange
|
| | | #
|
| | | #struct tagCMFacePicChange
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD FacePicID; // 幻化的ID
|
| | | #};
|
| | | def OnFacePicChange(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | facePicID = clientData.FacePicID
|
| | | |
| | | if not IsFacePicCanUse(curPlayer, facePicID):
|
| | | GameWorld.DebugLog("该头像框不可用! facePicID=%s" % (facePicID), playerID)
|
| | | return
|
| | | GameWorld.DebugLog("头像框幻化! facePicID=%s" % (facePicID), playerID)
|
| | | curPlayer.SetFacePic(facePicID)
|
| | | PlayerFamily.RefreshFamilyMember(curPlayer)
|
| | | return
|
| | |
|
| | | #// B2 29 头像框升星 #tagCMFacePicStarUP
|
| | | #
|
| | | #struct tagCMFacePicStarUP
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD FacePicID;
|
| | | #};
|
| | | def OnFacePicStarUP(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | def OnFacePicStarUP(curPlayer, facePicID):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | facePicID = clientData.FacePicID
|
| | | |
| | | if not IsFacePicCanUse(curPlayer, facePicID):
|
| | | GameWorld.DebugLog("该头像框不可用! facePicID=%s" % (facePicID), playerID)
|
| | | return
|
| | | |
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % facePicID) |
| | | nextStar = curStar + 1
|
| | | nextIpyData = IpyGameDataPY.GetIpyGameData("PlayerFacePicStar", facePicID, nextStar)
|
| | | if not nextIpyData:
|
| | | GameWorld.DebugLog("不存在该头像框星级! facePicID=%s,nextStar=%s" % (facePicID, nextStar), playerID)
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if not ipyData:
|
| | | return
|
| | | needItemList = nextIpyData.GetStarUpNeedItemList()
|
| | | if not needItemList:
|
| | | starMax = ipyData.GetStarMax()
|
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % facePicID)
|
| | | if curStar >= starMax:
|
| | | GameWorld.DebugLog("头像框星级已满! facePicID=%s,curStar=%s >= %s" % (facePicID, curStar, starMax), playerID)
|
| | | return
|
| | | if ipyData.GetUnlockWay() != 2:
|
| | | return
|
| | | itemID = ipyData.GetUnlockValue()
|
| | | itemCount = ipyData.GetUnlockNeedCnt()
|
| | | if not itemID or not itemCount:
|
| | | return
|
| | | needItemList = [[itemID, itemCount]]
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack)
|
| | | if lackItemDict:
|
| | | GameWorld.DebugLog("头像框升星所需物品不足! facePicID=%s,nextStar=%s,needItemList=%s,lackItemDict=%s" |
| | | % (facePicID, nextStar, needItemList, lackItemDict), playerID)
|
| | | GameWorld.DebugLog("头像框升星所需物品不足! facePicID=%s,lackItemDict=%s" % (facePicID, lackItemDict), playerID)
|
| | | return
|
| | | ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "FacePicStarUP")
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicStar % facePicID, nextStar)
|
| | | |
| | | GameWorld.DebugLog("头像框升星! facePicID=%s,curStar=%s,nextStar=%s" % (facePicID, curStar, nextStar), playerID)
|
| | | |
| | | RefreshFacePicAttr(curPlayer)
|
| | | SyncFacePicInfo(curPlayer, [facePicID])
|
| | | nextStar = curStar + 1
|
| | | GameWorld.DebugLog("头像框升星! facePicID=%s,nextStar=%s" % (facePicID, nextStar), playerID)
|
| | | SetFacePicStar(curPlayer, facePicID, nextStar)
|
| | | return
|
| | |
|
| | | def GMSetFacePicStar(curPlayer, facePicID, setValue=None):
|
| | | ## GM设置星级
|
| | | |
| | | def SetFacePicStar(curPlayer, facePicID, setStar):
|
| | | if not IsFacePicCanUse(curPlayer, facePicID):
|
| | | return False, "The player has not activated the facePicID(%s)" % facePicID
|
| | | |
| | | if setValue == None:
|
| | | curStar = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % facePicID)
|
| | | setStar = curStar + 1 # 没指定星级时默认升星
|
| | | else:
|
| | | setStar = setValue
|
| | | |
| | | if setStar > 0:
|
| | | if not IpyGameDataPY.GetIpyGameData("PlayerFacePicStar", facePicID, setStar):
|
| | | return False, "The setStar(%s) star(%s) is not exist." % (setStar, setStar)
|
| | | |
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if not ipyData:
|
| | | return
|
| | | setStar = min(setStar, ipyData.GetStarMax())
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicStar % facePicID, setStar)
|
| | | GameWorld.Log("GM设置头像框星级: facePicID=%s,setStar=%s" % (facePicID, setStar), curPlayer.GetPlayerID())
|
| | | |
| | | RefreshFacePicAttr(curPlayer)
|
| | | SyncFacePicInfo(curPlayer, [facePicID])
|
| | | return True, ""
|
| | |
|
| | | def SyncFaceInfo(curPlayer, faceIDList=None):
|
| | | if faceIDList == None:
|
| | | syncIDList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetPlayerFaceCount()):
|
| | | ipyData = ipyDataMgr.GetPlayerFaceByIndex(index)
|
| | | syncIDList.append(ipyData.GetFaceID())
|
| | | else:
|
| | | syncIDList = faceIDList
|
| | | |
| | | faceList = []
|
| | | for faceID in syncIDList:
|
| | | state = 1 if IsFaceCanUse(curPlayer, faceID) else 0
|
| | | if not state and faceIDList == None:
|
| | | continue
|
| | | face = ChPyNetSendPack.tagMCFace()
|
| | | face.FaceID = faceID
|
| | | face.State = state
|
| | | face.EndTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % faceID)
|
| | | face.Star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID)
|
| | | faceList.append(face)
|
| | | |
| | | if not faceList:
|
| | | return
|
| | | |
| | | clientPack = ChPyNetSendPack.tagMCFaceInfo()
|
| | | clientPack.FaceList = faceList
|
| | | clientPack.Count = len(clientPack.FaceList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | | return True
|
| | |
|
| | | def SyncFacePicInfo(curPlayer, facePicIDList=None):
|
| | | if facePicIDList == None:
|
| | |
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID)
|
| | | if not state and facePicIDList == None:
|
| | | continue
|
| | | facePic = ChPyNetSendPack.tagMCFacePic()
|
| | | facePic = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCFacePic)
|
| | | facePic.FacePicID = facePicID
|
| | | facePic.State = state
|
| | | facePic.EndTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicEndTime % facePicID)
|
| | |
| | | if not facePicList:
|
| | | return
|
| | |
|
| | | clientPack = ChPyNetSendPack.tagMCFacePicInfo()
|
| | | clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCFacePicInfo)
|
| | | clientPack.FacePicList = facePicList
|
| | | clientPack.Count = len(clientPack.FacePicList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|