#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
##@package PlayerRecall  
 | 
#  
 | 
# @todo: ÕÙ»ØÍæ¼Ò  
 | 
# @author Alee  
 | 
# @date 2011-07-22 15:00  
 | 
# @version 1.7  
 | 
#  
 | 
# ÏêϸÃèÊö:  
 | 
# @change: "2011-07-22 17:00" Alee Ð޸ĻعéÍæ¼ÒÉÏÏß֪ͨ  
 | 
# @change: "2011-07-25 19:00" Alee ÀëÏßÌìÊý֪ͨ´íÎó  
 | 
# @change: "2011-07-26 11:00" Alee ÁìÈ¡ÎïÆ·ÏµÍ³ÌáʾºÍ±äÁ¿³õʼ»¯£¬Í¨ÖªÎÊÌâ  
 | 
# @change: "2011-07-26 13:30" Alee  ·¢ËÍÑûÇëÂëµÈ¼¶ÏÞÖÆ  
 | 
# @change: "2011-07-26 15:30" Alee ÐÞ¸´ÔÚMapServerºÍGameServer½»»¥ÆÚ¼ä»áÁìÈ¡¶à·ÝÀñÎï  
 | 
# @change: "2012-05-16 15:00" jiang C++Ð޸ĽӿÚGameServer_QueryPlayerByIDºÍGameServer_QueryPlayerResult  
 | 
# @change: "2012-07-30 16:30" wdb ²¹³äoss¼Ç¼  
 | 
#------------------------------------------------------------------------------   
 | 
"""Version = 2012-07-30 16:30"""  
 | 
#------------------------------------------------------------------------------   
 | 
  
 | 
import GameWorld  
 | 
import ChConfig  
 | 
import ReadChConfig  
 | 
import ItemControler  
 | 
import IPY_GameWorld  
 | 
import ShareDefine  
 | 
import PlayerControl  
 | 
import DataRecordPack  
 | 
  
 | 
  
 | 
#»Ø¹é½±ÀøµÄ×î¶Ìʱ¼ä  
 | 
Def_Base_OffDay = 7  
 | 
#»Ø¹é½±Àø×îµÍµÈ¼¶  
 | 
Def_Base_LV = 30  
 | 
  
 | 
  
 | 
##Íæ¼Ò»Ø¹é֪ͨ½±Àø  
 | 
# @param curPlayer Íæ¼ÒʵÀý  
 | 
# @return None  
 | 
def PlayerBack(curPlayer):  
 | 
    if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open:  
 | 
        return  
 | 
      
 | 
    #µÈ¼¶ÏÞÖÆ  
 | 
    if curPlayer.GetLV() < Def_Base_LV:  
 | 
        return  
 | 
      
 | 
    #µ±Ç°ÀëÏßʱ¼ä×Ö·û´«  
 | 
    logoffTimeStr = curPlayer.GetLogoffTime()  
 | 
  
 | 
    if logoffTimeStr == "" or logoffTimeStr == '0':  
 | 
        return  
 | 
  
 | 
    logoffTime = GameWorld.GetDateTimeByStr(logoffTimeStr)  
 | 
      
 | 
    limitTime = GameWorld.GetDateTimeByStr(ReadChConfig.GetEvalChConfig('PlayerRecall_TimeLimit'))  
 | 
      
 | 
    #¼Ç¼ÒÑÓÐÌìÊýºÍÐÂÌìÊý±äÁ¿  
 | 
    newOffDays = offDays = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_OffDaysAward)  
 | 
      
 | 
    #Åжϻʱ¼ä  
 | 
    if logoffTime > limitTime:  
 | 
        #֮ǰµÄÀëÏßδÁìÈ¡ÀñÎïµÄÅж¨  
 | 
        if  offDays == 0:  
 | 
            return  
 | 
      
 | 
    else:  
 | 
        loginTime = GameWorld.GetDateTimeByStr(GameWorld.GetCurrentDataTimeStr())  
 | 
        diffTime = loginTime - logoffTime  
 | 
          
 | 
        #¼Ç¼ÐÂʱ¼ä  
 | 
        newOffDays = diffTime.days  
 | 
        if newOffDays < Def_Base_OffDay:   
 | 
            if offDays == 0:  
 | 
                #ʱ¼ä²»×ã  
 | 
                return  
 | 
              
 | 
            #»ñÈ¡Éϴν±Àø£¬¾ÉµÄ½±Àø²»¸üÐÂ×ֵ䣬ÔÑù֪ͨ  
 | 
            newOffDays = offDays  
 | 
        else:  
 | 
            #³õʼ»¯Ò»´Î£¬±ÜÃ⿪¹ØÊ§°Ü  
 | 
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_CheckInviteCode, 0)  
 | 
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_OffDaysAward, newOffDays)  
 | 
          
 | 
    #֪ͨÓÐÀñÎï¿ÉÁì  
 | 
    curPlayer.Sync_PlayerBeRecalledInfo(newOffDays)  
 | 
      
 | 
    #·Ç0±íʾÒÑ·¢ËÍ  
 | 
    if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_CheckInviteCode) != 0:  
 | 
        #֪ͨ¿Í»§¶ËÒÑ·¢Ë͹ýÑûÇëÂë  
 | 
        curPlayer.Sync_PlayerBeRecalledInfo(0)  
 | 
      
 | 
    return  
 | 
  
 | 
