From d41a44a9fd316c021c4e85bde9cb0fab4c2e0be1 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期五, 15 三月 2019 17:23:43 +0800 Subject: [PATCH] 2683 子 天赋技能和新增双职业各两个技能 / 【后端】天赋技能 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py | 181 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 167 insertions(+), 14 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 2e88be0..040d5b8 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 @@ -71,6 +71,8 @@ import random import math import time + +g_mysticalShopDict = {} #神秘商店{等级范围:[等级段,{金钱类型:库}]} #--------------------------------------------------------------------- ##开始交易 # @param curPlayer 玩家实例 @@ -200,9 +202,12 @@ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftHasOpen, 1) - SyncMysticalShopInfo(curPlayer) + SyncMysticalLimitShopInfo(curPlayer) SyncShopItemTodayBuyCount(curPlayer) SyncSuperGiftInfo(curPlayer) + if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % 0): + __DoMysticalShopRefresh(curPlayer, True, GameWorld.GetGameWorld().GetTick()) + SyncMysticalShopInfo(curPlayer) return ##商店物品OnDay @@ -213,21 +218,36 @@ UpdataSuperGiftTime(curPlayer, True) OSSaleOpenMail(curPlayer) refreshType = [3] + #神秘商店刷新次数重置 + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, 0) + SyncMysticalShopInfo(curPlayer) + elif onEventType == ShareDefine.Def_OnEventTypeEx: refreshType = [4] openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) - if openServerDay % 3 == 0: - refreshType = [4,7] + isMixServer = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_IsMixServer) + if isMixServer: + mixServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MixServerDay) + if mixServerDay % 3 == 0: + refreshType.append(7) + elif openServerDay % 3 == 0: + refreshType.append(7) else: return - __ResetShopItemBuyCount(curPlayer, refreshType) + ResetShopItemBuyCount(curPlayer, refreshType) return ##商店物品OnWeek # @param curPlayer 玩家实例 # @return def ShopItemOnWeek(curPlayer, onEventType): - __ResetShopItemBuyCount(curPlayer, [onEventType]) + if onEventType == ShareDefine.Def_OnEventType: + refreshType = [1] + elif onEventType == ShareDefine.Def_OnEventTypeEx: + refreshType = [2] + else: + return + ResetShopItemBuyCount(curPlayer, refreshType) return ##商店物品OnMonth @@ -240,24 +260,29 @@ refreshType = 6 else: return - __ResetShopItemBuyCount(curPlayer, [refreshType]) + ResetShopItemBuyCount(curPlayer, [refreshType]) return def ShopItemOnCrossPKSeasonChange(curPlayer): ## 按跨服PK赛季重置 refreshType = 8 - __ResetShopItemBuyCount(curPlayer, [refreshType]) + ResetShopItemBuyCount(curPlayer, [refreshType]) return -def __ResetShopItemBuyCount(curPlayer, onEventTypeList): +def ResetShopItemBuyCount(curPlayer, resetTypeList): + #@param resetTypeList: 需要重置的类型列表 #重置商店物品购买次数 1:周一0点刷新 2:周一5点刷新 3:每日0点刷新 4:每日5点刷新 5每月0点 6每月5点 7每3天5点 8每赛季 + if not resetTypeList: + # 暂定必须指定类型列表,防止终身限购的误被重置 + return + syncIndexList = [] ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetStoreCount()): shopItem = ipyDataMgr.GetStoreByIndex(i) if not shopItem.GetLimitCnt(): continue - if shopItem.GetRefreshType() not in onEventTypeList: + if shopItem.GetRefreshType() not in resetTypeList: continue dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID() curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) @@ -289,7 +314,7 @@ SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True) return -def MysticalShopOpen(curPlayer, befLV, aftLV): +def MysticalLimitShopOpen(curPlayer, befLV, aftLV): ##神秘限购开启 ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('Store', {'ShopType':16}, True) if not ipyDataList: @@ -304,10 +329,10 @@ syncGoodsList.append(goodsID) GameWorld.DebugLog('神秘限购商品%s 开卖'%goodsID, curPlayer.GetID()) if syncGoodsList: - SyncMysticalShopInfo(curPlayer) + SyncMysticalLimitShopInfo(curPlayer) return -def SyncMysticalShopInfo(curPlayer): +def SyncMysticalLimitShopInfo(curPlayer): ##神秘限购通知 packData = ChPyNetSendPack.tagMCMysticalShopTimeInfo() packData.ShopTimeList = [] @@ -329,6 +354,134 @@ if not packData.ShopTimeList: return packData.Count = len(packData.ShopTimeList) + NetPackCommon.SendFakePack(curPlayer, packData) + return + +def CheckMysticalShopRefresh(curPlayer, tick): + ##神秘商店刷新 + createRoleTime = curPlayer.GetCreateRoleTime() + diffTime = GameWorld.GetCurrentTime() - GameWorld.GetDateTimeByStr(createRoleTime, ChConfig.TYPE_Time_Format) + pastSeconds = diffTime.days*24*60*60 + diffTime.seconds + refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4) + if pastSeconds % refreshTime == 0: + __DoMysticalShopRefresh(curPlayer, True, tick) + return + +#// A2 32 神秘商店刷新 #tagCMRefreshMysticalShop +#struct tagCMRefreshMysticalShop +#{ +# tagHead Head; +#}; +def OnMysticalShopRefresh(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + __DoMysticalShopRefresh(curPlayer, False, tick) + return + +def __DoMysticalShopRefresh(curPlayer, isFree, tick): + global g_mysticalShopDict #{等级范围:[等级段,{金钱类型:库}]} + + lastTime = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MysticalShopLastTime) + if lastTime and tick - lastTime < 1000: + #GameWorld.DebugLog('神秘商店刷新,过于频繁!') + return + curPlayer.SetDict(ChConfig.Def_PlayerKey_MysticalShopLastTime, tick) + if not g_mysticalShopDict: + ipyMgr= IpyGameDataPY.IPY_Data() + for i in xrange(ipyMgr.GetMysteryShopCount()): + ipyData = ipyMgr.GetMysteryShopByIndex(i) + lvRange = ipyData.GetLVRange() + goodsID = ipyData.GetGoodsID() + goodsIpyData = IpyGameDataPY.GetIpyGameData('Store', goodsID) + moneyType = goodsIpyData.GetMoneyType() + weight = goodsIpyData.GetLimitValue() + lvkey = tuple(lvRange) + if lvkey not in g_mysticalShopDict: + g_mysticalShopDict[lvkey] = [lvkey[0], {}] + weightDict = {} + if moneyType not in g_mysticalShopDict[lvkey][1]: + g_mysticalShopDict[lvkey][1][moneyType] = [] + weightDict[moneyType] = weightDict.get(moneyType, 0) + weight + g_mysticalShopDict[lvkey][1][moneyType].append([weightDict[moneyType], goodsID]) + + playerLV = curPlayer.GetLV() + curLVDan, shopDict = GameWorld.GetDictValueByRangeKey(g_mysticalShopDict, playerLV) + if not shopDict: + return + maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1) + goldGoodsCnt =GameWorld.GetResultByRandomList(IpyGameDataPY.GetFuncEvalCfg('MysteryShopGoods', 2)) + if not goldGoodsCnt: + return + specialGoodsID = 0 #必出的商品ID + if not isFree: + #优先道具,再仙玉 + itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) + costItemID = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 1) + costItemCntDict = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 2) + curRefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt) + cntList = [int(cnt) for cnt in costItemCntDict.keys()] + cntList.sort() + costItemCnt = costItemCntDict[str(cntList[-1])] + for cnt in cntList: + if curRefreshCnt < cnt: + costItemCnt = costItemCntDict[str(cnt)] + break + enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(costItemID, itemPack, costItemCnt) + costGold = 0 + if not enough: + costGold = lackCnt * IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 3) + if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_MysteryShopRefresh): + return + ItemCommon.ReduceItem(curPlayer, itemPack, indexList, costItemCnt, False, "MysteryShopRefresh") + curLVRefreshData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopLVRefreshCnt) + curLVRefreshCnt, lvDan = curLVRefreshData / 10000, curLVRefreshData % 10000 + updLVRefreshCnt = 1 if curLVDan != lvDan else curLVRefreshCnt + 1 #等级段变更,重置该等级段的刷新次数 + updLVRefreshData = min(updLVRefreshCnt * 10000+curLVDan, ChConfig.Def_UpperLimit_DWord) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopLVRefreshCnt, updLVRefreshData) + specialRefreshCfg = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 5) + if curLVDan in specialRefreshCfg and updLVRefreshCnt == specialRefreshCfg[curLVDan][0]: + specialGoodsID = specialRefreshCfg[curLVDan][1] + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, curRefreshCnt+1) + + goldGoodsCnt = min(goldGoodsCnt, maxCnt) + sliverGoodsCnt = maxCnt - goldGoodsCnt + goodsResultList = [] + if goldGoodsCnt: + goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Gold_Money, []), goldGoodsCnt, []) + if sliverGoodsCnt: + goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Silver_Money, []), sliverGoodsCnt, []) + if specialGoodsID and specialGoodsID not in goodsResultList: + goodsResultList[0] = specialGoodsID + GameWorld.DebugLog('神秘商店刷新特殊规则,等级段:%s,updLVRefreshCnt=%s,specialGoodsID=%s'%(curLVDan, updLVRefreshCnt, specialGoodsID)) + + GameWorld.DebugLog('神秘商店刷新isFree=%s,goldGoodsCnt=%s,sliverGoodsCnt=%s,goodsResultList=%s'%(isFree, goldGoodsCnt, sliverGoodsCnt, goodsResultList)) + syncIndexList = [] + for i in xrange(maxCnt): + goodsID = goodsResultList[i] if i < len(goodsResultList) else 0 + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopGoods % i, goodsID) + + dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % goodsID + curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey) + if curDayBuyCnt: + PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0) + syncIndexList.append(goodsID) + if syncIndexList: + SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True) + #通知 + SyncMysticalShopInfo(curPlayer) + return + +def SyncMysticalShopInfo(curPlayer): + ##神秘商店通知 + packData = ChPyNetSendPack.tagMCMysticalShopInfo() + packData.RefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt) + packData.GoodsList = [] + maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1) + for i in xrange(maxCnt): + goodsID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % i) + goodsInfo = ChPyNetSendPack.tagMCMysticalShopGoods() + goodsInfo.GoodsID = goodsID + packData.GoodsList.append(goodsInfo) + packData.Count = len(packData.GoodsList) NetPackCommon.SendFakePack(curPlayer, packData) return @@ -408,7 +561,7 @@ if not state: GameWorld.DebugLog("限时特惠非活动中!state=%s" % (state), curPlayer.GetPlayerID()) return - shopTypeList = PlayerSpringSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0)) + shopTypeList = PlayerSpringSale.GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), actInfo.get(ShareDefine.ActKey_WorldLV, 0)) if not shopTypeList: return actShopType = shopTypeList[-1] if state > len(shopTypeList) else shopTypeList[state - 1] @@ -579,7 +732,7 @@ itemControl = ItemControler.PlayerItemControler(curPlayer) for itemID, itemCount, isBind in totalItemList: - curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, isBind) + curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, False) if not curItemObj: continue userData = curItemObj.GetUserData() -- Gitblit v1.8.0