hxp
2019-12-24 56ae47514b78d6b4ae0019e4fccc8837df076be4
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
@@ -96,25 +96,46 @@
    return
def GetPlayerGoldGiftFirst(curPlayer):
def GetPlayerGoldGiftFirst(curPlayer, giftDay):
    '''领取玩家首充奖励
    @param dayIndex: 首充第几天奖励
    '''
    
    isGet = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
    if isGet:
        GameWorld.DebugLog("已经领取过首充奖励!", curPlayer.GetPlayerID())
    if not giftDay:
        return
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
    firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
    if not firstGoldServerDay:
        GameWorld.DebugLog("还未充值过!firstGoldServerDay=%s" % firstGoldServerDay)
        return
    canGetMaxDay = openServerDay - firstGoldServerDay + 1
    if giftDay > canGetMaxDay:
        GameWorld.DebugLog("还未到可领取的首充天,无法领取!openServerDay=%s,firstGoldServerDay=%s,canGetMaxDay=%s < giftDay=%s"
                           % (openServerDay, firstGoldServerDay, canGetMaxDay, giftDay))
        return
    dayIndex = giftDay - 1
    getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
    if getRecord & pow(2, dayIndex):
        GameWorld.DebugLog("已经领取过首充奖励!giftDay=%s" % giftDay, curPlayer.GetPlayerID())
        return
    
    if not curPlayer.GetChangeCoinPointTotal():
        GameWorld.DebugLog("没有充值过,无法领取首充奖励!", curPlayer.GetPlayerID())
        return
    
    firstGoldRewardDict = IpyGameDataPY.GetFuncEvalCfg("FirstGold", 1)
    jobStr = str(curPlayer.GetJob())
    if jobStr not in firstGoldRewardDict:
        GameWorld.ErrLog("没有配置该职业对应的首充奖励!job=%s" % jobStr, curPlayer.GetPlayerID())
    ipyData = IpyGameDataPY.GetIpyGameData("FirstGold", giftDay)
    if not ipyData:
        return
    rewardItemList = firstGoldRewardDict[jobStr]
    jobItemInfoDict = ipyData.GetJobItemInfo()
    commItemList = ipyData.GetCommItemList()
    rewardItemList = []
    jobStr = str(curPlayer.GetJob())
    if jobStr in jobItemInfoDict:
        rewardItemList += jobItemInfoDict[jobStr]
    rewardItemList += commItemList
    if not rewardItemList:
        return
    needSpace = len(rewardItemList)
@@ -126,17 +147,22 @@
        return
    
    # 更新已领取成功标记
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftFirstRecord, 1)
    updGetRecord = getRecord | pow(2, dayIndex)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftFirstRecord, updGetRecord)
    GameWorld.DebugLog("领取首充奖励: giftDay=%s,getRecord=%s,updGetRecord=%s, %s" % (giftDay, getRecord, updGetRecord, rewardItemList))
    
    # 给物品
    for itemID, itemCount, isBind in rewardItemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
    isAuctionItem = False
    for itemID, itemCount in rewardItemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
        
    # 全服提示
    if len(rewardItemList) >= 2:
        PlayerControl.WorldNotify(0, "FirstPayReward1", [curPlayer.GetPlayerName(), rewardItemList[0][0], rewardItemList[1][0]])
        PlayerControl.WorldNotify(0, "FirstPayReward1", [curPlayer.GetPlayerName(), rewardItemList[0][0], rewardItemList[1][0], giftDay])
    # 记录领取事件
    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "FirstGoldGift")
    infoDict = {"GiftDay":giftDay, "ItemList":rewardItemList}
    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "FirstGoldGift", infoDict)
    
    # 通知客户端
    Sync_FirstGoldInfo(curPlayer)
@@ -169,12 +195,14 @@
#  @param addGold: 充元宝数
#  @return: None
def OnPlayerChargeGold(curPlayer, addGold):
    DayChargeRedPackAward(curPlayer)
    
    # 更新今日已充值数
    dailyGoldCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeCnt)
    updDailyGoldCnt = dailyGoldCnt + addGold
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyGoldChargeCnt, updDailyGoldCnt)
    #PlayerControl.NotifyPlayerDictValue(curPlayer, ChConfig.Def_PDict_DailyGoldChargeCnt)
    firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
    if not firstGoldServerDay:
        recordServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldServerDay, recordServerDay)
        GameWorld.DebugLog("记录首充开服天: recordServerDay=%s" % recordServerDay)
        Sync_FirstGoldInfo(curPlayer)
    
    return
@@ -184,6 +212,7 @@
    sendPack.Clear()
    sendPack.FirstGoldRewardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
    sendPack.FirstGoldTry = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTry)
    sendPack.FirstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return