#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
##@package PlayerGoldGift  
 | 
#  
 | 
# @todo: ¼ÇÂ¼Íæ¼ÒµÄ³äÖµºÀÀñ½±ÀøÐÅÏ¢£¬¶þ½øÖÆÎ»±êʾ£¬Ä¿Ç°ÓÃÁËÒ»¸ö×Öµä  
 | 
# @author hxp  
 | 
# @date 2013-10-16 17:00  
 | 
#  
 | 
# @version 3.0  
 | 
# ¼òҪ˵Ã÷:  
 | 
# ÏêϸÃèÊö:   
 | 
# @change: "2013-10-22 11:10" hxp Ð޸ĶÁÈ¡½±ÀøÎïÆ·±í·½Ê½  
 | 
# @change: "2013-11-12 17:00" hxp Ôö¼ÓÊ׳佱ÀøÁìÈ¡Âß¼  
 | 
# @change: "2013-12-09 18:00" hxp Ôö¼ÓÁ콱ȫ·þ¹ã²¥mark  
 | 
# @change: "2014-05-11 14:35" xcc Ôö¼ÓmarkÈç¹ûΪ¿Õ£¬¾Í²»Ìáʾ  
 | 
# @change: "2014-06-06 20:30" hxp Á콱ȫ·þ¹ã²¥ÐÞ¸Ä  
 | 
# @change: "2014-06-12 21:00" hxp Ôö¼ÓÌìÌìÊ×³ä  
 | 
# @change: "2014-08-22 12:00" hxp È¥³ý¶àÓàÈ«·þ¹ã²¥  
 | 
# @change: "2014-10-09 14:00" hxp Ê׳ä/ÌìÌìÊ׳乿ÔòÐ޸ģ¬ÌìÌìÊ׳äÒ»ÌìÖ»ÄÜÁìȡһ´Î  
 | 
# @change: "2014-12-16 18:00" hxp ·¢ËͳäÖµºÀÀñ·¢ËÍÓʼþ  
 | 
# @change: "2014-12-22 14:00" hxp Ôö¼Óµ¥ÈÕ³äÖµ¶àѡһÀñ°ü  
 | 
# @change: "2015-02-06 10:30" hxp µ¥ÈÕ³äÖµ¶àѡһÀñ°üÖ§³ÖÅäÖÃÐÇÆÚ¼¸  
 | 
# @change: "2015-02-11 18:30" hxp µ¥ÈÕ³äÖµ¶àѡһÀñ°ü¿ª·þǰ¼¸Ìì²»¿ªÆôµÄ½öÏÞÖÆÐÇÆÚ¼¸µÄ»î¶¯  
 | 
# @change: "2015-04-23 12:00" hxp µ±ÈÕ³äÖµ¶àѡһÀñ°üÖ§³Ö¶à¸ö×êʯµµ½±Àø  
 | 
# @change: "2015-04-28 16:00" hxp Ôö¼ÓÿÈÕ³äÖµÔª±¦Êý֪ͨ  
 | 
# @change: "2015-05-21 14:30" hxp Ôö¼Óµ±ÈÕ³äÖµÎÞÏÞÁìÈ¡Àñ°ü  
 | 
# @change: "2015-06-09 20:30" hxp ½±ÀøÃû³Æ¸ÄΪ¿Í»§¶ËÅäÖà  
 | 
# @change: "2016-01-26 15:00" hxp PY±íÖ§³ÖÖØ¶Á  
 | 
# @change: "2016-06-27 14:00" hxp Ê׳äÖ§³Ö¿ÉÅäÖöî¶È  
 | 
#------------------------------------------------------------------------------   
 | 
#"""Version = 2017-05-12 18:00"""  
 | 
#------------------------------------------------------------------------------   
 | 
import GameWorld  
 | 
import IPY_GameWorld  
 | 
import ReadChConfig  
 | 
import ItemControler  
 | 
import ChConfig  
 | 
import ItemCommon  
 | 
import PlayerControl  
 | 
import ShareDefine  
 | 
import DataRecordPack  
 | 
import ChPyNetSendPack  
 | 
import PlayerFamilyRedPacket  
 | 
import NetPackCommon  
 | 
import PyMapTable  
 | 
import PlayerCoin  
 | 
import IpyGameDataPY  
 | 
import PlayerTJG  
 | 
import ChEquip  
 | 
  
 | 
import time  
 | 
import FunctionNPCCommon  
 | 
  
 | 
# ¶¨ÒåÅä±íÍâΧË÷Òý  
 | 
(  
 | 
Def_NotifyMark, # ÏµÍ³Ìáʾmark  
 | 
Def_NeedSpace, # ËùÐè¸ñ×ÓÊý  
 | 
Def_GiftInfo, # ½±Æ·ÐÅÏ¢  
 | 
) = range(3)  
 | 
  
 | 
# ¶¨Òå½±ÀøÎïÆ·ÐÅÏ¢Ë÷Òý  
 | 
(  
 | 
Def_InfoIndex_ItemType, # ÎïÆ·ÀàÐÍ   
 | 
Def_InfoIndex_ItemID, # ÎïÆ·id»ò¶¨ÖÆÎïÆ·Ë÷Òý  
 | 
Def_InfoIndex_ItemCount, # ÎïÆ·¸öÊý  
 | 
Def_InfoIndex_IsBind, # ÊÇ·ñ°ó¶¨  
 | 
) = range(4)  
 | 
  
 | 
  
 | 
# ¶¨ÒåÎïÆ·ÀàÐÍ  
 | 
(  
 | 
Def_ItemType_CommonItem, # Ò»°ãÎïÆ·  
 | 
Def_ItemType_AppointItem, # ÌØÊâ¶¨ÖÆÎïÆ·  
 | 
) = range(2)  
 | 
  
 | 
## ÁìÈ¡Íæ¼Ò³äÖµºÀÀñ½±Àø  
 | 
