#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerNewFairyCeremony
|
#
|
# @todo:ÐÂÏɽçÊ¢µä
|
# @author xdh
|
# @date 2018-07-23 16:50
|
# @version 1.0
|
#
|
#
|
# ÏêϸÃèÊö: ÐÂÏɽçÊ¢µä
|
#
|
#---------------------------------------------------------------------
|
"""Version = 2018-07-23 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
|
import PlayerBillboard
|
|
(
|
Def_FC_Recharge, #³äÖµ´óÀñ
|
Def_FC_Fireworks, #ÑÌ»¨
|
Def_FC_Party, #È«ÃñÀ´àË
|
Def_FC_RechargeRank, #¾ø°æ½µÁÙ
|
) = range(1, 5)
|
|
|
def OnLogin(curPlayer):
|
isReset = __CheckPlayerNewFairyCeremonyAction(curPlayer)
|
if not isReset:
|
actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_NewFairyCeremony, {})
|
# »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢
|
if actCostRebateInfo.get(ShareDefine.ActKey_State):
|
SyncFCRechargeInfo(curPlayer)
|
SyncFCPartyInfo(curPlayer)
|
return
|
|
def RefreshOperationAction_NewFairyCeremony():
|
playerManager = GameWorld.GetPlayerManager()
|
for i in xrange(playerManager.GetPlayerCount()):
|
curPlayer = playerManager.GetPlayerByIndex(i)
|
if not GameWorld.IsNormalPlayer(curPlayer):
|
continue
|
__CheckPlayerNewFairyCeremonyAction(curPlayer)
|
return
|
|
|
def __CheckPlayerNewFairyCeremonyAction(curPlayer):
|
## ¼ì²éÍæ¼ÒÐÂÏɽçÊ¢µä»î¶¯Êý¾ÝÐÅÏ¢
|
playerID = curPlayer.GetPlayerID()
|
|
actNewFairyCeremonyInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_NewFairyCeremony, {})
|
NewFairyCeremonyID = actNewFairyCeremonyInfo.get(ShareDefine.ActKey_ID, 0)
|
state = actNewFairyCeremonyInfo.get(ShareDefine.ActKey_State, 0)
|
|
playerNewFairyCeremonyID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFairyCeremonyID) # Íæ¼ÒÉíÉϵĻID
|
|
# »î¶¯ID ÏàͬµÄ»°²»´¦Àí
|
if NewFairyCeremonyID == playerNewFairyCeremonyID:
|
#GameWorld.DebugLog("ÐÂÏɽçÊ¢µä»î¶¯ID²»±ä£¬²»´¦Àí£¡", curPlayer.GetPlayerID())
|
return
|
actWorldLV = actNewFairyCeremonyInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
playerFCWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCActionWorldLV)
|
GameWorld.DebugLog("ÐÂÏɽçÊ¢µäÖØÖÃ! NewFairyCeremonyID=%s,playerCostRebateID=%s,state=%s,ActWorldLV=%s,playerFCWorldLV=%s"
|
% (NewFairyCeremonyID, playerNewFairyCeremonyID, state, actWorldLV, playerFCWorldLV), playerID)
|
|
# δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å
|
__SendNewFairyCeremonyMail(curPlayer, playerFCWorldLV)
|
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFairyCeremonyID, NewFairyCeremonyID)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCActionWorldLV, actWorldLV)
|
#ÖØÖóäÖµ´óÀñ¼Ç¼
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCRechargeState, 0)
|
SyncFCRechargeInfo(curPlayer)
|
#ÖØÖÃÈ«ÃñÀ´àË
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCPartyCurPoint, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCPartyAwardRecord, 0)
|
for actid in ChConfig.PeoplePartyActIDList:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCPartyCurCnt % actid, 0)
|
SyncFCPartyInfo(curPlayer)
|
#ÖØÖÃÏû·Ñ
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCCostGold, 0)
|
return True
|
|
def __SendNewFairyCeremonyMail(curPlayer, playerFCWorldLV):
|
# δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å
|
#³äÖµ´óÀñ
|
playerID = curPlayer.GetID()
|
playerName = curPlayer.GetName()
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCRechargeState) == 1:
|
worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Recharge)
|
awardInfoDict = IpyGameDataPY.GetFuncEvalCfg('NewCeremonyRecharge', 1, {})
|
if str(worldLvNum) not in awardInfoDict:
|
GameWorld.ErrLog(' Óʼþ·¢·Å³äÖµ´óÀñ½±Àø CeremonyRecharge δÅäÖý±Àø worldLvNum=%s' % worldLvNum)
|
else:
|
awardList = awardInfoDict[str(worldLvNum)]
|
PlayerControl.SendMailByKey('NewCeremonyPayPack', [playerID], awardList, [playerName])
|
#È«ÃñÀ´àË
|
worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Party)
|
curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyCurPoint)
|
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyAwardRecord)
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('NewAllPeoplePartyAward', {'WorldLvNum':worldLvNum}, True)
|
if not ipyDataList:
|
GameWorld.ErrLog(' Óʼþ·¢·ÅÈ«ÃñÀ´à˽±Àø AllPeoplePartyAward δÅäÖÃÊÀ½çµÈ¼¶µµ WorldLvNum=%s' % worldLvNum)
|
return
|
|
partyAwardList = []
|
for ipyData in ipyDataList:
|
index = ipyData.GetIndex()
|
if awardRecord & pow(2, index):
|
continue
|
needPoint = ipyData.GetNeedPoint()
|
if curPoint < needPoint:
|
continue
|
awardInfoDict = ipyData.GetAward()
|
job = curPlayer.GetJob()
|
if str(job) not in awardInfoDict:
|
GameWorld.ErrLog(' Óʼþ·¢·ÅÈ«ÃñÀ´à˽±Àø AllPeoplePartyAward δÅäÖÃÖ°Òµ½±Àø job=%s' % job)
|
continue
|
awardList = awardInfoDict[str(job)]
|
partyAwardList += awardList
|
if partyAwardList:
|
PlayerControl.SendMailByKey('NewCeremonyHaiPoint', [playerID], partyAwardList, [playerName])
|
return
|
|
def __IsAtFCAction():
|
##ÊÇ·ñÔÚÐÂÏɽçÊ¢µä»î¶¯ÖÐ
|
actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_NewFairyCeremony, {})
|
state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0)
|
return state == 1
|
|
def __GetFCWorldLVIndex(curPlayer, fcType):
|
#»ñÈ¡»î¶¯ÊÀ½çµÈ¼¶µµ
|
playerFCWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCActionWorldLV)
|
fcWorldlvDict = IpyGameDataPY.GetFuncEvalCfg('NewCeremonyWorldLv', 1, {})
|
if str(fcType) not in fcWorldlvDict:
|
return 0
|
worldLVIndex = 0
|
worldlvList = fcWorldlvDict[str(fcType)]
|
for index, lvinfo in enumerate(worldlvList):
|
minlv, maxlv = lvinfo
|
if minlv <= playerFCWorldLV <= maxlv:
|
worldLVIndex = index
|
break
|
return worldLVIndex
|
|
#################³äÖµ´óÀñ##############################
|
def OnFCRecharge(curPlayer):
|
if not __IsAtFCAction():
|
return
|
curState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCRechargeState)
|
if curState != 0:
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCRechargeState, 1)
|
SyncFCRechargeInfo(curPlayer)
|
return
|
|
def GetFCRechargeAward(curPlayer):
|
## ÁìÈ¡³äÖµ´óÀñ½±Àø
|
curState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCRechargeState)
|
if curState != 1:
|
return
|
worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Recharge)
|
awardInfoDict = IpyGameDataPY.GetFuncEvalCfg('NewCeremonyRecharge', 1, {})
|
if str(worldLvNum) not in awardInfoDict:
|
GameWorld.ErrLog(' ÁìÈ¡³äÖµ´óÀñ½±Àø CeremonyRecharge δÅäÖý±Àø worldLvNum=%s' % worldLvNum)
|
return
|
awardList = awardInfoDict[str(worldLvNum)]
|
# ¼ì²é±³°ü
|
needSpace = len(awardList)
|
packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
|
if needSpace > packSpace:
|
PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
|
return
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCRechargeState, 2)
|
for itemID, itemCnt, isBind in awardList:
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
|
|
SyncFCRechargeInfo(curPlayer)
|
|
PlayerControl.WorldNotify(0, 'NewCeremonyRecharge', [curPlayer.GetName()])
|
return
|
|
|
def SyncFCRechargeInfo(curPlayer):
|
## ֪ͨ³äÖµ´óÀñ»î¶¯×´Ì¬
|
packData = ChPyNetSendPack.tagMCNewXJSDRecharge()
|
packData.State = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCRechargeState)
|
NetPackCommon.SendFakePack(curPlayer, packData)
|
return
|
|
#################È«ÃñÀ´àË##############################
|
def AddFCPartyActionCnt(curPlayer, actionID, addCnt=1):
|
##Ôö¼ÓÈ«ÃñÀ´àËÍê³É´ÎÊý
|
if not __IsAtFCAction():
|
return
|
ipyData = IpyGameDataPY.GetIpyGameData('NewAllPeopleParty', actionID)
|
if not ipyData:
|
return
|
maxCnt = ipyData.GetTotalTimes()
|
curCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyCurCnt % actionID)
|
if curCnt >= maxCnt:
|
return
|
newCnt = min(maxCnt, curCnt + addCnt)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCPartyCurCnt % actionID, newCnt)
|
singlePoint = ipyData.GetAddPoint()
|
addPoint = (newCnt - curCnt) * singlePoint
|
curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyCurPoint)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCPartyCurPoint, curPoint + addPoint)
|
SyncFCPartyInfo(curPlayer, [actionID])
|
return
|
|
def GetFCPartyAward(curPlayer, index):
|
## È«ÃñÀ´àËÁì½±
|
worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Party)
|
|
ipyData = IpyGameDataPY.GetIpyGameData('NewAllPeoplePartyAward', worldLvNum, index)
|
if not ipyData:
|
return
|
|
curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyCurPoint)
|
if curPoint < ipyData.GetNeedPoint():
|
GameWorld.DebugLog(' È«ÃñÀ´àËÁì½±, µãÊý²»×ã%s, worldLvNum=%s, index=%s' % (ipyData.GetNeedPoint(), worldLvNum, index), curPlayer.GetID())
|
return
|
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyAwardRecord)
|
awardMark = pow(2, index)
|
if awardRecord & awardMark:
|
GameWorld.DebugLog(' È«ÃñÀ´àËÁì½±, ÒÑÁì½±, worldLvNum=%s, index=%s' % (worldLvNum, index), curPlayer.GetID())
|
return
|
awardInfoDict = ipyData.GetAward()
|
job = curPlayer.GetJob()
|
if str(job) not in awardInfoDict:
|
return
|
awardList = awardInfoDict[str(job)]
|
# ¼ì²é±³°ü
|
needSpace = len(awardList)
|
packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
|
if needSpace > packSpace:
|
PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
|
return
|
#¸üмǼ
|
awardRecord |= awardMark
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCPartyAwardRecord, awardRecord)
|
for itemID, itemCnt, isBind in awardList:
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
|
#֪ͨ
|
SyncFCPartyInfo(curPlayer, isGetAward=True)
|
return
|
|
|
def SyncFCPartyInfo(curPlayer, actIDList=[], isGetAward=False):
|
##֪ͨȫÃñÀ´àËÐÅÏ¢
|
packData = ChPyNetSendPack.tagMCNewAllPeoplePartyInfo()
|
packData.Clear()
|
packData.CurPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyCurPoint)
|
packData.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyAwardRecord)
|
if not isGetAward:
|
packData.BuyCountList = []
|
for actID in ChConfig.PeoplePartyActIDList:
|
if actIDList and actID not in actIDList:
|
continue
|
finishInfo = ChPyNetSendPack.tagMCNewAllPeoplePartyCount()
|
finishInfo.ActID = actID
|
finishInfo.CurTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCPartyCurCnt % actID)
|
packData.BuyCountList.append(finishInfo)
|
packData.Count = len(packData.BuyCountList)
|
|
NetPackCommon.SendFakePack(curPlayer, packData)
|
return
|
|
#################¾ø°æ½µÁÙ##############################
|
def AddFCCostGold(curPlayer, costGold):
|
##³äÖµXÔª
|
if costGold <= 0:
|
return
|
# if costType in ChConfig.CostRebate_DisableType:
|
# #GameWorld.DebugLog("²»¼ÆÈë¾ø°æ½µÁÙÏû·ÑµÄÏû·ÑÀàÐÍ!costType=%s" % costType, curPlayer.GetPlayerID())
|
# return
|
if not __IsAtFCAction():
|
return
|
curCostGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NewFCCostGold)
|
updCostGold = curCostGold + costGold
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NewFCCostGold, updCostGold)
|
|
if updCostGold < IpyGameDataPY.GetFuncCfg('NewCeremonyRankLimit'):
|
return
|
|
#¸üÐÂÅÅÐаñ
|
PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_NewFCCostGold, updCostGold)
|
|
GameWorld.DebugLog("Íæ¼Ò¾ø°æ½µÁÙÏû·Ñ»î¶¯: curCostGold=%s,costGold=%s,updCostGold=%s"
|
% (curCostGold, costGold, updCostGold), curPlayer.GetPlayerID())
|
return
|
|
#################ÑÌ»¨¿ñ»¶##############################
|
def IsCanBuyFireworks(curPlayer, itemIndex):
|
##µ±Ç°ÊÇ·ñ¿ÉÒÔÂòÑÌ»¨
|
if not __IsAtFCAction():
|
GameWorld.Log(' ÑÌ»¨¿ñ»¶ÂòÑÌ»¨ »î¶¯Î´¿ªÆô, ÎÞ·¨¹ºÂò')
|
return False
|
fireworksDict = IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {})
|
worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Fireworks)
|
canBuyID = fireworksDict.get(str(worldLvNum), 0)
|
if canBuyID != itemIndex:
|
GameWorld.Log(' ÑÌ»¨¿ñ»¶ÂòÑÌ»¨ µ±Ç°¿ÉÒÔÂòÑÌ»¨Îª %s, ÎÞ·¨¹ºÂò %s,worldLvNum=%s'%(canBuyID, itemIndex,worldLvNum), curPlayer.GetID())
|
return False
|
return True
|