|  |  |  | 
|---|
|  |  |  | import PlayerControl | 
|---|
|  |  |  | import IpyGameDataPY | 
|---|
|  |  |  | import PlayerActivity | 
|---|
|  |  |  | import ItemControler | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import copy | 
|---|
|  |  |  | import random | 
|---|
|  |  |  | import FBCommon | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #0-奇遇 1-宝藏 2-仙草 3-妖王 4-灵草 | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def OnLogin(curPlayer): | 
|---|
|  |  |  | NotifyVisitFairyDomainInfo(curPlayer) | 
|---|
|  |  |  | NotifyFairyAdventuresInfo(curPlayer) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | GameWorld.DebugLog("    未开始寻访仙域, 无法结束") | 
|---|
|  |  |  | return | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainState, 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for i in xrange(maxEventCnt): | 
|---|
|  |  |  | fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i) | 
|---|
|  |  |  | if fdEventID: | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventID%i, 0) | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState%fdEventID, 0) | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NotifyVisitFairyDomainInfo(curPlayer) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fdEventIDList = [] | 
|---|
|  |  |  | for eventType, cnt in fdEventTypeDict.items(): | 
|---|
|  |  |  | fdEventIDList += __RandomFDEventByType(curPlayer, eventType, cnt) | 
|---|
|  |  |  | randomList = __RandomFDEventByType(curPlayer, eventType, cnt) | 
|---|
|  |  |  | if not randomList: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if eventType == FDEventType0: | 
|---|
|  |  |  | #奇遇事件 随机档位数据 | 
|---|
|  |  |  | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1 | 
|---|
|  |  |  | for fdEventID in randomList: | 
|---|
|  |  |  | ipyData = IpyGameDataPY.InterpolationSearch('FairyAdventures', 'OpenServerDay', openServerDay, {'EventID':randomList[0]}) | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | GameWorld.ErrLog('寻访仙域, 奇遇事件没有随机出对应档位 randomList=%s,openServerDay=%s' % (randomList, openServerDay)) | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | conditionList = ipyData.GetCondition() | 
|---|
|  |  |  | if not conditionList: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | condition = random.choice(conditionList) | 
|---|
|  |  |  | index = conditionList.index(condition) | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, ipyData.GetID() * 100 + index) | 
|---|
|  |  |  | NotifyFairyAdventuresInfo(curPlayer) | 
|---|
|  |  |  | fdEventIDList += randomList | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if not fdEventIDList: | 
|---|
|  |  |  | GameWorld.Log('寻访仙域, 没有随机出事件!!') | 
|---|
|  |  |  | return | 
|---|
|  |  |  | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdeventID, state) | 
|---|
|  |  |  | NotifyVisitFairyDomainInfo(curPlayer, fdeventID) | 
|---|
|  |  |  | NotifyVisitFairyDomainInfo(curPlayer, [fdeventID]) | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | packData.Count = len(packData.InfoList) | 
|---|
|  |  |  | NetPackCommon.SendFakePack(curPlayer, packData) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ###=========================奇遇=============================== | 
|---|
|  |  |  | def NotifyFairyAdventuresInfo(curPlayer): | 
|---|
|  |  |  | ##通知奇遇信息 | 
|---|
|  |  |  | packData = ChPyNetSendPack.tagMCFairyAdventuresInfo() | 
|---|
|  |  |  | packData.InfoList = [] | 
|---|
|  |  |  | otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2) | 
|---|
|  |  |  | maxEventCnt = max([info[1] for info in otherCntRateList]) + 1  #最大可出现事件个数 | 
|---|
|  |  |  | for i in xrange(maxEventCnt): | 
|---|
|  |  |  | fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i) | 
|---|
|  |  |  | adventuresdata = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyAdventuresData % fdEventID) | 
|---|
|  |  |  | if not adventuresdata: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | ipyData = IpyGameDataPY.GetIpyGameDataNotLog('FairyAdventures', adventuresdata / 100) | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | conditionList = ipyData.GetCondition() | 
|---|
|  |  |  | index = adventuresdata % 100 | 
|---|
|  |  |  | condition = conditionList[index] if index < len(conditionList) else 0 | 
|---|
|  |  |  | adventuresdata = ChPyNetSendPack.tagMCFairyAdventuresData() | 
|---|
|  |  |  | adventuresdata.Gear = index + 1 | 
|---|
|  |  |  | adventuresdata.Condition = condition | 
|---|
|  |  |  | adventuresdata.EventID = fdEventID | 
|---|
|  |  |  | packData.InfoList.append(adventuresdata) | 
|---|
|  |  |  | if not packData.InfoList: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | packData.Cnt = len(packData.InfoList) | 
|---|
|  |  |  | NetPackCommon.SendFakePack(curPlayer, packData) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetFairyAdventuresAward(curPlayer, fdeventID, state): | 
|---|
|  |  |  | ##奇遇领取奖励 | 
|---|
|  |  |  | state = GameWorld.ToIntDef(state, 0) | 
|---|
|  |  |  | if state == FDEventState_Visiting: | 
|---|
|  |  |  | SetFairyDomainEventState(curPlayer, fdeventID, state) | 
|---|
|  |  |  | elif state == FDEventState_Visited: | 
|---|
|  |  |  | SetFairyDomainEventState(curPlayer, fdeventID, state) | 
|---|
|  |  |  | #给奖励 | 
|---|
|  |  |  | adventuresdata = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyAdventuresData % fdeventID) | 
|---|
|  |  |  | ipyData = IpyGameDataPY.GetIpyGameDataNotLog('FairyAdventures', adventuresdata / 100) | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | conditionList = ipyData.GetCondition() | 
|---|
|  |  |  | index = adventuresdata % 100 | 
|---|
|  |  |  | condition = conditionList[index] if index < len(conditionList) else 0 | 
|---|
|  |  |  | if fdeventID != ipyData.GetEventID(): | 
|---|
|  |  |  | GameWorld.Log('奇遇领取奖励 事件ID错误!') | 
|---|
|  |  |  | return | 
|---|
|  |  |  | #1-等级奇遇 2-境界奇遇 3-战力奇遇 4-气运奇遇 | 
|---|
|  |  |  | if fdeventID == 1: | 
|---|
|  |  |  | curData = curPlayer.GetLV() | 
|---|
|  |  |  | elif fdeventID == 2: | 
|---|
|  |  |  | curData = curPlayer.GetOfficialRank() | 
|---|
|  |  |  | elif fdeventID == 3: | 
|---|
|  |  |  | curData = curPlayer.GetFightPower() | 
|---|
|  |  |  | elif fdeventID == 4: | 
|---|
|  |  |  | curData = curPlayer.GetLuckValue() | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | if curData >= condition: | 
|---|
|  |  |  | gearAwardList = ipyData.GetGearAward() | 
|---|
|  |  |  | if not gearAwardList: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | itemRateList = gearAwardList[index] if index < len(gearAwardList) else gearAwardList[-1] | 
|---|
|  |  |  | itemInfo = GameWorld.GetResultByWeightList(itemRateList) | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | itemInfo = ipyData.GetBasicAward() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ItemControler.GivePlayerItemOrMail(curPlayer, [itemInfo]) | 
|---|
|  |  |  | msgDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList([itemInfo])} | 
|---|
|  |  |  | FBCommon.Notify_FB_Over(curPlayer, msgDict) | 
|---|
|  |  |  | GameWorld.DebugLog('缥缈奇遇领奖 msgDict=%s, fdeventID=%s' % (msgDict, fdeventID)) | 
|---|
|  |  |  | return | 
|---|