xdh
2019-04-09 f87b69ad9c32c75d74d40689e0d0427f0a1a6e46
6457 【后端】【2.0】缥缈仙域开发单(奇遇)
7个文件已修改
393 ■■■■■ 已修改文件
PySysDB/PySysDBPY.h 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
PySysDB/PySysDBPY.h
@@ -1798,4 +1798,16 @@
    BYTE        CostEnergy;    //消耗体力
    BYTE        NeedAlchemyLV;    //出现的炼丹等级要求
    DWORD        Weight;    //权重
};
//缥缈奇遇表
struct tagFairyAdventures
{
    WORD        _ID;    //ΨһID
    DWORD        OpenServerDay;    //开服天
    BYTE        EventID;    //事件编号
    list        Condition;    //条件
    list        GearAward;    //档位奖励
    list        BasicAward;    //保底奖励
};
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -13748,6 +13748,118 @@
#------------------------------------------------------
# A3 07 缥缈奇遇信息 #tagMCFairyAdventuresInfo
class  tagMCFairyAdventuresData(Structure):
    _pack_ = 1
    _fields_ = [
                  ("EventID", c_ubyte),
                  ("Gear", c_ubyte),    #第几档
                  ("Condition", c_int),    #条件
                  ]
    def __init__(self):
        self.Clear()
        return
    def ReadData(self, stringData, _pos=0, _len=0):
        self.Clear()
        memmove(addressof(self), stringData[_pos:], self.GetLength())
        return _pos + self.GetLength()
    def Clear(self):
        self.EventID = 0
        self.Gear = 0
        self.Condition = 0
        return
    def GetLength(self):
        return sizeof(tagMCFairyAdventuresData)
    def GetBuffer(self):
        return string_at(addressof(self), self.GetLength())
    def OutputString(self):
        DumpString = '''// A3 07 缥缈奇遇信息 //tagMCFairyAdventuresInfo:
                                EventID:%d,
                                Gear:%d,
                                Condition:%d
                                '''\
                                %(
                                self.EventID,
                                self.Gear,
                                self.Condition
                                )
        return DumpString
class  tagMCFairyAdventuresInfo(Structure):
    Head = tagHead()
    Cnt = 0    #(BYTE Cnt)
    InfoList = list()    #(vector<tagMCFairyAdventuresData> InfoList)// 信息
    data = None
    def __init__(self):
        self.Clear()
        self.Head.Cmd = 0xA3
        self.Head.SubCmd = 0x07
        return
    def ReadData(self, _lpData, _pos=0, _Len=0):
        self.Clear()
        _pos = self.Head.ReadData(_lpData, _pos)
        self.Cnt,_pos = CommFunc.ReadBYTE(_lpData, _pos)
        for i in range(self.Cnt):
            temInfoList = tagMCFairyAdventuresData()
            _pos = temInfoList.ReadData(_lpData, _pos)
            self.InfoList.append(temInfoList)
        return _pos
    def Clear(self):
        self.Head = tagHead()
        self.Head.Clear()
        self.Head.Cmd = 0xA3
        self.Head.SubCmd = 0x07
        self.Cnt = 0
        self.InfoList = list()
        return
    def GetLength(self):
        length = 0
        length += self.Head.GetLength()
        length += 1
        for i in range(self.Cnt):
            length += self.InfoList[i].GetLength()
        return length
    def GetBuffer(self):
        data = ''
        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
        data = CommFunc.WriteBYTE(data, self.Cnt)
        for i in range(self.Cnt):
            data = CommFunc.WriteString(data, self.InfoList[i].GetLength(), self.InfoList[i].GetBuffer())
        return data
    def OutputString(self):
        DumpString = '''
                                Head:%s,
                                Cnt:%d,
                                InfoList:%s
                                '''\
                                %(
                                self.Head.OutputString(),
                                self.Cnt,
                                "..."
                                )
        return DumpString
