#!/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)
|
SyncBossRebornPlayerInfo(curPlayer)
|
return
|
|
|
def RefreshOperationAction_BossReborn():
|
playerManager = GameWorld.GetPlayerManager()
|
for i in xrange(playerManager.GetPlayerCount()):
|
curPlayer = playerManager.GetPlayerByIndex(i)
|
if not GameWorld.IsNormalPlayer(curPlayer):
|
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)
|
cfgID = actBossRebornInfo.get(ShareDefine.ActKey_CfgID, 0)
|
|
playerBossRebornID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornID) # Íæ¼ÒÉíÉϵĻID
|
|
# »î¶¯ID ÏàͬµÄ»°²»´¦Àí
|
if bossRebornID == playerBossRebornID:
|
#GameWorld.DebugLog("BOSS¸´»î»î¶¯ID²»±ä£¬²»´¦Àí£¡", curPlayer.GetPlayerID())
|
return
|
actWorldLV = actBossRebornInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV)
|
|
templateID = 0
|
if cfgID:
|
actBossIpyData = IpyGameDataPY.GetIpyGameData("ActBossReborn", cfgID)
|
templateID = 0 if not actBossIpyData else actBossIpyData.GetTemplateID()
|
playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornTemplateID)
|
|
GameWorld.DebugLog("BOSS¸´»îÖØÖÃ! costRebateID=%s,playerCostRebateID=%s,state=%s,templateID=%s,playerTemplateID=%s"
|
% (bossRebornID, playerBossRebornID, state, templateID, playerTemplateID), playerID)
|
|
# δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å
|
__SendBossRebornMail(curPlayer, playerTemplateID, playerWorldLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionWorldLV, actWorldLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BossRebornID, bossRebornID)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BossRebornTemplateID, templateID)
|
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)
|
SyncBossRebornPlayerInfo(curPlayer)
|
return True
|
|
|
def __SendBossRebornMail(curPlayer, playerTemplateID, playerWorldLV):
|
# δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("BossReborn", {'TemplateID':playerTemplateID}, True)
|
if not ipyDataList:
|
return
|
|
totalItemDict = {}
|
for ipyData in ipyDataList:
|
brid = ipyData.GetID()
|
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, ipyData, playerWorldLV, 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
|
playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornTemplateID)
|
ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', playerTemplateID, 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)
|
|
SyncBossRebornPlayerInfo(curPlayer, actionID)
|
return
|
|
|
def GetBossRebornActionAward(curPlayer, actionID):
|
'''ÁìÈ¡boss¸´»î»î¶¯½±Àø'''
|
playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornTemplateID)
|
ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', playerTemplateID, 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
|
playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV)
|
#¸ø½±Àø
|
awardDict = __GetAwardItem(curPlayer, ipyData, playerWorldLV)
|
# ¼ì²é±³°ü
|
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, 0, [IPY_GameWorld.rptItem])
|
SyncBossRebornPlayerInfo(curPlayer, actionID)
|
return
|
|
|
def __GetAwardItem(curPlayer, ipyData, worldLV, times=1):
|
awardDict = {}
|
|
awardList = GameWorld.GetDictValueByRangeKey(ipyData.GetReward(), worldLV, [])
|
for itemID, itemCnt, isbind in awardList:
|
if not itemID or not itemCnt:
|
continue
|
awardDict[itemID] = awardDict.get(itemID, 0) + itemCnt * times
|
|
return awardDict
|
|
|
def SyncBossRebornPlayerInfo(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
|
|
|
def SyncBossRebornInfo(curPlayer):
|
actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {})
|
state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0)
|
cfgID = actBossRebornInfo.get(ShareDefine.ActKey_CfgID, 0)
|
if not state or not cfgID:
|
return
|
actBossIpyData = IpyGameDataPY.GetIpyGameData("ActBossReborn", cfgID)
|
if not actBossIpyData:
|
return
|
templateID = actBossIpyData.GetTemplateID()
|
if not templateID:
|
return
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("BossReborn", {'TemplateID':templateID}, True)
|
if not ipyDataList:
|
return
|
worldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV)
|
startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(actBossIpyData)
|
actInfo = ChPyNetSendPack.tagMCBossRebornInfo()
|
actInfo.Clear()
|
actInfo.StartDate = startDateStr
|
actInfo.EndtDate = endDateStr
|
actInfo.ResetType = actBossIpyData.GetResetType()
|
actInfo.LimitLV = actBossIpyData.GetLVLimit()
|
actInfo.TaskInfo = []
|
for ipyData in ipyDataList:
|
taskInfo = ChPyNetSendPack.tagMCBossRebornTaskInfo()
|
taskInfo.TaskID = ipyData.GetID()
|
taskInfo.TotalTimes = ipyData.GetTotalTimes()
|
taskInfo.SingleTimes = ipyData.GetSingleTimes()
|
taskInfo.AwardItem = []
|
awardList = GameWorld.GetDictValueByRangeKey(ipyData.GetReward(), worldLV, [])
|
for itemID, itemCnt, isBind in awardList:
|
awardItem = ChPyNetSendPack.tagMCBossRebornAwardItem()
|
awardItem.ItemID = itemID
|
awardItem.ItemCount = itemCnt
|
awardItem.IsBind = isBind
|
taskInfo.AwardItem.append(awardItem)
|
taskInfo.AwardItemCount = len(taskInfo.AwardItem)
|
actInfo.TaskInfo.append(taskInfo)
|
actInfo.TaskCnt = len(actInfo.TaskInfo)
|
NetPackCommon.SendFakePack(curPlayer, actInfo)
|
return
|
|
def DoBossRebornActionBossOnKilledLogic(npcRankHurtMgr):
|
## boss¸´»î»î¶¯boss±»»÷ɱ
|
# @param rankHurtList: NPCHurtMgr.PlayerRankHurtList
|
|
npcID = npcRankHurtMgr.npcID
|
|
GameWorld.Log("Boss¸´»î»î¶¯boss±»»÷ɱ: npcID=%s" % (npcID))
|
rankItemDict = IpyGameDataPY.GetFuncEvalCfg("BossRebornServerBoss", 2) # {Ãû´Î:[[ÎïÆ·ID,¸öÊý,ÊÇ·ñÅÄÆ·], ...], ...}
|
|
for index in xrange(npcRankHurtMgr.GetHurtCount()):
|
rank = index + 1
|
hurtObj = npcRankHurtMgr.GetHurtAt(index)
|
if hurtObj.GetValueType() != ChConfig.Def_NPCHurtTypePlayer:
|
continue
|
playerID = hurtObj.GetValueID()
|
rankItemList = GameWorld.GetOrderValueByDict(rankItemDict, rank)
|
GameWorld.Log(" ÅÅÐÐÍæ¼Ò½±Àø: rank=%s,rankItemList=%s" % (rank, rankItemList), playerID)
|
if not rankItemList:
|
continue
|
paramList = [npcID, rank]
|
PlayerControl.SendMailByKey("BossRebornActionBossRank", [playerID], rankItemList, paramList)
|
|
entireMailItemList = IpyGameDataPY.GetFuncEvalCfg("BossRebornServerBoss", 1) # [[ÎïÆ·ID,¸öÊý,ÊÇ·ñÅÄÆ·], ...]
|
if entireMailItemList:
|
getDays, limitLV, limitLVType = IpyGameDataPY.GetFuncEvalCfg("BossRebornServerBoss", 4)
|
paramList = [npcID]
|
#ɾ³ý¾É°æ·¢ËÍÓʼþ£¬Èç¹û¹¦ÄÜ»¹ÓÐÐèÒª£¬¿ÉʹÓÃа汾·¢ËÍÓʼþ PlayerMail
|
|
return
|
|
|
|