xdh
2018-11-23 c28653c492d97956946b6017e7439e6736425524
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFlashGiftbag.py
@@ -29,14 +29,18 @@
import ChConfig
def GetGiftbagTypeList(cfgID, dayIndex):
    if cfgID == None or dayIndex == None:
        return []
    ipyData = IpyGameDataPY.GetIpyGameData("ActFlashGiftbag", cfgID)
    if not ipyData:
        return []
    giftbagTypeList = ipyData.GetGiftbagTypeList()
    todayGiftbag = giftbagTypeList[-1] if dayIndex >= len(giftbagTypeList) else giftbagTypeList[dayIndex]
    return todayGiftbag
def OnPlayerLogin(curPlayer):
    isReset = __CheckPlayerFlashGiftbagAction(curPlayer)
    if not isReset:
        actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashGiftbag, {})
        # 活动中同步活动信息
        if actInfo.get(ShareDefine.ActKey_State):
            SyncFlashGiftbagBuyCount(curPlayer, giftbagTypeList=actInfo.get(ShareDefine.ActKey_GiftbagTypeList, []))
            Sync_FlashGiftbagActionInfo(curPlayer)
    __CheckPlayerFlashGiftbagAction(curPlayer)
    return
def RefreshFlashGiftbagActionInfo():
@@ -57,26 +61,36 @@
    actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashGiftbag, {})
    actID = actInfo.get(ShareDefine.ActKey_ID, 0)
    state = actInfo.get(ShareDefine.ActKey_State, 0)
    giftbagTypeList = actInfo.get(ShareDefine.ActKey_GiftbagTypeList, [])
    #if not state or not giftbagTypeList:
    #    return
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
    
    playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashGiftbagID) # 玩家身上的活动ID
    # 活动ID 相同的话不处理
    if actID == playerActID:
    giftbagTypeList = [] if not cfgID else GetGiftbagTypeList(cfgID, actInfo.get(ShareDefine.ActKey_DayIndex, 0))
    isReset = False
    if actID != playerActID:
        isReset = True
        __ResetGiftbagItemBuyCount(curPlayer, giftbagTypeList)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashGiftbagID, actID)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashGiftbagMailState, 0)
        GameWorld.DebugLog("限时礼包重置! actID=%s,playerActID=%s,state=%s,giftbagTypeList=%s" % (actID, playerActID, state, giftbagTypeList), playerID)
        Sync_FlashGiftbagActionInfo(curPlayer)
    else:
        GameWorld.DebugLog("限时礼包活动ID不变,不处理!", curPlayer.GetPlayerID())
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashGiftbagID, actID)
    ResetGiftbagItemBuyCount(curPlayer, giftbagTypeList)
    GameWorld.DebugLog("限时礼包重置! actID=%s,playerActID=%s,state=%s,giftbagTypeList=%s" % (actID, playerActID, state, giftbagTypeList), playerID)
    Sync_FlashGiftbagActionInfo(curPlayer)
    return True
    playerMailState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashGiftbagMailState) # 玩家身上的活动提醒邮件状态
    if actID and state and state != playerMailState:
        flashGiftbagIpyData = IpyGameDataPY.GetIpyGameData("ActFlashGiftbag", cfgID)
        if flashGiftbagIpyData and flashGiftbagIpyData.GetMailKey() and curPlayer.GetLV() >= flashGiftbagIpyData.GetLVLimit():
            PlayerControl.SendMailByKey(flashGiftbagIpyData.GetMailKey(), [playerID], flashGiftbagIpyData.GetMailItemPrize())
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashGiftbagMailState, state)
            GameWorld.DebugLog("    发送新限时礼包邮件提醒! state=%s,playerMailState=%s" % (state, playerMailState), playerID)
    if not isReset and cfgID:
        if giftbagTypeList:
            SyncFlashGiftbagBuyCount(curPlayer, giftbagTypeList=giftbagTypeList)
        Sync_FlashGiftbagActionInfo(curPlayer)
    return isReset
def ResetGiftbagItemBuyCount(curPlayer, giftbagTypeList):
def __ResetGiftbagItemBuyCount(curPlayer, giftbagTypeList):
    ##重置限时礼包限购物品次数
    syncIDList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
@@ -108,7 +122,7 @@
        DataRecordPack.DR_CTGError(curPlayer, "FlashGiftbag state is 0!", addDRDict)
        return
    
    giftbagTypeList = actInfo.get(ShareDefine.ActKey_GiftbagTypeList, [])
    giftbagTypeList = GetGiftbagTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0))
    if not giftbagTypeList:
        DataRecordPack.DR_CTGError(curPlayer, "FlashGiftbag GiftbagTypeList is null!", addDRDict)
        return