m_NAtagMCFairyAdventuresInfo=tagMCFairyAdventuresInfo()
ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCFairyAdventuresInfo.Head.Cmd,m_NAtagMCFairyAdventuresInfo.Head.SubCmd))] = m_NAtagMCFairyAdventuresInfo
#------------------------------------------------------
# A3 06 缥缈仙域信息 #tagMCFairyDomainInfo
class  tagMCFairyDomainEvent(Structure):
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3848,6 +3848,7 @@
Def_PDict_FairyDomainEventID = "FairyDomainEventID%s" #事件ID 参数第n个事件
Def_PDict_FairyDomainEnergy = "FairyDomainEnergy" #体力值
Def_PDict_FairyDomainVisitCnt = "FairyDomainVisitCnt" #寻访总次数
Def_PDict_FairyAdventuresData = "FairyAdventuresData_%s" #奇遇数值 唯一ID*100+档位 参数事件ID
#-------------------------------------------------------------------------------
#可以从07 41封包购买的背包类型,和对应字典{背包类型:[字典key, 默认格子数]}
@@ -5058,7 +5059,8 @@
Def_RewardType_NewFairyCParty, # 新仙界盛典全民来嗨24
Def_RewardType_FeastWeekPartyAct, # 领取节日巡礼活动奖励25
Def_RewardType_FeastWeekPartyPoint, # 领取节日巡礼积分奖励26
)= range(27)
Def_RewardType_FairyAdventuresAward, #缥缈奇遇领取27
)= range(28)
#boss复活相关活动定义
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -13748,6 +13748,118 @@
#------------------------------------------------------
# A3 07 缥缈奇遇信息 #tagMCFairyAdventuresInfo
class  tagMCFairyAdventuresData(Structure):
    _pack_ = 1
    _fields_ = [
                  ("EventID", c_ubyte),
                  ("Gear", c_ubyte),    #第几档
                  ("Condition", c_int),    #条件
                  ]
    def __init__(self):
        self.Clear()
        return
    def ReadData(self, stringData, _pos=0, _len=0):
        self.Clear()
        memmove(addressof(self), stringData[_pos:], self.GetLength())
        return _pos + self.GetLength()
    def Clear(self):
        self.EventID = 0
        self.Gear = 0
        self.Condition = 0
        return
    def GetLength(self):
        return sizeof(tagMCFairyAdventuresData)
    def GetBuffer(self):
        return string_at(addressof(self), self.GetLength())
    def OutputString(self):
        DumpString = '''// A3 07 缥缈奇遇信息 //tagMCFairyAdventuresInfo:
                                EventID:%d,
                                Gear:%d,
                                Condition:%d
                                '''\
                                %(
                                self.EventID,
                                self.Gear,
                                self.Condition
                                )
        return DumpString
class  tagMCFairyAdventuresInfo(Structure):
    Head = tagHead()
    Cnt = 0    #(BYTE Cnt)
    InfoList = list()    #(vector<tagMCFairyAdventuresData> InfoList)// 信息
    data = None
    def __init__(self):
        self.Clear()
        self.Head.Cmd = 0xA3
        self.Head.SubCmd = 0x07
        return
    def ReadData(self, _lpData, _pos=0, _Len=0):
        self.Clear()
        _pos = self.Head.ReadData(_lpData, _pos)
        self.Cnt,_pos = CommFunc.ReadBYTE(_lpData, _pos)
        for i in range(self.Cnt):
            temInfoList = tagMCFairyAdventuresData()
            _pos = temInfoList.ReadData(_lpData, _pos)
            self.InfoList.append(temInfoList)
        return _pos
    def Clear(self):
        self.Head = tagHead()
        self.Head.Clear()
        self.Head.Cmd = 0xA3
        self.Head.SubCmd = 0x07
        self.Cnt = 0
        self.InfoList = list()
        return
    def GetLength(self):
        length = 0
        length += self.Head.GetLength()
        length += 1
        for i in range(self.Cnt):
            length += self.InfoList[i].GetLength()
        return length
    def GetBuffer(self):
        data = ''
        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
        data = CommFunc.WriteBYTE(data, self.Cnt)
        for i in range(self.Cnt):
            data = CommFunc.WriteString(data, self.InfoList[i].GetLength(), self.InfoList[i].GetBuffer())
        return data
    def OutputString(self):
        DumpString = '''
                                Head:%s,
                                Cnt:%d,
                                InfoList:%s
                                '''\
                                %(
                                self.Head.OutputString(),
                                self.Cnt,
                                "..."
                                )
        return DumpString
m_NAtagMCFairyAdventuresInfo=tagMCFairyAdventuresInfo()
ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCFairyAdventuresInfo.Head.Cmd,m_NAtagMCFairyAdventuresInfo.Head.SubCmd))] = m_NAtagMCFairyAdventuresInfo
#------------------------------------------------------
# A3 06 缥缈仙域信息 #tagMCFairyDomainInfo
class  tagMCFairyDomainEvent(Structure):
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -1391,6 +1391,15 @@
                        ("BYTE", "NeedAlchemyLV", 0),
                        ("DWORD", "Weight", 0),
                        ),
                "FairyAdventures":(
                        ("WORD", "ID", 1),
                        ("DWORD", "OpenServerDay", 0),
                        ("BYTE", "EventID", 0),
                        ("list", "Condition", 0),
                        ("list", "GearAward", 0),
                        ("list", "BasicAward", 0),
                        ),
                }
