#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package Player.PlayerBossReborn # # @todo:BOSS¸´»î # @author xdh # @date 2018-07-12 16:50 # @version 1.0 # # # ÏêϸÃèÊö: BOSS¸´»î # #--------------------------------------------------------------------- """Version = 2018-07-12 16:50""" #--------------------------------------------------------------------- import IPY_GameWorld import GameWorld import ChConfig import IpyGameDataPY import PlayerControl import ItemControler import ChPyNetSendPack import NetPackCommon import ShareDefine import PyGameData import ItemCommon def OnLogin(curPlayer): isReset = __CheckPlayerBossRebornAction(curPlayer) if not isReset: actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {}) # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢ if actCostRebateInfo.get(ShareDefine.ActKey_State): SyncBossRebornInfo(curPlayer) return def RefreshOperationAction_BossReborn(): playerManager = GameWorld.GetPlayerManager() for i in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(i) if curPlayer == None or not curPlayer.GetInitOK(): continue __CheckPlayerBossRebornAction(curPlayer) return def __CheckPlayerBossRebornAction(curPlayer): ## ¼ì²éÍæ¼ÒBOSS¸´»î»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {}) bossRebornID = actBossRebornInfo.get(ShareDefine.ActKey_ID, 0) state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0) playerBossRebornID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornID) # Íæ¼ÒÉíÉϵĻID # »î¶¯ID ÏàͬµÄ»°²»´¦Àí if bossRebornID == playerBossRebornID: #GameWorld.DebugLog("BOSS¸´»î»î¶¯ID²»±ä£¬²»´¦Àí£¡", curPlayer.GetPlayerID()) return BRWorldLV = actBossRebornInfo.get(ShareDefine.ActKey_WorldLV, 0) playerBRWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV) GameWorld.DebugLog("BOSS¸´»îÖØÖÃ! costRebateID=%s,playerCostRebateID=%s,state=%s,BRWorldLV=%s,playerBRWorldLV=%s" % (bossRebornID, playerBossRebornID, state, BRWorldLV, playerBRWorldLV), playerID) # δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å __SendBossRebornMail(curPlayer, playerBRWorldLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BossRebornID, bossRebornID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionWorldLV, BRWorldLV) for brid in ChConfig.BossRebornActIDList: PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionCurTimes % brid, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionGotTimes % brid, 0) SyncBossRebornInfo(curPlayer) return True def __SendBossRebornMail(curPlayer, playerBRWorldLV): #δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å totalItemDict = {} for brid in ChConfig.BossRebornActIDList: ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', brid) if not ipyData: continue singleTimes = ipyData.GetSingleTimes() curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % brid) gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionGotTimes % brid) canGotCnt = (curTimes - gotTimes) / singleTimes if not canGotCnt: continue itemDict = __GetAwardItem(curPlayer, playerBRWorldLV, ipyData, canGotCnt) GameWorld.AddDictValue(totalItemDict, itemDict) #È¥µô¸´»îµãµÀ¾ß totalItemDict.pop(ChConfig.Def_ItemID_BossReborn, 0) if not totalItemDict: return totalItemList = [[itemID, itemCnt, 1] for itemID, itemCnt in totalItemDict.items()] PlayerControl.SendMailByKey('BossFHUnGetMail', [curPlayer.GetID()], totalItemList) return def AddBossRebornActionCnt(curPlayer, actionID, addCnt=1): '''Ôö¼Óboss¸´»îÏà¹Ø»î¶¯Íê³É´ÎÊý''' #ÅжϻÊÇ·ñ¿ªÆô actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {}) state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0) if not state: return ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', actionID) if not ipyData: return totalTimes = ipyData.GetTotalTimes() curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % actionID) addCnt = addCnt if totalTimes == 0 else min(totalTimes - curTimes, addCnt) if addCnt <= 0: return PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionCurTimes % actionID, curTimes + addCnt) SyncBossRebornInfo(curPlayer, actionID) return def GetBossRebornActionAward(curPlayer, actionID): '''ÁìÈ¡boss¸´»î»î¶¯½±Àø''' ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', actionID) if not ipyData: return singleTimes = ipyData.GetSingleTimes() curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % actionID) gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionGotTimes % actionID) if curTimes - gotTimes < singleTimes: return #¸ø½±Àø curWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV) awardDict = __GetAwardItem(curPlayer, curWorldLV, ipyData) # ¼ì²é±³°ü needSpace = len(awardDict) packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace) if needSpace > packSpace: PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") return #¸üдÎÊý ÿ´ÎÁì½±Ö»ÁìÒ»´Î newGotTimes = gotTimes + singleTimes #GameWorld.Log(' actionID=%s,curTimes=%s,gotTimes=%s,singleTimes=%s,newGotTimes=%s'%(actionID, curTimes, gotTimes,singleTimes, newGotTimes)) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionGotTimes % actionID, newGotTimes) for itemID, itemCnt in awardDict.items(): ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 1, [IPY_GameWorld.rptItem]) SyncBossRebornInfo(curPlayer, actionID) return def __GetAwardItem(curPlayer, worldLV, ipyData, times=1): worldLVList = ipyData.GetWorldLVList() playerLV = curPlayer.GetLV() awardIndex = len(worldLVList) - 1 for i, lv in enumerate(worldLVList): prelv = 0 if i ==0 else worldLVList[i-1] if prelv<=playerLV < lv: awardIndex = i break awardDict = {} for i in xrange(3): #ĿǰÅäÖÃ3¸ö½±Àø if not hasattr(ipyData, 'GetRewardItemID%s' % (i + 1)): break itemIDList = getattr(ipyData, 'GetRewardItemID%s' % (i + 1))() itemCntList = getattr(ipyData, 'GetRewardItemCnt%s' % (i + 1))() if awardIndex >= len(itemIDList) or awardIndex >= len(itemCntList): GameWorld.ErrLog('BOSS¸´»î±í½±ÀøÅäÖôíÎó£¡') return awardDict itemID, itemCnt = itemIDList[awardIndex], itemCntList[awardIndex] if not itemID or not itemCnt: continue awardDict[itemID] = awardDict.get(itemID, 0) + itemCnt * times return awardDict def SyncBossRebornInfo(curPlayer, actID= -1): #֪ͨµ±Ç°´ÎÊý¡¢ÒÑÁì´ÎÊý packData = ChPyNetSendPack.tagMCBossRebornPlayerInfo() packData.DataList = [] if actID !=-1: syneActIDList = [actID] else: syneActIDList = [] ipyMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyMgr.GetBossRebornCount()): ipyData = ipyMgr.GetBossRebornByIndex(i) syneActIDList.append(ipyData.GetID()) for actid in syneActIDList: curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % actid) gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionGotTimes % actid) tiemInfo = ChPyNetSendPack.tagMCBossRebornData() tiemInfo.ActID = actid tiemInfo.CurTimes = curTimes tiemInfo.GotTimes = gotTimes packData.DataList.append(tiemInfo) packData.Count = len(packData.DataList) NetPackCommon.SendFakePack(curPlayer, packData) return