From 866ce280c4c931a34cedd06d86b81019018d4160 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期五, 03 一月 2020 20:33:56 +0800 Subject: [PATCH] 8364 【恺英】【后端】缥缈随机任务(S副本未处理) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyRedPacket.py | 114 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 81 insertions(+), 33 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyRedPacket.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyRedPacket.py index 368ac60..db0a347 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyRedPacket.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamilyRedPacket.py @@ -19,15 +19,13 @@ import IpyGameDataPY import IPY_GameWorld import ChPyNetSendPack +import PlayerFeastRedPacket import NetPackCommon import PlayerVip import ShareDefine import time #--------------------------------------------------------------------- - -Def_GoldPacket = 0 #主动发钻石红包 - ( State_NoSend, #未发 @@ -46,42 +44,84 @@ ## OnDay处理 # @param curPlayer # @return None -def RedPacketOnDay(curPlayer): - #发钻石红包额度重置 - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyRedPacketGoldLimit, 0) - __NotifyGoldLimt(curPlayer) +def RedPacketOnDay(curPlayer, onEventType): + if onEventType == ShareDefine.Def_OnEventType: + #发钻石红包额度重置 + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyRedPacketGoldLimit, 0) + __NotifyGoldLimt(curPlayer) + elif onEventType == ShareDefine.Def_OnEventTypeEx: + oscDay = IpyGameDataPY.GetFuncCfg('OpenServerRedPacketCfg') + openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + if openServerDay < oscDay: + grabCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OSRedPacketCanGrabCnt, 0) + sendCnt = IpyGameDataPY.GetFuncCfg('OpenServerRedPacketCfg', 5) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OSRedPacketCanGrabCnt, grabCnt+sendCnt) + NotifyOSRedPacket(curPlayer) return -def CreatRedPacketByID(curPlayer, redPacketID, state=State_NoSend, data=0): - #根据红包ID生成红包 +def CreatCacheRedPacktet(curPlayer): + #加入仙盟后,发放待发的红包 + ipyMgr = IpyGameDataPY.IPY_Data() + for i in xrange(ipyMgr.GetFamilyRedPackCount()): + ipyData = ipyMgr.GetFamilyRedPackByIndex(i) + redPacketID = ipyData.GetID() + if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FamilyRedPacketCache, redPacketID): + CreatRedPacketByID(curPlayer, redPacketID) + GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FamilyRedPacketCache, redPacketID, 0) + return + + +def CreatRedPacketByID(curPlayer, redPacketID, state=State_NoSend, data=0, wishInfo=""): + '''根据红包ID生成红包 - 外部功能调用接口 + ''' ipyData = IpyGameDataPY.GetIpyGameData('FamilyRedPack', redPacketID) if not ipyData: return - DoCreatFamilyRedPacket(curPlayer, ipyData.GetGetType(), ipyData.GetMoneyType(), ipyData.GetMoneyNum(), ipyData.GetPacketCnt(), state, '', data) - return - -## 生成红包 -def DoCreatFamilyRedPacket(curPlayer, getType, moneyType=2, awardNum=100, packetCnt=10, state=State_NoSend, wishInfo='', data=0): -# if not curPlayer.GetFamilyID(): -# #没家族 -# return - - if getType == IpyGameDataPY.GetFuncCfg('OpenServerRedPacketType'): + getType = ipyData.GetGetType() + if not getType: + return + if getType == ShareDefine.RedPackType_OpenServer: oscDay = IpyGameDataPY.GetFuncCfg('OpenServerRedPacketCfg') openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) if openServerDay >= oscDay: GameWorld.DebugLog(' 发开服红包,活动已过,不可发送!') return + isFamilyRedPacket = False + elif getType == ShareDefine.RedPackType_FeastSucc: + if not PlayerFeastRedPacket.GetFeastRedPacketState(): + GameWorld.DebugLog(' 非节日红包活动中,不可发送!') + return + isFamilyRedPacket = False + else: + if not curPlayer.GetFamilyID(): + #没家族 先存起来,等进仙盟时再补发 + GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FamilyRedPacketCache, redPacketID, 1) + return + isFamilyRedPacket = True + + __DoCreatRedPacket(curPlayer, getType, ipyData.GetMoneyType(), ipyData.GetMoneyNum(), ipyData.GetPacketCnt(), state, wishInfo, data, isFamilyRedPacket) + return + +## 生成红包,注意外部不可直接调用该函数 +def __DoCreatRedPacket(curPlayer, getType, moneyType=2, awardNum=100, packetCnt=10, state=State_NoSend, wishInfo='', data=0, isFamilyRedPacket=True): playerID = curPlayer.GetPlayerID() packetCnt = min(packetCnt, awardNum) - if getType == Def_GoldPacket: + if isFamilyRedPacket and not curPlayer.GetFamilyID(): + GameWorld.DebugLog("玩家无仙盟,无法发放归属仙盟的红包!getType=%s" % (getType), playerID) + return + + if getType == ShareDefine.RedPackType_GoldPacket: goldLimit = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyRedPacketGoldLimit, 0) familyRedPacketGoldLimit = IpyGameDataPY.GetFuncCfg('FamilyRedPacketGoldLimit') if awardNum + goldLimit > familyRedPacketGoldLimit: GameWorld.DebugLog(' 主动发仙盟钻石红包,额度已超%s,不可发送!' % familyRedPacketGoldLimit, playerID) return - + if not PlayerControl.HaveMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney, awardNum): + curBourseMoney = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney) + GameWorld.Log(" 不能发钻石红包 no enough bourse money! priceCount=%s,curBourseMoney=%s" + % (awardNum, curBourseMoney), playerID) + return if not PlayerControl.PayMoney(curPlayer, moneyType, awardNum, ChConfig.Def_Cost_FamilyRedPacket): return @@ -95,9 +135,9 @@ # return #通知Gameserver生成红包 - msg = str([playerID, getType, packetCnt, moneyType, awardNum, wishInfo, state, data]) - GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "CreatFamilyRedPacket", msg, len(msg)) - GameWorld.DebugLog(' DoCreatFamilyRedPacket 通知Gameserver生成红包 msg=%s' % msg) + msg = str([playerID, getType, packetCnt, moneyType, awardNum, wishInfo, state, data, isFamilyRedPacket]) + GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "MapServer_CreatRedPacket", msg, len(msg)) + GameWorld.DebugLog(' 通知Gameserver生成红包 msg=%s' % msg) return @@ -124,8 +164,9 @@ if not PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_FamilyGoldPack): GameWorld.DebugLog("主动发的钻石红包 VIP权限不足") return - DoCreatFamilyRedPacket(curPlayer, Def_GoldPacket, IPY_GameWorld.TYPE_Price_Gold_Money, moneyNum, packetCnt, State_NoGot, wishInfo) + __DoCreatRedPacket(curPlayer, ShareDefine.RedPackType_GoldPacket, IPY_GameWorld.TYPE_Price_Gold_Money, moneyNum, packetCnt, State_NoGot, wishInfo) else: + # 注意:该函数发放的是已创建的红包,该操作只是把该红包开放给玩家可抢 msg = str([curPlayer.GetPlayerID(), redPacketID, packetCnt]) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "SendFamilyRedPacket", msg, len(msg)) return @@ -156,21 +197,27 @@ return -#// A4 04 抢家族红包 #tagCGGrabFamilyRedPacket +#// AB 12 抢红包 #tagCMGrabFamilyRedPacket # -#struct tagCGGrabFamilyRedPacket +#struct tagCMGrabFamilyRedPacket #{ # tagHead Head; # DWORD RedPaketID; // 红包ID +# BYTE GetWay; //获得途径 #}; -## 抢红包 def OnGrabFamilyRedPacket(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) redPacketID = clientData.RedPaketID - OSCanGrabCnt = GetOSCanGrabCnt(curPlayer) - msg = str([redPacketID, OSCanGrabCnt]) + reqGetWay = clientData.GetWay + if reqGetWay == ShareDefine.RedPackType_OpenServer: + canGrabCnt = GetOSCanGrabCnt(curPlayer) + elif reqGetWay == ShareDefine.RedPackType_FeastSucc: + canGrabCnt = PlayerFeastRedPacket.GetFeastSuccRedPacketCanGrabCnt(curPlayer) + else: + canGrabCnt = -1 + msg = str([redPacketID, reqGetWay, canGrabCnt]) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "GrabFamilyRedPacket", msg, len(msg)) - GameWorld.DebugLog(' 抢红包 OSCanGrabCnt=%s'%OSCanGrabCnt) + GameWorld.DebugLog(' 抢红包 getWay=%s,canGrabCnt=%s' % (reqGetWay, canGrabCnt)) return @@ -209,8 +256,8 @@ if not isSelf: #抢自己的红包不扣次数 grabCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OSRedPacketCanGrabCnt, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OSRedPacketCanGrabCnt, max(0, grabCnt-1)) - if grabCnt == IpyGameDataPY.GetFuncCfg('OpenServerRedPacketCfg', 4): - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OSRedPacketStartTime, int(time.time())) +# if grabCnt == IpyGameDataPY.GetFuncCfg('OpenServerRedPacketCfg', 4): +# PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OSRedPacketStartTime, int(time.time())) #通知 @@ -218,6 +265,7 @@ return def ProcessOSRedPacket(curPlayer, tick): + return #开服红包恢复次数 if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_OSRedPacket, tick): return -- Gitblit v1.8.0