From 43a9e6c87a5a4980902e86eb0470d885b1a3fb8f Mon Sep 17 00:00:00 2001 From: xdh <xiefantasy@qq.com> Date: 星期一, 22 十月 2018 21:23:02 +0800 Subject: [PATCH] 4282 【主干】【1.1.0】【后端】新增物品效果:获得X法宝X经验 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py | 108 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 86 insertions(+), 22 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py index d4802cb..421db9c 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py @@ -57,13 +57,14 @@ import PlayerControl import ItemCommon import ShareDefine -import DataRecordPack +import PlayerFlashSale #import EventSrc import ChItem import IpyGameDataPY import PlayerRune -import PlayerSuccess +import GameFuncComm import PlayerFairyCeremony +import PlayerSpringSale import PyGameData import random @@ -201,6 +202,7 @@ if onEventType == ShareDefine.Def_OnEventType: UpdataSuperGiftTime(curPlayer, True) SyncSuperGiftInfo(curPlayer) + OSSaleOpenMail(curPlayer) refreshType = [3] elif onEventType == ShareDefine.Def_OnEventTypeEx: refreshType = [4] @@ -338,19 +340,33 @@ if not ipyData: return shopType = ipyData.GetShopType() - - if ipyData.GetOperationActionShop(): + operationActionShopType = ipyData.GetOperationActionShop() + if operationActionShopType == 1: actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_SpringSale, {}) state = actInfo.get(ShareDefine.ActKey_State, 0) if not state: GameWorld.DebugLog("限时特惠非活动中!state=%s" % (state), curPlayer.GetPlayerID()) return - shopTypeList = actInfo.get(ShareDefine.ActKey_ShopTypeList, []) + shopTypeList = PlayerSpringSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0)) if not shopTypeList: return actShopType = shopTypeList[-1] if state > len(shopTypeList) else shopTypeList[state - 1] if shopType != actShopType: GameWorld.DebugLog("限时特惠非活动中的商店类型!state=%s,shopType=%s,actShopType=%s,shopTypeList=%s" + % (state, shopType, actShopType, shopTypeList), curPlayer.GetPlayerID()) + return + elif operationActionShopType == 2: + actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {}) + state = actInfo.get(ShareDefine.ActKey_State, 0) + if not state: + GameWorld.DebugLog("限时抢购非活动中!state=%s" % (state), curPlayer.GetPlayerID()) + return + shopTypeList = PlayerFlashSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), state) + if not shopTypeList: + return + actShopType = shopTypeList[0] + if shopType != actShopType: + GameWorld.DebugLog("限时抢购非活动中的商店类型!state=%s,shopType=%s,actShopType=%s,shopTypeList=%s" % (state, shopType, actShopType, shopTypeList), curPlayer.GetPlayerID()) return @@ -379,7 +395,7 @@ if limitBuyCnt == -1: GameWorld.DebugLog(" vip%s才能购买"%viplv) return - + curDayBuyCnt = 0 dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex if limitBuyCnt > 0: @@ -392,7 +408,10 @@ GameWorld.DebugLog("BuyShopItem 修正购买次数!shopType=%s,itemIndex=%s,clientBuyCount=%s,canBuyCnt=%s" % (shopType, itemIndex, clientBuyCount, canBuyCnt)) clientBuyCount = canBuyCnt - + serverLimitCnt = ipyData.GetServerLimitCnt() + if serverLimitCnt > 0: + clientBuyCount = min(serverLimitCnt, clientBuyCount) + itemID, itemCount, isBind = ipyData.GetItemID(), ipyData.GetItemCnt(), ipyData.GetIsBind() itemListEx = ipyData.GetItemListEx() priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum() @@ -421,8 +440,8 @@ if not curItem: GameWorld.ErrLog("Store shop item error! shopType=%s,itemID=%s" % (shopType, itemID)) return - packType = ShareDefine.rptRune if curItem.GetType() == ChConfig.Def_ItemType_Rune else IPY_GameWorld.rptItem - needSpace = int(math.ceil(float(itemCnt) / curItem.GetPackCount())) + packType = ChConfig.GetItemPackType(curItem.GetType()) + needSpace = ItemControler.GetItemNeedPackCount(packType, curItem, itemCnt) needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace if i == 0: @@ -433,30 +452,62 @@ GameWorld.DebugLog("购买物品: shopType=%s,itemIndex=%s,clientBuyCount=%s,totalItemList=%s,mainItemID=%s,needPackSpaceDict=%s" % (shopType, itemIndex, clientBuyCount, totalItemList, mainItemID, needPackSpaceDict), curPlayer.GetPlayerID()) - + mailKey = ipyData.GetMailKey() + isLackPack = False #是否背包不足 for packType, needSpace in needPackSpaceDict.items(): if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace): - curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace) - PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType]) - return + isLackPack = True + if mailKey: + break + else: + curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace) + PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType]) + return + sendMailKey = mailKey if isLackPack and mailKey else '' #背包不足且配置了mailKey的才发邮件 # 购买限制条件扩展 if CheckBuyItemLimitEx(curPlayer, shopType, itemIndex, mainItemID, ipyData.GetLimitValue()): GameWorld.Log("Store shop item buy limit! shopType=%s,itemIndex=%s,limitValue=%s" % (shopType, itemIndex, ipyData.GetLimitValue()), curPlayer.GetPlayerID()) return + if not PlayerControl.HaveMoney(curPlayer, priceType, itemPrice): + curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoMoney) + return + if serverLimitCnt > 0: #全服限购判断放到最后面,GameServer直接加次数 + if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StoreQueryState) == 1: + #已经在查询中, 不重复查询 + GameWorld.DebugLog("全服购买次数已经在查询中, 不重复查询 itemIndex=%s" % itemIndex) + return + cmdStr = '%s' % ([itemIndex, serverLimitCnt, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey]) + GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, + "GetStoreServerBuyCnt", cmdStr, len(cmdStr)) + #设置状态查询中 + curPlayer.SetDict(ChConfig.Def_PlayerKey_StoreQueryState, 1) + return #-------------------------开始购买物品----------------------------- + DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData) + + return + +def DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData=None): + if not ipyData: + ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex) + priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum() + itemPrice *= clientBuyCount + shopType = ipyData.GetShopType() + beforeMoney = PlayerControl.GetMoney(curPlayer, priceType) infoDict = {"TotalItemList":totalItemList, "ClientBuyCount":clientBuyCount, "ShopType":shopType, "ShopItemIndex":itemIndex, ChConfig.Def_Cost_Reason_SonKey:mainItemID} - if not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount): - curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoMoney) - return + PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount) + afterMoney = PlayerControl.GetMoney(curPlayer, priceType) # 今日购买次数+1 if limitBuyCnt > 0: + dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex + curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, curDayBuyCnt + clientBuyCount) SyncShopItemTodayBuyCount(curPlayer, [itemIndex]) @@ -464,23 +515,26 @@ "ItemPrice":itemPrice, "MoneyType":priceType, "BeforeMoney":beforeMoney, "AfterMoney":afterMoney} isForceEvent = priceType not in [IPY_GameWorld.TYPE_Price_Silver_Money] - + itemControl = ItemControler.PlayerItemControler(curPlayer) for itemID, itemCount, isBind in totalItemList: curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, isBind) if not curItemObj: continue userData = curItemObj.GetUserData() - packType = ShareDefine.rptRune if curItemObj.GetType() == ChConfig.Def_ItemType_Rune else IPY_GameWorld.rptItem - if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]): + if not sendMailKey: + packType = ChConfig.GetItemPackType(curItemObj.GetType()) + if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]): + curItemObj.Clear() + continue + else: curItemObj.Clear() - continue - EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount) if ipyData.GetNotifyMark() and itemID == mainItemID: PlayerControl.WorldNotify(0, ipyData.GetNotifyMark(), [curPlayer.GetName(), mainItemID, userData]) - + if sendMailKey: + PlayerControl.SendMailByKey(sendMailKey, [curPlayer.GetID()], totalItemList, detail=dataDict) #触发任务购买物品 EventShell.EventRespons_ShopBuy(curPlayer, shopType) #curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrShopOK) @@ -562,6 +616,16 @@ # 默认不限制 return False +def OSSaleOpenMail(curPlayer): + #开服特惠开启邮件 + if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_OSSail): + return + openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1 + if openServerDay not in IpyGameDataPY.GetFuncEvalCfg('OSSaleOpenMail'): + return + addItemList = IpyGameDataPY.GetFuncEvalCfg('OSSaleOpenMail', 2) + PlayerControl.SendMailByKey('SellMail1', [curPlayer.GetID()], addItemList) + return #超值礼包购买时间 def UpdataSuperGiftTime(curPlayer, isOnday=False): -- Gitblit v1.8.0