#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.CrossActCTGBillboard
|
#
|
# @todo:¿ç·þÔËÓª»î¶¯ - ³äÖµÅÅÐÐ
|
# @author hxp
|
# @date 2020-01-13
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ¿ç·þÔËÓª»î¶¯ - ³äÖµÅÅÐÐ
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2020-01-13 17:00"""
|
#-------------------------------------------------------------------------------
|
|
import ChConfig
|
import ShareDefine
|
import PlayerControl
|
import NetPackCommon
|
import PlayerBillboard
|
import CrossRealmPlayer
|
import ChPyNetSendPack
|
import ItemControler
|
import IPY_GameWorld
|
import IpyGameDataPY
|
import GameWorld
|
import CommFunc
|
|
def OnPlayerLogin(curPlayer):
|
isReset = __CheckPlayerCrossActCTGBillboard(curPlayer)
|
if not isReset:
|
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_CTGBillboard)
|
# »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢
|
if actInfo.get(ShareDefine.ActKey_State):
|
Sync_CrossActCTGBillboardInfo(curPlayer)
|
Sync_CrossActCTGBillboardPlayerInfo(curPlayer)
|
UpdateCTGRMBCrossBillboard(curPlayer, actInfo)
|
return
|
|
def RefreshCrossActCTGBillboardInfo():
|
## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢
|
playerManager = GameWorld.GetPlayerManager()
|
for index in xrange(playerManager.GetPlayerCount()):
|
curPlayer = playerManager.GetPlayerByIndex(index)
|
if curPlayer.GetID() == 0:
|
continue
|
__CheckPlayerCrossActCTGBillboard(curPlayer)
|
return
|
|
def __CheckPlayerCrossActCTGBillboard(curPlayer):
|
## ¼ì²éÍæ¼ÒÀۼƳäÖµ»î¶¯Êý¾ÝÐÅÏ¢
|
|
playerID = curPlayer.GetPlayerID()
|
|
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_CTGBillboard)
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
actID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
state = actInfo.get(ShareDefine.ActKey_State, 0)
|
dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0)
|
templateID = actInfo.get(ShareDefine.ActKey_TemplateID, 0)
|
|
playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardID) # Íæ¼ÒÉíÉϵĻID
|
playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardTemplateID)
|
|
# »î¶¯ID ÏàͬµÄ»°²»´¦Àí
|
if actID == playerActID:
|
GameWorld.DebugLog("¿ç·þ³äÖµÅÅÐлID²»±ä£¬²»´¦Àí£¡cfgID=%s,dayIndex=%s,templateID=%s" % (cfgID, dayIndex, templateID), playerID)
|
if state:
|
if playerTemplateID != templateID and templateID:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardTemplateID, templateID)
|
GameWorld.DebugLog(" »î¶¯Ä£°åID±ä¸ü£¬¸üÐÂÍæ¼ÒÉíÉÏÄ£°åID¼Ç¼£¡playerTemplateID=%s,updTemplateID=%s"
|
% (playerTemplateID, templateID), playerID)
|
Sync_CrossActCTGBillboardInfo(curPlayer)
|
|
return
|
|
GameWorld.DebugLog("¿ç·þ³äÖµÅÅÐлÖØÖÃ! cfgID=%s,actID=%s,playerActID=%s,state=%s" % (cfgID, actID, playerActID, state), playerID)
|
|
if not state:
|
CrossRealmPlayer.NotifyCrossActEnd(curPlayer, ShareDefine.CrossActName_CTGBillboard)
|
|
if playerActID and playerTemplateID:
|
__SendDabiaoAwardMail(curPlayer, playerTemplateID)
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardID, actID)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardTemplateID, templateID)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardRMB, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardAward, 0)
|
|
Sync_CrossActCTGBillboardInfo(curPlayer)
|
Sync_CrossActCTGBillboardPlayerInfo(curPlayer)
|
return True
|
|
def __SendDabiaoAwardMail(curPlayer, playerTemplateID):
|
## ²¹·¢Î´ÁìÈ¡µÄ´ï±ê½±Àø
|
|
totalRMB = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardRMB)
|
if not totalRMB:
|
return
|
|
ipyDataList = IpyGameDataPY.GetIpyGameDataList("CrossActCTGBillboardDabiao", playerTemplateID)
|
if not ipyDataList:
|
return
|
|
playerID = curPlayer.GetPlayerID()
|
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardAward)
|
batchPlayerIDList, batchAddItemList, batchParamList = [], [], []
|
for ipyData in ipyDataList:
|
ctgNeed = ipyData.GetCTGNeed()
|
awardIndex = ipyData.GetAwardIndex()
|
if totalRMB < CommFunc.RMBToCoin(ctgNeed):
|
continue
|
if awardRecord & pow(2, awardIndex):
|
continue
|
batchPlayerIDList.append([playerID])
|
batchAddItemList.append(ipyData.GetAwardItemList())
|
batchParamList.append([ctgNeed])
|
awardRecord = awardRecord | pow(2, awardIndex)
|
|
if not batchPlayerIDList:
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardAward, awardRecord)
|
|
GameWorld.DebugLog("²¹·¢¿ç·þ³äÖµÅÅÐлδÁìÈ¡´ï±ê½±Àø!", playerID)
|
PlayerControl.SendMailBatch("CACTGBillboardDabiao", batchPlayerIDList, batchAddItemList, batchParamList)
|
return
|
|
def GetDabiaoAward(curPlayer, awardIndex):
|
## ÊÖ¶¯ÁìÈ¡´ï±ê½±Àø
|
|
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_CTGBillboard)
|
state = actInfo.get(ShareDefine.ActKey_State, 0)
|
if not state:
|
GameWorld.DebugLog("·Ç»î¶¯ÖÐ")
|
return
|
|
totalRMB = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardRMB)
|
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardAward)
|
if awardRecord & pow(2, awardIndex):
|
GameWorld.DebugLog("ÒÑÁìÈ¡¹ý¸Ã½±Àø! awardIndex=%s" % awardIndex)
|
return
|
|
playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardTemplateID)
|
ipyDataList = IpyGameDataPY.GetIpyGameDataList("CrossActCTGBillboardDabiao", playerTemplateID)
|
if not ipyDataList:
|
return
|
|
awardItemList = []
|
for ipyData in ipyDataList:
|
ctgNeed = CommFunc.RMBToCoin(ipyData.GetCTGNeed())
|
if awardIndex == ipyData.GetAwardIndex():
|
if totalRMB < ctgNeed:
|
GameWorld.DebugLog("³äÖµ¶î¶Èδ´ï±ê£¬ÎÞ·¨ÁìÈ¡! awardIndex=%s,totalRMB=%s,ctgNeed=%s"
|
% (awardIndex, totalRMB, ctgNeed))
|
return
|
awardItemList = ipyData.GetAwardItemList()
|
break
|
|
GameWorld.DebugLog("ÁìÈ¡¿ç·þ³äÖµ»î¶¯´ï±ê½±Àø£¡awardIndex=%s,awardItemList=%s" % (awardIndex, awardItemList))
|
if not awardItemList:
|
return
|
|
if not ItemControler.CheckPackSpaceEnough(curPlayer, awardItemList):
|
return
|
|
updAwardRecord = awardRecord | pow(2, awardIndex)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardAward, updAwardRecord)
|
Sync_CrossActCTGBillboardPlayerInfo(curPlayer)
|
|
for itemID, itemCount, isAuctionItem in awardItemList:
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem],
|
event=["CrossActCTGBillboard", False, {}])
|
|
return
|
|
def AddCTGRMB(curPlayer, addRMB):
|
## Ôö¼Ó»î¶¯ÒÑÀۼƳäÖµRMB
|
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_CTGBillboard)
|
if not actInfo:
|
return
|
|
if not actInfo.get(ShareDefine.ActKey_State):
|
GameWorld.DebugLog("Íæ¼ÒÇø·þID¿ç·þ³äÖµÅÅÐзǻÖÐ!playerServerID=%s" % GameWorld.GetPlayerServerID(curPlayer))
|
return
|
|
totalRMB = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardRMB) + addRMB, ChConfig.Def_UpperLimit_DWord)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_CTGBillboardRMB, totalRMB)
|
|
GameWorld.DebugLog("¿ç·þ³äÖµÅÅÐлÔö¼ÓÍæ¼ÒÀۼƳäÖµRMB: addRMB=%s,totalRMB=%s" % (addRMB, totalRMB), curPlayer.GetPlayerID())
|
Sync_CrossActCTGBillboardPlayerInfo(curPlayer)
|
UpdateCTGRMBCrossBillboard(curPlayer, actInfo)
|
return
|
|
def UpdateCTGRMBCrossBillboard(curPlayer, actInfo):
|
## ¸üпç·þ³äÖµ»î¶¯°ñ
|
totalRMB = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardRMB)
|
if not totalRMB:
|
return
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
if not cfgID:
|
return
|
|
playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardTemplateID)
|
orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("CrossActCTGBillboardOrder", playerTemplateID)
|
if not orderIpyDataList:
|
return
|
|
atleastRMBMin = None
|
for orderIpyData in orderIpyDataList:
|
atleastRMB = orderIpyData.GetCTGAtleast()
|
if atleastRMBMin == None or atleastRMBMin > atleastRMB:
|
atleastRMBMin = atleastRMB
|
|
if atleastRMBMin == None:
|
return
|
|
if totalRMB < atleastRMBMin:
|
GameWorld.DebugLog("¿ç·þ³äÖµÅÅÐл³äÖµ¶î¶È²»×㣬ÎÞ·¨ÉÏ°ñ! totalRMB(%s) < atleastRMBMin(%s)"
|
% (totalRMB, atleastRMBMin), curPlayer.GetPlayerID())
|
return
|
|
cmpValue = totalRMB
|
PlayerBillboard.UpdatePlayerCrossBillboard(curPlayer, ShareDefine.Def_CBT_ActCTG, cfgID, cmpValue)
|
return
|
|
def Sync_CrossActCTGBillboardPlayerInfo(curPlayer):
|
## ֪ͨ»î¶¯Íæ¼ÒÊý¾ÝÐÅÏ¢
|
playerActInfo = ChPyNetSendPack.tagMCCACTGBillboardPlayerInfo()
|
playerActInfo.CTGRMBTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardRMB)
|
playerActInfo.DabiaoAwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_CTGBillboardAward)
|
NetPackCommon.SendFakePack(curPlayer, playerActInfo)
|
return
|
|
def Sync_CrossActCTGBillboardInfo(curPlayer):
|
## ֪ͨ»î¶¯ÐÅÏ¢
|
|
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_CTGBillboard)
|
if not actInfo:
|
return
|
|
if not actInfo.get(ShareDefine.ActKey_State):
|
return
|
|
ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {})
|
if not ipyDataDict:
|
return 0
|
|
templateIDList = ipyDataDict.get("TemplateIDList", [])
|
if not templateIDList:
|
return
|
|
actPack = ChPyNetSendPack.tagMCCACTGBillboardInfo()
|
actPack.ServerIDRangeInfo = str(actInfo.get(ShareDefine.ActKey_ServerIDRangeList, []))
|
actPack.ServerInfoLen = len(actPack.ServerIDRangeInfo)
|
actPack.GroupValue1 = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
actPack.StartDate = ipyDataDict.get("StartDate", "")
|
actPack.EndtDate = ipyDataDict.get("EndDate", "")
|
actPack.TemplateID = actInfo.get(ShareDefine.ActKey_TemplateID, 0)
|
actPack.TempInfo = []
|
for templateID in templateIDList:
|
tempInfo = ChPyNetSendPack.tagMCCACTGBillboardTempInfo()
|
|
# ´ï±ê
|
tempInfo.TemplateID = templateID
|
tempInfo.DabiaoAwardInfo = []
|
dabiaoIpyDataList = IpyGameDataPY.GetIpyGameDataList("CrossActCTGBillboardDabiao", templateID)
|
if dabiaoIpyDataList:
|
for dabiaoIpyData in dabiaoIpyDataList:
|
dabiaoInfo = ChPyNetSendPack.tagMCCACTGBillboardDabiao()
|
dabiaoInfo.NeedRMB = dabiaoIpyData.GetCTGNeed()
|
dabiaoInfo.AwardIndex = dabiaoIpyData.GetAwardIndex()
|
dabiaoInfo.AwardItemList = []
|
for itemID, itemCount, isBind in dabiaoIpyData.GetAwardItemList():
|
itemInfo = ChPyNetSendPack.tagMCCACTGBillboardAwardItem()
|
itemInfo.ItemID = itemID
|
itemInfo.ItemCount = itemCount
|
itemInfo.IsBind = isBind
|
dabiaoInfo.AwardItemList.append(itemInfo)
|
dabiaoInfo.AwardItemCount = len(dabiaoInfo.AwardItemList)
|
tempInfo.DabiaoAwardInfo.append(dabiaoInfo)
|
tempInfo.DabiaoAwardCount = len(tempInfo.DabiaoAwardInfo)
|
|
# ÅÅÐÐ
|
tempInfo.OrderAwardInfo = []
|
orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("CrossActCTGBillboardOrder", templateID)
|
if orderIpyDataList:
|
for orderIpyData in orderIpyDataList:
|
orderInfo = ChPyNetSendPack.tagMCCACTGBillboardOrder()
|
orderInfo.OrderA = orderIpyData.GetOrderA()
|
orderInfo.OrderB = orderIpyData.GetOrderB()
|
orderInfo.NeedRMB = orderIpyData.GetCTGAtleast()
|
orderInfo.AwardItemList = []
|
for itemID, itemCount, isBind in orderIpyData.GetAwardItemList():
|
itemInfo = ChPyNetSendPack.tagMCCACTGBillboardAwardItem()
|
itemInfo.ItemID = itemID
|
itemInfo.ItemCount = itemCount
|
itemInfo.IsBind = isBind
|
orderInfo.AwardItemList.append(itemInfo)
|
orderInfo.AwardItemCount = len(orderInfo.AwardItemList)
|
tempInfo.OrderAwardInfo.append(orderInfo)
|
tempInfo.OrderAwardCount = len(tempInfo.OrderAwardInfo)
|
|
actPack.TempInfo.append(tempInfo)
|
|
actPack.TemplateCount = len(actPack.TempInfo)
|
NetPackCommon.SendFakePack(curPlayer, actPack)
|
return
|