#===============================================================================  
 | 
# //03 3D ÁìÈ¡±»Õٻؽ±Àø#tagCReceiveBeRecalledReward  
 | 
# struct tagCReceiveBeRecalledReward  
 | 
# {  
 | 
#         tagHead Head;  
 | 
# };  
 | 
#===============================================================================  
 | 
##Íæ¼Ò»Ø¹é½±Àø  
 | 
#@param index Íæ¼ÒË÷Òý  
 | 
#@param tick Ê±¼ä´Á  
 | 
#@return ·µ»ØÖµÎÞÒâÒå  
 | 
def PlayerBackAward(index, tick):  
 | 
    if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open:  
 | 
        return  
 | 
      
 | 
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  
 | 
      
 | 
    playerLV = curPlayer.GetLV()  
 | 
    if playerLV < Def_Base_LV:  
 | 
        return  
 | 
      
 | 
    offDays = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_OffDaysAward)  
 | 
    if offDays == 0:  
 | 
        return  
 | 
      
 | 
    lvList = ReadChConfig.GetEvalChConfig('PlayerRecall_OffDays')  
 | 
      
 | 
    #µÈ¼¶  
 | 
    offDaysList = GameWorld.GetResultByRiseList(lvList, playerLV)  
 | 
    if offDaysList == None:  
 | 
        GameWorld.ErrLog("PlayerBackAward, LVErr LV=%s, award=%s"%(playerLV, lvList))  
 | 
        return  
 | 
      
 | 
    #ÀëÏßÌìÊý  
 | 
    itemList = GameWorld.GetResultByRiseList(offDaysList, offDays)  
 | 
    if itemList == None:  
 | 
        GameWorld.ErrLog("PlayerBackAward, offDaysErr LV=%s, offDays=%s, award=%s"%(playerLV, offDays, lvList))  
 | 
        return  
 | 
      
 | 
    itemID, count = itemList  
 | 
      
 | 
    #°ÑµØÍ¼ÎïÆ··Åµ½±³°üÖÐ  
 | 
    dataDict = {'PlayerLV':playerLV, 'OffDays':offDays}  
 | 
    if not ItemControler.GivePlayerItem(curPlayer, itemID, count, True, [IPY_GameWorld.rptItem], True,  
 | 
                                        showSysInfo=True, event=["PlayerBackAward", True, dataDict]):  
 | 
        return  
 | 
      
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_OffDaysAward, 0)  
 | 
    return  
 | 
  
 | 
#===============================================================================  
 | 
# //03 3E ±»ÕÙ»ØÍæ¼Ò·¢ËÍÑûÇëÂë#tagCBeRecalledInviteCode  
 | 
# struct tagCBeRecalledInviteCode  
 | 
# {  
 | 
#         tagHead Head;  
 | 
#         DWORD InviteCode; // ÑûÇëÂë  
 | 
# };  
 | 
#===============================================================================  
 | 
##Íæ¼Ò»Ø¹é½±Àø  
 | 
#@param index Íæ¼ÒË÷Òý  
 | 
#@param tick Ê±¼ä´Á  
 | 
#@return ·µ»ØÖµÎÞÒâÒå  
 | 
def RecallInviteCode(index, tick):  
 | 
    if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open:  
 | 
        return  
 | 
          
 | 
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  
 | 
      
 | 
    #ÑûÇëÂëµÈ¼¶ÏÞÖÆ  
 | 
    if curPlayer.GetLV() < Def_Base_LV:  
 | 
        return  
 | 
      
 | 
    #Ìí¼Ó×ÖµäÓÃÓÚÔÚGameServer »Ø¸´ÏûϢǰ£¬ÏÞÖÆ·¢°ü£¬Î´È·ÈϽá¹û  
 | 
    if curPlayer.GetDictByKey(ChConfig.Def_Player_NoSave_Dict_SendInviteCode) == 1:  
 | 
        return  
 | 
      
 | 
    curPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_SendInviteCode, 1)  
 | 
      
 | 
    if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_CheckInviteCode) == 1:  
 | 
        #´æÓÚÊý¾Ý¿âÖУ¬¼Ç¼ÄãÕæµÄÌá½»¹ýÑûÇëÂë²¢³É¹¦  
 | 
        return  
 | 
         
 | 
    pack = IPY_GameWorld.IPY_CBeRecalledInviteCode()  
 | 
    inviteCode = pack.GetInviteCode()  
 | 
  
 | 
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetPlayerID(), 0,   
 | 
                                                              int(inviteCode), 'SendInviteCode', '', 0)  
 | 
      
 | 
    return  
 | 
      
 | 
      
 | 
     
 |