#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GameWorldLogic.FBProcess.GameLogic_Tianzi
|
#
|
# @todo:Ìì×Ó¿¼Ñé
|
# @author hxp
|
# @date 2025-09-30
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: Ìì×Ó¿¼Ñé
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2025-09-30 19:30"""
|
#-------------------------------------------------------------------------------
|
|
import ChConfig
|
import FBCommon
|
import GameWorld
|
import ItemControler
|
import PlayerControl
|
import PlayerBillboard
|
import ChPyNetSendPack
|
import NetPackCommon
|
import IpyGameDataPY
|
import ShareDefine
|
import PlayerMail
|
import DBDataMgr
|
import ObjPool
|
|
def OnDay():
|
## ½áËã×òÈÕ½±Àø
|
__DoGiveTianziDayAward()
|
return
|
|
def OnFBPlayerOnDay(curPlayer):
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TianziTodayHurt, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TianziTodayHurtEx, 0)
|
SyncTianziInfo(curPlayer)
|
return
|
|
def OnFBPlayerOnLogin(curPlayer):
|
SyncTianziInfo(curPlayer)
|
return
|
|
def GetTianziTodayInfo(curPlayer):
|
## »ñÈ¡½ñÈÕÌì×Ó¿¼ÑéÐÅÏ¢
|
# @return: lineID, bossID
|
|
lineList = []
|
for lineID in range(10):
|
ipyData = IpyGameDataPY.GetIpyGameDataNotLog("FBLine", ChConfig.Def_FBMapID_Tianzi, lineID)
|
if ipyData:
|
lineList.append(ipyData)
|
elif lineID > 0:
|
break
|
if not lineList:
|
return 0, 0
|
|
ServerDay = DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_ServerDay)
|
todayIpyData = lineList[ServerDay % len(lineList)]
|
lineID = todayIpyData.GetLineID()
|
bossID = 0
|
for lineupID in todayIpyData.GetLineupIDList():
|
lineupIpyData = IpyGameDataPY.GetIpyGameData("NPCLineup", lineupID)
|
if not lineupIpyData:
|
continue
|
bossID = lineupIpyData.GetBossID()
|
if bossID:
|
break
|
|
return lineID, bossID
|
|
def OnTurnFightRequest(curPlayer, mapID, funcLineID, tagType, tagID, valueList):
|
## »ØºÏÕ½¶·ÇëÇó
|
|
lineID, bossID = GetTianziTodayInfo(curPlayer)
|
if funcLineID != lineID:
|
GameWorld.DebugLog("·Ç½ñÈÕÌì×Ó¿¼Ñé! mapID=%s,funcLineID=%s != %s,bossID=%s" % (mapID, funcLineID, lineID, bossID))
|
return
|
|
return True
|
|
def GetFBNPCInitAttr(curPlayer, turnFight, npcObj):
|
## »ñÈ¡¸±±¾Ö¸¶¨NPC³õʼ»¯ÊôÐÔ
|
bossID = npcObj.GetNPCID()
|
ipyDataList = IpyGameDataPY.GetIpyGameDataList("Tianzi", bossID)
|
if not ipyDataList:
|
return {}
|
return __getBossAttrDict(ipyDataList[0])
|
|
def OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer):
|
## ¸±±¾NPC±»»÷ɱǰ´¦Àí£¬Ò»°ãÓÃÓÚ´¦ÀíһЩ²»±»»÷ɱµÄ¸±±¾NPCÂß¼
|
# @return: ¿É·ñ±»Õý³£»÷ɱ
|
|
# ±¾¸±±¾²»¿É±»»÷ɱ£¬Ö±µ½ËùÓÐѪÌõµÖ¿ÛÍê
|
bossID = gameObj.GetNPCID()
|
ipyDataList = IpyGameDataPY.GetIpyGameDataList("Tianzi", bossID)
|
if not ipyDataList:
|
return True
|
|
statDefValueTotal = gameObj.GetStatDefValue() # µ±Ç°×ܳÐÉË
|
hpNum = 1
|
totalHPMax = 0
|
ipyDataNow = None
|
for ipyData in ipyDataList:
|
hpNum = ipyData.GetHPNum()
|
maxHP = ipyData.GetMaxHP()
|
ipyDataNow = ipyData
|
totalHPMax += maxHP
|
if statDefValueTotal < totalHPMax:
|
break
|
|
if not ipyDataNow:
|
return True
|
|
hp = max(0, totalHPMax - statDefValueTotal)
|
if hp <= 0:
|
GameWorld.Log("Ìì×Ó¿¼ÑéÈ«²¿ÑªÌõ±»»÷ɱ! totalHPMax=%s,statDefValueTotal=%s" % (totalHPMax, statDefValueTotal))
|
return True
|
|
gameObj.SetMaxHP(ipyDataNow.GetMaxHP(), True)
|
gameObj.SetHP(hp, True)
|
GameWorld.DebugLog("¸üÐÂNPCѪÌõ: hpNum=%s,hp=%s/%s, statDefValueTotal=%s" % (hpNum, gameObj.GetHP(), gameObj.GetMaxHP(), statDefValueTotal))
|
turnFight.SetDict("hpNum", hpNum)
|
turnFight.syncHelp({"hpNum":hpNum})
|
gameObj.UpdInitBatAttr(__getBossAttrDict(ipyDataNow))
|
return False
|
|
def __getBossAttrDict(ipyData):
|
attrDict = {ChConfig.AttrID_Atk:ipyData.GetAtk(),
|
ChConfig.AttrID_Def:ipyData.GetDef(),
|
ChConfig.AttrID_MaxHP:ipyData.GetMaxHP(),
|
}
|
attrDict.update(ipyData.GetOtherAttrDict())
|
return attrDict
|
|
def OnTurnFightOver(curPlayer, turnFight, mapID, funcLineID, overMsg):
|
## »ØºÏÕ½¶·½áÊø
|
|
if not curPlayer:
|
return
|
|
#isWin = turnFight.isWin
|
lineID, bossID = GetTianziTodayInfo(curPlayer)
|
if lineID != funcLineID:
|
GameWorld.ErrLog("½áËãʱ·Ç½ñÈÕÌì×Ó¿¼Ñé! mapID=%s,funcLineID=%s != %s,bossID=%s" % (mapID, funcLineID, lineID, bossID))
|
return
|
|
hpNum = turnFight.GetDictByKey("hpNum")
|
batFaction = turnFight.getBatFaction(ChConfig.Def_FactionA)
|
totalHurt = batFaction.getTotalHurt()
|
|
historyHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziHisHurt % bossID)
|
historyHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziHisHurtEx % bossID)
|
historyHurtTotal = historyHurtEx * ChConfig.Def_PerPointValue + historyHurt
|
todayHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziTodayHurt)
|
todayHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziTodayHurtEx)
|
todayHurtTotal = todayHurtEx * ChConfig.Def_PerPointValue + todayHurt
|
|
GameWorld.DebugLog("Ìì×Ó¿¼Ñé½áËã: lineID=%s,bossID=%s,hpNum=%s,totalHurt=%s,todayHurtTotal=%s,historyHurtTotal=%s"
|
% (lineID, bossID, hpNum, totalHurt, todayHurtTotal, historyHurtTotal))
|
if totalHurt > historyHurtTotal:
|
historyHurtTotal = totalHurt
|
historyHurt = historyHurtTotal % ChConfig.Def_PerPointValue
|
historyHurtEx = historyHurtTotal / ChConfig.Def_PerPointValue
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TianziHisHurt % bossID, historyHurt)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TianziHisHurtEx % bossID, historyHurtEx)
|
GameWorld.DebugLog("¸üÐÂÀúÊ·×î¸ßÉ˺¦: %s" % historyHurtTotal)
|
|
if totalHurt > todayHurtTotal:
|
todayHurtTotal = totalHurt
|
todayHurt = todayHurtTotal % ChConfig.Def_PerPointValue
|
todayHurtEx = todayHurtTotal / ChConfig.Def_PerPointValue
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TianziTodayHurt, todayHurt)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TianziTodayHurtEx, todayHurtEx)
|
GameWorld.DebugLog("¸üнñÈÕ×î¸ßÉ˺¦: %s" % todayHurtTotal)
|
#¸üаñµ¥
|
PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_Tianzi, todayHurtEx, todayHurt)
|
|
itemList = __getTianziAwardList(todayHurt, bossID)
|
FBCommon.AddEnterFBCount(curPlayer, mapID)
|
ItemControler.GivePlayerItemOrMail(curPlayer, itemList, event=["Tianzi", False, {}], isNotifyAward=False)
|
overMsg.update({FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(itemList), "totalHurt":totalHurt, "todayHurtTotal":todayHurtTotal})
|
SyncTianziInfo(curPlayer, lineID, bossID)
|
return
|
|
def __getTianziAwardList(todayHurt, bossID, sweepCnt=1):
|
## »ñÈ¡½áËã½±Àø
|
GameWorld.DebugLog("Ìì×Ó¿¼Ñé½áËã½±Àø: hurtValue=%s,bossID=%s" % (todayHurt, bossID))
|
ipyDataList = IpyGameDataPY.GetIpyGameDataList("Tianzi", bossID)
|
if not ipyDataList:
|
return []
|
awardDict = {}
|
totalHPMax = 0
|
for ipyData in ipyDataList:
|
hpNum = ipyData.GetHPNum()
|
maxHP = ipyData.GetMaxHP()
|
totalHPMax += maxHP
|
if todayHurt < totalHPMax:
|
break
|
randWeightItemList = ipyData.GetRandWeightItemList()
|
randItemInfo = GameWorld.GetResultByWeightList(randWeightItemList)
|
if not randItemInfo or len(randItemInfo) < 2:
|
continue
|
itemID = randItemInfo[0]
|
itemCount = randItemInfo[1]
|
awardDict[itemID] = awardDict.get(itemID, 0) + itemCount * sweepCnt
|
GameWorld.DebugLog("ѪÌõ±àºÅ: %s,itemID=%s,itemID=%s,%s" % (hpNum, itemID, itemCount, awardDict))
|
|
itemList = [[itemID, itemCount] for itemID, itemCount in awardDict.items()]
|
GameWorld.DebugLog("×îÖÕ½±Àø: %s" % itemList)
|
return itemList
|
|
def OnPlayerFBSweepAsk(curPlayer, mapID, lineID, sweepCnt, dataEx):
|
## ¿É·ñɨµ´
|
|
_, bossID = GetTianziTodayInfo(curPlayer)
|
todayHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziTodayHurt)
|
todayHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziTodayHurtEx)
|
todayHurtTotal = todayHurtEx * ChConfig.Def_PerPointValue + todayHurt
|
|
if not bossID or not todayHurtTotal:
|
GameWorld.DebugLog("Ìì×Ó¿¼Ñé½ñÈÕ»¹Ã»ÓÐÉ˺¦ÎÞ·¨É¨µ´!")
|
return
|
|
return bossID, todayHurtTotal
|
|
def OnPlayerFBSweepResult(curPlayer, mapID, lineID, sweepCnt, dataEx, askRet):
|
## ɨµ´½á¹û£¬´ÎÊýÏûºÄÒÑÔÚÍâ²ã´¦Àí¿Û³ý
|
|
bossID, todayHurtTotal = askRet
|
GameWorld.DebugLog("Ìì×Ó¿¼Ñéɨµ´: mapID=%s,lineID=%s,sweepCnt=%s,todayHurtTotal=%s,bossID=%s"
|
% (mapID, lineID, sweepCnt, todayHurtTotal, bossID))
|
itemList = __getTianziAwardList(todayHurtTotal, bossID, sweepCnt)
|
ItemControler.GivePlayerItemOrMail(curPlayer, itemList, event=["Tianzi", False, {}], isNotifyAward=False)
|
|
isPass = 1
|
overDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(itemList), FBCommon.Over_isSweep:1,
|
"totalHurt":todayHurtTotal, "todayHurtTotal":todayHurtTotal}
|
FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
return True
|
|
def SyncTianziInfo(curPlayer, lineID=None, bossID=None):
|
if lineID == None:
|
lineID, bossID = GetTianziTodayInfo(curPlayer)
|
clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCTianziKYInfo)
|
clientPack.LineID = lineID
|
clientPack.HistoryHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziHisHurt % bossID)
|
clientPack.HistoryHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziHisHurtEx % bossID)
|
clientPack.TodayHurt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziTodayHurt)
|
clientPack.TodayHurtEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TianziTodayHurtEx)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|
def __DoGiveTianziDayAward():
|
GameWorld.Log("=== Ìì×Ó¿¼Ñé½áËãÅÅÐн±Àø! ===")
|
|
billboardMgr = DBDataMgr.GetBillboardMgr()
|
billBoard = billboardMgr.GetBillboard(ShareDefine.Def_BT_Tianzi)
|
if not billBoard:
|
return
|
billBoard.SortDelayDo()
|
|
billboradAwardDict = IpyGameDataPY.GetFuncEvalCfg("TianziBillboradAward", 1, {})
|
|
orderList = [int(orderStr) for orderStr in billboradAwardDict.keys()]
|
orderList.sort()
|
GameWorld.Log(" ½±ÀøÃû´ÎÁбí: %s" % orderList)
|
|
awardOrder = orderList[0]
|
orderPlayerIDDict = {}
|
billboardCount, billboardMaxCount = billBoard.GetCount(), billBoard.GetMaxCount()
|
GameWorld.Log(" °ñµ¥Êý¾ÝÊý! billboardCount=%s,billboardMaxCount=%s" % (billboardCount, billboardMaxCount))
|
for index in xrange(billboardCount):
|
billBoardData = billBoard.At(index)
|
if not billBoardData:
|
continue
|
order = index + 1
|
|
if order > awardOrder:
|
nextOrderIndex = orderList.index(awardOrder) + 1
|
if nextOrderIndex >= len(orderList):
|
break
|
awardOrder = orderList[nextOrderIndex]
|
|
playerID = billBoardData.GetID()
|
if playerID < ShareDefine.RealPlayerIDStart:
|
# ·ÇÕæÈ˲»´¦Àí
|
continue
|
|
orderPlayerIDDict[playerID] = [order, awardOrder]
|
|
paramList = [order]
|
awardList = billboradAwardDict[str(awardOrder)]
|
PlayerMail.SendMailByKey("TianziBillboardAward", playerID, awardList, paramList)
|
|
GameWorld.Log(" ½±ÀøÍæ¼ÒÃû´ÎÐÅÏ¢: %s" % orderPlayerIDDict)
|
return
|