#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerZhanling # # @todo:Õ½Áî # @author hxp # @date 2023-12-05 # @version 1.0 # # ÏêϸÃèÊö: Õ½Áî # #------------------------------------------------------------------------------- #"""Version = 2023-12-05 15:30""" #------------------------------------------------------------------------------- import GameWorld import NetPackCommon import IpyGameDataPY import PlayerControl import ChPyNetSendPack import PlayerGatherTheSoul import ItemControler import IPY_GameWorld import PlayerGubao import ChConfig import time # Õ½ÁîÀàÐÍ ZhanlingTypeList = ( ZhanlingType_LV, ZhanlingType_Realm, ZhanlingType_SkyTower, ZhanlingType_GubaoStar, ZhanlingType_Login, ZhanlingType_GatherTheSoulLV, ) = range(1, 1 + 6) def OnPlayerLogin(curPlayer): for zhanlingType in ZhanlingTypeList: if zhanlingType == ZhanlingType_Login: value1 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingValue1 % zhanlingType) if not value1: firstLoginTime = int(time.time()) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ZhanlingValue1 % zhanlingType, firstLoginTime) GameWorld.DebugLog("ÉèÖõǼսÁîÊ״εǼʱ¼ä: %s" % firstLoginTime, curPlayer.GetPlayerID()) SyncZhanlingInfo(curPlayer, zhanlingType) return def OnActiviteByCTGID(curPlayer, ctgID): zhanlingCTGIDDict = IpyGameDataPY.GetFuncEvalCfg("Zhanling", 1) for zhanlingTypeStr, ctgIDList in zhanlingCTGIDDict.items(): if ctgID not in ctgIDList: continue zhanlingType = int(zhanlingTypeStr) state = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingState) if state&pow(2, zhanlingType): break updState = state|pow(2, zhanlingType) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ZhanlingState, updState) SyncZhanlingInfo(curPlayer, zhanlingType) GameWorld.Log("¼¤»îÕ½ÁîÆÕͨ: zhanlingType=%s,updState=%s" % (zhanlingType, updState), curPlayer.GetPlayerID()) break # ¸ß¼¶Õ½Áî zhanlingCTGIDDictH = IpyGameDataPY.GetFuncEvalCfg("Zhanling", 3) for zhanlingTypeStr, ctgIDList in zhanlingCTGIDDictH.items(): if ctgID not in ctgIDList: continue zhanlingType = int(zhanlingTypeStr) state = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingStateH) if state&pow(2, zhanlingType): break updState = state|pow(2, zhanlingType) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ZhanlingStateH, updState) SyncZhanlingInfo(curPlayer, zhanlingType) GameWorld.Log("¼¤»îÕ½Áî¸ß¼¶: zhanlingType=%s,updState=%s" % (zhanlingType, updState), curPlayer.GetPlayerID()) break return def GetZhanlingReward(curPlayer, zhanlingType, rewardID): ## ÁìȡսÁî½±Àø rewardID = GameWorld.ToIntDef(rewardID) needValue, rewardType = rewardID/10, rewardID%10 # rewardType£º 0-Ãâ·Ñ£»1-ÆÕͨ£»2-¸ß¼¶ playerID = curPlayer.GetPlayerID() ipyData = IpyGameDataPY.GetIpyGameData("Zhanling", zhanlingType, needValue) if not ipyData: return curValue = 0 if zhanlingType == ZhanlingType_LV: curValue = curPlayer.GetLV() elif zhanlingType == ZhanlingType_Realm: curValue = curPlayer.GetOfficialRank() elif zhanlingType == ZhanlingType_SkyTower: curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_SkyTowerFloor) elif zhanlingType == ZhanlingType_GubaoStar: _, curValue = PlayerGubao.GetGubaoTotalLVStar(curPlayer) elif zhanlingType == ZhanlingType_Login: firstLoginTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingValue1 % zhanlingType) if not firstLoginTime: return curValue = GameWorld.GetDiff_Day(int(time.time()), firstLoginTime) + 1 elif zhanlingType == ZhanlingType_GatherTheSoulLV: curValue = PlayerGatherTheSoul.GetGatherTheSoulTotalLV(curPlayer) else: return if curValue < needValue: GameWorld.DebugLog("Õ½ÁîËùÐèÖµ²»×㣬ÎÞ·¨Áì½±: zhanlingType=%s,curValue=%s < %s" % (zhanlingType, curValue, needValue), playerID) return rewardIndex = ipyData.GetRewardIndex() itemList = ipyData.GetFreeRewardItemList() rewardKey = ChConfig.Def_PDict_ZhanlingRewardFree if rewardType == 1: itemList = ipyData.GetZLRewardItemList() rewardKey = ChConfig.Def_PDict_ZhanlingReward state = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingState) if not state&pow(2, zhanlingType): GameWorld.DebugLog("ÆÕͨսÁîδ¼¤»î£¬ÎÞ·¨ÁìȡսÁî½±Àø: zhanlingType=%s,state=%s" % (zhanlingType, state), playerID) return elif rewardType == 2: itemList = ipyData.GetZLRewardItemListH() rewardKey = ChConfig.Def_PDict_ZhanlingRewardH state = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingStateH) if not state&pow(2, zhanlingType): GameWorld.DebugLog("¸ß¼¶Õ½Áîδ¼¤»î£¬ÎÞ·¨ÁìȡսÁî½±Àø: zhanlingType=%s,state=%s" % (zhanlingType, state), playerID) return if not itemList: GameWorld.DebugLog("ûÓиÃÕ½Áî½±Àø! zhanlingType=%s,needValue=%s,rewardType=%s" % (zhanlingType, needValue, rewardType), playerID) return if GameWorld.GetDictValueByBit(curPlayer, rewardKey, rewardIndex, True, [zhanlingType]): GameWorld.DebugLog("ÒѾ­ÁìÈ¡¹ý¸ÃÕ½Áî½±Àø! zhanlingType=%s,needValue=%s,rewardType=%s" % (zhanlingType, needValue, rewardType), playerID) return # ¼ì²é±³°ü if not ItemControler.CheckPackSpaceEnough(curPlayer, itemList): return # ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç GameWorld.SetDictValueByBit(curPlayer, rewardKey, rewardIndex, 1, True, [zhanlingType]) SyncZhanlingInfo(curPlayer, zhanlingType, ipyData) GameWorld.DebugLog("ÁìȡսÁî½±Àø: zhanlingType=%s,needValue=%s,rewardType=%s,itemList=%s" % (zhanlingType, needValue, rewardType, itemList), playerID) # ¸øÎïÆ· for itemID, itemCount, isAuctionItem in itemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem]) return def SyncZhanlingInfo(curPlayer, zhanlingType, ipyData=None): ipyDataList = [] if ipyData == None: ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Zhanling", {"ZhanlingType":zhanlingType}, True) else: ipyDataList = [ipyData] if not ipyDataList: return rewardList = [] for ipyData in ipyDataList: rewardIndex = ipyData.GetRewardIndex() reward = ChPyNetSendPack.tagMCZhanling() reward.Clear() reward.NeedValue = ipyData.GetNeedValue() reward.FreeRewardState = 1 if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ZhanlingRewardFree, rewardIndex, True, [zhanlingType]) else 0 reward.ZLRewardState = 1 if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ZhanlingReward, rewardIndex, True, [zhanlingType]) else 0 reward.ZLRewardStateH = 1 if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ZhanlingRewardH, rewardIndex, True, [zhanlingType]) else 0 rewardList.append(reward) clientPack = ChPyNetSendPack.tagMCZhanlingInfo() clientPack.Clear() clientPack.ZhanlingType = zhanlingType clientPack.IsActivite = 1 if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingState)&pow(2, zhanlingType) else 0 clientPack.IsActiviteH = 1 if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingStateH)&pow(2, zhanlingType) else 0 clientPack.Value1 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhanlingValue1 % zhanlingType) clientPack.RewardList = rewardList clientPack.RewardCount = len(clientPack.RewardList) NetPackCommon.SendFakePack(curPlayer, clientPack) return