@@ -4254,6 +4263,25 @@
    def GetCostEnergy(self): return self.CostEnergy # 消耗体力
    def GetNeedAlchemyLV(self): return self.NeedAlchemyLV # 出现的炼丹等级要求
    def GetWeight(self): return self.Weight # 权重
# 缥缈奇遇表
class IPY_FairyAdventures():
    def __init__(self):
        self.ID = 0
        self.OpenServerDay = 0
        self.EventID = 0
        self.Condition = []
        self.GearAward = []
        self.BasicAward = []
        return
    def GetID(self): return self.ID # ΨһID
    def GetOpenServerDay(self): return self.OpenServerDay # 开服天
    def GetEventID(self): return self.EventID # 事件编号
    def GetCondition(self): return self.Condition # 条件
    def GetGearAward(self): return self.GearAward # 档位奖励
    def GetBasicAward(self): return self.BasicAward # 保底奖励
def Log(msg, playerID=0, par=0):
@@ -4561,6 +4589,8 @@
        self.ipyHorsePetBossAwardLen = len(self.ipyHorsePetBossAwardCache)
        self.ipyFairyDomainCache = self.__LoadFileData("FairyDomain", IPY_FairyDomain)
        self.ipyFairyDomainLen = len(self.ipyFairyDomainCache)
        self.ipyFairyAdventuresCache = self.__LoadFileData("FairyAdventures", IPY_FairyAdventures)
        self.ipyFairyAdventuresLen = len(self.ipyFairyAdventuresCache)
        Log("IPY_FuncConfig count=%s" % len(self.ipyFuncConfigDict))
        Log("IPY_DataMgr InitOK!")
        return
@@ -5009,6 +5039,8 @@
    def GetHorsePetBossAwardByIndex(self, index): return self.ipyHorsePetBossAwardCache[index]
    def GetFairyDomainCount(self): return self.ipyFairyDomainLen
    def GetFairyDomainByIndex(self, index): return self.ipyFairyDomainCache[index]
    def GetFairyAdventuresCount(self): return self.ipyFairyAdventuresLen
    def GetFairyAdventuresByIndex(self, index): return self.ipyFairyAdventuresCache[index]
IPYData = IPY_DataMgr()
def IPY_Data(): return IPYData
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -5345,6 +5345,10 @@
    # 领取节日巡礼积分奖励
    elif rewardType == ChConfig.Def_RewardType_FeastWeekPartyPoint:
        PlayerFeastWeekParty.GetFeastWeekPartyPointAward(curPlayer, dataEx, dataExStr)
    #缥缈奇遇领取
    elif rewardType == ChConfig.Def_RewardType_FairyAdventuresAward:
        PlayerFairyDomain.GetFairyAdventuresAward(curPlayer, dataEx, dataExStr)
    return
    
    
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py
@@ -24,8 +24,11 @@
import PlayerControl
import IpyGameDataPY
import PlayerActivity
import ItemControler
import copy
import random
import FBCommon
#0-奇遇 1-宝藏 2-仙草 3-妖王 4-灵草
(
@@ -37,15 +40,16 @@
) = range(5)
(
FDEventState_No, #不可拜访0
FDEventState_CanVisit, #可拜访1
FDEventState_Visiting, #拜访中2
FDEventState_Visited, #已拜访3
FDEventState_No,  #不可拜访0
FDEventState_CanVisit,  #可拜访1
FDEventState_Visiting,  #拜访中2
FDEventState_Visited,  #已拜访3
) = range(4)
def OnLogin(curPlayer):
    NotifyVisitFairyDomainInfo(curPlayer)
    NotifyFairyAdventuresInfo(curPlayer)
    return
@@ -71,11 +75,13 @@
            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_FairyDomainEventID % i, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdEventID, 0)
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, 0)
                
        NotifyVisitFairyDomainInfo(curPlayer)
        return
@@ -119,7 +125,27 @@
                    
        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
@@ -190,7 +216,7 @@
            return
        
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdeventID, state)
    NotifyVisitFairyDomainInfo(curPlayer, fdeventID)
    NotifyVisitFairyDomainInfo(curPlayer, [fdeventID])
    return True
@@ -215,3 +241,78 @@
    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