#  @param giftNum£ººÀÀñ±àºÅ£¬´Ó0¿ªÊ¼  
 | 
#  @return None  
 | 
def GetPlayerGoldGift(curPlayer, giftNum):  
 | 
      
 | 
    # ¼ì²é¿É·ñÁìÈ¡  
 | 
    if not __CheckCanGetGift(curPlayer, giftNum):  
 | 
        GameWorld.DebugLog("return can not Get GoldGift!!!")  
 | 
        return  
 | 
      
 | 
    goldGiftInfo = ReadChConfig.GetEvalChConfig("GoldGiftInfo_%s" % giftNum)  
 | 
      
 | 
    # ¼ì²é±³°ü  
 | 
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)  
 | 
    needSpace = goldGiftInfo[Def_NeedSpace]  
 | 
    if needSpace > packSpace:  
 | 
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  
 | 
        return  
 | 
      
 | 
    # ¸øÎïÆ·  
 | 
    if not __GiveGoldGift(curPlayer, goldGiftInfo[Def_GiftInfo]):  
 | 
        return  
 | 
      
 | 
    # È«·þÌáʾ  
 | 
    notifyMark = goldGiftInfo[Def_NotifyMark]  
 | 
    #Èç¹ûÓÐÏûÏ¢Ìáʾ  
 | 
    if notifyMark.strip() != "":  
 | 
        PlayerControl.WorldNotify(0, notifyMark, [curPlayer.GetPlayerName()])  
 | 
    vipLV = curPlayer.GetVIPLv()  
 | 
    msgParamList = [vipLV, curPlayer.GetPlayerName(), giftNum + 1]  
 | 
    PlayerControl.WorldNotify(0, "GeRen_liubo_927007", msgParamList)  
 | 
          
 | 
    # ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç  
 | 
    __UpdateLVAwardGetRecord(curPlayer, giftNum)  
 | 
      
 | 
    # ¼Ç¼Áìȡʼþ  
 | 
    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, giftNum)  
 | 
      
 | 
    # Í¨Öª¿Í»§¶Ë  
 | 
    Sync_GoldGiftGetRecordInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
  
 | 
## Í¨Öª³äÖµºÀÀñÁìÈ¡¼Ç¼ÐÅÏ¢  
 | 
#  @param None  
 | 
#  @return None  
 | 
def Sync_GoldGiftGetRecordInfo(curPlayer):  
 | 
    #getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftGetRecord, 0,  
 | 
    #                                          ChConfig.Def_PDictType_GoldGift)  
 | 
    #ChPlayer.Sync_RewardGetRecordInfo(curPlayer, ShareDefine.Def_RewardType_GoldGift, getRecord)  
 | 
    return  
 | 
  
 | 
  
 | 
## ¸øÍæ¼Ò³äÖµºÀÀñ½±ÀøÎïÆ·  
 | 
#  @param curPlayer£ºÍæ¼ÒʵÀý  
 | 
#  @param goldGiftInfoDict£º³äÖµºÀÀñÎïÆ·ÅäÖÃ×Öµä  
 | 
#  @return None  
 | 
def __GiveGoldGift(curPlayer, goldGiftInfoDict):  
 | 
  
 | 
    goldGiftInfoList = __GetGoldGiftInfoList(curPlayer, goldGiftInfoDict)  
 | 
      
 | 
    # Èç¹ûÕÒ²»µ½¶ÔÓ¦µÄ½±ÀøÐÅÏ¢£¬Ôò·µ»ØFalse  
 | 
    if not goldGiftInfoList:  
 | 
        return False  
 | 
      
 | 
    # ¸øÎïÆ·  
 | 
    for giftInfo in goldGiftInfoList:  
 | 
        itemType = giftInfo[Def_InfoIndex_ItemType]  
 | 
        itemCount = giftInfo[Def_InfoIndex_ItemCount]  
 | 
        itemID = giftInfo[Def_InfoIndex_ItemID]  
 | 
        isBind = 0  
 | 
        if len(giftInfo) > Def_InfoIndex_IsBind:  
 | 
            isBind = giftInfo[Def_InfoIndex_IsBind]  
 | 
  
 | 
        if itemCount <= 0:  
 | 
            continue  
 | 
          
 | 
        # Ò»°ãÎïÆ·  
 | 
        if itemType == Def_ItemType_CommonItem:  
 | 
            ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], True, showSysInfo=True)  
 | 
          
 | 
        # ÌØÊâ¶¨ÖÆÎïÆ·  
 | 
        elif itemType == Def_ItemType_AppointItem:  
 | 
            itemData = PyMapTable.GetPyMapTable("AppointItemList").GetRecord("ItemIndex", str(itemID))  
 | 
            GameWorld.DebugLog("__GiveGoldGift itemData=%s" % itemData)  
 | 
            if not itemData:  
 | 
                GameWorld.ErrLog("__GiveGoldGift()itemType=%s,ItemIndex=%s not data" % (itemType, itemID))  
 | 
                continue  
 | 
              
 | 
            if len(itemData) != 1:  
 | 
                GameWorld.ErrLog("__GiveGoldGift()itemType=%s,ItemIndex=%s,recordCount=%s !=1 error" % \  
 | 
                                                        (itemType, itemID, len(itemData)))  
 | 
                continue  
 | 
              
 | 
            itemDictData = itemData[0]  
 | 
            itemDictData['IsBind'] = str(isBind)  
 | 
            ItemControler.GivePlayerEquip(curPlayer, itemDictData, True, showSysInfo=True)  
 | 
  
 | 
    return True  
 | 
  
 | 
  
 | 
## ¸øÍæ¼Ò³äÖµºÀÀñ½±ÀøÎïÆ·ÐÅÏ¢ÁÐ±í  
 | 
#  @param curPlayer£ºÍæ¼ÒʵÀý  
 | 
