#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package Player.PlayerFairyCeremony # # @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 = __CheckPlayerFairyCeremonyAction(curPlayer) if not isReset: actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FairyCeremony, {}) # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢ if actCostRebateInfo.get(ShareDefine.ActKey_State): SyncFCRechargeInfo(curPlayer) SyncFCPartyInfo(curPlayer) return def RefreshOperationAction_FairyCeremony(): playerManager = GameWorld.GetPlayerManager() for i in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(i) if not GameWorld.IsNormalPlayer(curPlayer): continue __CheckPlayerFairyCeremonyAction(curPlayer) return def __CheckPlayerFairyCeremonyAction(curPlayer): ## ¼ì²éÍæ¼ÒÏɽçÊ¢µä»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actFairyCeremonyInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FairyCeremony, {}) FairyCeremonyID = actFairyCeremonyInfo.get(ShareDefine.ActKey_ID, 0) state = actFairyCeremonyInfo.get(ShareDefine.ActKey_State, 0) playerFairyCeremonyID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyCeremonyID) # Íæ¼ÒÉíÉϵĻID # »î¶¯ID ÏàͬµÄ»°²»´¦Àí if FairyCeremonyID == playerFairyCeremonyID: #GameWorld.DebugLog("ÏɽçÊ¢µä»î¶¯ID²»±ä£¬²»´¦Àí£¡", curPlayer.GetPlayerID()) return ctgRMBTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TodayCTGCoinTotal) / 100 actWorldLV = actFairyCeremonyInfo.get(ShareDefine.ActKey_WorldLV, 0) playerFCWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCActionWorldLV) GameWorld.DebugLog("ÏɽçÊ¢µäÖØÖÃ! FairyCeremonyID=%s,playerCostRebateID=%s,state=%s,ActWorldLV=%s,playerFCWorldLV=%s,ctgRMBTotal=%s" % (FairyCeremonyID, playerFairyCeremonyID, state, actWorldLV, playerFCWorldLV, ctgRMBTotal), playerID) # δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å __SendFairyCeremonyMail(curPlayer, playerFCWorldLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyCeremonyID, FairyCeremonyID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCActionWorldLV, actWorldLV) #ÖØÖóäÖµ´óÀñ¼Ç¼ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCRechargeState, 0) #ÖØÖÃÈ«ÃñÀ´àË PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCPartyCurPoint, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCPartyAwardRecord, 0) for actid in ChConfig.PeoplePartyActIDList: PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCPartyCurCnt % actid, 0) SyncFCPartyInfo(curPlayer) #ÖØÖÃÒѳäÖµRMB¼°ÑÌ»¨Ïà¹Ø PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCCTGRMBTotal, ctgRMBTotal) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCFireworksBuyCount, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCFireworksScore, 0) SyncFCRechargeInfo(curPlayer) return True def __SendFairyCeremonyMail(curPlayer, playerFCWorldLV): # δÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å #³äÖµ´óÀñ playerID = curPlayer.GetID() playerName = curPlayer.GetName() if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCRechargeState) == 1: worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Recharge) awardInfoDict = IpyGameDataPY.GetFuncEvalCfg('CeremonyRecharge', 1, {}) if str(worldLvNum) not in awardInfoDict: GameWorld.ErrLog(' Óʼþ·¢·Å³äÖµ´óÀñ½±Àø CeremonyRecharge δÅäÖý±Àø worldLvNum=%s' % worldLvNum) else: awardList = awardInfoDict[str(worldLvNum)] PlayerControl.SendMailByKey('CeremonyPayPack', [playerID], awardList, [playerName]) #È«ÃñÀ´àË worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Party) curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurPoint) awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyAwardRecord) ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('AllPeoplePartyAward', {'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('CeremonyHaiPoint', [playerID], partyAwardList, [playerName]) return def __IsAtFCAction(): ##ÊÇ·ñÔÚÏɽçÊ¢µä»î¶¯ÖÐ actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FairyCeremony, {}) state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0) return state == 1 def __GetFCWorldLVIndex(curPlayer, fcType): #»ñÈ¡»î¶¯ÊÀ½çµÈ¼¶µµ playerFCWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCActionWorldLV) fcWorldlvDict = IpyGameDataPY.GetFuncEvalCfg('CeremonyWorldLv', 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_FCRechargeState) if curState != 0: return PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCRechargeState, 1) SyncFCRechargeInfo(curPlayer) return def GetFCRechargeAward(curPlayer): ## ÁìÈ¡³äÖµ´óÀñ½±Àø curState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCRechargeState) if curState != 1: return worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Recharge) awardInfoDict = IpyGameDataPY.GetFuncEvalCfg('CeremonyRecharge', 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_FCRechargeState, 2) for itemID, itemCnt, isBind in awardList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem]) SyncFCRechargeInfo(curPlayer) PlayerControl.WorldNotify(0, 'CeremonyRecharge', [curPlayer.GetName()]) return def SyncFCRechargeInfo(curPlayer): ## ֪ͨ³äÖµ´óÀñ»î¶¯×´Ì¬ packData = ChPyNetSendPack.tagMCXJSDRecharge() packData.State = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCRechargeState) packData.CTGTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCCTGRMBTotal) packData.FireworksBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCFireworksBuyCount) packData.FirewordsScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCFireworksScore) NetPackCommon.SendFakePack(curPlayer, packData) return #################È«ÃñÀ´àË############################## def AddFCPartyActionCnt(curPlayer, actionID, addCnt=1): ##Ôö¼ÓÈ«ÃñÀ´àËÍê³É´ÎÊý if not __IsAtFCAction(): return ipyData = IpyGameDataPY.GetIpyGameData('AllPeopleParty', actionID) if not ipyData: return maxCnt = ipyData.GetTotalTimes() curCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurCnt % actionID) if curCnt >= maxCnt: return newCnt = min(maxCnt, curCnt + addCnt) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCPartyCurCnt % actionID, newCnt) singlePoint = ipyData.GetAddPoint() addPoint = (newCnt - curCnt) * singlePoint curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurPoint) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCPartyCurPoint, curPoint + addPoint) PlayerControl.NotifyCode(curPlayer, "AddFCPartyPoint", [addPoint]) SyncFCPartyInfo(curPlayer, [actionID]) return def AddFCPartyPoint(curPlayer, addPoint): ## Ö±½ÓÔö¼Óà˵ã curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurPoint) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCPartyCurPoint, curPoint + addPoint) PlayerControl.NotifyCode(curPlayer, "AddFCPartyPoint", [addPoint]) SyncFCPartyInfo(curPlayer) return def GetFCPartyAward(curPlayer, index): ## È«ÃñÀ´àËÁì½± worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Party) ipyData = IpyGameDataPY.GetIpyGameData('AllPeoplePartyAward', worldLvNum, index) if not ipyData: return curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurPoint) if curPoint < ipyData.GetNeedPoint(): GameWorld.DebugLog(' È«ÃñÀ´àËÁì½±, µãÊý²»×ã%s, worldLvNum=%s, index=%s' % (ipyData.GetNeedPoint(), worldLvNum, index), curPlayer.GetID()) return awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyAwardRecord) 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_FCPartyAwardRecord, 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.tagMCAllPeoplePartyInfo() packData.Clear() packData.CurPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurPoint) packData.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyAwardRecord) if not isGetAward: packData.BuyCountList = [] for actID in ChConfig.PeoplePartyActIDList: if actIDList and actID not in actIDList: continue finishInfo = ChPyNetSendPack.tagMCAllPeoplePartyCount() finishInfo.ActID = actID finishInfo.CurTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCPartyCurCnt % actID) packData.BuyCountList.append(finishInfo) packData.Count = len(packData.BuyCountList) NetPackCommon.SendFakePack(curPlayer, packData) return #################¾ø°æ½µÁÙ############################## def AddFCCTGRMB(curPlayer, ctgRMB): ## ³äÖµXÔª if ctgRMB <= 0: return if not __IsAtFCAction(): return curRMBTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCCTGRMBTotal) updRMBTotal = curRMBTotal + ctgRMB PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCCTGRMBTotal, updRMBTotal) GameWorld.Log("¸üÐÂÏɽçÊ¢µä³äÖµRMBÖµ: curRMBTotal=%s,ctgRMB=%s,updRMBTotal=%s" % (curRMBTotal, ctgRMB, updRMBTotal), curPlayer.GetPlayerID()) SyncFCRechargeInfo(curPlayer) return def OnBuyFireworks(curPlayer, itemIndex, clientBuyCount): ## ¹ºÂòÑÌ»¨ if not __IsAtFCAction(): return fireworksDict = IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 1, {}) worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Fireworks) canBuyIDList = fireworksDict.get(str(worldLvNum), []) #[ÆÕͨÑÌ»¨, ¸ß¼¶ÑÌ»¨] if itemIndex not in canBuyIDList: return fireworksIndex = canBuyIDList.index(itemIndex) AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Fireworks, clientBuyCount) if fireworksIndex == 1: fireworksBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCFireworksBuyCount) + clientBuyCount PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCFireworksBuyCount, fireworksBuyCount) GameWorld.DebugLog("¸üÐÂÍæ¼Ò¸ß¼¶ÑÌ»¨ÒѹºÂò´ÎÊý: clientBuyCount=%s,fireworksBuyCount=%s" % (clientBuyCount, fireworksBuyCount), curPlayer.GetPlayerID()) fireworksScoreList = IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 2) # [ÆÕͨÑÌ»¨»ý·Ö, ¸ß¼¶ÑÌ»¨»ý·Ö] addScore = fireworksScoreList[fireworksIndex] * clientBuyCount curFireworksScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCFireworksScore) updFireworksScore = curFireworksScore + addScore PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FCFireworksScore, updFireworksScore) billboardNeedScore = IpyGameDataPY.GetFuncCfg('CeremonyFireParty', 4) if updFireworksScore >= billboardNeedScore: #¸üÐÂÅÅÐаñ GameWorld.DebugLog("Íæ¼Ò¾ø°æ½µÁÙ»ý·ÖÅÅÐиüÐÂ: itemIndex=%s,clientBuyCount=%s,curFireworksScore=%s,addScore=%s,updFireworksScore=%s" % (itemIndex, clientBuyCount, curFireworksScore, addScore, updFireworksScore), curPlayer.GetPlayerID()) PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_FCCostGold, updFireworksScore) else: GameWorld.DebugLog("Íæ¼Ò¾ø°æ½µÁÙÑÌ»¨»ý·Ö²»×㣬ÎÞ·¨Éϰñ! updFireworksScore=%s < billboardNeedScore=%s" % (updFireworksScore, billboardNeedScore), curPlayer.GetPlayerID()) SyncFCRechargeInfo(curPlayer) return #################ÑÌ»¨¿ñ»¶############################## def IsCanBuyFireworks(curPlayer, itemIndex, clientBuyCount): ##µ±Ç°ÊÇ·ñ¿ÉÒÔÂòÑÌ»¨ if not __IsAtFCAction(): GameWorld.Log(' ÑÌ»¨¿ñ»¶ÂòÑÌ»¨ »î¶¯Î´¿ªÆô, ÎÞ·¨¹ºÂò') return False fireworksDict = IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 1, {}) worldLvNum = __GetFCWorldLVIndex(curPlayer, Def_FC_Fireworks) canBuyIDList = fireworksDict.get(str(worldLvNum), []) #[ÆÕͨÑÌ»¨, ¸ß¼¶ÑÌ»¨] if itemIndex not in canBuyIDList: GameWorld.Log(' ÑÌ»¨¿ñ»¶ÂòÑÌ»¨ µ±Ç°¿ÉÒÔÂòÑÌ»¨Îª %s, ÎÞ·¨¹ºÂò %s,worldLvNum=%s'%(canBuyIDList, itemIndex,worldLvNum), curPlayer.GetID()) return False #¸ß¼¶ÑÌ»¨ÐèÒªÅжϳäÖµµÄ×ܶî buyOneNeedRMB = IpyGameDataPY.GetFuncCfg('CeremonyFireParty', 3) # ¹ºÂòÒ»¸ö¸ß¼¶ÑÌ»¨ËùÐè³äÖµRMBÖµ£¬µ¥Î»XÔª if itemIndex == canBuyIDList[-1] and buyOneNeedRMB: curRMBTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCCTGRMBTotal) fireworksBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FCFireworksBuyCount) totalCanBuyCount = curRMBTotal / buyOneNeedRMB if (fireworksBuyCount + clientBuyCount) > totalCanBuyCount: GameWorld.Log(' ÑÌ»¨¿ñ»¶ÂòÑÌ»¨ ¸ß¼¶ÑÌ»¨ËùÐèÖØÖÃRMB²»×ã, ÎÞ·¨¹ºÂò! curRMBTotal=%s,totalCanBuyCount=%s < fireworksBuyCount=%s + clientBuyCount=%s' % (curRMBTotal, totalCanBuyCount, fireworksBuyCount, clientBuyCount), curPlayer.GetID()) return False return True