| | |
| | | import ChConfig
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import PlayerBossReborn
|
| | | import ShareDefine
|
| | | import GameWorld
|
| | | import GameLogic_CrossGrassland
|
| | | import PlayerControl
|
| | | import IpyGameDataPY
|
| | | import PlayerActivity
|
| | | import ItemControler
|
| | | import PlayerWeekParty
|
| | | import PlayerFairyCeremony
|
| | | import PlayerNewFairyCeremony
|
| | | import ItemCommon
|
| | | import PyGameData
|
| | | import EventShell
|
| | | import FBCommon
|
| | | import NPCCommon
|
| | |
|
| | | import copy
|
| | | import random
|
| | | import FBCommon
|
| | |
|
| | | #0-奇遇 1-宝藏 2-仙草 3-妖王 4-灵草
|
| | | (
|
| | |
| | | AdventuresType4,
|
| | | ) = range(1, 5)
|
| | |
|
| | | #事件副本类型
|
| | | (
|
| | | FDEventFBType_Client, #前端本0
|
| | | FDEventFBType_Server, #本服本1
|
| | | FDEventFBType_CrossServer, #跨服本2
|
| | | ) = range(3)
|
| | |
|
| | | def OnLogin(curPlayer):
|
| | | NotifyVisitFairyDomainInfo(curPlayer)
|
| | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | |
|
| | | otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
| | | maxEventCnt = max([info[1] for info in otherCntRateList]) + 1 #最大可出现事件个数
|
| | | maxEventCnt = GetMaxEventCnt() #最大可出现事件个数
|
| | | fairyDomainState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainState) #是否寻访中 0未寻访 1寻访中 2任务标记可寻访
|
| | | if clientData.Type == 1: #结束寻访
|
| | | if fairyDomainState != 1:
|
| | |
| | | if fairyDomainState == 1:
|
| | | GameWorld.DebugLog(" 正在寻访仙域中!请先退出寻访")
|
| | | return
|
| | | |
| | | if fairyDomainState != 2 and not PlayerActivity.AddDailyActionFinishCnt(curPlayer, dailyID):
|
| | | GameWorld.DebugLog(" 寻访仙域次数不足!")
|
| | | costPoint = IpyGameDataPY.GetFuncCfg('ImmortalDomainActivePoint', 2)
|
| | | if not PlayerActivity.CostActivityPoint(curPlayer, costPoint, True):
|
| | | GameWorld.DebugLog(" 寻访仙域需要活跃点不足!costPoint=%s"%costPoint)
|
| | | return
|
| | | |
| | |
|
| | | #随机事件 重置事件状态
|
| | | visitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
| | | appointIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog('FairyDomainAppoint', visitCnt + 1)
|
| | |
| | | fdEventIDList.append(appointIpyData.GetEventID())
|
| | | else:
|
| | | fdEventTypeDict = {}
|
| | | #先随机奇遇事件
|
| | | fortuitousEventRate = IpyGameDataPY.GetFuncCfg('ImmortalDomain')
|
| | | if GameWorld.CanHappen(fortuitousEventRate):
|
| | | fdEventTypeDict[FDEventType0] = 1
|
| | | |
| | | #先随机独立事件
|
| | | singleEventRateDict = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 1, {})
|
| | | for eventType, rate in singleEventRateDict.items():
|
| | | if GameWorld.CanHappen(rate):
|
| | | fdEventTypeDict[eventType] = 1
|
| | |
|
| | | otherCnt = GameWorld.GetResultByRandomList(otherCntRateList, 0)
|
| | | if otherCnt:
|
| | | otherEventRateList = copy.deepcopy(IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 3))
|
| | | unRepeatTypeList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 4)
|
| | | for _ in xrange(otherCnt):
|
| | | otherEventType = GameWorld.GetResultByRandomList(otherEventRateList, 0)
|
| | | if not otherEventType:
|
| | | otherEventType = GameWorld.GetResultByRandomList(otherEventRateList)
|
| | | if otherEventType is None:
|
| | | continue
|
| | | if otherEventType in unRepeatTypeList:
|
| | | for index, info in enumerate(otherEventRateList):
|
| | |
| | | #更新全服出现次数
|
| | | msgStr = str(fdEventIDList)
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'AddFairyDomainEvent', msgStr, len(msgStr))
|
| | | if not fdEventIDList:
|
| | | fdEventIDList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 5)
|
| | | GameWorld.Log('寻访仙域, 没有随机出事件,使用默认事件!! playerLV=%s,visitCnt=%s,默认fdEventIDList=%s'%(curPlayer.GetLV(), visitCnt, fdEventIDList), curPlayer.GetID())
|
| | | if not fdEventIDList:
|
| | | return
|
| | | PlayerActivity.CostActivityPoint(curPlayer, costPoint)
|
| | | #奇遇事件 随机档位数据
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
| | | for fdEventID in fdEventIDList:
|
| | |
| | | continue
|
| | | conditionList = ipyData.GetCondition()
|
| | | if not conditionList:
|
| | | fdEventIDList.remove(fdEventID)
|
| | | continue
|
| | | condition = random.choice(conditionList)
|
| | | index = conditionList.index(condition)
|
| | | index = 0
|
| | | else:
|
| | | condition = random.choice(conditionList)
|
| | | index = conditionList.index(condition)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, ipyData.GetID() * 100 + index)
|
| | | |
| | | if not fdEventIDList:
|
| | | GameWorld.Log('寻访仙域, 没有随机出事件!!')
|
| | | return
|
| | | |
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainVisitCnt, min(visitCnt + 1, ChConfig.Def_UpperLimit_DWord))
|
| | | #设置事件
|
| | | for i in xrange(maxEventCnt):
|
| | |
| | | #֪ͨ
|
| | | NotifyVisitFairyDomainInfo(curPlayer, fdEventIDList)
|
| | | NotifyFairyAdventuresInfo(curPlayer)
|
| | |
|
| | | PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_FairyDomain, 1)
|
| | | PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_FairyDomain, 1)
|
| | | PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FairyDomain, 1)
|
| | | PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FairyDomain, 1)
|
| | | return
|
| | |
|
| | |
|
| | | def EndFairyDomain(curPlayer):
|
| | | GameWorld.DebugLog("EndFairyDomain", curPlayer.GetID())
|
| | | ##结束寻访
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainState, 0)
|
| | | otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
| | | maxEventCnt = max([info[1] for info in otherCntRateList]) + 1 #最大可出现事件个数
|
| | | maxEventCnt = GetMaxEventCnt() #最大可出现事件个数
|
| | | for i in xrange(maxEventCnt):
|
| | | fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
|
| | | if fdEventID:
|
| | |
| | | return
|
| | | if curState == state:
|
| | | return True
|
| | | |
| | | ipyData = IpyGameDataPY.GetIpyGameData('FairyDomain', fdeventID)
|
| | | if not ipyData:
|
| | | return
|
| | | if state == FDEventState_Visiting:
|
| | | if curState != FDEventState_CanVisit:
|
| | | GameWorld.DebugLog('缥缈仙域事件状态设置错误,fdeventID=%s, state=%s, curState=%s' % (fdeventID, state, curState))
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData('FairyDomain', fdeventID)
|
| | | if not ipyData:
|
| | | return
|
| | | |
| | | costEnergy = ipyData.GetCostEnergy()
|
| | | curEnergy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEnergy)
|
| | | if curEnergy < costEnergy:
|
| | |
| | | # if curState != FDEventState_Visiting:
|
| | | # GameWorld.Log('缥缈仙域事件状态设置错误,fdeventID=%s, state=%s, curState=%s' % (fdeventID, state, curState))
|
| | | # return
|
| | | EventShell.EventRespons_FairyDomain(curPlayer)
|
| | | EventShell.EventRespons_FairyDomain(curPlayer, ipyData.GetEventType())
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdeventID, state)
|
| | | NotifyVisitFairyDomainInfo(curPlayer, [fdeventID], 0)
|
| | | return True
|
| | |
|
| | |
|
| | | def NotifyVisitFairyDomainInfo(curPlayer, fdEventList=[], isAll=1):
|
| | | def NotifyVisitFairyDomainInfo(curPlayer, fdEventList=None, isAll=1):
|
| | | if not fdEventList:
|
| | | syncFDEventList = []
|
| | | otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
| | | maxEventCnt = max([info[1] for info in otherCntRateList]) + 1 #最大可出现事件个数
|
| | | maxEventCnt = GetMaxEventCnt() #最大可出现事件个数
|
| | | for i in xrange(maxEventCnt):
|
| | | fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
|
| | | if fdEventID:
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, packData)
|
| | | return
|
| | |
|
| | | def GetMaxEventCnt():
|
| | | # 最大可出现事件个数
|
| | | otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
| | | maxEventCnt = max([info[1] for info in otherCntRateList]) + len(IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain'))
|
| | | return maxEventCnt
|
| | |
|
| | | ###=========================奇遇===============================
|
| | | def NotifyFairyAdventuresInfo(curPlayer):
|
| | |
| | |
|
| | | packData = ChPyNetSendPack.tagMCFairyAdventuresInfo()
|
| | | packData.InfoList = []
|
| | | otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
| | | maxEventCnt = max([info[1] for info in otherCntRateList]) + 1 #最大可出现事件个数
|
| | | maxEventCnt = GetMaxEventCnt() #最大可出现事件个数
|
| | | for i in xrange(maxEventCnt):
|
| | | fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
|
| | | if fdEventID not in AdventuresTypeList:
|
| | |
| | | gearAwardList = ipyData.GetGearAward()
|
| | | if not gearAwardList:
|
| | | return
|
| | | itemRateList = gearAwardList[index] if index < len(gearAwardList) else gearAwardList[-1]
|
| | | giveItemList = [GameWorld.GetResultByWeightList(itemRateList)]
|
| | | giveItemList = []
|
| | | itemRandomList = gearAwardList[index] if index < len(gearAwardList) else gearAwardList[-1]
|
| | | for itemRateList in itemRandomList:
|
| | | itemRateList = ItemCommon.GetWeightItemListByAlchemyDiffLV(curPlayer, itemRateList, 0)
|
| | | giveItemList.append(GameWorld.GetResultByWeightList(itemRateList))
|
| | | else:
|
| | | giveItemList = [ipyData.GetBasicAward()]
|
| | | |
| | | ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList)
|
| | | NPCCommon.DoGiveItemByVirtualDrop(curPlayer, giveItemList, 0)
|
| | | msgDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)}
|
| | | FBCommon.Notify_FB_Over(curPlayer, msgDict)
|
| | | GameWorld.DebugLog('缥缈奇遇领奖 msgDict=%s, fdeventID=%s' % (msgDict, fdeventID))
|
| | |
| | | ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomainAppoint', {'Cnt':visitCnt, 'EventID':fdEventID}, False, False)
|
| | | if not ipyData:
|
| | | return
|
| | | return ipyData.GetAward()
|
| | | job = curPlayer.GetJob()
|
| | | itemList = []
|
| | | for itemInfo in ipyData.GetAward():
|
| | | if type(itemInfo[0]) == dict:
|
| | | if job not in itemInfo[0]:
|
| | | continue
|
| | | itemList.append([itemInfo[0][job], itemInfo[1], itemInfo[2]])
|
| | | else:
|
| | | itemList.append(itemInfo)
|
| | | |
| | | for itemRateList in ipyData.GetRandomAward():
|
| | | itemRateList = ItemCommon.GetWeightItemListByAlchemyDiffLV(curPlayer, itemRateList, 1)
|
| | | giveItem = GameWorld.GetResultByWeightList(itemRateList)
|
| | | if not giveItem:
|
| | | continue
|
| | | itemList.append(giveItem)
|
| | | return itemList
|