#  @param awardItemInfoDict£º½±ÀøÎïÆ·ÅäÖÃ×Öµä  
 | 
#  @return None  
 | 
def __GetGoldGiftInfoList(curPlayer, goldGiftInfoDict):  
 | 
    infoKey = () # Ä¬ÈÏkey  
 | 
    job = curPlayer.GetJob()  
 | 
    for key in goldGiftInfoDict.keys():  
 | 
        # Èç¹ûÍæ¼ÒÖ°ÒµÔÚÅäÖõÄkeyÀÔòȡָ¶¨µÄkeyÐÅÏ¢  
 | 
        if job in key:  
 | 
            infoKey = key  
 | 
            break  
 | 
          
 | 
    return goldGiftInfoDict[infoKey]  
 | 
  
 | 
  
 | 
## ¸üÐÂÁìÈ¡¼Ç¼  
 | 
#  @param giftNum£ººÀÀñ±àºÅ£¬´Ó0¿ªÊ¼  
 | 
#  @return None  
 | 
def __UpdateLVAwardGetRecord(curPlayer, giftNum):  
 | 
      
 | 
    curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftGetRecord, 0,  
 | 
                                              ChConfig.Def_PDictType_GoldGift)  
 | 
      
 | 
    curValue = curValue|(1 << giftNum)  
 | 
      
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftGetRecord, curValue,  
 | 
                                   ChConfig.Def_PDictType_GoldGift)  
 | 
    return  
 | 
  
 | 
## ¼ì²é¿É·ñÁìÈ¡  
 | 
#  @param giftNum£ººÀÀñ±àºÅ  
 | 
#  @return True-¿ÉÁìÈ¡  
 | 
def __CheckCanGetGift(curPlayer, giftNum):  
 | 
      
 | 
    needGoldCntList = ReadChConfig.GetEvalChConfig("NeedGoldCntList")  
 | 
      
 | 
    # ·Ç·¨Ë÷Òý  
 | 
    if giftNum < 0 or giftNum >= len(needGoldCntList):  
 | 
        GameWorld.ErrLog("__CheckCanGetGift() error£ºnot giftNum=%s" % (giftNum))  
 | 
        return False  
 | 
      
 | 
    # ÅжÏÒѳåÔª±¦ÊýÊÇ·ñÂú×ã  
 | 
    curChangeCoin = curPlayer.GetChangeCoinPointTotal()  
 | 
    curChangeGold = PlayerCoin.GetCoinRate() * curChangeCoin  
 | 
    if curChangeGold < needGoldCntList[giftNum]:  
 | 
        GameWorld.DebugLog("__CheckCanGetGift() curChangeGold not enough " + \  
 | 
                                       "giftNum=%s,needGold=%s,changeGold=%s" % \  
 | 
                                       (giftNum, needGoldCntList[giftNum], curChangeGold))  
 | 
        return False  
 | 
      
 | 
    # ÅжÏÊÇ·ñÒÑÁìÈ¡  
 | 
    curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftGetRecord, 0,  
 | 
                                              ChConfig.Def_PDictType_GoldGift)  
 | 
    return not (curValue & pow(2, giftNum))  
 | 
  
 | 
  
 | 
##------------------------------------------------------------------------------  
 | 
def DoFirstGoldOpen(curPlayer):  
 | 
    ## Ê׳俪Æô  ¼Ç¼ÌáʾʣÓàʱ¼ä  
 | 
    if curPlayer.GetChangeCoinPointTotal():  
 | 
        return  
 | 
    showSysTime = IpyGameDataPY.GetFuncCfg("FirstGold", 3)  
 | 
    if not showSysTime:  
 | 
        return  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldRemainTime, showSysTime)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))  
 | 
      
 | 
    Sync_FirstGoldTime(curPlayer)  
 | 
    return  
 | 
  
 | 
def UpdateFirstGoldTime(curPlayer):  
 | 
    #¸üÐÂÊ׳äÌáʾʣÓàʱ¼ä  
 | 
    if PlayerTJG.GetIsTJG(curPlayer):  
 | 
        return  
 | 
    remainTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime)  
 | 
    if not remainTime:  
 | 
        return  
 | 
    if curPlayer.GetChangeCoinPointTotal():  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldRemainTime, 0)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, 0)  
 | 
    else:  
 | 
        curTime = int(time.time())  
 | 
        startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTipStartTime)  
 | 
        remainTime = max(0, remainTime - (curTime - startTime))  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldRemainTime, remainTime)  
 | 
        if not remainTime:  
 | 
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, 0)  
 | 
    return  
 | 
  
 | 
def Sync_FirstGoldTime(curPlayer):  
 | 
    ##֪ͨÊ׳äÌáʾʣÓàʱ¼ä  
 | 
    showSysTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime)  
 | 
    if not showSysTime:  
 | 
        return  
 | 
    sendPack = ChPyNetSendPack.tagMCFirstGoldTime()  
 | 
    sendPack.Clear()  
 | 
    sendPack.FirstGoldRemainTime = showSysTime  
 | 
    NetPackCommon.SendFakePack(curPlayer, sendPack)  
 | 
    return  
 | 
  
 | 
  
 | 
