#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package Player.PlayerCostVIP # # @todo:Ïû·ÑVIP # @author ljd # @date 2015-04-21 11:30 # @version 1.7 # # @change: "2015-08-18 15:50" ljd ÌØÊâ´¦ÀíÊýÖµÅä´í,VIPµÈ¼¶¾­Ñéµ÷С,ÌØÊâ´¦ÀíÍâÍøÒÑÉý¼¶VIPÍæ¼Ò,²¹»ØVIPµÈ¼¶ # @change: "2016-01-26 15:00" hxp PY±íÖ§³ÖÖØ¶Á # @change: "2016-06-15 12:00" hxp ³èÎïÊØ»¤Î»½âËø # @change: "2016-07-02 16:30" hxp VIPÌØÈ¨buff¸ÄΪ±»¶¯¼¼ÄܼÓÕ½¶·Á¦ # @change: "2016-10-17 16:00" hxp Ôö¼Ó¾­Ñ鸱±¾¡¢½ð±Ò¸±±¾ÊÕÒæÌØÈ¨ # @change: "2017-04-01 10:30" xdh CostVIP.txtÈ¥³ýÖ°ÒµÇø±ð # @change: "2017-05-24 16:08" xdh Ôö¼ÓVIP³É³¤½±Àø # # ÏêϸÃèÊö: Ïû·Ñ×êʯÊýÔö¼ÓVIPµÈ¼¶,¸ù¾ÝVIPµÈ¼¶Ôö¼ÓÌØÈ¨ºÍ¸øÓè½±Àø # #--------------------------------------------------------------------- #"""Version = 2017-05-24 16:08""" #--------------------------------------------------------------------- import IPY_GameWorld import GameWorld import ChConfig import ReadChConfig import PyMapTable import ItemControler import PlayerControl import DataRecordPack import ShareDefine import ChPyNetSendPack import NetPackCommon import ChPlayer import SkillCommon import BuffSkill import EventShell import HighLadderTube import Operate_PlayerBuyZhenQi # Ïû·ÑVIPÐÅÏ¢±íÁбêʶ CostVIPData_LV = "LV" # VIPµÈ¼¶ CostVIPData_Exp = "EXP" # Éý¼¶ËùÐè¾­Ñé # ----- Íâµ÷ÔÙ·â×°º¯ÊýʹÓà ----- CostVIPData_PrayNum = "PrayNum" # Æíµ»´ÎÊý CostVIPData_ArenaNum = "ArenaNum" # ¾º¼¼³¡Ôö¼Ó´ÎÊý CostVIPData_RoundReward = "RoundReward" # »·ÈÎÎñ½±Àø¼Ó³É <°Ù·ÖÂÊ> CostVIPData_RoundStar = "RoundStar" # »·ÈÎÎñ×ÖµäÐǼ¶ CostVIPData_BZZDExpAddRate = "BZZDExpAddRate" # ¾­ÑéÃØ¾³¾­Ñé¼Ó³É CostVIPData_RedPacketGrabCnt = "RedPacketGrabCnt" # ÇÀºì°üÿÈÕ¿ÉÇÀ´ÎÊýÔö¼Ó CostVIPData_KillWorldBossAddCnt = "KillWorldBossAddCnt" # »÷ɱÊÀ½çboss´ÎÊýÔö¼Ó # Ïû·ÑVIPÐÅÏ¢±í½±ÀøÅäÖøñʽ ( Reward_Item_Type, # ÎïÆ·ÀàÐÍ Reward_Item_Id, # ÎïÆ·ID Reward_Item_Num, # ÎïÆ·ÊýÁ¿ Reward_Item_Bind, # ÊÇ·ñ°ó¶¨ ) = range(4) # ÎïÆ·ÀàÐÍ ( Item_Type_Common, # Ò»°ãÎïÆ·±í Item_Type_Appoint, # ÌØÊâ¶¨ÖÆÎïÆ· ) = range(2) ## Ôö¼ÓÏû·ÑVIP¾­Ñé # @param curPlayer # @param costType Ïû·ÑÀàÐÍ # @param costGold Ïû·Ñ×êʯÊý # @return def AddCostVIPExp(curPlayer, costType, costGold): GameWorld.DebugLog("==[PlayerCostVIP]== In->AddCostVIPExp() player(%s)" % curPlayer.GetPlayerName()) if costGold <= 0: GameWorld.DebugLog("AddCostVIPExp() no cost(%s) gold" % costType) return if costType in ChConfig.CostVIP_CostType: GameWorld.DebugLog("AddCostVIPExp() no use cost(%s) type" % costType) return moneyToExpScale = eval(ReadChConfig.GetEvalChConfig('CostVIPMoneyToExp')) addExp = int(costGold * moneyToExpScale) if addExp <= 0: GameWorld.DebugLog("AddCostVIPExp() no add EXP") return curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostVIPExp) lastLV = curPlayer.GetVIPLv() __AddCostVIPExp(curPlayer, addExp) if lastLV != curPlayer.GetVIPLv(): DataRecordPack.DR_PlayerCostVIPLV(curPlayer, lastLV, curExp, addExp, costType, costGold) return ## Ôö¼ÓÏû·ÑVIP¾­Ñé def __AddCostVIPExp(curPlayer, addExp): curLV = curPlayer.GetVIPLv() needExp = __GetCostVIPData(curPlayer, curLV, CostVIPData_Exp) if not needExp: GameWorld.DebugLog("__AddCostVIPExp() EXP no configuration vipLV(%s)" % curLV) return curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostVIPExp) newExp = curExp + addExp while needExp and newExp >= needExp: curLV += 1 __SetVIPLV(curPlayer, curLV) newExp -= needExp needExp = __GetCostVIPData(curPlayer, curLV, CostVIPData_Exp) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostVIPExp, newExp if needExp else 0) Sync_CostVIPInfo(curPlayer) GameWorld.DebugLog(" __AddCostVIPExp() LV(%s) EXP(%s)" % (curLV, newExp)) return ## Ïû·ÑVIPµÇ½ # @param curPlayer # @param tick # @return def CostVIPOnLogin(curPlayer, tick): Sync_CostVIPInfo(curPlayer) Sync_CostVIPAwardState(curPlayer) Sync_CostVIPGrowUpAwardState(curPlayer) return ## ¹ºÂòÏû·ÑVIPÎïÆ· # @param index # @param clientPack # @param tick # @return def BuyCostVIPItem(index, clientPack, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) GameWorld.DebugLog("==[PlayerCostVIP]== In->BuyCostVIPItem(), Name:%s" % curPlayer.GetPlayerName()) getVIPLV = clientPack.VIPLV if getVIPLV > curPlayer.GetVIPLv(): GameWorld.DebugLog("BuyCostVIPItem() VIP LV(%s) no buy LV(%s)" % (curPlayer.GetVIPLv(), getVIPLV)) return buyItemStateKey = ChConfig.Def_PDict_CostVIPBuyItem buyItemState = curPlayer.NomalDictGetProperty(buyItemStateKey) if buyItemState & pow(2, getVIPLV): GameWorld.DebugLog("BuyCostVIPItem() had buy reward(%s)" % getVIPLV) return VIPBuyItemCfg = ReadChConfig.GetEvalChConfig('VIPBuyItemCfg') if getVIPLV not in VIPBuyItemCfg: GameWorld.DebugLog("VIPBuyItemCfg.txt δÅäÖùºÂòÐÅÏ¢ vip=%s" % getVIPLV) return buyItemInfo = VIPBuyItemCfg[getVIPLV] if len(buyItemInfo) !=3: return itemPrice, needSpace, itemList = buyItemInfo packSpace = ItemControler.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) if packSpace < needSpace: GameWorld.DebugLog("BuyCostVIPItem() no enough(%s) pack space(%s)" % (needSpace, packSpace)) return moneyType = IPY_GameWorld.TYPE_Price_Gold_Money if itemPrice > 0: if not PlayerControl.HaveMoney(curPlayer, moneyType, itemPrice, True): GameWorld.DebugLog("BuyCostVIPItem() no enough money(%s)" % itemPrice) return PlayerControl.NomalDictSetProperty(curPlayer, buyItemStateKey, buyItemState | pow(2, getVIPLV)) if itemPrice > 0: infoDict = {"getVIPLV":getVIPLV, ChConfig.Def_Cost_Reason_SonKey:"VIP%s"%getVIPLV} PlayerControl.PayMoney(curPlayer, moneyType, itemPrice, ChConfig.Def_Cost_BuyVIPItem, infoDict) __GiveItem(curPlayer, itemList) Sync_CostVIPInfo(curPlayer) GameWorld.DebugLog("==[PlayerCostVIP]== Out->BuyCostVIPItem()") return ## ÁìÈ¡Ïû·ÑVIP½±Àø # @param curPlayer # @param getVIPLV ÁìÈ¡µÄVIPµÈ¼¶ # @return def GetCostVIPAward(curPlayer, getVIPLV): if getVIPLV > curPlayer.GetVIPLv(): GameWorld.DebugLog("GetCostVIPAward() VIP LV(%s) no buy LV(%s)" % (curPlayer.GetVIPLv(), getVIPLV)) return rewardStateKey = ChConfig.Def_PDict_CostVIPLVReward rewardState = curPlayer.NomalDictGetProperty(rewardStateKey) if rewardState & pow(2, getVIPLV): GameWorld.DebugLog("GetCostVIPAward() had got reward(%s)" % getVIPLV) return VIPAwardCfg = ReadChConfig.GetEvalChConfig('VIPAwardCfg') if getVIPLV not in VIPAwardCfg: GameWorld.DebugLog("VIPAwardCfg.txt δÅäÖý±ÀøÐÅÏ¢ vip=%s" % getVIPLV) return rewardList = VIPAwardCfg[getVIPLV] packSpace = ItemControler.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) if packSpace < rewardList[0]: GameWorld.DebugLog("GetCostVIPAward() no enough(%s) pack space(%s)" % (rewardList[0], packSpace)) return PlayerControl.NomalDictSetProperty(curPlayer, rewardStateKey, rewardState | pow(2, getVIPLV)) __GiveItem(curPlayer, rewardList[1:]) Sync_CostVIPAwardState(curPlayer) return ## ÁìÈ¡VIP³É³¤½±Àø def GetVIPGrowUpAward(curPlayer, index): growUpAwardDict = ReadChConfig.GetEvalChConfig('VIPGrowUpAward') if index not in growUpAwardDict: return rewardStateKey = ChConfig.Def_PDict_CostVIPGrowUpReward rewardState = curPlayer.NomalDictGetProperty(rewardStateKey) if rewardState & pow(2, index): GameWorld.DebugLog(" ÁìÈ¡VIP³É³¤½±Àø had got reward(%s)" % index) return needLV, vipExp, itemList = growUpAwardDict[index] if curPlayer.GetLV() < needLV: GameWorld.DebugLog(' ÁìÈ¡VIP³É³¤½±Àøindex=%s, Íæ¼ÒµÈ¼¶²»×ã%s'%(index, needLV)) return packSpace = ItemControler.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) if packSpace < len(itemList): GameWorld.DebugLog("ÁìÈ¡VIP³É³¤½±Àø no enough(%s) pack space(%s)" % (len(itemList), packSpace)) return PlayerControl.NomalDictSetProperty(curPlayer, rewardStateKey, rewardState | pow(2, index)) __AddCostVIPExp(curPlayer, vipExp) PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_437683", [vipExp]) __GiveItem(curPlayer, itemList) Sync_CostVIPGrowUpAwardState(curPlayer) return ## ֪ͨ³É³¤½±ÀøÁìȡ״̬ # @param curPlayer # @return def Sync_CostVIPGrowUpAwardState(curPlayer): # awardType = ShareDefine.Def_RewardType_CostVIPGrowUp # awardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostVIPGrowUpReward) # ChPlayer.Sync_RewardGetRecordInfo(curPlayer, awardType, awardState) return ## ֪ͨÏû·ÑVIPÐÅÏ¢ # @param curPlayer # @return def Sync_CostVIPInfo(curPlayer): sendPack = ChPyNetSendPack.tagMCVIPInfo() sendPack.Clear() sendPack.Exp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostVIPExp) sendPack.BuyState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostVIPBuyItem) NetPackCommon.SendFakePack(curPlayer, sendPack) return ## ֪ͨ½±ÀøÁìȡ״̬ # @param curPlayer # @return def Sync_CostVIPAwardState(curPlayer): #awardType = ShareDefine.Def_RewardType_CostVIPLV #awardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostVIPLVReward) #ChPlayer.Sync_RewardGetRecordInfo(curPlayer, awardType, awardState) return ## Ïû·ÑVIPÉý¼¶VIP # @param curPlayer # @param vipLV Ïû·ÑVIPµÈ¼¶ # @return def __SetVIPLV(curPlayer, vipLV): curPlayer.SetVIPLv(vipLV) #vipµÈ¼¶¸Ä±ä´¥·¢ÈÎÎñ EventShell.EventResponse_OnVipLvUp(curPlayer) tick = GameWorld.GetGameWorld().GetTick() __AddBuff(curPlayer, tick) __NtfChangeInfo(curPlayer, tick) return ## ¸øÓèÎïÆ· # @param curPlayer # @param itemList ÎïÆ·Áбí # @return def __GiveItem(curPlayer, itemList): giveFailList = [] for itemInfo in itemList: itemType = itemInfo[Reward_Item_Type] itemId = itemInfo[Reward_Item_Id] itemNum = itemInfo[Reward_Item_Num] itemIsBind = itemInfo[Reward_Item_Bind] if isinstance(itemId, dict): if curPlayer.GetJob() not in itemId: GameWorld.ErrLog(" PlayerCostVIP __GiveItem itemId=%s, Ö°Òµ(%s)δÅäÖÃ" % (itemId, curPlayer.GetJob())) continue itemId = itemId[curPlayer.GetJob()] if itemNum <= 0 or itemId <= 0: continue if itemType == Item_Type_Common: packIndexList = [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere] if not ItemControler.GivePlayerItem(curPlayer, itemId, itemNum, itemIsBind, packIndexList, True, showSysInfo=True): giveFailList.append(itemInfo) elif itemType == Item_Type_Appoint: if not ItemControler.GivePlayerAppointItem(curPlayer, itemId, itemIsBind, True, showSysInfo=True): giveFailList.append(itemInfo) if giveFailList: GameWorld.ErrLog("__GiveItem() give fail item(%s)" % str(giveFailList), curPlayer.GetPlayerID()) return ## ¼ÓBuff # @param curPlayer # @param tick # @return ÊÇ·ñ¼Ó³É¹¦ def __AddBuff(curPlayer, tick): costVIPBuffTypeID = ChConfig.Def_SkillID_CostVipBuff curVIPLv = curPlayer.GetVIPLv() curSkill = GameWorld.GetGameData().FindSkillByType(costVIPBuffTypeID, curVIPLv) if not curSkill: return playerSkillManager = curPlayer.GetSkillManager() BuffSkill.DelBuffBySkillID(curPlayer, costVIPBuffTypeID, tick) playerSkillManager.DeleteSkillBySkillTypeID(costVIPBuffTypeID) skillID = curSkill.GetSkillID() playerSkillManager.LVUPSkillByID(skillID) SkillCommon.AddBuffBySkillType(curPlayer, costVIPBuffTypeID, tick, curVIPLv) return True ## ֪ͨÐÅÏ¢±ä»¯ # @param curPlayer # @param tick # @return None def __NtfChangeInfo(curPlayer, tick): HighLadderTube.SendHighLadderState(curPlayer, tick) Operate_PlayerBuyZhenQi.Sync_NotifyDataChange(curPlayer) return ## »ñÈ¡Ïû·ÑVIPÅäÖÃÐÅÏ¢ # @param curPlayer # @param vipLV VIPµÈ¼¶ # @param dataKey ÏûÏ¢±íÁбí±êʶ # @return ·µ»Ø¶ÔÓ¦ÐÅÏ¢ def __GetCostVIPData(curPlayer, vipLV=-1, dataKey=''): if vipLV < 0: vipLV = curPlayer.GetVIPLv() searchDict = {CostVIPData_LV:str(vipLV)} costVIPTable = PyMapTable.GetPyMapTable("CostVIP") costVIPDataList = costVIPTable.GetRecordByDic(searchDict) if len(costVIPDataList) != 1: GameWorld.DebugLog("__GetCostVIPData() vipLV(%s) configuration repeat" % (vipLV)) return if dataKey == '': return costVIPDataList[0] costVIPData = costVIPDataList[0].get(dataKey) if not costVIPData: GameWorld.DebugLog("__GetCostVIPData() %s no configuration vipLV(%s)" % (dataKey, vipLV)) return return eval(costVIPData) # ----- Íâµ÷ÔÙ·â×°º¯Êý ----- ## »ñÈ¡Æíµ»´ÎÊýÁбí def GetPrayNumList(curPlayer, default=[]): prayNumList = __GetCostVIPData(curPlayer, dataKey = CostVIPData_PrayNum) if not prayNumList: return default return prayNumList # »ñÈ¡¾º¼¼³¡Ôö¼Ó´ÎÊý def GetArenaNum(curPlayer, default=0): arenaNum = __GetCostVIPData(curPlayer, dataKey = CostVIPData_ArenaNum) if not arenaNum: return default return arenaNum # »ñÈ¡»·ÈÎÎñ½±Àø¼Ó³É<°Ù·ÖÂÊ> def GetRoundReward(curPlayer, default=0): roundReward = __GetCostVIPData(curPlayer, dataKey = CostVIPData_RoundReward) if not roundReward: return default return roundReward # »ñÈ¡»·ÈÎÎñ×ÖµäÐǼ¶ def GetRoundStar(curPlayer, default=0): roundStar = __GetCostVIPData(curPlayer, dataKey = CostVIPData_RoundStar) if not roundStar: return default return roundStar # ¾­ÑéÃØ¾³¾­Ñé¼Ó³É def GetBZZDExpAddRate(curPlayer): addValue = __GetCostVIPData(curPlayer, dataKey = CostVIPData_BZZDExpAddRate) if not addValue: return 0 return addValue # ÇÀºì°üÿÈÕ¿ÉÇÀÔö¼Ó´ÎÊý def GetRedPacketGrabCntAdd(curPlayer): addCnt = __GetCostVIPData(curPlayer, dataKey = CostVIPData_RedPacketGrabCnt) if not addCnt: return 0 return addCnt # »÷ɱÊÀ½çboss´ÎÊýÔö¼Ó def GetKillWorldBossAddCnt(curPlayer): addCnt = __GetCostVIPData(curPlayer, dataKey = CostVIPData_KillWorldBossAddCnt) if not addCnt: return 0 return addCnt