#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerFairyDomain
|
#
|
# @todo:çÎç¿ÏÉÓò
|
# @author xdh
|
# @date 2019-04-04
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: çÎç¿ÏÉÓò
|
#---------------------------------------------------------------------
|
#"""Version = 2019-04-04"""
|
#---------------------------------------------------------------------
|
|
import ChConfig
|
import ChPyNetSendPack
|
import NetPackCommon
|
import PlayerBossReborn
|
import ShareDefine
|
import GameWorld
|
import GameLogic_CrossGrassland
|
import PlayerControl
|
import IpyGameDataPY
|
import PlayerActivity
|
import PlayerWeekParty
|
import PlayerFeastTravel
|
import PlayerFairyCeremony
|
import PlayerNewFairyCeremony
|
import ItemControler
|
import ItemCommon
|
import PyGameData
|
import EventShell
|
import FBCommon
|
import NPCCommon
|
|
import copy
|
import random
|
|
#0-ÆæÓö 1-±¦²Ø 2-ÏÉ²Ý 3-ÑýÍõ 4-Áé²Ý
|
(
|
FDEventType0,
|
FDEventType1,
|
FDEventType_GrasslandXian,
|
FDEventType3,
|
FDEventType_GrasslandLing,
|
) = range(5)
|
|
(
|
FDEventState_No, #²»¿É°Ý·Ã0
|
FDEventState_CanVisit, #¿É°Ý·Ã1
|
FDEventState_Visiting, #°Ý·ÃÖÐ2
|
FDEventState_Visited, #ÒѰݷÃ3
|
) = range(4)
|
|
#1-µÈ¼¶ÆæÓö 2-¾³½çÆæÓö 3-Õ½Á¦ÆæÓö 4-ÆøÔËÆæÓö
|
AdventuresTypeList = (
|
AdventuresType1,
|
AdventuresType2,
|
AdventuresType3,
|
AdventuresType4,
|
) = range(1, 5)
|
|
#ʼþ¸±±¾ÀàÐÍ
|
(
|
FDEventFBType_Client, #ǰ¶Ë±¾0
|
FDEventFBType_Server, #±¾·þ±¾1
|
FDEventFBType_CrossServer, #¿ç·þ±¾2
|
) = range(3)
|
|
def OnLogin(curPlayer):
|
NotifyVisitFairyDomainInfo(curPlayer)
|
NotifyFairyAdventuresInfo(curPlayer)
|
return
|
|
|
def OnHour(curPlayer):
|
__ResetFairyDomainCntLimit(curPlayer, 1)
|
return
|
|
|
def OnDay(curPlayer):
|
__ResetFairyDomainCntLimit(curPlayer, 2)
|
return
|
|
|
def __ResetFairyDomainCntLimit(curPlayer, resetType):
|
## ÖØÖøöÈËçÎç¿Ê¼þ³öÏÖ´ÎÊý¼Ç¼
|
ipyMgr = IpyGameDataPY.IPY_Data()
|
for i in xrange(ipyMgr.GetFairyDomainCount()):
|
ipyData = ipyMgr.GetFairyDomainByIndex(i)
|
eventID = ipyData.GetID()
|
appearCntInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventAppearCnt % eventID)
|
if not appearCntInfo:
|
continue
|
hourAppearCntPri, dayAppearCntPri = appearCntInfo % 1000, appearCntInfo / 1000
|
if resetType == 1:
|
updAppearCntInfo = dayAppearCntPri * 1000
|
elif resetType == 2:
|
updAppearCntInfo = hourAppearCntPri
|
else:
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventAppearCnt % eventID, updAppearCntInfo)
|
return
|
|
|
#// A5 26 Ѱ·ÃÏÉÓò #tagCMVisitFairyDomain
|
#
|
#struct tagCMVisitFairyDomain
|
#{
|
# tagHead Head;
|
# BYTE Type; //0-¿ªÊ¼Ñ°·Ã 1-½áÊøÑ°·Ã
|
#};
|
def OnVisitFairyDomain(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
maxEventCnt = GetMaxEventCnt() #×î´ó¿É³öÏÖʼþ¸öÊý
|
fairyDomainState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainState) #ÊÇ·ñѰ·ÃÖÐ 0δѰ·Ã 1Ѱ·ÃÖÐ 2ÈÎÎñ±ê¼Ç¿ÉѰ·Ã
|
if clientData.Type == 1: #½áÊøÑ°·Ã
|
if fairyDomainState != 1:
|
GameWorld.DebugLog(" δ¿ªÊ¼Ñ°·ÃÏÉÓò£¬ ÎÞ·¨½áÊø")
|
return
|
EndFairyDomain(curPlayer)
|
|
NotifyVisitFairyDomainInfo(curPlayer)
|
return
|
|
dailyID = ShareDefine.DailyActionID_FairyDomain
|
hasOpen = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % dailyID)
|
if fairyDomainState != 2 and not hasOpen:
|
GameWorld.DebugLog(" Ѱ·ÃÏÉÓò»î¶¯Î´¿ªÆô£¡")
|
return
|
|
#ÊÇ·ñѰ·ÃÖÐ
|
if fairyDomainState == 1:
|
GameWorld.DebugLog(" ÕýÔÚѰ·ÃÏÉÓòÖУ¡ÇëÏÈÍ˳öѰ·Ã")
|
return
|
remainCnt = PlayerActivity.GetDailyActionrRemainCnt(curPlayer, dailyID)
|
if not remainCnt:
|
GameWorld.DebugLog(" ûÓÐѰ·Ã´ÎÊýÁË£¡")
|
return
|
|
#Ëæ»úʼþ ÖØÖÃʼþ״̬
|
visitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
appointIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog('FairyDomainAppoint', visitCnt + 1)
|
if appointIpyDataList:
|
fdEventIDList = []
|
for appointIpyData in appointIpyDataList:
|
fdEventIDList.append(appointIpyData.GetEventID())
|
else:
|
fdEventTypeDict = {}
|
#ÏÈËæ»ú¶ÀÁ¢Ê¼þ
|
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)
|
if otherEventType is None:
|
continue
|
if otherEventType in unRepeatTypeList:
|
for index, info in enumerate(otherEventRateList):
|
if otherEventType == info[1]:
|
otherEventRateList = GameWorld.ResetRiseList(otherEventRateList, index)
|
break
|
fdEventTypeDict[otherEventType] = fdEventTypeDict.get(otherEventType, 0) + 1
|
|
fdEventIDList = []
|
for eventType, cnt in fdEventTypeDict.items():
|
randomList = __RandomFDEventByType(curPlayer, eventType, cnt)
|
if not randomList:
|
continue
|
fdEventIDList += randomList
|
#¸üиöÈ˳öÏÖ´ÎÊý
|
for fdEventID in fdEventIDList:
|
appearCntInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventAppearCnt % fdEventID)
|
hourAppearCntPri, dayAppearCntPri = appearCntInfo % 1000, appearCntInfo / 1000
|
updAppearCntInfo = (dayAppearCntPri + 1) * 1000 + (hourAppearCntPri + 1)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventAppearCnt % fdEventID, updAppearCntInfo)
|
#¸üÐÂÈ«·þ³öÏÖ´ÎÊý
|
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
|
|
for fdEventID in fdEventIDList:
|
domainIpyData = IpyGameDataPY.GetIpyGameData('FairyDomain', fdEventID)
|
if not domainIpyData:
|
continue
|
|
# ²ÝÔ°ÖØÖÃ
|
if domainIpyData.GetEventType() in [FDEventType_GrasslandXian, FDEventType_GrasslandLing]:
|
GameLogic_CrossGrassland.DoResetCrossGrassland(curPlayer, domainIpyData.GetEventType(), fdEventID)
|
|
if not PlayerActivity.AddDailyActionFinishCnt(curPlayer, dailyID):
|
return
|
|
#ÆæÓöʼþ Ëæ»úµµÎ»Êý¾Ý
|
openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
for fdEventID in fdEventIDList:
|
if fdEventID not in AdventuresTypeList:
|
continue
|
ipyData = IpyGameDataPY.InterpolationSearch('FairyAdventures', 'OpenServerDay', openServerDay, {'EventID':fdEventID})
|
if not ipyData:
|
#GameWorld.ErrLog('Ѱ·ÃÏÉÓò, ÆæÓöʼþûÓÐËæ»ú³ö¶ÔÓ¦µµÎ» randomList=%s,openServerDay=%s' % (randomList, openServerDay))
|
continue
|
conditionList = ipyData.GetCondition()
|
if not conditionList:
|
index = 0
|
else:
|
condition = random.choice(conditionList)
|
index = conditionList.index(condition)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, ipyData.GetID() * 100 + index)
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainVisitCnt, min(visitCnt + 1, ChConfig.Def_UpperLimit_DWord))
|
#ÉèÖÃʼþ
|
for i in xrange(maxEventCnt):
|
fdEventID = fdEventIDList[i] if i < len(fdEventIDList) else 0
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventID % i, fdEventID)
|
if fdEventID:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdEventID, FDEventState_CanVisit)
|
#ÉèÖÃѰ·ÃÖÐ
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainState, 1)
|
#ÉèÖóõʼÌåÁ¦
|
initEnergy = IpyGameDataPY.GetFuncCfg('ImmortalDomainStrength')
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEnergy, initEnergy)
|
GameWorld.DebugLog('Ѱ·ÃÏÉÓò Ëæ»ú½á¹û fdEventIDList=%s, visitCnt=%s' % (fdEventIDList, visitCnt))
|
#֪ͨ
|
NotifyVisitFairyDomainInfo(curPlayer, fdEventIDList)
|
NotifyFairyAdventuresInfo(curPlayer)
|
|
PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_FairyDomain, 1)
|
PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_FairyDomain, 1)
|
PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_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)
|
maxEventCnt = GetMaxEventCnt() #×î´ó¿É³öÏÖʼþ¸öÊý
|
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)
|
return
|
|
|
def __RandomFDEventByType(curPlayer, eventType, cnt):
|
##¸ù¾ÝʼþÀàÐÍËæ»úʼþ
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomain', {'EventType':eventType}, True)
|
if not ipyDataList:
|
return []
|
randomRateList = []
|
rate = 0
|
curAlchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV)
|
curLV = curPlayer.GetLV()
|
for ipyData in ipyDataList:
|
needAlchemyLV = ipyData.GetNeedAlchemyLV()
|
if curAlchemyLV < needAlchemyLV - 1:
|
#µ¤Â¯µÈ¼¶²»×ã
|
continue
|
lvLimit = ipyData.GetNeedLV()
|
if lvLimit and not (lvLimit[0] <= curLV <= lvLimit[1]):
|
#µÈ¼¶·¶Î§²»Âú×ã
|
continue
|
eventID = ipyData.GetID()
|
appearCntInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventAppearCnt % eventID)
|
hourAppearCntPri, dayAppearCntPri = appearCntInfo % 1000, appearCntInfo / 1000
|
hourCntPriLimit, dayCntPriLimit = ipyData.GetHourCntPriLimit(), ipyData.GetDayCntPriLimit()
|
if hourCntPriLimit and hourAppearCntPri >= hourCntPriLimit:
|
#³¬¹ý±¾Ð¡Ê±¸öÈ˿ɳöÏÖ´ÎÊýÉÏÏÞ
|
continue
|
if dayCntPriLimit and dayAppearCntPri >= dayCntPriLimit:
|
#³¬¹ý½ñÈÕ¸öÈ˿ɳöÏÖ´ÎÊýÉÏÏÞ
|
continue
|
if eventID in PyGameData.g_fairyDomainLimit:
|
#³¬¹ýÈ«·þ¿É³öÏÖ´ÎÊý
|
continue
|
rate += ipyData.GetWeight()
|
randomRateList.append([rate, ipyData.GetID()])
|
if not randomRateList:
|
GameWorld.DebugLog(' çÎç¿ÏÉÓòË¢ÐÂ³Ø ¸ÃÀàÐÍûÓзûºÏÌõ¼þµÄʼþ£¡eventType=%s' % eventType, curPlayer.GetID())
|
return []
|
realCnt = min(len(randomRateList), cnt)
|
randomResultList = GameWorld.GetResultByRandomListEx(randomRateList, realCnt, [])
|
GameWorld.DebugLog('eventType=%s, cnt=%s,randomRateList=%s,randomResultList=%s' % (eventType, cnt, randomRateList, randomResultList))
|
return randomResultList
|
|
|
def GetFairyDomainFBEventState(curPlayer, mapID, lineID):
|
## »ñÈ¡çÎç¿Ïà¹Ø¸±±¾Ñ°·Ã״̬
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
|
if not ipyData:
|
return FDEventState_No
|
fdeventID = ipyData.GetID()
|
curState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventState % fdeventID)
|
return curState
|
|
|
def SetFairyDomainFBEventState(curPlayer, mapID, lineID, state):
|
## ÉèÖÃçÎç¿Ïà¹Ø¸±±¾Ñ°·Ã״̬
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
|
if not ipyData:
|
return False
|
fdeventID = ipyData.GetID()
|
return SetFairyDomainEventState(curPlayer, fdeventID, state)
|
|
|
def SetFairyDomainEventState(curPlayer, fdeventID, state):
|
## ÉèÖÃçÎç¿Ê¼þ״̬£¬ return ÊÇ·ñ³É¹¦
|
if state not in [FDEventState_Visiting, FDEventState_Visited]: # 1-δ°Ý·Ã 2-°Ý·ÃÖÐ 3-ÒѰݷÃ
|
GameWorld.Log('çÎç¿ÏÉÓòʼþ״̬ÉèÖôíÎó£¬state=%s' % state)
|
return
|
curState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventState % fdeventID)
|
if not curState:
|
#ûÓиÃʼþ
|
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
|
|
costEnergy = ipyData.GetCostEnergy()
|
curEnergy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEnergy)
|
if curEnergy < costEnergy:
|
GameWorld.Log('çÎç¿ÏÉÓòʼþ״̬ÉèÖÃ,ÌåÁ¦²»×㣡£¬fdeventID=%s, costEnergy=%s, curEnergy=%s' % (fdeventID, costEnergy, curEnergy))
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEnergy, curEnergy - costEnergy)
|
|
# ²ÝÔ°ÖØÖÃ
|
if ipyData.GetEventType() in [FDEventType_GrasslandXian, FDEventType_GrasslandLing]:
|
GameLogic_CrossGrassland.DoResetCrossGrassland(curPlayer, ipyData.GetEventType(), fdeventID)
|
|
elif state == FDEventState_Visited:
|
#ÉèÖýáÊø£¬Ôݲ»×öÏÞÖÆ£¬·ÀÖ¹Òì³£µ¼ÖÂÎÞ·¨½áÊø
|
# if curState != FDEventState_Visiting:
|
# GameWorld.Log('çÎç¿ÏÉÓòʼþ״̬ÉèÖôíÎó£¬fdeventID=%s, state=%s, curState=%s' % (fdeventID, state, curState))
|
# return
|
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=None, isAll=1):
|
if not fdEventList:
|
syncFDEventList = []
|
maxEventCnt = GetMaxEventCnt() #×î´ó¿É³öÏÖʼþ¸öÊý
|
for i in xrange(maxEventCnt):
|
fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
|
if fdEventID:
|
syncFDEventList.append(fdEventID)
|
else:
|
syncFDEventList = fdEventList
|
|
packData = ChPyNetSendPack.tagMCFairyDomainInfo()
|
packData.IsAll = isAll
|
packData.State = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainState)
|
packData.Energy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEnergy)
|
packData.VisitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
packData.InfoList = []
|
for fdeventID in syncFDEventList:
|
fdeventData = ChPyNetSendPack.tagMCFairyDomainEvent()
|
fdeventData.EventID = fdeventID
|
fdeventData.EventState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventState % fdeventID)
|
packData.InfoList.append(fdeventData)
|
packData.Count = len(packData.InfoList)
|
NetPackCommon.SendFakePack(curPlayer, packData)
|
return
|
|
def GetMaxEventCnt():
|
# ×î´ó¿É³öÏÖʼþ¸öÊý
|
otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
|
maxEventCnt = max([info[1] for info in otherCntRateList]) + len(IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 1, {}))
|
return maxEventCnt
|
|
###=========================ÆæÓö===============================
|
def NotifyFairyAdventuresInfo(curPlayer):
|
##Í¨ÖªÆæÓöÐÅÏ¢
|
visitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
|
packData = ChPyNetSendPack.tagMCFairyAdventuresInfo()
|
packData.InfoList = []
|
maxEventCnt = GetMaxEventCnt() #×î´ó¿É³öÏÖʼþ¸öÊý
|
for i in xrange(maxEventCnt):
|
fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
|
if fdEventID not in AdventuresTypeList:
|
continue
|
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
|
if IpyGameDataPY.GetIpyGameDataByCondition('FairyDomainAppoint', {'Cnt':visitCnt, 'EventID':fdEventID}, False, False):
|
condition = 0 #¶¨ÖƵÄÌõ¼þΪ0
|
else:
|
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)
|
isSweep, state = state / 10, state % 10
|
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
|
giveItemList = GetFairyAppointAward(curPlayer, fdeventID)
|
if not giveItemList:
|
#1-µÈ¼¶ÆæÓö 2-¾³½çÆæÓö 3-Õ½Á¦ÆæÓö 4-ÆøÔËÆæÓö
|
if fdeventID == AdventuresType1:
|
curData = curPlayer.GetLV()
|
elif fdeventID == AdventuresType2:
|
curData = curPlayer.GetOfficialRank()
|
elif fdeventID == AdventuresType3:
|
curData = PlayerControl.GetFightPower(curPlayer)
|
elif fdeventID == AdventuresType4:
|
curData = curPlayer.GetLuckValue()
|
else:
|
return
|
if curData >= condition:
|
gearAwardList = ipyData.GetGearAward()
|
if not gearAwardList:
|
return
|
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()]
|
msgDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)}
|
if isSweep:
|
ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList)
|
msgDict.update({FBCommon.Over_dataMapID:ChConfig.Def_FBMapID_FairyTreasure,
|
FBCommon.Over_isPass:1, FBCommon.Over_isSweep:1})
|
else:
|
NPCCommon.DoGiveItemByVirtualDrop(curPlayer, giveItemList, 0)
|
FBCommon.Notify_FB_Over(curPlayer, msgDict)
|
GameWorld.DebugLog('çÎç¿ÆæÓöÁì½± msgDict=%s, fdeventID=%s, isSweep=%s' % (msgDict, fdeventID, isSweep))
|
return
|
|
|
def GetFairyAppointAward(curPlayer, fdEventID):
|
##»ñȡʼþ¶¨Öƽ±Àø, ûÓеĸøÕý³£½±Àø
|
visitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomainAppoint', {'Cnt':visitCnt, 'EventID':fdEventID}, False, False)
|
if not ipyData:
|
return
|
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
|