| | |
| | | import IpyGameDataPY
|
| | | import IPY_GameWorld
|
| | | import ChPyNetSendPack
|
| | | import PlayerFeastRedPacket
|
| | | import NetPackCommon
|
| | | import PlayerVip
|
| | | import ShareDefine
|
| | |
|
| | | import time
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | Def_GoldPacket = 0 #主动发钻石红包
|
| | |
|
| | |
|
| | | (
|
| | | State_NoSend, #未发
|
| | |
| | | return
|
| | |
|
| | |
|
| | | def CreatRedPacketByID(curPlayer, redPacketID, state=State_NoSend, data=0):
|
| | | #根据红包ID生成红包
|
| | | def CreatRedPacketByID(curPlayer, redPacketID, state=State_NoSend, data=0, wishInfo=""):
|
| | | '''根据红包ID生成红包 - 外部功能调用接口
|
| | | '''
|
| | | ipyData = IpyGameDataPY.GetIpyGameData('FamilyRedPack', redPacketID)
|
| | | if not ipyData:
|
| | | return
|
| | | getType = ipyData.GetGetType()
|
| | | if getType == IpyGameDataPY.GetFuncCfg('OpenServerRedPacketType'):
|
| | | 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
|
| | |
|
| | | DoCreatFamilyRedPacket(curPlayer, getType, ipyData.GetMoneyType(), ipyData.GetMoneyNum(), ipyData.GetPacketCnt(), state, '', data)
|
| | | __DoCreatRedPacket(curPlayer, getType, ipyData.GetMoneyType(), ipyData.GetMoneyNum(), ipyData.GetPacketCnt(), state, wishInfo, data, isFamilyRedPacket)
|
| | | return
|
| | |
|
| | | ## 生成红包
|
| | | def DoCreatFamilyRedPacket(curPlayer, getType, moneyType=2, awardNum=100, packetCnt=10, state=State_NoSend, wishInfo='', data=0):
|
| | |
|
| | | |
| | | |
| | | ## 生成红包,注意外部不可直接调用该函数
|
| | | 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:
|
| | |
| | | # 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
|
| | |
|
| | |
|
| | |
| | | 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
|
| | |
| | | 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
|
| | |
|
| | |
|