#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package GameWorldLogic.FBProcess.GameLogic_TrialTower # # @todo:·ûÓ¡Ëþ # @author xdh # @date 2017-05-05 # @version 1.0 # ÏêϸÃèÊö: ·ûÓ¡Ëþ # #--------------------------------------------------------------------- #"""Version = 2017-05-05 11:00""" #--------------------------------------------------------------------- import FBCommon import GameWorld import PlayerControl import ChPyNetSendPack import ItemControler import NetPackCommon import ShareDefine import IpyGameDataPY import PlayerRune import ItemCommon import ChConfig import PlayerSuccess import PlayerActivity import PlayerBillboard import PlayerWeekParty import PlayerActLogin import EventReport import PlayerBossReborn import random import math g_runeTypeDict = {} def GetTowerIpyData(level): return IpyGameDataPY.GetIpyGameData('RuneTower', level) def OnFBPlayerLogin(curPlayer): SyncTrialLevelInfo(curPlayer) return def OnFBPlayerOnDay(curPlayer): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_TrialTower_LastDayPassLV, __GetTrialLevelCurPassLV(curPlayer)) #֪ͨ SyncTrialLevelInfo(curPlayer) return ## ͬ²½·ûÓ¡Ëþ¹Ø¿¨ÐÅÏ¢ # @fbLevel Ϊ0ʱĬÈÏÈ«²¿Í¬²½£¬> 0ʱ½öͬ²½¸Ã¹Ø¿¨ def SyncTrialLevelInfo(curPlayer): ttInfo = ChPyNetSendPack.tagMCTrialTowerInfo() ttInfo.Clear() ttInfo.PassLV = __GetTrialLevelCurPassLV(curPlayer) ttInfo.YesterDayPassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_LastDayPassLV) NetPackCommon.SendFakePack(curPlayer, ttInfo) return ## »ñÈ¡µ±Ç°ÒÑͨ¹Ø¹Ø¿¨ def __GetTrialLevelCurPassLV(curPlayer): return curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_PassLV) ## ¸üе±Ç°ÒÑͨ¹Ø¹Ø¿¨ def SetTrialLevelCurPassLV(curPlayer, passlv): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_TrialTower_PassLV, passlv) PlayerRune.DoUnlockRuneHole(curPlayer) #ͨ¹Ø·ûÓ¡Ëþ³É¾Í PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_PassRuneTower, 1, [passlv]) PlayerBillboard.UpdateRuneTowerBillboard(curPlayer) PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Tower, passlv, False, True) GameWorld.DebugLog(' ¸üзûÓ¡ËþÒÑͨ¹ØÊý %s' % passlv) return def OnTurnFightRequest(curPlayer, mapID, funcLineID, tagType, tagID, valueList): ## »ØºÏÕ½¶·ÇëÇó - µØÍ¼ÑéÖ¤ playerID = curPlayer.GetPlayerID() ipyData = GetTowerIpyData(funcLineID) if not ipyData: GameWorld.ErrLog("·ûÓ¡Ëþ¹Ø¿¨²»´æÔÚ: funcLineID=%s" % (funcLineID), playerID) return False # ÊÇ·ñÒѹý¹Ø if funcLineID <= __GetTrialLevelCurPassLV(curPlayer): GameWorld.DebugLog("·ûÓ¡Ëþ±¾¹ØÒѹý¹Ø, ÎÞ·¨ÌôÕ½! funcLineID=%s" % funcLineID, playerID) return False bossID = ipyData.GetNPCID() if tagID != bossID or tagType != ChConfig.TurnBattle_TagType_NPC: GameWorld.ErrLog("Ä¿±êbossID´íÎó£¬ÎÞ·¨ÌôÕ½! mapID=%s,funcLineID=%s,bossID=%s,tagType=%s,tagID=%s" % (mapID, funcLineID, bossID, tagType, tagID), curPlayer.GetPlayerID()) return False return True def OnTurnFightOver(curPlayer, mapID, funcLineID, tagType, tagID, valueList, fightRet): ## »ØºÏÕ½¶·½áÊø # @return: ÊÇ·ñÐèҪͬ²½GameServer, ½±ÀøÁбí, ͬ²½½á¹ûÐÅÏ¢ needSendGameServer = False awardItemList = [] overInfoEx = {} fbLevel = funcLineID ipyData = GetTowerIpyData(fbLevel) if not ipyData: return FBCommon.OnFBJoin(curPlayer, mapID, funcLineID) isWin = fightRet[0] if not isWin: return floorCnt = IpyGameDataPY.GetFuncCfg('TowerRuneType', 2) if fbLevel % 100 == floorCnt: # ¼Ç¼¹ý¹Ø EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_TrialTower, 0, ChConfig.CME_Log_End, 0, 1) # ¹ý¹ØÈ«·þ¹ã²¥ if ipyData.GetIsNotify(): IPY_Data = IpyGameDataPY.IPY_Data() maxLevel = IPY_Data.GetRuneTowerByIndex(IPY_Data.GetRuneTowerCount()-1).GetID() sysMark = 'RuneTowerInfo_1' if fbLevel == maxLevel else 'GeRen_liubo_471172' PlayerControl.WorldNotify(0, sysMark, [curPlayer.GetPlayerName(), fbLevel / 100]) #¸üйؿ¨ SetTrialLevelCurPassLV(curPlayer, fbLevel) # ¸ø¹ý¹Ø½±Àø prizeDict = __GiveFBPassPrize(curPlayer, fbLevel) __SendTrialTowerOverInfo(curPlayer, fbLevel, True, prizeDict) #ÈÎÎñ #EventShell.EventRespons_TrialTowerCnt(curPlayer, fbLevel) SyncTrialLevelInfo(curPlayer) # ͬ²½×îйؿ¨ÐÅÏ¢ #ÿÈÕÈÎÎñ PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_Tower) FBCommon.OnFBPass(curPlayer, mapID, funcLineID) overInfoEx.update(prizeDict) return needSendGameServer, awardItemList, overInfoEx ## ¸ø¹ý¹Ø½±Àø def __GiveFBPassPrize(curPlayer, fbLevel): ipyData = GetTowerIpyData(fbLevel) if not ipyData: return {} #·ûÓ¡¾«»ª addJH = ipyData.GetRunePoint() PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Rune, addJH) #·ûӡħ¾« RuneMagicEssence = ipyData.GetYsog() PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Ysog, RuneMagicEssence) specialAwardDict = IpyGameDataPY.GetFuncEvalCfg('PreFourAward') if fbLevel in specialAwardDict: prizeItemList = [] for itemID, itemCnt in specialAwardDict[fbLevel]: for _ in xrange(itemCnt): prizeItemList.append([itemID, 1, 1]) else: prizeItemList = __GetEndAward(curPlayer, fbLevel) #¹Ì¶¨½±Àø FixEndAward = ipyData.GetFixEndAward() for itemID, itemCnt in FixEndAward: for _ in xrange(itemCnt): prizeItemList.append([itemID, 1, 1]) #ºÃ¶«Î÷ goodDropDict = ipyData.GetGoodDrop() for itemID, rate in goodDropDict.items(): if GameWorld.CanHappen(rate): prizeItemList.append([itemID, 1, 1]) #ÌØÊâ·ûÓ¡¹ã²¥ for itemID, itemCnt, isBind in prizeItemList: itemData = GameWorld.GetGameData().GetItemByTypeID(itemID) if not itemData: continue if itemData.GetItemColor() >= ShareDefine.Def_Item_Color_Orange: PlayerControl.WorldNotify(0, 'RuneTowerInfo_2', [curPlayer.GetName(), fbLevel, itemID]) # ·¢Óʼþ»ò·ÅÈë·ûÓ¡±³°ü needSpace = len(prizeItemList) emptySpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptRune, needSpace) isSendMail = int(needSpace > emptySpace) # ÊÇ·ñ·¢ËÍÓʼþ if isSendMail: PlayerControl.SendMailByKey('TowerPrize', [curPlayer.GetPlayerID()], prizeItemList) GameWorld.DebugLog("±³°ü¿Õ¼ä²»¹»£¬·¢ËÍÓʼþ: mailItemList=%s" % str(prizeItemList), curPlayer.GetPlayerID()) else: for itemID, itemCnt, isBind in prizeItemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [ShareDefine.rptRune], event=["RuneTower", False, {}]) moneyDict = {ShareDefine.TYPE_Price_Rune:addJH, ShareDefine.TYPE_Price_Ysog:RuneMagicEssence} prizeDict = {FBCommon.Over_money:FBCommon.GetJsonMoneyList(moneyDict), FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(prizeItemList)} # for _ in xrange(challengeCnt): # EventReport.WriteEvent_custom_mission_log(curPlayer, ChConfig.CME_FB_TrialTower, ChConfig.CME_Log_End, 1, cmeInfoEx=bossName) return prizeDict def __GetEndAward(curPlayer, fbLevel): #½áËã½±Àø giveItemCountRateList = GameWorld.GetDictValueByRangeKey(IpyGameDataPY.GetFuncEvalCfg('RuneAwardCntRate', 1, {}), fbLevel, []) giveItemCount = GameWorld.GetResultByRandomList(giveItemCountRateList) if not giveItemCount: return [] runeTypeList = GetRuneTypeByTowerLV(fbLevel) if not runeTypeList: return InitRuneTypeColorInfo(curPlayer) giveItemList = [] runeColorRateDict = GameWorld.GetDictValueByRangeKey(IpyGameDataPY.GetFuncEvalCfg('RuneAwardColor', 1, {}), fbLevel, {}) for _ in xrange(giveItemCount): giveRuneType = random.choice(runeTypeList) if giveRuneType not in g_runeTypeDict: break runeColorRateList = GameWorld.GetDictValueByKey(runeColorRateDict, giveRuneType) giveColor = GameWorld.GetResultByRandomList(runeColorRateList) if giveColor == None: break giveItemID = g_runeTypeDict[giveRuneType].get(giveColor) if not giveItemID: continue giveItemList.append([giveItemID, 1, 1]) GameWorld.DebugLog(" Ëæ»ú¸øÎïÆ·Êý: %s, giveItemList=%s,runeTypeList=%s" % (giveItemCount, giveItemList,runeTypeList)) return giveItemList ## ¸ù¾ÝÀàÐÍ»ñÈ¡·ûÓ¡ÊÇ·ñÒѽâËø def InitRuneTypeColorInfo(curPlayer): global g_runeTypeDict if not g_runeTypeDict: ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetRuneCount()): ipyData = ipyDataMgr.GetRuneByIndex(i) itemID = ipyData.GetID() itemData = GameWorld.GetGameData().GetItemByTypeID(itemID) if not itemData: continue itemColor = itemData.GetItemColor() curEff = itemData.GetEffectByIndex(0) curRuneType = curEff.GetEffectID() if curRuneType in g_runeTypeDict: g_runeTypeDict[curRuneType][itemColor] = itemID else: g_runeTypeDict[curRuneType] = {itemColor:itemID} return ## ·¢ËÍÌôÕ½½á¹ûÐÅÏ¢ def __SendTrialTowerOverInfo(curPlayer, fbLevel, isPass, overDict={}): overDict[FBCommon.Over_dataMapID] = ChConfig.Def_FBMapID_TrialTower overDict[FBCommon.Over_wheel] = fbLevel overDict[FBCommon.Over_isPass] = int(isPass) GameWorld.DebugLog("__SendTrialTowerOverInfo overDict=%s" % (str(overDict)), curPlayer.GetPlayerID()) FBCommon.Notify_FB_Over(curPlayer, overDict) return def GetRuneTypeByTowerLV(towerLV): #»ñÈ¡¹Ø¿¨¿ÉµôÂä·ûÓ¡ÀàÐÍ towerRuneTypeDict = IpyGameDataPY.GetFuncEvalCfg('TowerRuneType') return towerRuneTypeDict.get(str(towerLV/100), []) ## ¿É·ñɨµ´ def OnPlayerFBSweepAsk(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx): yesterDayPassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_LastDayPassLV) if not yesterDayPassLV: GameWorld.DebugLog(' δͨ¹ØÒ»²ã£¬²»ÄÜɨµ´') return False #ÅжÏɨµ´»¨·Ñ curDayTimes, dayTimesLimit = PlayerActivity.GetDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_TowerSD) if curDayTimes >= dayTimesLimit: GameWorld.DebugLog(' ɨµ´´ÎÊý²»×㣡') return needMoney = IpyGameDataPY.GetFuncCfg('RuneTowerSweepBuy', 2) if curDayTimes else 0 if needMoney: costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, needMoney) if not costMoneyList: return for moneyType, moneyNum in costMoneyList: if not PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_FBSweep): GameWorld.DebugLog("·ûÓ¡Ëþɨµ´ÏÉÓñ²»×ã!costGold=%s£¬curDayTimes=%s" % (needMoney, curDayTimes)) return if not PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_TowerSD): GameWorld.DebugLog(' ɨµ´´ÎÊý²»×㣡') return False return True ## ɨµ´½á¹û def OnPlayerFBSweepResult(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx): passLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_LastDayPassLV) InitRuneTypeColorInfo(curPlayer) giveItemList = [] floorItemDict = {} #{´ó²ãID:{itemID:itemCnt}} giveRunePointDict = {} giveRuneYsogDict = {} giveRunePoint = 0 giveRuneYsog = 0 ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetRuneTowerCount()): ipyData = ipyDataMgr.GetRuneTowerByIndex(i) towerLV = ipyData.GetID() floor = towerLV / 100 if towerLV > passLV: break #·ûÓ¡¾«»ª giveRunePointDict[floor] = giveRunePointDict.get(floor, 0) + ipyData.GetSweepRunePoint() giveRunePoint += ipyData.GetSweepRunePoint() giveRuneYsogDict[floor] = giveRuneYsogDict.get(floor, 0) + ipyData.GetSweepYsog() giveRuneYsog += ipyData.GetSweepYsog() giveItemCountRateList = GameWorld.GetDictValueByRangeKey(IpyGameDataPY.GetFuncEvalCfg('RuneAwardCntRate', 2, {}), towerLV, []) giveItemCount = GameWorld.GetResultByRandomList(giveItemCountRateList) if not giveItemCount: continue runeTypeList = GetRuneTypeByTowerLV(towerLV) if not runeTypeList: continue runeColorRateDict = GameWorld.GetDictValueByRangeKey(IpyGameDataPY.GetFuncEvalCfg('RuneAwardColor', 2, {}), towerLV, {}) for _ in xrange(giveItemCount): giveRuneType = random.choice(runeTypeList) if giveRuneType not in g_runeTypeDict: break runeColorRateList = GameWorld.GetDictValueByKey(runeColorRateDict, giveRuneType) giveColor = GameWorld.GetResultByRandomList(runeColorRateList) if giveColor == None: break giveItemID = g_runeTypeDict[giveRuneType].get(giveColor) if not giveItemID: continue if floor in floorItemDict: floorItemDict[floor][giveItemID] = floorItemDict[floor].get(giveItemID,0) +1 else: floorItemDict[floor] = {giveItemID:1} giveItemList.append([giveItemID, 1, 1]) #ºÃ¶«Î÷ goodDropDict = ipyData.GetSweepGoodDrop() for itemID, rate in goodDropDict.items(): if GameWorld.CanHappen(rate): giveItemList.append([itemID, 1, 1]) if floor in floorItemDict: floorItemDict[floor][itemID] = floorItemDict[floor].get(itemID,0) +1 else: floorItemDict[floor] = {itemID:1} jsonItemDict = {} for floor, itemDict in floorItemDict.items(): jsonitemList = FBCommon.GetJsonItemList(itemDict.items()) jsonItemDict[floor] = jsonitemList for itemID in itemDict.keys(): itemData = GameWorld.GetGameData().GetItemByTypeID(itemID) if not itemData: continue if itemData.GetItemColor() >= ShareDefine.Def_Item_Color_Orange: PlayerControl.WorldNotify(0, 'RuneTowerInfo_3', [curPlayer.GetName(), floor, itemID]) if giveRunePoint: PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Rune, giveRunePoint) if giveRuneYsog: PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Ysog, giveRuneYsog) # ·¢Óʼþ»ò·ÅÈë·ûÓ¡±³°ü needSpace = len(giveItemList) emptySpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptRune, needSpace) isSendMail = int(needSpace > emptySpace) # ÊÇ·ñ·¢ËÍÓʼþ if isSendMail: PlayerControl.SendMailByKey('RunePackUnEnough', [curPlayer.GetPlayerID()], giveItemList) GameWorld.DebugLog("±³°ü¿Õ¼ä²»¹»£¬·¢ËÍÓʼþ: mailItemList=%s" % str(giveItemList), curPlayer.GetPlayerID()) else: for itemID, itemCnt, isBind in giveItemList: ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [ShareDefine.rptRune], event=["RuneTowerSD", False, {}]) overDict = {FBCommon.Over_isSweep:1, FBCommon.Over_dataMapID:ChConfig.Def_FBMapID_TrialTower, "SDTowerItem":jsonItemDict, "SDTowerPoint":giveRunePointDict, "SDTowerYsog":giveRuneYsogDict} GameWorld.DebugLog(' overDict=%s'%overDict) FBCommon.Notify_FB_Over(curPlayer, overDict) #³É¾Í PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_TowerSD, 1) #BOSS¸´»î»î¶¯ PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_TowerSweep, 1) PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_TowerSweep, 1) return True