def GetPlayerGoldGiftFirst(curPlayer):  
 | 
    '''ÁìÈ¡Íæ¼ÒÊ׳佱Àø  
 | 
    '''  
 | 
      
 | 
    isGet = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)  
 | 
    if isGet:  
 | 
        GameWorld.DebugLog("ÒѾÁìÈ¡¹ýÊ׳佱Àø£¡", 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())  
 | 
        return  
 | 
    rewardItemList = firstGoldRewardDict[jobStr]  
 | 
    if not rewardItemList:  
 | 
        return  
 | 
    needSpace = len(rewardItemList)  
 | 
      
 | 
    # ¼ì²é±³°ü  
 | 
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)  
 | 
    if needSpace > packSpace:  
 | 
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  
 | 
        return  
 | 
      
 | 
    # ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftFirstRecord, 1)  
 | 
      
 | 
    # ¸øÎïÆ·  
 | 
    for itemID, itemCount, isBind in rewardItemList:          
 | 
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem])  
 | 
          
 | 
    # È«·þÌáʾ  
 | 
    if len(rewardItemList) >= 2:  
 | 
        PlayerControl.WorldNotify(0, "FirstPayReward1", [curPlayer.GetPlayerName(), rewardItemList[0][0], rewardItemList[1][0]])  
 | 
    # ¼Ç¼Áìȡʼþ  
 | 
    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "FirstGoldGift")  
 | 
      
 | 
    # Í¨Öª¿Í»§¶Ë  
 | 
    Sync_FirstGoldInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
###################################################################  
 | 
  
 | 
## ³äÖµºÀÀñOnDay  
 | 
#  @param curPlayer: Íæ¼Ò  
 | 
#  @return: None  
 | 
def OnDay(curPlayer):  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyChargeState, 0)  
 | 
      
 | 
    #===============================================================================================  
 | 
    # curChangeCoin = curPlayer.GetChangeCoinPointTotal()  
 | 
    # # ½ñÌì֮ǰÓгäÖµ¹ý²ÅÐèÒª´¦ÀíÌìÌìÊ×³ä  
 | 
    # if curChangeCoin > 0:  
 | 
    #    # ÌìÌìÊ׳ä״̬¿ªÆô  
 | 
    #    dailyGoldState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeState, 0)  
 | 
    #    if not dailyGoldState:  
 | 
    #        UpdateDailyGoldState(curPlayer, 1)  
 | 
    #      
 | 
    #    # ÌìÌìÊ׳äÁ콱״̬ 0-²»¿ÉÁ죻1-¿ÉÁ죻2-ÒÑÁì  
 | 
    #    dailyGoldRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargePrizeRecord, 0)  
 | 
    #    if dailyGoldRecord != 1:  
 | 
    #        UpdateDailyGoldRecord(curPlayer, 0)  
 | 
    #===============================================================================================  
 | 
              
 | 
    # ÖØÖýñÈÕÒѳäÖµÊý, ÁìÈ¡Àñ°üË÷Òý  
 | 
    #PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyGoldChargeCnt, 0)  
 | 
    #PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SingleGoldGiftIndex, 0)  
 | 
    #PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnlimitedGoldGiftCnt, 0)  
 | 
    # Í¨Öªµ¥ÈÕ³äÖµ¶àѡһÀñ°üÐÅÏ¢  
 | 
    #Sync_SingleGoldGiftInfo(curPlayer, True)  
 | 
    #Sync_UnlimitedGoldGiftRecord(curPlayer)  
 | 
    return  
 | 
  
 | 
## ³äÖµºÀÀñOnLogin  
 | 
#  @param curPlayer: Íæ¼Ò  
 | 
#  @return: None  
 | 
def OnLogin(curPlayer):  
 | 
    Sync_FirstGoldInfo(curPlayer)  
 | 
      
 | 
    Sync_FirstGoldTime(curPlayer)  
 | 
    #¸üÐÂÊ׳äÌáʾ¿ªÊ¼¼ÆÊ±Ê±¼ä  
 | 
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime):  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))  
 | 
    return  
 | 
  
 | 
## Íæ¼Ò³äÖµÔª±¦  
 | 
#  @param curPlayer: Íæ¼Ò  
 | 
#  @param addGold: ³äÔª±¦Êý  
 | 
#  @return: None  
 | 
def OnPlayerChargeGold(curPlayer, addGold):  
 | 
      
 | 
    # ¸üнñÈÕÒѳäÖµÊý  
 | 
    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)  
 | 
      
 | 
    # ÌìÌìÊ׳äÒÑ¿ªÆô²Å´¦Àí  
 | 
    dailyGoldState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeState, 0)  
 | 
    if dailyGoldState:  
 | 
        # ÌìÌìÊ׳äÁ콱״̬ 0-²»¿ÉÁ죻1-¿ÉÁ죻2-ÒÑÁì  
 | 
        dailyGoldRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargePrizeRecord, 0)  
 | 
        # ²»¿ÉÁìµÄʱºò²ÅÖÃΪ¿ÉÁì  
 | 
        if dailyGoldRecord == 0:  
 | 
            UpdateDailyGoldRecord(curPlayer, 1)  
 | 
      
 | 
    # ³äÖµ´ïµ½¶î¶¨Ôª±¦»ñµÃ½±Àø£¬Óʼþ·¢ËÍ  
 | 
    __GiveGoldGiftByMail(curPlayer)  
 | 
      
 | 
    # Í¨Öªµ¥ÈÕ³äÖµ¶àѡһÀñ°üÐÅÏ¢  
 | 
    Sync_SingleGoldGiftInfo(curPlayer, True)  
 | 
    return  
 | 
  
 | 
## µ¥ÈÕ³äÖµÈÎѡһ½±Àø  
 | 
#  @param curPlayer: Íæ¼Ò  
 | 
#  @param giftIndex: Àñ°üË÷Òý  
 | 
#  @param giftLV: Àñ°üµµ´Î  
 | 
#  @return: None  
 | 