@@ -149,10 +163,12 @@
            for itemID, itemCount, isBind in giftItemList:
                ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], 
                                             event=[ChConfig.ItemGive_CTG, True, addDRDict])
    # 取玩家APPID,混服使用
    appID = GameWorld.GetPlayerPlatform(curPlayer)
    notifyKey = giftbagIpyData.GetNotifyKey()
    if notifyKey:
        orderIpyData = GetFlashGiftbagIDOrderInfoIpyData(giftbagID)
        orderIpyData = GetFlashGiftbagIDOrderInfoIpyData(giftbagID, appID)
        rmb = 0 if not orderIpyData else int(orderIpyData.GetPayRMBNum())
        PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), rmb, giftbagIpyData.GetMainItemID()])
        
@@ -196,13 +212,16 @@
    if not actInfo:
        return
    
    if not actInfo.get(ShareDefine.ActKey_State):
        return
    #需要提前通知,所以去掉此限制
    #if not actInfo.get(ShareDefine.ActKey_State):
    #    return
    
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
    giftbagTypeList = actInfo.get(ShareDefine.ActKey_GiftbagTypeList, 0)
    if not cfgID:
        return
    giftbagTypeList = GetGiftbagTypeList(cfgID, actInfo.get(ShareDefine.ActKey_DayIndex, 0))
    
    if not cfgID or not giftbagTypeList:
    if not giftbagTypeList:
        return
    
    flashGiftbagIpyData = IpyGameDataPY.GetIpyGameData("ActFlashGiftbag", cfgID)
@@ -215,9 +234,14 @@
        GameWorld.ErrLog("限时礼包开关时间时分配置错误!cfgID=%s" % cfgID)
        return
    
    # 取玩家APPID,混服使用
    appID = GameWorld.GetPlayerPlatform(curPlayer)
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
    packInfo = ChPyNetSendPack.tagMCFlashGiftbagInfo()
    packInfo.StartDate = flashGiftbagIpyData.GetStartDate()
    packInfo.EndtDate = flashGiftbagIpyData.GetEndDate()
    packInfo.StartDate = GameWorld.GetOperationActionDateStr(flashGiftbagIpyData.GetStartDate(), openServerDay)
    packInfo.EndtDate = GameWorld.GetOperationActionDateStr(flashGiftbagIpyData.GetEndDate(), openServerDay)
    packInfo.AdvanceMinutes = flashGiftbagIpyData.GetAdvanceMinutes()
    packInfo.ActivityTime = []
    for i, startTime in enumerate(startTimeList):
        timeInfo = ChPyNetSendPack.tagMCFlashGiftbagTime()
@@ -239,7 +263,7 @@
        
        for giftIpyData in giftbagIpyDataList:
            giftbagID = giftIpyData.GetGiftbagID()
            orderIpyData = GetFlashGiftbagIDOrderInfoIpyData(giftbagID)
            orderIpyData = GetFlashGiftbagIDOrderInfoIpyData(giftbagID, appID)
            giftBag = ChPyNetSendPack.tagMCFlashGiftbag()
            giftBag.GiftID = giftbagID
            giftBag.OrderInfo = "" if not orderIpyData else orderIpyData.GetOrderInfo()
@@ -265,21 +289,20 @@
    NetPackCommon.SendFakePack(curPlayer, packInfo)
    return
def GetFlashGiftbagIDOrderInfoIpyData(giftbagID):
def GetFlashGiftbagIDOrderInfoIpyData(giftbagID, appID):
    ## 获取礼包ID对应实际售价
    key = "FlashGiftbagIDRMB"
    FlashGiftbagIDRMBDict = IpyGameDataPY.GetConfigEx(key)
    if not FlashGiftbagIDRMBDict:
        FlashGiftbagIDRMBDict = {}
        appID = GameWorld.GetPlatform()
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for i in xrange(ipyDataMgr.GetOrderInfoCount()):
            ipyData = ipyDataMgr.GetOrderInfoByIndex(i)
            if ipyData.GetAppID() != appID:
                continue
            #if ipyData.GetAppID() != appID:
            #    continue
            if not ipyData.GetGiftbagID():
                continue
            FlashGiftbagIDRMBDict[ipyData.GetGiftbagID()] = ipyData
            FlashGiftbagIDRMBDict[(ipyData.GetGiftbagID(), ipyData.GetAppID())] = ipyData
        IpyGameDataPY.SetConfigEx(key, FlashGiftbagIDRMBDict)
    return FlashGiftbagIDRMBDict.get(giftbagID)
    return FlashGiftbagIDRMBDict.get((giftbagID, appID))