From bcdc9a6cf4da4c82e458b3c4232391a7a0ff9f90 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期四, 11 十月 2018 11:56:51 +0800
Subject: [PATCH] 4142 【后端】仙魔之争增加一个超级机器人

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py |  100 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 94 insertions(+), 6 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 35ba93f..b3684b9 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
@@ -58,12 +58,13 @@
 import ItemCommon
 import ShareDefine
 import DataRecordPack
-import EventSrc
+#import EventSrc
 import ChItem
 import IpyGameDataPY
 import PlayerRune
-import PlayerSuccess
+import GameFuncComm
 import PlayerFairyCeremony
+import PlayerSpringSale
 import PyGameData
 
 import random
@@ -191,6 +192,7 @@
 ## 登录
 def ShopItemOnLogin(curPlayer):
     SyncShopItemTodayBuyCount(curPlayer)
+    SyncSuperGiftInfo(curPlayer)
     return
 
 ##商店物品OnDay
@@ -198,6 +200,9 @@
 # @return 
 def ShopItemOnDay(curPlayer, onEventType):
     if onEventType == ShareDefine.Def_OnEventType:
+        UpdataSuperGiftTime(curPlayer, True)
+        SyncSuperGiftInfo(curPlayer)
+        OSSaleOpenMail(curPlayer)
         refreshType = [3]
     elif onEventType == ShareDefine.Def_OnEventTypeEx:
         refreshType = [4]
@@ -342,7 +347,7 @@
         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]
@@ -484,6 +489,8 @@
     SyncShoppingResult(curPlayer, itemIndex, clientBuyCount)
     if itemIndex in IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 1, {}).values():
         PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Fireworks, clientBuyCount)
+    if itemIndex in dict(IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')):
+        UpdataSuperGiftTime(curPlayer)
     return
 
 def __GetShopJobItem(job, itemID, jobItemList):
@@ -521,12 +528,16 @@
         if curFamilyLV <= 0:
             curFamilyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyLV)
         return curFamilyLV < limitValue
-    if shopNPCID in [15]: # 限时特惠商店
-        playerCreateRoleDays = GameWorld.GetCreateRoleDays(curPlayer)
-        return playerCreateRoleDays != limitValue
+    if shopNPCID in [15]: # 开服特惠商店
+        #playerCreateRoleDays = GameWorld.GetCreateRoleDays(curPlayer)
+        openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
+        return openServerDay != limitValue
     #烟花狂欢
     if itemIndex in IpyGameDataPY.GetFuncEvalCfg('CeremonyFireParty', 1, {}).values():
         return not PlayerFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex)
+    
+    if itemIndex in dict(IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')):
+        return not CheckSuperGiftBuy(curPlayer, itemIndex)
 #    
 #    limitPlusDict = {shopItem.GetLimitPlusType1():shopItem.GetLimitPlusValue1(),
 #                     shopItem.GetLimitPlusType2():shopItem.GetLimitPlusValue2(),
@@ -553,6 +564,83 @@
     # 默认不限制
     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):
+    superGiftData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftData)
+    giftIndex, startDay = superGiftData%10, superGiftData/10
+    superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')
+    if giftIndex >= len(superGiftTimeList):
+        return
+    if isOnday and not giftIndex:
+        return
+    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
+    newIndex = giftIndex
+    if isOnday:
+        lastDays = 0
+        pastDay = openServerDay - startDay
+        for i in xrange(giftIndex-1, len(superGiftTimeList)):
+            lastDays += superGiftTimeList[i][1]
+            if pastDay < lastDays:
+                break
+            if pastDay >= lastDays:
+                newIndex = i+2
+        
+    else:
+        newIndex = min(len(superGiftTimeList), giftIndex+1)
+        
+    if newIndex == giftIndex:
+        return
+    
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftData, openServerDay*10+newIndex)
+    #通知
+    if not isOnday:
+        SyncSuperGiftInfo(curPlayer)
+    if newIndex == 1:
+        addItemList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList', 2)
+        PlayerControl.SendMailByKey('SellMail2', [curPlayer.GetID()], addItemList)
+    return True
+
+def SyncSuperGiftInfo(curPlayer):
+    superGiftData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftData)
+    giftIndex, startDay = superGiftData%10, superGiftData/10
+    superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')
+    if giftIndex == 0 or giftIndex > len(superGiftTimeList):
+        return
+    giftID, day = superGiftTimeList[giftIndex-1]
+    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
+    remainDay = max(0, day - openServerDay+startDay)-1
+    
+    packData = ChPyNetSendPack.tagMCSuperGiftInfo()
+    packData.GiftID = giftID
+    packData.EndtDate = str(GameWorld.GetDatetimeByDiffDays(remainDay))[:10]
+    NetPackCommon.SendFakePack(curPlayer, packData)
+    return
+def CheckSuperGiftBuy(curPlayer, giftID):
+    #超值礼包是否可购买
+    superGiftData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftData)
+    giftIndex, startDay = superGiftData%10, superGiftData/10
+    superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')
+    if giftIndex == 0 or giftIndex > len(superGiftTimeList):
+        return
+    curGiftID, day = superGiftTimeList[giftIndex-1]
+    if giftID != curGiftID:
+        return
+    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
+    if not max(0, day - openServerDay+startDay):
+        return
+    return True
+
 ## 商店npcid
 #  @param curPlayer 玩家实例
 #  @return 

--
Gitblit v1.8.0