def GetSingleGoldGift(curPlayer, giftIndex, giftLV, giftType):  
 | 
      
 | 
    findSingleGoldGift = GetTodaySingleGoldGiftInfo()  
 | 
      
 | 
    GameWorld.DebugLog("µ±ÈÕ³äÖµ½±ÀøÁì½± (µµ%s - %s) giftType=%s,findSingleGoldGift=%s"   
 | 
                       % (giftLV, giftIndex, giftType, str(findSingleGoldGift)))  
 | 
      
 | 
    if not findSingleGoldGift:  
 | 
        GameWorld.DebugLog("    ½ñÈÕδÅäÖóäÖµµ¥Ñ¡Àñ°ü!")  
 | 
        return  
 | 
  
 | 
    todayGiftType = findSingleGoldGift[2]  
 | 
    if giftType != todayGiftType:  
 | 
        GameWorld.DebugLog("    ·Çµ±ÈÕ³äÖµÀñ°üÀàÐÍ£¡todayGiftType=%s" % todayGiftType)  
 | 
        return  
 | 
      
 | 
    goldGiftInfoList = findSingleGoldGift[3]  
 | 
      
 | 
    # ÎÞÏÞÁìÈ¡Àñ°üÀàÐÍ  
 | 
    if giftType == 1:  
 | 
        __GetUnlimitedGoldGift(curPlayer, goldGiftInfoList)  
 | 
        return  
 | 
      
 | 
    if giftIndex <= 0:  
 | 
        return  
 | 
      
 | 
    if giftLV >= len(goldGiftInfoList):  
 | 
        GameWorld.ErrLog("µ¥ÈÕ³äÖµµ¥Ñ¡Àñ°üÅäÖôíÎóSingleGoldGift.txt ²»´æÔڸý±Àøµµ!giftLV=%s" % giftLV)  
 | 
        return  
 | 
      
 | 
    curGoldGiftInfo = goldGiftInfoList[giftLV]  
 | 
    needGold, chooseGiftList = curGoldGiftInfo  
 | 
      
 | 
    dailyGoldCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeCnt)  
 | 
      
 | 
    if dailyGoldCnt < needGold:  
 | 
        GameWorld.DebugLog("    ½ñÈÕ³äÖµ¶î¶ÈδÂú×㣬ÎÞ·¨Áì½±!needGold=%s,dailyGoldCnt=%s"   
 | 
                           % (needGold, dailyGoldCnt))  
 | 
        return  
 | 
      
 | 
    goldGiftAwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SingleGoldGiftIndex)  
 | 
    singleGoldGiftIndex = GameWorld.GetDataByDigitPlace(goldGiftAwardRecord, giftLV)  
 | 
    if singleGoldGiftIndex > 0:  
 | 
        GameWorld.DebugLog("    ½ñÈÕÒÑÁìÈ¡!singleGoldGiftIndex=%s" % (singleGoldGiftIndex))  
 | 
        return  
 | 
      
 | 
    if giftIndex > len(chooseGiftList):  
 | 
        GameWorld.ErrLog("µ¥ÈÕ³äÖµµ¥Ñ¡Àñ°üÅäÖôíÎóSingleGoldGift.txt giftIndex=%s ²»ÔÚ½±ÀøÁбíÀï!" % giftIndex)  
 | 
        return  
 | 
      
 | 
    hasSpace = ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem)  
 | 
    if not hasSpace:  
 | 
        GameWorld.DebugLog("    ±³°üÒÑÂú£¡")  
 | 
        return  
 | 
      
 | 
    # ¸üÐÂÁì½±Ë÷Òý  
 | 
    updGoldGiftRecord = GameWorld.ChangeDataByDigitPlace(goldGiftAwardRecord, giftLV, giftIndex)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SingleGoldGiftIndex, updGoldGiftRecord)  
 | 
      
 | 
    itemID, itemCount, isBind = chooseGiftList[giftIndex - 1]  
 | 
    isOK = ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], True)  
 | 
    if not isOK:  
 | 
        return  
 | 
  
 | 
    # Á÷Ïò  
 | 
    infoDict = {"SingleGiftIndex":giftIndex, "ItemID":itemID, "ItemCount":itemCount, "IsBind":isBind,  
 | 
                "SingleGiftLV":giftLV, "GoldGiftAwardRecord":updGoldGiftRecord}  
 | 
    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "SingleGoldGift", infoDict)  
 | 
      
 | 
    # Í¬²½¿Í»§¶Ë״̬  
 | 
    Sync_SingleGoldGiftInfo(curPlayer)  
 | 
    GameWorld.DebugLog("    awardRecord=%s,updRecord=%s,infoDict=%s" % (goldGiftAwardRecord, updGoldGiftRecord, infoDict))  
 | 
    return  
 | 
  
 | 
