From 1ee23ed9a201181eca6b2da5fb256ca9af0639f2 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期一, 23 十二月 2019 18:11:08 +0800 Subject: [PATCH] 8359 【主干】活跃兑换(改为后端计算倒计时;优化次数启动及结算模式) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ActivityPlace.py | 7 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini | 6 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py | 201 ++++++++++++++------------- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py | 56 +++++++ ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py | 14 +- ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py | 56 +++++++ ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py | 14 +- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py | 3 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py | 6 9 files changed, 233 insertions(+), 130 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py index 7f40e82..2ae3d31 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py @@ -14006,6 +14006,54 @@ #------------------------------------------------------ +# B0 28 活跃放置快速完成 #tagCMActivityPlaceQuickFinish + +class tagCMActivityPlaceQuickFinish(Structure): + _pack_ = 1 + _fields_ = [ + ("Cmd", c_ubyte), + ("SubCmd", c_ubyte), + ] + + def __init__(self): + self.Clear() + self.Cmd = 0xB0 + self.SubCmd = 0x28 + 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.Cmd = 0xB0 + self.SubCmd = 0x28 + return + + def GetLength(self): + return sizeof(tagCMActivityPlaceQuickFinish) + + def GetBuffer(self): + return string_at(addressof(self), self.GetLength()) + + def OutputString(self): + DumpString = '''// B0 28 活跃放置快速完成 //tagCMActivityPlaceQuickFinish: + Cmd:%s, + SubCmd:%s + '''\ + %( + self.Cmd, + self.SubCmd + ) + return DumpString + + +m_NAtagCMActivityPlaceQuickFinish=tagCMActivityPlaceQuickFinish() +ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMActivityPlaceQuickFinish.Cmd,m_NAtagCMActivityPlaceQuickFinish.SubCmd))] = m_NAtagCMActivityPlaceQuickFinish + + +#------------------------------------------------------ # B0 27 活跃放置启动 #tagCMActivityPlaceStart class tagCMActivityPlaceStart(Structure): @@ -14013,7 +14061,6 @@ _fields_ = [ ("Cmd", c_ubyte), ("SubCmd", c_ubyte), - ("RewardEndType", c_ubyte), #是否结算探索,后端处理奖励后自动启动下一次放置探索;0-无结算启动,1-倒计时结束结算,2-快速结算; ] def __init__(self): @@ -14030,7 +14077,6 @@ def Clear(self): self.Cmd = 0xB0 self.SubCmd = 0x27 - self.RewardEndType = 0 return def GetLength(self): @@ -14042,13 +14088,11 @@ def OutputString(self): DumpString = '''// B0 27 活跃放置启动 //tagCMActivityPlaceStart: Cmd:%s, - SubCmd:%s, - RewardEndType:%d + SubCmd:%s '''\ %( self.Cmd, - self.SubCmd, - self.RewardEndType + self.SubCmd ) return DumpString diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py index 270b221..162ea87 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py @@ -29201,8 +29201,8 @@ class tagMCActivityPlaceInfo(Structure): Head = tagHead() - PlaceState = 0 #(BYTE PlaceState)// 是否启动状态 StartTime = 0 #(DWORD StartTime)// 开始探索time时间戳,完成一次探索会自动下一次探索并更新该时间 + PlaceCount = 0 #(BYTE PlaceCount)// 剩余未完成探索次数 RewardCount = 0 #(BYTE RewardCount)// 累计未领取探索奖励次数 RewardLen = 0 #(BYTE RewardLen) RewardInfo = "" #(String RewardInfo)//累计未领取探索奖励 [[itemID, count], ...] @@ -29217,8 +29217,8 @@ def ReadData(self, _lpData, _pos=0, _Len=0): self.Clear() _pos = self.Head.ReadData(_lpData, _pos) - self.PlaceState,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.StartTime,_pos = CommFunc.ReadDWORD(_lpData, _pos) + self.PlaceCount,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.RewardCount,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.RewardLen,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.RewardInfo,_pos = CommFunc.ReadString(_lpData, _pos,self.RewardLen) @@ -29229,8 +29229,8 @@ self.Head.Clear() self.Head.Cmd = 0xB0 self.Head.SubCmd = 0x27 - self.PlaceState = 0 self.StartTime = 0 + self.PlaceCount = 0 self.RewardCount = 0 self.RewardLen = 0 self.RewardInfo = "" @@ -29239,8 +29239,8 @@ def GetLength(self): length = 0 length += self.Head.GetLength() - length += 1 length += 4 + length += 1 length += 1 length += 1 length += len(self.RewardInfo) @@ -29250,8 +29250,8 @@ def GetBuffer(self): data = '' data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer()) - data = CommFunc.WriteBYTE(data, self.PlaceState) data = CommFunc.WriteDWORD(data, self.StartTime) + data = CommFunc.WriteBYTE(data, self.PlaceCount) data = CommFunc.WriteBYTE(data, self.RewardCount) data = CommFunc.WriteBYTE(data, self.RewardLen) data = CommFunc.WriteString(data, self.RewardLen, self.RewardInfo) @@ -29260,16 +29260,16 @@ def OutputString(self): DumpString = ''' Head:%s, - PlaceState:%d, StartTime:%d, + PlaceCount:%d, RewardCount:%d, RewardLen:%d, RewardInfo:%s '''\ %( self.Head.OutputString(), - self.PlaceState, self.StartTime, + self.PlaceCount, self.RewardCount, self.RewardLen, self.RewardInfo diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini index f048ca2..22d6543 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini @@ -1416,7 +1416,7 @@ Writer = xdh Releaser = xdh RegType = 0 -RegisterPackCount = 2 +RegisterPackCount = 3 PacketCMD_1=0xA5 PacketSubCMD_1=0x25 @@ -1426,6 +1426,10 @@ PacketSubCMD_2=0x27 PacketCallFunc_2=OnActivityPlaceStart +PacketCMD_3=0xB0 +PacketSubCMD_3=0x28 +PacketCallFunc_3=OnActivityPlaceQuickFinish + ;协助 [PlayerAssist] ScriptName = Player\PlayerAssist.py diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py index 617541f..749d299 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py @@ -3838,10 +3838,10 @@ # 活跃放置 Def_PDict_ActivityCanCostTotalPoint = "ActivityCanCostTotalPoint" # 当前总活跃值(可消耗) -Def_PDict_ActivityPlaceState = "ActivityPlaceState" # 活跃放置是否探索中 Def_PDict_ActivityPlaceStartTime = "ActivityPlaceStartTime" # 活跃放置开始time值 -Def_PDict_ActivityPlaceRewardTotalCount = "ActivityPlaceRewardTotalCount" # 活跃放置总共累计奖励次数 -Def_PDict_ActivityPlaceRewardCount = "ActivityPlaceRewardCount" # 活跃放置累计奖励次数 +Def_PDict_ActivityPlaceRemainCount = "ActivityPlaceRemainCount" # 活跃放置剩余进行次数 +Def_PDict_ActivityPlaceRewardCount = "ActivityPlaceRewardCount" # 活跃放置本次启动已累计奖励次数 +Def_PDict_ActivityPlaceRewardTotalCount = "ActivityPlaceRewardTotalCount" # 活跃放置历史总共累计奖励次数 Def_PDict_ActivityPlaceRewardItem = "ActivityPlaceItem" # 奖励物品个数 Def_PDict_ActivityPlaceRewardItemID = "ActivityPlaceItemID_%s" # 奖励物品ID,参数(index) Def_PDict_ActivityPlaceRewardItemCount = "ActivityPlaceItemCount_%s" # 奖励物品个数,参数(index) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py index 7f40e82..2ae3d31 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py @@ -14006,6 +14006,54 @@ #------------------------------------------------------ +# B0 28 活跃放置快速完成 #tagCMActivityPlaceQuickFinish + +class tagCMActivityPlaceQuickFinish(Structure): + _pack_ = 1 + _fields_ = [ + ("Cmd", c_ubyte), + ("SubCmd", c_ubyte), + ] + + def __init__(self): + self.Clear() + self.Cmd = 0xB0 + self.SubCmd = 0x28 + 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.Cmd = 0xB0 + self.SubCmd = 0x28 + return + + def GetLength(self): + return sizeof(tagCMActivityPlaceQuickFinish) + + def GetBuffer(self): + return string_at(addressof(self), self.GetLength()) + + def OutputString(self): + DumpString = '''// B0 28 活跃放置快速完成 //tagCMActivityPlaceQuickFinish: + Cmd:%s, + SubCmd:%s + '''\ + %( + self.Cmd, + self.SubCmd + ) + return DumpString + + +m_NAtagCMActivityPlaceQuickFinish=tagCMActivityPlaceQuickFinish() +ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMActivityPlaceQuickFinish.Cmd,m_NAtagCMActivityPlaceQuickFinish.SubCmd))] = m_NAtagCMActivityPlaceQuickFinish + + +#------------------------------------------------------ # B0 27 活跃放置启动 #tagCMActivityPlaceStart class tagCMActivityPlaceStart(Structure): @@ -14013,7 +14061,6 @@ _fields_ = [ ("Cmd", c_ubyte), ("SubCmd", c_ubyte), - ("RewardEndType", c_ubyte), #是否结算探索,后端处理奖励后自动启动下一次放置探索;0-无结算启动,1-倒计时结束结算,2-快速结算; ] def __init__(self): @@ -14030,7 +14077,6 @@ def Clear(self): self.Cmd = 0xB0 self.SubCmd = 0x27 - self.RewardEndType = 0 return def GetLength(self): @@ -14042,13 +14088,11 @@ def OutputString(self): DumpString = '''// B0 27 活跃放置启动 //tagCMActivityPlaceStart: Cmd:%s, - SubCmd:%s, - RewardEndType:%d + SubCmd:%s '''\ %( self.Cmd, - self.SubCmd, - self.RewardEndType + self.SubCmd ) return DumpString diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py index 270b221..162ea87 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py @@ -29201,8 +29201,8 @@ class tagMCActivityPlaceInfo(Structure): Head = tagHead() - PlaceState = 0 #(BYTE PlaceState)// 是否启动状态 StartTime = 0 #(DWORD StartTime)// 开始探索time时间戳,完成一次探索会自动下一次探索并更新该时间 + PlaceCount = 0 #(BYTE PlaceCount)// 剩余未完成探索次数 RewardCount = 0 #(BYTE RewardCount)// 累计未领取探索奖励次数 RewardLen = 0 #(BYTE RewardLen) RewardInfo = "" #(String RewardInfo)//累计未领取探索奖励 [[itemID, count], ...] @@ -29217,8 +29217,8 @@ def ReadData(self, _lpData, _pos=0, _Len=0): self.Clear() _pos = self.Head.ReadData(_lpData, _pos) - self.PlaceState,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.StartTime,_pos = CommFunc.ReadDWORD(_lpData, _pos) + self.PlaceCount,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.RewardCount,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.RewardLen,_pos = CommFunc.ReadBYTE(_lpData, _pos) self.RewardInfo,_pos = CommFunc.ReadString(_lpData, _pos,self.RewardLen) @@ -29229,8 +29229,8 @@ self.Head.Clear() self.Head.Cmd = 0xB0 self.Head.SubCmd = 0x27 - self.PlaceState = 0 self.StartTime = 0 + self.PlaceCount = 0 self.RewardCount = 0 self.RewardLen = 0 self.RewardInfo = "" @@ -29239,8 +29239,8 @@ def GetLength(self): length = 0 length += self.Head.GetLength() - length += 1 length += 4 + length += 1 length += 1 length += 1 length += len(self.RewardInfo) @@ -29250,8 +29250,8 @@ def GetBuffer(self): data = '' data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer()) - data = CommFunc.WriteBYTE(data, self.PlaceState) data = CommFunc.WriteDWORD(data, self.StartTime) + data = CommFunc.WriteBYTE(data, self.PlaceCount) data = CommFunc.WriteBYTE(data, self.RewardCount) data = CommFunc.WriteBYTE(data, self.RewardLen) data = CommFunc.WriteString(data, self.RewardLen, self.RewardInfo) @@ -29260,16 +29260,16 @@ def OutputString(self): DumpString = ''' Head:%s, - PlaceState:%d, StartTime:%d, + PlaceCount:%d, RewardCount:%d, RewardLen:%d, RewardInfo:%s '''\ %( self.Head.OutputString(), - self.PlaceState, self.StartTime, + self.PlaceCount, self.RewardCount, self.RewardLen, self.RewardInfo diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ActivityPlace.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ActivityPlace.py index 5d94d5b..dd69f92 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ActivityPlace.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ActivityPlace.py @@ -34,16 +34,17 @@ return if len(msgList) == 1 and not msgList[0]: - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, 0) - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, 0) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, 0) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, 0) rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem) for i in xrange(rewardItemCount): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemID % i, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i, 0) - + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItem, 0) + GameWorld.DebugAnswer(curPlayer, "重置活跃放置成功!") PlayerActivity.Sync_ActivityPlaceInfo(curPlayer) return diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py index 416fb05..2d39151 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py @@ -29,6 +29,7 @@ import PyGameData import GameFuncComm import EventShell +import PlayerTJG import PlayerPet import datetime import time @@ -629,74 +630,108 @@ #struct tagCMActivityPlaceStart #{ # tagHead Head; -# BYTE RewardEndType; //是否结算探索,后端处理奖励后自动启动下一次放置探索;0-无结算启动,1-倒计时结束结算,2-快速结算; #}; def OnActivityPlaceStart(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) - rewardEndType = clientData.RewardEndType + maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数 + remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount) rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount) - maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数 - if rewardCount >= maxRewardCount: - GameWorld.ErrLog("活跃放置奖励累计次数已达上限,无法启动") + + maxCanStartCount = maxRewardCount - remainCount - rewardCount + if maxCanStartCount <= 0: + GameWorld.DebugLog("活跃放置奖励累计次数已达上限,无法启动!remainCount=%s + rewardCount=%s >= maxRewardCount=%s" + % (remainCount, rewardCount, maxRewardCount)) + return + + costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # 单次放置消耗的活跃点数 + canUseActivityPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityCanCostTotalPoint) + pointCanUseCount = canUseActivityPoint / costPoint + startCount = min(maxCanStartCount, pointCanUseCount) + if startCount <= 0: + GameWorld.DebugLog("可用活跃不足,无法添加次数启动!canUseActivityPoint=%s,costPoint=%s" % (canUseActivityPoint, costPoint)) return - placeState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceState) + updRemainCount = remainCount + startCount + GameWorld.DebugLog("添加活跃放置次数: startCount=%s,rewardCount=%s,remainCount=%s,updRemainCount=%s" + % (startCount, rewardCount, remainCount, updRemainCount)) - endCount, nextStartReduceSeconds = 1, 0 + costPointTotal = costPoint * startCount + CostActivityPoint(curPlayer, costPointTotal) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, updRemainCount) - # 无结算启动 - if rewardEndType == 0: - if placeState: - GameWorld.DebugLog("已在放置探索中!") - return - __DoActivityPlaceStart(curPlayer) - - # 倒计时结束结算 - elif rewardEndType == 1: - if not placeState: - GameWorld.DebugLog("非放置探索中,无法结算!") - return - startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime) - if not startTime: - return - needSeconds = IpyGameDataPY.GetFuncCfg("ActivityPlace", 3) # 单次放置奖励持续时间,秒 + if not remainCount: curTime = int(time.time()) - passTime = curTime - startTime - if passTime < needSeconds: - GameWorld.DebugLog("探索时间未到,无法结算! curTime=%s,startTime=%s,passTime=%s < %s" % (curTime, startTime, passTime, needSeconds)) - return - endCount = passTime / needSeconds - nextStartReduceSeconds = passTime % needSeconds - __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds) - - # 快速结算 - elif rewardEndType == 2: - if not placeState: - GameWorld.DebugLog("非放置探索中,无法快速结算!") - return - - costItemID, costGoldParper = IpyGameDataPY.GetFuncEvalCfg("ActivityPlace", 5) - costItemCount = 1 - - costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount) - lackCnt = costItemCount - bindCnt - unBindCnt - if lackCnt > 0: - if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, costGoldParper, ChConfig.Def_Cost_ActivityPlace): - return - else: - ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, ChConfig.ItemDel_ActivityPlace) - - __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, curTime) + GameWorld.DebugLog(" 没有剩余次数,更新启动时间: %s" % curTime) Sync_ActivityPlaceInfo(curPlayer) return -def __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds): +#// B0 28 活跃放置快速完成 #tagCMActivityPlaceQuickFinish +# +#struct tagCMActivityPlaceQuickFinish +#{ +# tagHead Head; +#}; +def OnActivityPlaceQuickFinish(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + + remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount) + if not remainCount: + GameWorld.DebugLog("没有剩余活跃放置次数,无法快速完成!") + return + + costItemID, costGoldParper = IpyGameDataPY.GetFuncEvalCfg("ActivityPlace", 5) + costItemCount = 1 # 默认扣一个 + endCount = 1 # 只快速结算一次 + + costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount) + lackCnt = costItemCount - bindCnt - unBindCnt + if lackCnt > 0: + if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, costGoldParper, ChConfig.Def_Cost_ActivityPlace): + return + else: + ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, ChConfig.ItemDel_ActivityPlace) + + __DoActivityPlaceRewardEnd(curPlayer, endCount) + return + +def ProcessActivityPlace(curPlayer): + ## 活跃放置定时处理 + + remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount) + if remainCount <= 0: + #GameWorld.DebugLog("没有剩余放置次数不处理!") + return + + curTime = int(time.time()) + startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime) + if not startTime: + startTime = curTime + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, curTime) + + needSeconds = IpyGameDataPY.GetFuncCfg("ActivityPlace", 3) # 单次放置奖励持续时间,秒 + passTime = curTime - startTime + if passTime < needSeconds: + #GameWorld.DebugLog("探索时间未到,不结算! curTime=%s,startTime=%s,passTime=%s < %s" % (curTime, startTime, passTime, needSeconds)) + return + endCount = passTime / needSeconds + nextStartReduceSeconds = passTime % needSeconds + __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds) + return + +def __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds=0): ## 放置活跃奖励结算 - if not endCount: + remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount) + endCount = min(endCount, remainCount) + if endCount <= 0: return + + if PlayerTJG.GetIsTJG(curPlayer): + return + countDataDict = {} lvDataDict = {} ipyDataMgr = IpyGameDataPY.IPY_Data() @@ -719,36 +754,24 @@ if not lvRewardIpyData: lvRewardIpyData = lvDataDict[lvList[-1]] - costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # 单次放置消耗的活跃点数 - maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数 maxAppointCount = max(countDataDict) # 最大定制奖励次数 rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount) + rewardTotalCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardTotalCount) - isStop = False rewardItemDict = {} - GameWorld.DebugLog("结算放置活跃奖励: rewardCount=%s,endCount=%s,maxRewardCount=%s,maxAppointCount=%s" % (rewardCount, endCount, maxRewardCount, maxAppointCount)) - for endIndex in xrange(endCount): - #GameWorld.DebugLog("endIndex=%s" % endIndex) + GameWorld.DebugLog("结算放置活跃奖励: remainCount=%s,rewardCount=%s,endCount=%s,maxAppointCount=%s" % (remainCount, rewardCount, endCount, maxAppointCount)) + for _ in xrange(endCount): - # 超过1次的需要补扣活跃消耗 - if endCount > 1 and endIndex != 0: - if not CostActivityPoint(curPlayer, costPoint): - isStop = True - GameWorld.DebugLog(" 可消耗的活跃不足,无法继续结算奖励!") - break - rewardIpyData = None - rewardTotalCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardTotalCount) # 加奖励次数 + remainCount -= 1 rewardCount += 1 - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, rewardCount) if rewardTotalCount < maxAppointCount: rewardTotalCount += 1 - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, rewardTotalCount) if rewardTotalCount in countDataDict: rewardIpyData = countDataDict[rewardTotalCount] - #GameWorld.DebugLog(" 取定制次数奖励") + #GameWorld.DebugLog(" 取定制次数奖励: rewardTotalCount=%s" % rewardTotalCount) if not rewardIpyData: rewardIpyData = lvRewardIpyData @@ -768,13 +791,17 @@ if itemID: rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + 1 - GameWorld.DebugLog(" rewardCount=%s,rewardTotalCount=%s, %s" % (rewardCount, rewardTotalCount, rewardItemDict)) - - if rewardCount >= maxRewardCount: - isStop = True - GameWorld.DebugLog(" 放置活跃奖励次数已达上限!rewardCount=%s" % rewardCount) - break - + GameWorld.DebugLog(" remainCount=%s,rewardCount=%s,rewardTotalCount=%s, %s" % (remainCount, rewardCount, rewardTotalCount, rewardItemDict)) + + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, remainCount) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, rewardCount) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, rewardTotalCount) + + if remainCount > 0: + nextStartTime = int(time.time()) - nextStartReduceSeconds + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, nextStartTime) + GameWorld.DebugLog(" 还有剩余次数,更新启动时间: %s, nextStartReduceSeconds=%s" % (nextStartTime, nextStartReduceSeconds)) + # 存储奖励 rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem) for i in xrange(rewardItemCount): @@ -794,28 +821,8 @@ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItem, rewardItemCount) #GameWorld.DebugLog(" 新增探索奖励: itemID=%s,itemCount=%s,rewardItemCount=%s" % (itemID, itemCount, rewardItemCount)) - if isStop: - GameWorld.DebugLog(" 停止探索!") - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 0) - else: - __DoActivityPlaceStart(curPlayer, nextStartReduceSeconds) - + Sync_ActivityPlaceInfo(curPlayer) return - -def __DoActivityPlaceStart(curPlayer, reduceSeconds=0): - - costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # 单次放置消耗的活跃点数 - canUseActivityPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityCanCostTotalPoint) - if canUseActivityPoint < costPoint: - GameWorld.DebugLog("活跃度不足,无法启动放置探索!canUseActivityPoint=%s" % canUseActivityPoint) - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 0) - return - startTime = int(time.time()) - reduceSeconds - GameWorld.DebugLog(" 启动新一轮放置探索!reduceSeconds=%s" % reduceSeconds) - CostActivityPoint(curPlayer, costPoint) - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 1) - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, startTime) - return True def GetActivityPlaceReward(curPlayer): ## 领取活跃放置奖励 @@ -855,8 +862,8 @@ itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i) rewardItemInfo.append([itemID, itemCount]) placeInfo = ChPyNetSendPack.tagMCActivityPlaceInfo() - placeInfo.PlaceState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceState) placeInfo.StartTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime) + placeInfo.PlaceCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount) placeInfo.RewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount) placeInfo.RewardInfo = str(rewardItemInfo) placeInfo.RewardLen = len(placeInfo.RewardInfo) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py index 5c77754..b1a1c7d 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py @@ -57,6 +57,7 @@ import PlayerWing import ChEquip import PlayerYinji +import PlayerActivity #--------------------------------------------------------------------- #--------------------------------------------------------------------- @@ -1274,6 +1275,8 @@ ProcessAreaExp(curPlayer, tick) #神秘商店刷新 FunctionNPCCommon.CheckMysticalShopRefresh(curPlayer, tick) + #活跃放置 + PlayerActivity.ProcessActivityPlace(curPlayer) #跨服数据同步,放最后 CrossPlayerData.ProcessCrossPlayer(curPlayer, tick) return -- Gitblit v1.8.0