#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package Player.PlayerTeHui # # @todo:ÌØ»Ý»î¶¯ # @author hxp # @date 2014-06-21 # @version 2.2 # # @change: "2014-08-27 14:30" hxp Ôö¼ÓÁ콱ȫ·þ¹ã²¥ # @change: "2014-09-28 17:30" hxp Ôö¼Ó³äÖµÅÅÐÐÌØ»Ý»î¶¯ # @change: "2014-12-02 11:30" hxp ºÏ·þÕÛ¿Ûµê # @change: "2014-12-26 00:05" Alee ÑéÖ¤¹¦Äܽ׼¶ # @change: "2015-01-23 14:30" hxp ³äÖµÌØ»Ý»î¶¯±ä¸üʱÔö¼ÓÓʼþ²¹·¢ÉÏ´ÎδÁìÈ¡µÄ³äÖµ½±Àø # @change: "2015-01-29 22:30" hxp ÌØ»Ý³äÖµÈÕÖ¾ # @change: "2015-02-11 16:30" hxp Ôö¼ÓÇеØÍ¼³É¹¦ºó¼ì²éÌØ»Ý»î¶¯Ïà¹Ø # @change: "2015-04-16 19:10" ljd Ôö¼ÓÏû·Ñ·µÀû¡¢Ôö¼Ó²»¼ÆÏû·Ñ·µÀûÉ̵êNPCIDÁбí # @change: "2016-07-20 14:30" hxp Ïû·ÑµãÏû·Ñ¼Ç¼Âß¼­µ÷Õû # @change: "2016-10-14 14:30" xdh ÀÛ³ä»î¶¯ÏµÍ³Ìáʾ¿ª³öÅäÖà # @change: "2017-06-14 11:00" hxp »¹Ô­ÌØ»ÝÏû·Ñ·µÀû°ñ # @change: "2017-07-07 11:30" hxp ÐÞ¸´³äÖµÅÅÐС¢³äÖµ·µÀû¡¢Ïû·ÑÅÅÐиüл×êʯkeyֵʱûÓиø²ÎÊý¿ÉÄÜ´æÔÚÖµ²»¸üеÄbug # ÏêϸÃèÊö: ÌØ»Ý»î¶¯ #--------------------------------------------------------------------- #"""Version = 2017-07-07 11:30""" #--------------------------------------------------------------------- import ShareDefine import GameWorld import ChConfig import ReadChConfig import ItemCommon import IPY_GameWorld import PlayerControl import ItemControler import ChPyNetSendPack import NetPackCommon import DataRecordPack import ShopItemManage import PlayerBillboard ( Recharge_Type_Single, # ³äÖµÌØ»Ý¹æÔòÀàÐÍ - µ¥±Ê³äÖµ Recharge_Type_Total, # ³äÖµÌØ»Ý¹æÔòÀàÐÍ - ÀۼƳäÖµ ) = range(2) ( Recharge_Type, # ³äÖµÌØ»Ý¹æÔòÀàÐÍ Recharge_NeedGold, # ËùÐè×êʯÊý Recharge_MaxCnt, # ×î´ó½±Àø´ÎÊý Recharge_AwardItemInfo, # ½±ÀøÐÅÏ¢ ) = range(4) # Ïû·Ñ½±ÀøÅäÖà TeHuiAction_CostProfitAward ( CostProfit_GoldNum, # ×êʯÊý CostProfit_NeedSpace, # ÐèÒªµÄ±³°ü¸ñ×ÓÊý CostProfit_ItemList, # ½±ÀøÎïÆ·ÐÅÏ¢Áбí ) = range(3) ## »ñÈ¡Íæ¼ÒÌØ»Ý»î¶¯×ÖµäÖµ # @param curPlayer: # @return: None def __GetPlayerTeHuiDictValue(curPlayer, key, defaultValue=0): return curPlayer.NomalDictGetProperty(key, defaultValue, ChConfig.Def_PDictType_TeHuiAction) ## ÉèÖÃÍæ¼ÒÌØ»Ý»î¶¯×ÖµäÖµ # @param curPlayer: # @return: None def __SetPlayerTeHuiDictValue(curPlayer, key, value): PlayerControl.NomalDictSetProperty(curPlayer, key, value, ChConfig.Def_PDictType_TeHuiAction) return ## »ñÈ¡µ±Ç°»î¶¯ÕÛ¿ÛµêIDÁбí # @param None: # @return: None def GetCurActionShowIDList(): return [GetCurActionShopID(), GetCurMixActionShopID()] ## »ñÈ¡µ±Ç°»î¶¯ÕÛ¿ÛµêID # @param None: # @return: None def GetCurActionShopID(): gameWorld = GameWorld.GetGameWorld() shopIDKey = ShareDefine.Def_Notify_WorldKey_DayAction_DiscountShop shopID = gameWorld.GetGameWorldDictByKey(shopIDKey) return shopID ## »ñÈ¡µ±Ç°ºÏ·þ»î¶¯ÕÛ¿ÛµêID # @param None: # @return: None def GetCurMixActionShopID(): gameWorld = GameWorld.GetGameWorld() mixShopIDKey = ShareDefine.Def_Notify_WorldKey_DayAction_MixDiscountShop mixShopID = gameWorld.GetGameWorldDictByKey(mixShopIDKey) return mixShopID ## ÌØ»Ý»î¶¯¸Ä±äʱ(µÇ½ ºÍ key¸Ä±äʱ) # @param curPlayer: Ö÷½Ç # @return: None def ChangeTeHuiActionState(key): #__CheckResetAllPlayerData(key) return ## Íæ¼ÒµÇ¼ʱ # @param curPlayer:Íæ¼Ò # @return None def PlayerLogin_TeHui(curPlayer): #=========================================================================== # for teHuiKey in ShareDefine.TeHuiTypeKeyDict.values(): # __CheckResetPlayerData(curPlayer, teHuiKey) # # # ÀϺżÇ¼±¾´Î³äÖµÌØ»Ý»î¶¯±àºÅ, ±ØÐë·ÅÔÚ¼ì²é»î¶¯Êý¾ÝÖ®ºó´¦Àí # gameWorld = GameWorld.GetGameWorld() # rechargeActionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_Recharge # actionNum = gameWorld.GetGameWorldDictByKey(rechargeActionNumKey) # rechargeActionDict = ReadChConfig.GetEvalChConfig("TeHuiAction_Recharge") # if actionNum in rechargeActionDict: # lastRechargeNum = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_LastRechargeNum) # __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_LastRechargeNum, actionNum) # GameWorld.DebugLog("µÇ¼¼Ç¼±¾´Î³äÖµÌØ»Ý»î¶¯±àºÅlastRechargeNum=%s,actionNum=%s" % (lastRechargeNum, actionNum)) # # Sync_ClassUPDayAwardRecord(curPlayer) # #Sync_RechargeTeHuiInfo(curPlayer) # Sync_RechargeRankTeHuiInfo(curPlayer) # Sync_CostRankTeHuiInfo(curPlayer) # Sync_CostProfitInfo(curPlayer) # SyncPlayerCostRank(curPlayer) #=========================================================================== return ## Ïû·ÑÅÅÐаñÌØ»Ý»î¶¯ # @param None # @return None def SyncPlayerCostRank(curPlayer): gameWorld = GameWorld.GetGameWorld() actionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_CostRank actionNum = gameWorld.GetGameWorldDictByKey(actionNumKey) if not actionNum: return # ¸üÐÂ×ÜÀÛ¼ÆÏû·ÑÊý totalGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TeHui_CostRankTotalGold, 0, ChConfig.Def_PDictType_TeHuiAction) totalGold = max(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TeHui_CostRankTotalGoldEx, 0, ChConfig.Def_PDictType_TeHuiAction), totalGold) GameWorld.Log("ͬ²½Ïû·ÑÅÅÐÐÌØ»Ý»î¶¯£¡actionNum=%s,totalGold=%s" % (actionNum, totalGold), curPlayer.GetPlayerID()) # ¸üÐÂÅÅÐаñ actionID = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DayAction_ID % actionNumKey) PlayerBillboard.UpdateCostRankBillboard(curPlayer, actionID, actionNum, totalGold) return ## ÇеØÍ¼³É¹¦Ê± # @param curPlayer:Íæ¼Ò # @return None def PlayerLoadMapOK(curPlayer): #=========================================================================== # GameWorld.DebugLog("Íæ¼ÒÇеØÍ¼³É¹¦£¬¼ì²éÌØ»Ý»î¶¯£¡", curPlayer.GetPlayerID()) # for teHuiKey in ShareDefine.TeHuiTypeKeyDict.values(): # __CheckResetPlayerData(curPlayer, teHuiKey) #=========================================================================== return ## Çå³ýËùÓÐÍæ¼ÒÐÅÏ¢(key ¸Ä±äʱµ÷ÓÃ) # @param curPlayer: Íæ¼Ò # @return: None def __CheckResetAllPlayerData(key): for i in range(0, GameWorld.GetPlayerManager().GetPlayerCount()): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(i) if curPlayer == None or not curPlayer.GetPlayerID(): continue #Çå³ýÍæ¼ÒÐÅÏ¢ __CheckResetPlayerData(curPlayer, key) return ## Çå³ýÍæ¼ÒÐÅÏ¢ # @param curPlayer: Íæ¼Ò # @param key: ÌØ»Ý»î¶¯key£¬Ä¬ÈÏÈ«²¿¼ì²é£¬Ò»°ãµÇ¼ʱȫ²¿¼ì²é # @return: None def __CheckResetPlayerData(curPlayer, key): playerID = curPlayer.GetPlayerID() gameWorld = GameWorld.GetGameWorld() actionIDKey = ShareDefine.Def_Notify_WorldKey_DayAction_ID % key # µ±Ç°»î¶¯µÄid(»î¶¯ÉèÖÃʱµÄʱ¼äÓÃÓÚ±êʶ»î¶¯Î¨Ò») actionID = gameWorld.GetGameWorldDictByKey(actionIDKey) # Íæ¼ÒÉíÉÏÊý¾ÝµÄ»î¶¯id playerActionIDKey = ChConfig.Def_PDict_TeHui_ActionID % key playerActionID = __GetPlayerTeHuiDictValue(curPlayer, playerActionIDKey) if playerActionID == actionID: GameWorld.DebugLog("ÌØ»Ý»î¶¯idÏàͬ£¬²»´¦Àíkey=%s,actionID=%s" % (key, actionID), playerID) return GameWorld.DebugLog("ÌØ»Ý»î¶¯Êý¾ÝÖØÖÃkey=%s,actionID=%s" % (key, actionID), playerID) __SetPlayerTeHuiDictValue(curPlayer, playerActionIDKey, actionID) if key == ShareDefine.Def_Notify_WorldKey_DayAction_Recharge: ResetRechargeData(curPlayer) elif key == ShareDefine.Def_Notify_WorldKey_DayAction_ClassUPNum: ResetClassUPAwardRecord(curPlayer) elif key == ShareDefine.Def_Notify_WorldKey_DayAction_DiscountShop: # µÇ¼µÄʱºò»á´¥·¢Çå¿Õʱ»ú shopID = GetCurActionShopID() ShopItemManage.ClearPlayerShopItemBuyCnt(curPlayer, shopID) elif key == ShareDefine.Def_Notify_WorldKey_DayAction_MixDiscountShop: mixShopID = GetCurMixActionShopID() ShopItemManage.ClearPlayerShopItemBuyCnt(curPlayer, mixShopID) elif key == ShareDefine.Def_Notify_WorldKey_DayAction_RechargeRank: ResetRechargeRankData(curPlayer) elif key == ShareDefine.Def_Notify_WorldKey_DayAction_CostProfit: ResetCostProfitInfo(curPlayer) elif key == ShareDefine.Def_Notify_WorldKey_DayAction_CostRank: ResetCostRankData(curPlayer) return ## ÖØÖÃÏû·ÑÅÅÐÐÌØ»ÝÊý¾Ý # @param curPlayer: # @return: None def ResetCostRankData(curPlayer): __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGold, 0) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGoldEx, 0) Sync_CostRankTeHuiInfo(curPlayer) return ## ÖØÖóäÖµÅÅÐÐÌØ»ÝÊý¾Ý # @param curPlayer: # @return: None def ResetRechargeRankData(curPlayer): __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGold, 0) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGoldEx, 0) Sync_RechargeRankTeHuiInfo(curPlayer) return ## ÖØÖóäÖµÌØ»ÝÊý¾Ý # @param curPlayer: # @return: None def ResetRechargeData(curPlayer): gameWorld = GameWorld.GetGameWorld() rechargeActionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_Recharge actionNum = gameWorld.GetGameWorldDictByKey(rechargeActionNumKey) rechargeActionDict = ReadChConfig.GetEvalChConfig("TeHuiAction_Recharge") if actionNum not in rechargeActionDict: return # ²¹·¢ÉÏ´ÎδÁìÈ¡µÄ½±Àø __SendRechargeAwardMail(curPlayer, rechargeActionDict) # ¸üÐÂеĻ±àºÅ, ÖØÖÃÊý¾Ý __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_LastRechargeNum, actionNum) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGold, 0) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGoldEx, 0) ruleList = rechargeActionDict[actionNum] for index in range(len(ruleList)): __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeGotCnt % index, 0) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeCanGetCnt % index, 0) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeCurTotalGold % index, 0) Sync_RechargeTeHuiInfo(curPlayer) return ## Óʼþ²¹·¢ÉÏÒ»´Î³äÖµÌØ»ÝδÁìÈ¡½±Àø # @param curPlayer: # @return: None def __SendRechargeAwardMail(curPlayer, rechargeActionDict): try: lastRechargeNum = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_LastRechargeNum) if lastRechargeNum not in rechargeActionDict: GameWorld.DebugLog("__SendRechargeAwardMail lastRechargeNum=%s not in actionDict!" % lastRechargeNum) return # Óʼþ²¹·¢Î´ÁìÈ¡µÄ½±Àø rechargeMail = ReadChConfig.GetEvalChConfig("TeHuiAction_RechargeMail") lastRuleList = rechargeActionDict[lastRechargeNum] job = curPlayer.GetJob() for lastIndex, ruleInfo in enumerate(lastRuleList): canGetCntKey = ChConfig.Def_PDict_TeHui_RechargeCanGetCnt % lastIndex lastCanGetCnt = __GetPlayerTeHuiDictValue(curPlayer, canGetCntKey) GameWorld.DebugLog("³äÖµÌØ»ÝÓʼþ²¹·¢½±Àø: lastRechargeNum=%s,index=%s,lastCanGetCnt=%s" % (lastRechargeNum, lastIndex, lastCanGetCnt)) if lastCanGetCnt <= 0: continue mailTitle = rechargeMail[0] getDays = rechargeMail[1] mailContent = "" ruleType = ruleInfo[Recharge_Type] needGold = ruleInfo[Recharge_NeedGold] awardItemInfo = ruleInfo[Recharge_AwardItemInfo] itemList = awardItemInfo[1] mailItemList = [] for itemInfo in itemList: if isinstance(itemInfo, dict): if job not in itemInfo: GameWorld.ErrLog('TeHuiAction_Recharge.txt δÅäÖøÃÖ°Òµ½±Àø job=%s'%job) continue itemID, itemCnt, isBind = itemInfo[job] else: itemID, itemCnt, isBind = itemInfo mailItemList.append((itemID, itemCnt * lastCanGetCnt, isBind)) GameWorld.DebugLog(" ruleType=%s,needGold=%s,itemList=%s,mailItemList=%s" % (ruleType, needGold, str(itemList), str(mailItemList))) if ruleType == Recharge_Type_Single: mailContent = rechargeMail[2] % (needGold, lastCanGetCnt) elif ruleType == Recharge_Type_Total: mailContent = rechargeMail[3] % (needGold, lastCanGetCnt) isSend = PlayerControl.SendMail(mailTitle, mailContent, getDays, [curPlayer.GetPlayerID()], mailItemList) if isSend: GameWorld.Log("Óʼþ²¹·¢ÉϴγäÖµÌØ»Ý½±Àø£ºlastRechargeNum=%s,index=%s,canGetCnt=%s,mailItemList=%s" % (lastRechargeNum, lastIndex, lastCanGetCnt, str(mailItemList)), curPlayer.GetPlayerID()) except BaseException, e: GameWorld.ErrLog("Óʼþ²¹·¢ÉϴγäÖµÌØ»Ý½±Àø³ö´í£¡%s" % e, curPlayer.GetPlayerID()) return ## ÖØÖÃÉý½×ÌØ»Ý½±Àø¼Ç¼Êý¾Ý # @param curPlayer: # @return: None def ResetClassUPAwardRecord(curPlayer): for dayType in ShareDefine.ClassUPDayList: __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_ClassUPAwardRecord % dayType, 0) Sync_ClassUPDayAwardRecord(curPlayer) return ## Íæ¼Ò³äÖµ # @param curPlayer: Íæ¼Ò # @param addGold: ³äÖµÔª±¦Êý # @return: None def PlayerGoldCharge_TeHuiAction(curPlayer, addGold): GameWorld.Log("ÌØ»Ý»î¶¯³äÖµ: addGold=%s" % addGold, curPlayer.GetPlayerID()) # ³äÖµÅÅÐаñÌØ»Ý __PlayerRechargeRankAction(curPlayer, addGold) # ³äÖµÌØ»Ý gameWorld = GameWorld.GetGameWorld() rechargeActionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_Recharge actionNum = gameWorld.GetGameWorldDictByKey(rechargeActionNumKey) rechargeActionDict = ReadChConfig.GetEvalChConfig("TeHuiAction_Recharge") if actionNum not in rechargeActionDict: GameWorld.Log("³äÖµÌØ»Ý»î¶¯£¡Î޸û±àºÅ! actionNum=%s" % (actionNum), curPlayer.GetPlayerID()) return # ¸üÐÂ×ÜÀۼƳäÖµÊý totalGold = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGold) totalGold = max(__GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGoldEx), totalGold) updateGold = totalGold + addGold __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGoldEx, updateGold) GameWorld.Log("³äÖµÌØ»Ý»î¶¯£¡actionNum=%s,totalGold=%s,addGold=%s,updateGold=%s" % (actionNum, totalGold, addGold, updateGold), curPlayer.GetPlayerID()) ruleList = rechargeActionDict[actionNum] for index, ruleInfo in enumerate(ruleList): ruleType = ruleInfo[Recharge_Type] needGold = ruleInfo[Recharge_NeedGold] maxCnt = ruleInfo[Recharge_MaxCnt] # ¸üе±Ç°¹æÔòÀÛ³äÊý curTotalGoldKey = ChConfig.Def_PDict_TeHui_RechargeCurTotalGold % index curTotalGold = __GetPlayerTeHuiDictValue(curPlayer, curTotalGoldKey) curTotalGold += addGold __SetPlayerTeHuiDictValue(curPlayer, curTotalGoldKey, curTotalGold) canCntKey = ChConfig.Def_PDict_TeHui_RechargeCanGetCnt % index curCanCnt = __GetPlayerTeHuiDictValue(curPlayer, canCntKey) curGotCnt = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeGotCnt % index) # ´ïµ½×î´ó´ÎÊý£¬²»ÔÙ´¦Àí´ÎÊý if curGotCnt + curCanCnt >= maxCnt: continue if ruleType == Recharge_Type_Single: if addGold < needGold: continue # Âú×ãµ¥±Ê³äÖµ£¬¿ÉÁìÈ¡´ÎÊý+1 __SetPlayerTeHuiDictValue(curPlayer, canCntKey, curCanCnt + 1) elif ruleType == Recharge_Type_Total: # ÀÛ³äºóʵ¼Ê¿ÉÁì½±´ÎÊý(¿ÉÁìÈ¡×Ü´ÎÊý - ÒÑÁìÈ¡´ÎÊý) canMaxCnt = min(maxCnt, curTotalGold / needGold) # µ±Ç°ÀÛ³äʵ¼Ê×î´ó¿ÉÁì½±´ÎÊý canCnt = max(0, canMaxCnt - curGotCnt) if canCnt != curCanCnt: __SetPlayerTeHuiDictValue(curPlayer, canCntKey, canCnt) # ͬ²½¿Í»§¶Ë Sync_RechargeTeHuiInfo(curPlayer) return ## ³äÖµÅÅÐаñÌØ»Ý»î¶¯ # @param None # @return None def __PlayerRechargeRankAction(curPlayer, addGold): gameWorld = GameWorld.GetGameWorld() actionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_RechargeRank actionNum = gameWorld.GetGameWorldDictByKey(actionNumKey) if not actionNum: GameWorld.Log("µ±Ç°Ã»ÓгäÖµÅÅÐÐÌØ»Ý»î¶¯£¬²»ÐèÒª¸üÐÂÅÅÐаñ£¡actionNum=%s" % actionNum, curPlayer.GetPlayerID()) return # ¸üÐÂ×ÜÀۼƳäÖµÊý totalGold = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGold) totalGold = max(__GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGoldEx), totalGold) updateGold = totalGold + addGold __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGoldEx, updateGold) GameWorld.Log("³äÖµÅÅÐÐÌØ»Ý»î¶¯£¡actionNum=%s,totalGold=%s,addGold=%s,updateGold=%s" % (actionNum, totalGold, addGold, updateGold), curPlayer.GetPlayerID()) # ¸üÐÂÅÅÐаñ actionID = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DayAction_ID % actionNumKey) PlayerBillboard.UpdateRechargeRankBillboard(curPlayer, actionID, actionNum, updateGold) # ͬ²½¿Í»§¶ËÀۼƳäÖµÊý Sync_RechargeRankTeHuiInfo(curPlayer) return ## Ïû·ÑÅÅÐаñÌØ»Ý»î¶¯ # @param None # @return None def __PlayerCostRankAction(curPlayer, addGold): gameWorld = GameWorld.GetGameWorld() actionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_CostRank actionNum = gameWorld.GetGameWorldDictByKey(actionNumKey) if not actionNum: GameWorld.Log("µ±Ç°Ã»ÓÐÏû·ÑÅÅÐÐÌØ»Ý»î¶¯£¬²»ÐèÒª¸üÐÂÅÅÐаñ£¡actionNum=%s" % actionNum, curPlayer.GetPlayerID()) return # ¸üÐÂ×ÜÀÛ¼ÆÏû·ÑÊý totalGold = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGold) totalGold = max(__GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGoldEx), totalGold) updateGold = totalGold + addGold __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGoldEx, updateGold) GameWorld.Log("Ïû·ÑÅÅÐÐÌØ»Ý»î¶¯£¡actionNum=%s,totalGold=%s,addGold=%s,updateGold=%s" % (actionNum, totalGold, addGold, updateGold), curPlayer.GetPlayerID()) # ¸üÐÂÅÅÐаñ actionID = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DayAction_ID % actionNumKey) PlayerBillboard.UpdateCostRankBillboard(curPlayer, actionID, actionNum, updateGold) # ͬ²½¿Í»§¶ËÀÛ¼ÆÏû·ÑÊý Sync_CostRankTeHuiInfo(curPlayer) return ## ÑéÖ¤µ±Ç°½×¼¶ # @param classlv # @return bool def CheckClassLV(curPlayer, dayType, classLV): # if dayType == ShareDefine.ClassUPDay_Horse: # if classLV <= curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Horser_ClassLV, # 0, ChConfig.Def_PDictType_Horse): # return True if dayType == ShareDefine.ClassUPDay_Office: # ¹Ù¾ô if classLV <= curPlayer.GetOfficialRank(): return True return False # AA 02 ÁìÈ¡Éý½×¹¦ÄÜÌØ»Ý½±Àø #tagCMGetClassUPDayAward ## ¿Í·þ¶ËÁìÈ¡Éý½×ÈÕÌØ»Ý½±Àø # @param index:Íæ¼ÒË÷Òý # @param clientPack:·â°ü½á¹¹Ìå # @param tick:ʱ¼ä´Á # @return None def ClientGetClassUPDayAward(index, clientPack, tick): return curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) dayType = clientPack.DayType classLV = clientPack.ClassLV GameWorld.DebugLog("ÁìÈ¡Éý½×ÌØ»Ý½±Àø dayType=%s,classLV=%s" % (dayType, classLV), curPlayer.GetPlayerID()) if dayType not in ShareDefine.ClassUPDayList: GameWorld.ErrLog(" ÌØ»Ý»î¶¯ÀàÐÍ=%s ·Ç·¨!" % (dayType)) return #ÑéÖ¤µ±Ç°½×¼¶ if not CheckClassLV(curPlayer, dayType, classLV): return classUPTeHuiDict = ReadChConfig.GetEvalChConfig("TeHuiAction_ClassUP") gameWorld = GameWorld.GetGameWorld() # µ±Ç°Éý½×ÌØ»Ý»î¶¯±àºÅ classUPActionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_ClassUPNum actionNum = gameWorld.GetGameWorldDictByKey(classUPActionNumKey) if actionNum not in classUPTeHuiDict: GameWorld.ErrLog(" ÌØ»Ý»î¶¯±àºÅ=%s not in TeHuiAction_ClassUP.txt" % actionNum) return curDayTypeList = classUPTeHuiDict[actionNum] # µ±Ç°»î¶¯ÖеÄÉý½×ÈÕÌØ»Ý # ÊÇ·ñÊǵ±Ç°»î¶¯ÖеÄÉý½×ÈÕ if dayType not in curDayTypeList: GameWorld.ErrLog(" ÌØ»Ý»î¶¯ÀàÐÍ=%s ·Çµ±Ç°»î¶¯ÖеÄÉý½×ÌØ»ÝÈÕ£¡curDayTypeList=%s" % (dayType, str(curDayTypeList))) return awardRecordKey = ChConfig.Def_PDict_TeHui_ClassUPAwardRecord % dayType # ÊÇ·ñÒÑÁì½± awardRecord = __GetPlayerTeHuiDictValue(curPlayer, awardRecordKey) if awardRecord & pow(2, classLV): GameWorld.Log(" ÌØ»Ý»î¶¯ÀàÐÍ=%s,classLV=%s ÒÑÁì¹ý½±Àø£¡²»ÄÜÖØ¸´ÁìÈ¡£¡" % (dayType, classLV)) return awardDict = ReadChConfig.GetEvalChConfig("TeHuiAction_ClassUPAward") if dayType not in awardDict.keys(): GameWorld.ErrLog(" ÌØ»Ý»î¶¯ÀàÐÍ=%s δÅäÖý±ÀøÐÅÏ¢£¡Çë¼ì²é TeHuiAction_ClassUPAward.txt" % (dayType)) return awardClassInfoDict = awardDict[dayType] if classLV not in awardClassInfoDict.keys(): GameWorld.ErrLog(" ÌØ»Ý»î¶¯ÀàÐÍ=%s,classLV=%s δÅäÖý±ÀøÐÅÏ¢£¡Çë¼ì²éTeHuiAction_ClassUPAward.txt" % (dayType, classLV)) return awardInfo = awardClassInfoDict[classLV] # ¼ì²é±³°ü packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) needSpace = awardInfo[0] if needSpace > packSpace: PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") return itemList = awardInfo[1] # ¸üÐÂÁì½±¼Ç¼ awardRecord = awardRecord|(1<= len(ruleList): GameWorld.ErrLog(" ÁìÈ¡Ë÷Òý=%s >=¹æÔòÁбíÌõÊýlen=%s" % (index, len(ruleList))) return ruleInfo = ruleList[index] GameWorld.DebugLog(" ruleInfo=%s" % str(ruleInfo)) gotCnt = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeGotCnt % index) canGetCnt = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeCanGetCnt % index) maxCnt = ruleInfo[Recharge_MaxCnt] GameWorld.DebugLog(" gotCnt=%s,canGetCnt=%s,maxCnt=%s" % (gotCnt, canGetCnt, maxCnt)) if gotCnt >= maxCnt: GameWorld.ErrLog(" ÒÑ´ïµ½×î´óÁì½±´ÎÊý£¡") return if canGetCnt <= 0: GameWorld.ErrLog(" ûÓпÉÁìÈ¡´ÎÊý£¡") return awardInfo = ruleInfo[Recharge_AwardItemInfo] # ¼ì²é±³°ü packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) needSpace = awardInfo[0] if needSpace > packSpace: PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") return itemList = awardInfo[1] # ÁìÈ¡´ÎÊý+1£¬¿ÉÁì½±´ÎÊý-1 __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeGotCnt % index, gotCnt + 1) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeCanGetCnt % index, canGetCnt - 1) # ¸øÎïÆ· job = curPlayer.GetJob() for itemInfo in itemList: if isinstance(itemInfo, dict): if job not in itemInfo: GameWorld.ErrLog('TeHuiAction_Recharge.txt δÅäÖøÃÖ°Òµ½±Àø job=%s'%job) continue itemID, itemCnt, isBind = itemInfo[job] else: itemID, itemCnt, isBind = itemInfo isPutIn = ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem], True) if isPutIn: PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [itemID, itemCnt]) DataRecordPack.DR_PlayerTeHuiRechargePrize(curPlayer, actionID, actionNum, itemID, itemCnt, isPutIn, index) # Áì½±¹ã²¥ RechargeNotifyDict = ReadChConfig.GetEvalChConfig("TeHuiAction_RechargeNotify") notifyMark = RechargeNotifyDict.get(actionNum, '') if notifyMark: PlayerControl.WorldNotify(0, notifyMark, [curPlayer.GetPlayerName(), ruleInfo[Recharge_NeedGold]]) # ͬ²½¼Ç¼ Sync_RechargeTeHuiInfo(curPlayer) return ## ֪ͨÉý½×ÌØ»Ý½±Àø¼Ç¼ÐÅÏ¢ # @param awardType ĬÈÏ0Ϊȫ²¿Í¬²½ # @return None def Sync_ClassUPDayAwardRecord(curPlayer, awardType=0): awardRecordPack = ChPyNetSendPack.tagMCClassUPDayAwardRecordList() awardRecordPack.Clear() awardRecordPack.RecordInfoList = [] for dayType in ShareDefine.ClassUPDayList: if awardType not in [0, dayType]: continue recordObj = ChPyNetSendPack.tagMCClassUPDayAwardRecord() recordObj.Clear() recordObj.DayType = dayType awardRecordKey = ChConfig.Def_PDict_TeHui_ClassUPAwardRecord % dayType recordObj.Record = __GetPlayerTeHuiDictValue(curPlayer, awardRecordKey) awardRecordPack.RecordInfoList.append(recordObj) awardRecordPack.RecordCount = len(awardRecordPack.RecordInfoList) NetPackCommon.SendFakePack(curPlayer, awardRecordPack) return ## ֪ͨ³äÖµÌØ»ÝÐÅÏ¢ # @param None # @return None def Sync_RechargeTeHuiInfo(curPlayer): gameWorld = GameWorld.GetGameWorld() rechargeActionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_Recharge actionNum = gameWorld.GetGameWorldDictByKey(rechargeActionNumKey) rechargeActionDict = ReadChConfig.GetEvalChConfig("TeHuiAction_Recharge") if actionNum not in rechargeActionDict: return # µ±Ç°»î¶¯µÄid(»î¶¯ÉèÖÃʱµÄʱ¼äÓÃÓÚ±êʶ»î¶¯Î¨Ò») actionID = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DayAction_ID % ShareDefine.Def_Notify_WorldKey_DayAction_Recharge) rechargePack = ChPyNetSendPack.tagMCRechargeTeHuiInfoList() rechargePack.Clear() rechargePack.ActionID = actionID rechargePack.TotalGold = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGold) rechargePack.TotalGold = max(__GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeTotalGoldEx), rechargePack.TotalGold) rechargePack.InfoList = [] ruleList = rechargeActionDict[actionNum] for index in range(len(ruleList)): rechargeInfo = ChPyNetSendPack.tagMCRechargeTeHuiInfo() rechargeInfo.Clear() rechargeInfo.CurTotalGold = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeCurTotalGold % index) rechargeInfo.CanGetCnt = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeCanGetCnt % index) rechargeInfo.GotCnt = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeGotCnt % index) rechargePack.InfoList.append(rechargeInfo) rechargePack.InfoCnt = len(rechargePack.InfoList) NetPackCommon.SendFakePack(curPlayer, rechargePack) return ## ֪ͨ³äÖµÅÅÐÐÌØ»ÝÐÅÏ¢ # @param None # @return None def Sync_RechargeRankTeHuiInfo(curPlayer): gameWorld = GameWorld.GetGameWorld() actionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_RechargeRank actionNum = gameWorld.GetGameWorldDictByKey(actionNumKey) if not actionNum: return # µ±Ç°»î¶¯µÄid(»î¶¯ÉèÖÃʱµÄʱ¼äÓÃÓÚ±êʶ»î¶¯Î¨Ò») actionID = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DayAction_ID % actionNumKey) rechargePack = ChPyNetSendPack.tagMCRechargeRankTeHuiInfo() rechargePack.Clear() rechargePack.ActionID = actionID totalGold = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGold) totalGold = max(__GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_RechargeRankTotalGoldEx), totalGold) rechargePack.TotalGold = totalGold NetPackCommon.SendFakePack(curPlayer, rechargePack) return ## ֪ͨÏû·ÑÅÅÐÐÌØ»ÝÐÅÏ¢ # @param None # @return None def Sync_CostRankTeHuiInfo(curPlayer): gameWorld = GameWorld.GetGameWorld() actionNumKey = ShareDefine.Def_Notify_WorldKey_DayAction_CostRank actionNum = gameWorld.GetGameWorldDictByKey(actionNumKey) if not actionNum: return # µ±Ç°»î¶¯µÄid(»î¶¯ÉèÖÃʱµÄʱ¼äÓÃÓÚ±êʶ»î¶¯Î¨Ò») actionID = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DayAction_ID % actionNumKey) sendPack = ChPyNetSendPack.tagMCCostRankTeHuiInfo() sendPack.Clear() sendPack.ActionID = actionID sendPack.TotalCost = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGold) sendPack.TotalCost = max(__GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostRankTotalGoldEx), sendPack.TotalCost) NetPackCommon.SendFakePack(curPlayer, sendPack) return ## AA 04 ÁìÈ¡Ïû·Ñ½±Àø # @param index # @param clientData # @param tick # @return None def OnGetCostProfitAward(index, clientData, tick): return curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) GameWorld.DebugLog("==[PlayerTeHui]== In->OnGetCostProfitAward(), Name:%s" % curPlayer.GetPlayerName()) actionId = clientData.ActionID awardIndex = clientData.Index dayActionKeyId = ShareDefine.Def_Notify_WorldKey_DayAction_ID dayActionKey = ShareDefine.Def_Notify_WorldKey_DayAction_CostProfit curActionId = GameWorld.GetGameWorld().GetGameWorldDictByKey(dayActionKeyId % dayActionKey) if actionId != curActionId: GameWorld.DebugLog("OnGetCostProfitAward() action(%s) no equal current action(%s)" % (actionId, curActionId)) return gotState = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostAwardState) if gotState & pow(2, awardIndex): GameWorld.DebugLog("OnGetCostProfitAward() have got award(%s)" % awardIndex) return actionAwardInfoList = __GetCostProfitCfg(curPlayer) if not actionAwardInfoList or awardIndex >= len(actionAwardInfoList): GameWorld.DebugLog("OnGetCostProfitAward() no configuration action(%s)" % actionId) return actionAwardInfo = actionAwardInfoList[awardIndex] curGoldNum = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostTotalGold) needGoldNum = actionAwardInfo[CostProfit_GoldNum] if curGoldNum < needGoldNum: GameWorld.DebugLog("OnGetCostProfitAward() current cost(%s) need(%s)" % (curGoldNum, needGoldNum)) return packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) needSpace = actionAwardInfo[CostProfit_NeedSpace] if packSpace < needSpace: GameWorld.DebugLog("OnGetCostProfitAward() pack space(%s) need space(%s)" % (packSpace, needSpace)) return __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostAwardState, gotState | pow(2, awardIndex)) itemInfoList = actionAwardInfo[CostProfit_ItemList] for itemId, itemNum, itemIsBind in itemInfoList: ItemControler.GivePlayerItem(curPlayer, itemId, itemNum, itemIsBind, [IPY_GameWorld.rptItem], True) addDataDict = {"actionId":actionId, "needCostGold":needGoldNum, "costGold":curGoldNum, "itemInfoList":str(itemInfoList)} DataRecordPack.DR_FuncGiveItem(curPlayer, "CostProfitAward", addDataDict) Sync_CostProfitInfo(curPlayer) GameWorld.DebugLog("==[PlayerTeHui]== Out->OnGetCostProfitAward()") return ## Ïû·Ñ¼Ç¼ # @param curPlayer # @param costType Ïû·ÑÀàÐÍ # @param costGold Ïû·Ñ×êʯÊý # @param extraValue Ô¤ÁôÐÅÏ¢ # @return None def AddCostProfitGold(curPlayer, costType, costGold, infoDict): #=============================================================================================== # if costGold <= 0: # return # if costType in ChConfig.CostProfit_CostType: # return # # delNPCIdList = ReadChConfig.GetEvalChConfig("TeHuiAction_CostProfitDelNPCID") # if costType == ChConfig.Def_Cost_BuyNPCShopItem: # if infoDict.get("NPCID", 0) in delNPCIdList: # return # # __PlayerCostRankAction(curPlayer, costGold) # # curGoldNum = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostTotalGold) # __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostTotalGold, curGoldNum + costGold) # Sync_CostProfitInfo(curPlayer) #=============================================================================================== return ## ֪ͨÏû·Ñ·µÀûÐÅÏ¢ # @param curPlayer # @return None def Sync_CostProfitInfo(curPlayer): dayActionKeyId = ShareDefine.Def_Notify_WorldKey_DayAction_ID dayActionKey = ShareDefine.Def_Notify_WorldKey_DayAction_CostProfit actionId = GameWorld.GetGameWorld().GetGameWorldDictByKey(dayActionKeyId % dayActionKey) if actionId <= 0: GameWorld.DebugLog("Sync_CostProfitInfo() no open action") return sendPack = ChPyNetSendPack.tagMCCostProfitInfo() sendPack.Clear() sendPack.ActionID = actionId sendPack.TotalCost = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostTotalGold) sendPack.AwardState = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostAwardState) NetPackCommon.SendFakePack(curPlayer, sendPack) return ## ÖØÖÃÏû·Ñ·µÀûÐÅÏ¢ # @param curPlayer # @return None def ResetCostProfitInfo(curPlayer): __SendCostProfitRepairMail(curPlayer) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostTotalGold, 0) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostAwardState, 0) dayActionKey = ShareDefine.Def_Notify_WorldKey_DayAction_CostProfit actionIndex = GameWorld.GetGameWorld().GetGameWorldDictByKey(dayActionKey) __SetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_LastCostIndex, actionIndex) Sync_CostProfitInfo(curPlayer) return ## ·¢ËͲ¹³¥Óʼþ # @param curPlayer # @return None def __SendCostProfitRepairMail(curPlayer): mailInfo = ReadChConfig.GetEvalChConfig("TeHuiAction_CostProfitMail") actionAwardInfoList = __GetCostProfitCfg(curPlayer) if not actionAwardInfoList: GameWorld.DebugLog("__SendCostProfitRepairMail() no configuration") return awardNum = len(actionAwardInfoList) gotState = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostAwardState) if gotState >= pow(2, awardNum + 1) - 1: GameWorld.DebugLog("__SendCostProfitRepairMail() reward got finish") return curGoldNum = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_CostTotalGold) for i in range(awardNum): if gotState & pow(2, i): continue actionAwardInfo = actionAwardInfoList[i] itemInfoList = actionAwardInfo[CostProfit_ItemList] costGoldNum = actionAwardInfo[CostProfit_GoldNum] if curGoldNum < costGoldNum: GameWorld.DebugLog("__SendCostProfitRepairMail() cost(%s) gold no enough(%s)" % (curGoldNum, costGoldNum)) return mailTitle = mailInfo[0] mailDay = mailInfo[1] mailContent = mailInfo[2] % costGoldNum playerIdList = [curPlayer.GetPlayerID()] if not PlayerControl.SendMail(mailTitle, mailContent, mailDay, playerIdList, itemInfoList): GameWorld.ErrLog("__SendCostProfitRepairMail() repair(%s) mail send fail" % i) return ## »ñÈ¡Ïû·Ñ·µÀûÅäÖÃÐÅÏ¢ # @param None # @return ÅäÖÃÐÅÏ¢Áбí def __GetCostProfitCfg(curPlayer): costProfitDict = ReadChConfig.GetEvalChConfig("TeHuiAction_CostProfitAward") lastCostIndex = __GetPlayerTeHuiDictValue(curPlayer, ChConfig.Def_PDict_TeHui_LastCostIndex) actionAwardInfoList = costProfitDict.get(lastCostIndex, []) if not actionAwardInfoList: GameWorld.DebugLog("__GetCostProfitCfg() no configuration action index(%s)" % lastCostIndex) return actionAwardInfoList