def __GetUnlimitedGoldGift(curPlayer, goldGiftInfoList):  
 | 
      
 | 
    dailyGoldCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeCnt)  
 | 
      
 | 
    # ÒÑÁìÈ¡´ÎÊý  
 | 
    hadGetCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnlimitedGoldGiftCnt)  
 | 
      
 | 
    maxGetCnt = goldGiftInfoList[0] # ×î´óÖØ¸´ÁìÈ¡´ÎÊý  
 | 
    perNeedGold = goldGiftInfoList[1] # Ã¿´ÎÁìÈ¡ÐèÒª³äÖµ×êʯÊý  
 | 
    curCanGetCnt = dailyGoldCnt / perNeedGold # µ±Ç°¿ÉÁìÈ¡µÄ×î´ó´ÎÊý  
 | 
    if maxGetCnt > 0:  
 | 
        curCanGetCnt = min(curCanGetCnt, maxGetCnt)  
 | 
      
 | 
    GameWorld.DebugLog("ÁìÈ¡µ±ÈÕ³äÖµÎÞÏÞÁìÈ¡Àñ°ü£ºdailyGoldCnt=%s / per(%s) = canCnt(%s),hadGetCnt=%s,MaxCntCfg=%s"   
 | 
                       % (dailyGoldCnt, perNeedGold, curCanGetCnt, hadGetCnt, maxGetCnt))  
 | 
      
 | 
    if curCanGetCnt <= 0:  
 | 
        GameWorld.DebugLog("    ¿ÉÁìÈ¡´ÎÊý=%s,²»¿ÉÁìÈ¡!" % curCanGetCnt)  
 | 
        return  
 | 
      
 | 
    if hadGetCnt >= curCanGetCnt:  
 | 
        GameWorld.DebugLog("    ÒÑ´ïµ½×î´óÁìÈ¡´ÎÊý!%s" % curCanGetCnt)  
 | 
        return  
 | 
      
 | 
    getCnt = curCanGetCnt - hadGetCnt  
 | 
      
 | 
    # ¼ì²é±³°ü  
 | 
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)  
 | 
    needSpace = goldGiftInfoList[2]  
 | 
    if needSpace > packSpace:  
 | 
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  
 | 
        return  
 | 
  
 | 
    # ¸øÎïÆ·  
 | 
    curGetCnt = getCnt  
 | 
    awardItemList = goldGiftInfoList[3]  
 | 
    for itemID, itemCnt, isBind in awardItemList:  
 | 
        gameData = GameWorld.GetGameData()  
 | 
        curItemData = gameData.GetItemByTypeID(itemID)  
 | 
        if curItemData == None:  
 | 
            GameWorld.ErrLog("ÁìÈ¡µ±ÈÕ³äÖµÎÞÏÞÁìÈ¡Àñ°ü£¬ÎïÆ·IDÊý¾Ý´íÎó£¡(%s)" % itemID, curPlayer.GetPlayerID())  
 | 
            return  
 | 
          
 | 
        maxPackCount = curItemData.GetPackCount()  
 | 
        perSpaceCanGetCnt = maxPackCount / itemCnt # µ¥¸ö¿Õλ×î´ó¿ÉÁìÈ¡´ÎÊý  
 | 
        curGetCnt = min(perSpaceCanGetCnt, curGetCnt)  
 | 
        #GameWorld.DebugLog("    itemID=%s,maxPackCount=%s,giveCnt=%s,perSpaceCanGetCnt=%s,curGetCnt=%s"   
 | 
        #                   % (itemID, maxPackCount, itemCnt, perSpaceCanGetCnt, curGetCnt))  
 | 
      
 | 
    # ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç  
 | 
    updGetCnt = hadGetCnt + curGetCnt  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnlimitedGoldGiftCnt, updGetCnt)  
 | 
  
 | 
    # ¸øÎïÆ·  
 | 
    awardItemList = goldGiftInfoList[3]  
 | 
    isOKStr = ""  
 | 
    for itemID, itemCnt, isBind in awardItemList:  
 | 
        isOK = ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt * curGetCnt, isBind,   
 | 
                                            [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], True)  
 | 
          
 | 
        isOKStr = "%s%s" % (str(int(isOK)), isOKStr)  
 | 
      
 | 
    # ¼Ç¼Áìȡʼþ  
 | 
    addDataDict = {"isOKStr":isOKStr, "awardItemList":str(awardItemList), "DailyGoldCnt":dailyGoldCnt,  
 | 
                   "TodayGetCnt":updGetCnt, "CurGetCnt":curGetCnt}  
 | 
    DataRecordPack.DR_FuncGiveItem(curPlayer, "UnlimitedGoldGift", addDataDict)  
 | 
      
 | 
    # Í¨Öª¿Í»§¶Ë  
 | 
    Sync_UnlimitedGoldGiftRecord(curPlayer)  
 | 
    GameWorld.DebugLog("    ÁìÈ¡³äÖµÎÞÏÞÁìÈ¡Àñ°ü½±ÀøOK£¡TodayGetCnt=%s,CurGetCnt=%s" % (updGetCnt, curGetCnt))  
 | 
    return  
 | 
  
 | 
  
 | 
## Í¨ÖªÎÞÏÞÁìÈ¡Àñ°üÒÑÁìÈ¡´ÎÊý  
 | 
#  @param None  
 | 
#  @return None  
 | 
def Sync_UnlimitedGoldGiftRecord(curPlayer):  
 | 
    #record = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnlimitedGoldGiftCnt)  
 | 
    #ChPlayer.Sync_RewardGetRecordInfo(curPlayer, ShareDefine.Def_RewardType_UnlimitedGoldGift, record)  
 | 
    return  
 | 
  
 | 
  
 | 
## Íæ¼ÒÀۼƳäÖµÔª±¦·¢ËÍÓʼþ½±Àø  
 | 
#  @param curPlayer: Íæ¼Ò  
 | 
#  @return: None  
 | 
def __GiveGoldGiftByMail(curPlayer):  
 | 
    coinPointTotal = curPlayer.GetChangeCoinPointTotal()  
 | 
    goldTotal = PlayerCoin.GetCoinRate() * coinPointTotal  
 | 
    GameWorld.DebugLog("Óʼþ·¢ËͳäÖµºÀÀñ£ºgoldTotal=%s" % (goldTotal))  
 | 
    if goldTotal <= 0:  
 | 
        return  
 | 
      
 | 
    goldGiftByMailList = ReadChConfig.GetEvalChConfig("GoldGiftByMail")  
 | 
    playerID = curPlayer.GetPlayerID()  
 | 
    for i, giftInfo in enumerate(goldGiftByMailList):  
 | 
          
 | 
        needGold = giftInfo[0]  
 | 
        giftItemList = giftInfo[1]  
 | 
        mailTitle = giftInfo[2]  
 | 
        mailContent = giftInfo[3]  
 | 
        getDays = giftInfo[4]  
 | 
          
 | 
        curMailRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftMailRecord, 0,   
 | 
                                                       ChConfig.Def_PDictType_GoldGift)  
 | 
          
 | 
        if curMailRecord&pow(2, i):  
 | 
            GameWorld.DebugLog("Óʼþ·¢ËͳäÖµºÀÀñ£ºÒÑ·¢Ë͹ý£¡i=%s,needGold=%s" % (i, needGold))  
 | 
            continue  
 | 
      
 | 
        if goldTotal < needGold:  
 | 
            continue  
 | 
          
 | 
        if not PlayerControl.SendMail(mailTitle, mailContent, getDays, [playerID], giftItemList):  
 | 
            continue  
 | 
          
 | 
        updMailRecord = curMailRecord|pow(2, i)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftMailRecord, updMailRecord,  
 | 
                                       ChConfig.Def_PDictType_GoldGift)  
 | 
          
 | 
        GameWorld.DebugLog("Óʼþ·¢ËͳäÖµºÀÀñ£ºi=%s,needGold=%s,giftItemList=%s,updMailRecord=%s"   
 | 
                           % (i, needGold, str(giftItemList), updMailRecord))  
 | 
        # Á÷Ïò  
 | 
        DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "GoldGiftSendMail_%s_%s" % (i, needGold))  
 | 
    return  
 | 
  
 | 
## ÁìÈ¡Íæ¼ÒÌìÌìÊ׳佱Àø  
 | 
#  @param curPlayer  
 | 
#  @return None  
 | 
def GetPlayerDailyGoldChargeGift(curPlayer):  
 | 
      
 | 
    dailyGoldRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargePrizeRecord, 0)  
 | 
      
 | 
    if dailyGoldRecord != 1:  
 | 
        GameWorld.DebugLog("ÌìÌìÊ׳䲻¿ÉÁ죡µ±Ç°×´Ì¬=%s" % dailyGoldRecord)  
 | 
        return  
 | 
      
 | 
    dailyFirstGoldPrizeInfo = ReadChConfig.GetEvalChConfig("GoldGiftInfoFirstDaily")  
 | 
      
 | 
    # ¼ì²é±³°ü  
 | 
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)  
 | 
    needSpace = dailyFirstGoldPrizeInfo[Def_NeedSpace]  
 | 
    if needSpace > packSpace:  
 | 
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  
 | 
        return  
 | 
      
 | 
    # ¸øÎïÆ·  
 | 
    if not __GiveGoldGift(curPlayer, dailyFirstGoldPrizeInfo[Def_GiftInfo]):  
 | 
        return  
 | 
  
 | 
    # È«·þÌáʾ  
 | 
    notifyMark = dailyFirstGoldPrizeInfo[Def_NotifyMark]  
 | 
    if notifyMark:  
 | 
        PlayerControl.WorldNotify(0, notifyMark, [curPlayer.GetPlayerName()])  
 | 
  
 | 
    UpdateDailyGoldRecord(curPlayer, 2)  
 | 
      
 | 
    # ¼Ç¼Áìȡʼþ  
 | 
    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "dailyFirstGoldPrize")  
 | 
    return  
 | 
  
 | 
  
 | 
## ¸üÐÂÌìÌìÊ׳佱Àø¼Ç¼  
 | 
#  @param curPlayer  
 | 
#  @return None  
 | 
def UpdateDailyGoldRecord(curPlayer, record):  
 | 
    #PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyGoldChargePrizeRecord, record)  
 | 
    #Sync_DailyGoldRecordInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
def Sync_FirstGoldInfo(curPlayer):  
 | 
    ## Í¨ÖªÊ׳äÐÅÏ¢  
 | 
    sendPack = ChPyNetSendPack.tagMCFirstGoldInfo()  
 | 
    sendPack.Clear()  
 | 
    sendPack.FirstGoldRewardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)  
 | 
    sendPack.FirstGoldTry = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTry)  
 | 
    NetPackCommon.SendFakePack(curPlayer, sendPack)  
 | 
    return  
 | 
  
 | 
## Í¨Öªµ¥ÈÕ³äÖµ¶àѡһÀñ°üÐÅÏ¢  
 | 
#  @param curPlayer  
 | 
#  @return None  
 | 
def Sync_SingleGoldGiftInfo(curPlayer, isCheckTime=False):  
 | 
    #===============================================================================================  
 | 
    # if isCheckTime:  
 | 
    #    todayGiftInfo = GetTodaySingleGoldGiftInfo()  
 | 
    #    if not todayGiftInfo:  
 | 
    #        return  
 | 
    #   
 | 
    # sendPack = ChPyNetSendPack.tagMCSingleGoldGift()  
 | 
    # sendPack.Clear()  
 | 
    # sendPack.GoldCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeCnt)  
 | 
    # sendPack.GiftIndex = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SingleGoldGiftIndex)  
 | 
    # NetPackCommon.SendFakePack(curPlayer, sendPack)  
 | 
    #===============================================================================================  
 | 
    return  
 | 
  
 | 
## »ñÈ¡µ¥ÈÕ³äÖµ¶àѡһÀñ°üÐÅÏ¢  
 | 
#  @param None  
 | 
#  @return None´ú±í½ñÈÕÎ޻  
 | 
def GetTodaySingleGoldGiftInfo():  
 | 
    # ¿ª·þǰ7ÌìĬÈϲ»¿ªÆô  
 | 
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)  
 | 
      
 | 
    singleGoldGiftList = ReadChConfig.GetEvalChConfig("SingleGoldGift")  
 | 
      
 | 
    curDataTimeStr = GameWorld.GetCurrentDataTimeStr()  
 | 
      
 | 
    curTime = GameWorld.GetCurrentTime()  
 | 
    weekday = curTime.weekday() + 1  
 | 
      
 | 
    findSingleGoldGift = None  
 | 
    for giftInfo in singleGoldGiftList:  
 | 
          
 | 
        # ÅжÏÈÕÆÚ, ÈÕÆÚ»î¶¯ÓÅÏÈ  
 | 
        dateTimeInfo = giftInfo[0]  
 | 
        if dateTimeInfo:  
 | 
            startTime = dateTimeInfo[0]  
 | 
            endTime = dateTimeInfo[1]  
 | 
            if startTime <= curDataTimeStr <= endTime:  
 | 
                findSingleGoldGift = giftInfo  
 | 
                break  
 | 
          
 | 
        # ÅжÏÐÇÆÚ, ¿ª·þǰ7ÌìĬÈϲ»¿ªÆôÐÇÆÚ»î¶¯  
 | 
        weekDayInfo = giftInfo[1]  
 | 
        if weekday in weekDayInfo and openServerDay >= ShareDefine.Def_OSC_ValidDay:  
 | 
            findSingleGoldGift = giftInfo  
 | 
            break  
 | 
      
 | 
    return findSingleGoldGift  
 | 
  
 | 
  
 | 
#// A5 11 ÊÔÓÃÊ׳äÎäÆ÷ #tagCMTryFirstGoldItem  
 | 
#  
 | 
#struct    tagCMTryFirstGoldItem  
 | 
#  
 | 
#{  
 | 
#    tagHead        Head;  
 | 
#};  
 | 
def OnTryFirstGoldItem(index, clientData, tick):  
 | 
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  
 | 
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTry) != 1:  
 | 
        return  
 | 
    tryItemDict = IpyGameDataPY.GetFuncEvalCfg('FirstGoldTryItem', 1, {})  
 | 
    tryItemID = tryItemDict.get(curPlayer.GetJob(), 0)  
 | 
    if not tryItemID:  
 | 
        return  
 | 
      
 | 
      
 | 
    #ÏÈжÏÂÖ÷ÊÖÎäÆ÷£¨Èô±³°üÂúÔò·¢Óʼþ£©£¬ÔÙ´©ÉÏË͵ÄÎäÆ÷  
 | 
    equipPlace = ShareDefine.retWeapon  
 | 
    curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  
 | 
    curItem = curPack.GetAt(equipPlace)  
 | 
    if ItemCommon.CheckItemCanUse(curItem):  
 | 
        spaceIndex = ItemControler.GetItemPackSpaceIndex(curPlayer, IPY_GameWorld.rptItem)  
 | 
        if spaceIndex == -1:  
 | 
            itemObj = ItemCommon.GetMailItemDict(curItem)  
 | 
            PlayerControl.SendMailByKey('', [curPlayer.GetID()], [itemObj])  
 | 
            ItemCommon.DelItem(curPlayer, curItem, 1, False)  
 | 
        else:  
 | 
            result = ItemControler.PlayerItemControler(curPlayer).UnEquipItem(equipPlace, spaceIndex)  
 | 
            if not result:  
 | 
                GameWorld.Log('    ÊÔÓÃÊ׳äÎäÆ÷ Ð¶ÏÂÔ×°±¸Ê§°Ü£¡£¡', curPlayer.GetID())  
 | 
                return  
 | 
              
 | 
    tryItem = ItemControler.GetOutPutItemObj(tryItemID, 1, 1)  
 | 
    if ChEquip.DoPlayerEquipItem(curPlayer, tryItem, equipPlace, tick):  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTry, 2)  
 | 
    else:  
 | 
        curItem.clear()  
 | 
        GameWorld.Log('    ÊÔÓÃÊ׳äÎäÆ÷ ÊÔ´©Ê§°Ü£¡£¡tryItemID=%s'%tryItemID, curPlayer.GetID())  
 | 
    Sync_FirstGoldInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
def FirstGoldTryItemOutTime(curPlayer):  
 | 
    ##Ê׳äÊÔÓÃÎïÆ·¹ýÆÚÁË Èô±³°ü²Ö¿âûÎäÆ÷ÔòËÍÒ»°Ñ  
 | 
      
 | 
    haveEquip = False #ÊÇ·ñÓпɴ©µÄÎäÆ÷  
 | 
    playerItemControl = ItemControler.PlayerItemControler(curPlayer)  
 | 
    for packIndex in [IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]:  
 | 
        curPack = curPlayer.GetItemManager().GetPack(packIndex)  
 | 
        for i in range(0, curPack.GetCount()):  
 | 
            curItem = curPack.GetAt(i)  
 | 
            if not ItemCommon.CheckItemCanUse(curItem):  
 | 
                continue  
 | 
            if curItem.GetEquipPlace() != ShareDefine.retWeapon:  
 | 
                continue  
 | 
            if not ItemCommon.CheckItemCanUseByExpireTime(curItem):  
 | 
                # ¹ýÆÚ  
 | 
                continue  
 | 
            if not playerItemControl.PlayerCanEquipItem(curItem, False):  
 | 
                continue  
 | 
            haveEquip = True  
 | 
            break  
 | 
    if not haveEquip:  
 | 
        giveItemDict = IpyGameDataPY.GetFuncEvalCfg('FirstGoldTryItem', 2, {})  
 | 
        giveItemID = giveItemDict.get(curPlayer.GetJob(), 0)  
 | 
        if not giveItemID:  
 | 
            return  
 | 
        GameWorld.DebugLog('Ê׳äÊÔÓÃÎïÆ·¹ýÆÚÁË ±³°ü²Ö¿âûÎäÆ÷ÔòËÍÒ»°ÑgiveItemID=%s'%giveItemID, curPlayer.GetID())  
 | 
        if not ItemControler.GivePlayerItem(curPlayer, giveItemID, 1, True, [IPY_GameWorld.rptItem], True):  
 | 
            GameWorld.DebugLog('Ê׳äÊÔÓÃÎïÆ·¹ýÆÚÁË ±³°ü²Ö¿âûÎäÆ÷ÔòËÍÒ»°Ñ Ã»¸ø³É¹¦£¡£¡giveItemID=%s'%giveItemID, curPlayer.GetID())  
 | 
              
 | 
    return  
 | 
#ÿÈÕ³äÖµÈÎÒâ½ð¶îºì°ü½±Àø  
 | 
def DayChargeRedPackAward(curPlayer):  
 | 
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyChargeState) == 1:  
 | 
        return  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyChargeState, 1)  
 | 
    PlayerFamilyRedPacket.CreatRedPacketByID(curPlayer, 2)  
 | 
    return 
 |