| #!/usr/bin/python  | 
| #-*- coding: GBK -*-  | 
| #----------------------------------------------------------------------------------------------------  | 
| #  | 
| #----------------------------------------------------------------------------------------------------  | 
| #  | 
| ##@package PlayerNewGuyCard.py  | 
| # ÐÂÊÖ¿¨  | 
| #  | 
| # @author wdb  | 
| # @date 2012-05-07  | 
| # @version 3.2  | 
| #  | 
| # ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  | 
| # @change: "2012-05-07 18:30" wdb ÐÞ¸ÄʹÓÃÒ»¸ö×Öµä¼Ç¼ʹÓÃÐÂÊÖ¿¨Çé¿ö  | 
| # @change: "2012-05-14 15:30" wdb ´úÂëÓÅ»¯ÐÞ¸Ä  | 
| # @change: "2012-06-15 11:00" wdb Î´¼Ç¼·À·¶Ê±¼ä¼ä¸ô  | 
| # @change: "2012-06-19 12:00" wdb c++½Ó¿ÚÐ޸Ġ  | 
| # @change: "2012-06-21 15:30" wdb Ôö¼ÓʹÓÃgm¹¤¾ßÔÙdbÖвåÈëÐÂÊÖ¿¨·½Ê½   | 
| # @change: "2012-06-27 12:00" wdb È¥³ýÐÂÊÖ¿¨ÀàÐÍ×î´ó29ÏÞÖÆ£¬´óÓë29ÀàÐͲ»¼Ç¼´óÍæ¼Ò×Öµä  | 
| # @change: "2012-07-05 11:00" wdb ²éѯ·µ»Ø½á¹ûÀàÐÍСÓÚ1ʱ£¬Åж¨Îª¿¨ºÅ²»ÕýÈ·  | 
| # @change: "2012-07-05 12:00" wdb È¥³ýÅä±íÊÇ·ñÕýÈ·ÅÐ¶Ï  | 
| # @change: "2013-11-14 16:30" hxp »Ö¸´ÐÂÊÖ¿¨¹¦ÄÜ  | 
| # @change: "2014-12-12 16:00" hxp ÐÞ¸ÄÐÂÊÖ¿¨Öظ´Ê¹ÓùæÔòÂß¼£»¿¨ÀàÐÍ×î´óÖ§³ÖÀàÐ͵½255  | 
| # @change: "2014-12-28 23:10" ljd Ôö¼ÓÖ¸¶¨Õ˺ÅÐÂÊÖ¿¨Ê¹Óà  | 
| # @change: "2014-12-29 15:30" hxp Ö¸¶¨Õ˺ÅÐÂÊÖ¿¨Ê¹ÓÃÔö¼ÓÀۼƳäÖµ×êʯÊýÏÞÖÆ  | 
| # @change: "2015-01-07 14:10" ljd ÐÞ¸ÄÖ¸¶¨Õ˺ÅÐÂÊÖ¿¨ÑéÖ¤¹æÔò  | 
| # @change: "2015-05-25 19:30" hxp Ôö¼ÓͨÓÃÐÂÊÖ¿¨  | 
| # @change: "2015-06-06 15:30" hxp ÐÞ¸´ÈÕÖ¾Êä³ö±¨´í  | 
| # @change: "2015-06-08 20:30" hxp Ôö¼ÓÁ÷Ïòʼþ»ã±¨  | 
| # @change: "2015-08-13 14:00" ljd ¿ÉÖØ¸´ÁìÈ¡µÄ¿¨ÏÞÖÆÈÕÁìÈ¡´ÎÊý  | 
| # @change: "2016-07-30 19:00" hxp Ö¸¶¨Õ˺ÅÐÂÊÖ¿¨Ö§³Öͨ·þ¿¨ºÅ  | 
| # @change: "2016-08-15 20:00" hxp ´úÂëÕûÀí£»Ôö¼Ó¿ÉÅäÖÃÓÐЧÈÕÆÚ  | 
| # @change: "2016-08-31 20:00" hxp Í¨Óÿ¨¿É°ó¶¨³£¹æ¿¨ÀàÐÍ; Í³¼ÆÐÂÊÖ¿¨Ê¹ÓÃʼþ  | 
| # @change: "2017-05-26 14:00" hxp Ôö¼ÓаæÃ½Ì忨·¢·Å½±ÀøÖ§³Ö  | 
| # @change: "2017-07-01 15:30" hxp Æ½Ì¨ÐÅÏ¢¸ÄΪ´ÓÍæ¼ÒÕ˺ÅÖÐÈ¡£¬Ö§³Ö»ì·þ  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-07-01 15:30"""  | 
| #---------------------------------------------------------------------  | 
| #µ¼Èë  | 
| import GameWorld  | 
| import IPY_GameWorld  | 
| import ChConfig  | 
| import ReadChConfig  | 
| import PlayerControl  | 
| import ItemControler  | 
| import EventReport  | 
| import ItemCommon  | 
| import DataRecordPack  | 
| import PlayerCoin  | 
|   | 
| import md5  | 
| #---------------------------------------------------------------------  | 
| # Ö¸¶¨Õ˺ÅÉú³ÉµÄÐÂÊÖ¿¨±êʶ  | 
| MarkIdCardFlag = 'v'  | 
| # GM¹¤¾ßÉú³ÉµÄÐÂÊÖ¿¨±êÖ¾  | 
| StoreInDBCardFlag = 'n'  | 
|   | 
| (  | 
| Def_NCard_KeyList, # Éú³É¿¨ËùÓõÄkeyÁÐ±í  | 
| Def_NCard_Notify, # ÒÑÁìÈ¡¹ýµÄÌáʾ  | 
| Def_NCard_RepeatCnt, # Ã¿ÈÕ¿ÉÖØ¸´ÁìÈ¡´ÎÊý  | 
| Def_NCard_ItemInfo, # (ÎïÆ·ID, ÎïÆ·ÊýÁ¿, ÊÇ·ñ°ó¶¨)  | 
| Def_NCard_ValidTime, # ÓÐЧÈÕÆÚ¸ñʽyyyy-MM-dd hh:mm:ss  | 
| Def_NCard_WriteEvent, # ÊÇ·ñ¼Ç¼ʹÓÃʼþ  | 
| ) = range(6)  | 
|   | 
| #=======================================================================================================================  | 
| #//A5 10  Ê¹ÓÃÐÂÊÖ¿¨ #tagUseNewGuyCard  | 
| #  | 
| #struct    tagUseNewGuyCard  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        CodeStrLen;  | 
| #    char        CodeStr[CodeStrLen];        //size = CodeStrLen  | 
| #};  | 
| #=======================================================================================================================  | 
| ## Ê¹ÓÃÐÂÊÖ¿¨  | 
| #  @param index Ë÷Òý  | 
| #  @param clientData ·â°ü½á¹¹Ìå  | 
| #  @param tick Ê±¼ä´Á  | 
| #  @return None  | 
| def UseNewGuyCard(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|   | 
|     if tick - curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_NewGuyCard) \  | 
|             <= ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_NewGuyCard]:  | 
|         #ÐÂÊÖ¿¨²éѯʱ¼ä¼ä¸ô  | 
|         return  | 
|       | 
|     codeStr = clientData.CodeStr    | 
|     GameWorld.DebugLog("ʹÓÃÐÂÊÖ¿¨ codeStr=%s" % codeStr, curPlayer.GetPlayerID())  | 
|       | 
|     curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_NewGuyCard, tick)  | 
|       | 
|     # ÕýÔÚ²éѯÖÐ  | 
|     if curPlayer.GetQueryNewGuyCardState() == IPY_GameWorld.qngcsQuerying:  | 
|         GameWorld.DebugLog("    ÕýÔÚ²éѯÖÐ")  | 
|         return  | 
|       | 
|     # ±³°ü¿Õ¼ä²»×ã  | 
|     if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])  | 
|         return  | 
|       | 
|     # ¿¨ÖÖ1: Í¨Óÿ¨¼ì²â  | 
|     if UseCommonNewGuyCard(curPlayer, codeStr):  | 
|         return  | 
|       | 
|     # ¿¨ÖÖ2: Ö¸¶¨Õ˺ſ¨¼ì²â  | 
|     if UseAccIDNewGuyCard(curPlayer, codeStr):  | 
|         return  | 
|       | 
|     # ¿¨ÖÖ3: GM¹¤¾ßÉú³ÉµÄп¨£¬Ê¹ÓÃÇé¿öÒÑÈ«²¿¼Ç¼ÔÚÊý¾Ý¿âÖУ¬Ö±½Ó²éѯ  | 
|     if codeStr.startswith(StoreInDBCardFlag):  | 
|         # ÇëÇó¿¨ÊÇ·ñ±»Ê¹Óùý  | 
|         GameWorld.DebugLog("    ÊÇGM¹¤¾ßÉú³ÉµÄ¿¨, ²éѯGM¹¤¾ßÉú³É¿¨ÊÇ·ñ±»Ê¹Óùý")  | 
|         curPlayer.SendQueryNewGuyCardState(codeStr)  | 
|         return  | 
|       | 
|     # ¿¨ÖÖ4: ·ÇGM¹¤¾ßÉú³ÉµÄ¾É¿¨£¬Òª½âÎö»ñµÃ¿¨µÄÀàÐÍ  | 
|     curCardType, notifyMsg, dailyGetCnt = GetNewGuyCardType(codeStr)  | 
|       | 
|     GameWorld.DebugLog("    ·ÇGM¹¤¾ßÉú³ÉµÄ¾É¿¨,curCardType=%s,notifyMsg=%s,dailyGetCnt=%s" % (curCardType, notifyMsg, dailyGetCnt))  | 
|   | 
|     # ¼Ù¿¨  | 
|     if curCardType <= 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_161234")  | 
|         return  | 
|   | 
|     # ²»¿ÉÖØ¸´ÁìÈ¡µÄ£¬ÑéÖ¤Íæ¼ÒÊÇ·ñÒÑÓùý¸ÃÀàÐÍ¿¨; ¿ÉÖØ¸´ÁìÈ¡µÄÑé֤ÿÈÕʹÓôÎÊýÉÏÏÞ  | 
|     if not dailyGetCnt:  | 
|         if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardState, curCardType):  | 
|             PlayerControl.NotifyCode(curPlayer, notifyMsg)  | 
|             return  | 
|     else:  | 
|         repeatGotNum = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_UseNewGuyCardNum % curCardType)  | 
|         if repeatGotNum >= dailyGetCnt:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_lwh_372238")  | 
|             return  | 
|           | 
|     # ÇëÇó¿¨ÊÇ·ñ±»Ê¹Óùý  | 
|     curPlayer.SendQueryNewGuyCardState(codeStr)  | 
|       | 
|     # ¼Ç¼²éѯµÄÀàÐÍ£¬ºÍkeyµÄλÖà  | 
|     curPlayer.SetDict(ChConfig.Def_PlayerKey_QueryNewGuyCardType, curCardType)  | 
|     return  | 
|   | 
| ## Í¨ÓÃÐÂÊÖ¿¨Ê¹Óà  | 
| #  @param curPlayer  | 
| #  @param codeStr ¿¨ºÅ  | 
| #  @return False-·Ç¸ÃÖÖÀ࿨; True-ÊǸÃÖÖÀ࿨  | 
| def UseCommonNewGuyCard(curPlayer, codeStr):  | 
|     CommonCardDict = ReadChConfig.GetEvalChConfig("CommonCardData")  | 
|     if codeStr not in CommonCardDict:  | 
|         GameWorld.DebugLog("    ·ÇͨÓÿ¨£¡%s" % (codeStr))  | 
|         return False  | 
|       | 
|     # ÒÔϱØÐë¶¼·µ»Ø True, ´ú±íÊǸÿ¨ÖÖ  | 
|     cardIndex, itemInfo, hadUseNotify, needLV, needGold, validTime, cardType, isEventLog = CommonCardDict[codeStr]  | 
|     if needLV > 0 and curPlayer.GetLV() < needLV:          | 
|         PlayerControl.NotifyCode(curPlayer, "LvErr")  | 
|         return True  | 
|       | 
|     if needGold > 0:  | 
|         Def_CoinRate = PlayerCoin.GetCoinRate()  | 
|         coinPointTotal = curPlayer.GetChangeCoinPointTotal()  | 
|         if coinPointTotal * Def_CoinRate < needGold:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_hgg_676165", [needGold])  | 
|             return True  | 
|           | 
|     isUsed = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_CommonNewGuyCardState, cardIndex)  | 
|     if isUsed:  | 
|         PlayerControl.NotifyCode(curPlayer, hadUseNotify)  | 
|         return True  | 
|       | 
|     # ´óÓÚ0Ôò¶ÔÓ¦ NewGuyCardKey.txt ¼° StoreInDBCardData.txt ÖеĿ¨ÀàÐÍ, Á½Õß°ó¶¨, ½ö¿Éͨ¹ýÆäÖÐÒ»ÖÖ·½Ê½Ê¹ÓÃÒ»´Î  | 
|     if cardType > 0:  | 
|         if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardState, cardType):  | 
|             PlayerControl.NotifyCode(curPlayer, hadUseNotify)  | 
|             return True  | 
|           | 
|     if validTime != "" and GameWorld.GetPastSeconds(validTime) >= 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_795514")  | 
|         return True  | 
|       | 
|     #¸øÓèÎïÆ·  | 
|     itemID, itemCnt, isBand = itemInfo  | 
|     if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem]):  | 
|         #±³°ü¿Õ¼ä²»×ã  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])  | 
|         return True  | 
|       | 
|     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_CommonNewGuyCardState, cardIndex, 1) # ¸üиÃÍæ¼ÒÒÑʹÓøÿ¨  | 
|     #PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [itemID, itemCnt])  | 
|     DoUseReport(curPlayer, codeStr, "CommonCard", itemID, itemCnt) # ¼ÇÂ¼Íæ¼ÒʹÓÃÐÂÊÖ¿¨  | 
|       | 
|     if cardType > 0:  | 
|         GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardState, cardType, 1)  | 
|           | 
|     if isEventLog:  | 
|         itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|         itemName = itemID if not itemData else itemData.GetName()  | 
|         #EventReport.WriteEvent_custom_events(curPlayer, EventReport.Def_Custom_Events_CommonCard % codeStr, itemName)  | 
|       | 
|     GameWorld.DebugLog("ͨÓÿ¨Ê¹ÓÃOK£¡codeStr=%s,cardType=%s,itemID=%s,itemCnt=%s" % (codeStr, cardType, itemID, itemCnt))  | 
|     return True  | 
|   | 
| ## Ê¹ÓÃÖ¸¶¨Õ˺ſ¨ºÅ  | 
| #  @param curPlayer  | 
| #  @param codeStr ¿¨ºÅ  | 
| #  @return False-·Ç¸ÃÖÖÀ࿨; True-ÊǸÃÖÖÀ࿨  | 
| def UseAccIDNewGuyCard(curPlayer, codeStr):  | 
|     idflagLen = len(MarkIdCardFlag)  | 
|     if not (len(codeStr) == idflagLen + 32 and MarkIdCardFlag == codeStr[:idflagLen]):  | 
|         GameWorld.DebugLog("    ·ÇÖ¸¶¨Õ˺ſ¨ºÅ£¡%s" % (codeStr))  | 
|         return False  | 
|       | 
|     # ÒÔϱØÐë¶¼·µ»Ø True, ´ú±íÊǸÿ¨ÖÖ  | 
|     cardBack = CheckMarkIdCardRule(curPlayer, codeStr)  | 
|     if cardBack == None:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_161234")  | 
|         return True  | 
|               | 
|     cardIndex, cardInfo = cardBack  | 
|     codeKey, itemInfo, hadUseNotify, validTime = cardInfo  | 
|       | 
|     isUsed = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_IDNewGuyCardState, cardIndex)  | 
|     if isUsed:  | 
|         PlayerControl.NotifyCode(curPlayer, hadUseNotify)  | 
|         return True  | 
|       | 
|     if validTime != "" and GameWorld.GetPastSeconds(validTime) >= 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_795514")  | 
|         return True  | 
|   | 
|     #¸øÓèÎïÆ·  | 
|     itemID, itemCnt, isBand = itemInfo  | 
|     GameWorld.DebugLog("    itemInfo=%s" % str(itemInfo))  | 
|     if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem]):  | 
|         #±³°ü¿Õ¼ä²»×ã  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])  | 
|         return True  | 
|       | 
|     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_IDNewGuyCardState, cardIndex, 1)  # ¸üиÃÍæ¼ÒÒÑʹÓøÿ¨  | 
|     #PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [itemID, itemCnt])  | 
|     DoUseReport(curPlayer, codeStr, "AccIDCard", itemID, itemCnt) # ¼ÇÂ¼Íæ¼ÒʹÓÃÐÂÊÖ¿¨  | 
|       | 
|     GameWorld.DebugLog("Ö¸¶¨Õ˺ſ¨Ê¹ÓÃOK£¡codeKey=%s,codeStr=%s,cardIndex=%s,itemID=%s,itemCnt=%s"   | 
|                        % (codeKey, codeStr, cardIndex, itemID, itemCnt), curPlayer.GetPlayerID())  | 
|     return True  | 
|   | 
| ## ÊÇ·ñ·ûºÏÖ¸¶¨Õ˺ÅÉú³Éп¨¹æÔò  | 
| #  @param cardCode ¿¨ºÅ  | 
| #  @return ÐòºÅ  | 
| def CheckMarkIdCardRule(curPlayer, cardCode):  | 
|     idName = curPlayer.GetAccID()  | 
|     platform = GameWorld.GetPlayerPlatform(curPlayer)  | 
|     platFormIdName = GameWorld.GetPlatformAccID(idName)  | 
|     markIdCardData = ReadChConfig.GetEvalChConfig("IDMarkCardData")  | 
|     for cardIndex, cardInfo in markIdCardData.items():  | 
|         codeKey = cardInfo[0]  | 
|         markMD5 = md5.md5('wyOu' + platform + codeKey).hexdigest()  | 
|           | 
|         # Æ½Ì¨Õ˺Åͨ·þ¿¨ºÅ  | 
|         md5PlatFormId = md5.md5(markMD5 + platFormIdName).hexdigest()  | 
|         if MarkIdCardFlag + md5PlatFormId == cardCode:  | 
|             return cardIndex, cardInfo  | 
|   | 
|         # ¶ÔÓ¦ÓÎÏ·Çø·þÕ˺ſ¨ºÅ  | 
|         md5Id = md5.md5(markMD5 + idName).hexdigest()  | 
|         if MarkIdCardFlag + md5Id == cardCode:  | 
|             return cardIndex, cardInfo  | 
|     return  | 
|   | 
| ## =================================================================================================  | 
|   | 
| ## ÑéÖ¤²¢»ñµÃÐÂÊÖ¿¨µÄÀàÐÍ  | 
| #  @param codeStr ¿¨ºÅ  | 
| #  @return None  | 
| def GetNewGuyCardType(codeStr):  | 
|     curCardType = 0  | 
|     notifyMsg = ""  | 
|     dailyGetCnt = 0 # Ã¿ÈÕ¿ÉÖØ¸´ÁìÈ¡´ÎÊý  | 
|     NewGuyCardKeyDict = ReadChConfig.GetEvalChConfig("NewGuyCardKey")  | 
|     if NewGuyCardKeyDict == {} or NewGuyCardKeyDict == None:  | 
|         return curCardType, notifyMsg, dailyGetCnt  | 
|       | 
|     # »ñµÃ¿¨µÄË÷Òý  | 
|     keyStr, cardIndex = GetCardInfo(codeStr)  | 
|   | 
|     # ÊÇ·ñÊÇÐÂÊÖ¿¨»òÕßýÌ忨  | 
|     for cardType, values in NewGuyCardKeyDict.items():  | 
|           | 
|         for key in values[Def_NCard_KeyList]:  | 
|                       | 
|             # ÊÇ·ñÓëkeyÆ¥Åä  | 
|             if GetRealCardStr(keyStr, cardIndex, key) != codeStr:  | 
|                 continue  | 
|               | 
|             curCardType = cardType  | 
|             notifyMsg = values[Def_NCard_Notify]  | 
|             dailyGetCnt = values[Def_NCard_RepeatCnt]  | 
|             break   | 
|       | 
|     return curCardType, notifyMsg, dailyGetCnt  | 
|   | 
|   | 
| ## »ñµÃ¶ÔÓ¦ÕýÈ·µÄ¿¨ºÅ  | 
| #  @param codeStr ¿¨ºÅ  | 
| #  @param mark ÑéÖ¤key  | 
| #  @return None  | 
| def GetRealCardStr(keyStr, cardIndex, mark):  | 
|     key = 'CJC729058'  | 
|       | 
|     #Ë÷Òý×Ö·û·±¶      | 
|     markMD5 = md5.md5('wyOu' + mark).hexdigest()  | 
|     realStr = str(cardIndex) * 2 + markMD5 + key  | 
|     result = md5.md5(realStr).hexdigest()  | 
|   | 
|     return (result[:3] + keyStr + result[-3:])  | 
|   | 
|   | 
| ## »ñµÃ¿¨ºÅÐÅÏ¢  | 
| #  @param codeStr ¿¨ºÅ  | 
| #  @return None  | 
| def GetCardInfo(codeStr):  | 
|     xorkey = 11784950  | 
|       | 
|     cardIndex = -1  | 
|     keyStr = ''  | 
|       | 
|     if len(codeStr) <= 6:        | 
|         return keyStr, cardIndex  | 
|       | 
|     # È¥³ý¼ÓÃÜ×Ö¶Î  | 
|     keyStr = codeStr[3:]  | 
|     keyStr = keyStr[:-3]  | 
|       | 
|     try:  | 
|         indexNum = int(keyStr, 16)  | 
|     except ValueError:  | 
|         return keyStr, cardIndex  | 
|       | 
|     cardIndex = indexNum ^ xorkey  | 
|     return keyStr, cardIndex  | 
|       | 
|       | 
| ## ²éѯ»Ø¸´  | 
| #  @param index Ë÷Òý  | 
| #  @param tick Ê±¼ä´Á  | 
| #  @return None  | 
| def QueryNewGuyCardState(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|   | 
|     # ÒѾʹÓùý  | 
|     if curPlayer.GetNewGuyCardIsUsed():  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_543685")  | 
|         return  | 
|       | 
|     dbValidTime = curPlayer.GetNewGuyCardValidTime()  | 
|     if dbValidTime != '':  | 
|         # ½Ó¿ÚÖÐΪµ±Ç°Ê±¼ä¼õ´«Èë²ÎÊýʱ¼ä, ½á¹û´óÓÚ0£¬Ôò¿¨ÒѹýÆÚ      | 
|         if GameWorld.GetPastSeconds(dbValidTime) >= 0:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_pan_795514")  | 
|             return  | 
|       | 
|     # »ñµÃµ±Ç°µÄÐÂÊÖ¿¨ÐÅÏ¢  | 
|     newGuyCardStr = curPlayer.GetNewGuyCardID()  | 
|     validTime = ""  | 
|     itemInfo = None  | 
|     dailyGetCnt = 0 # Ã¿ÈÕ¿ÉÖØ¸´ÁìÈ¡´ÎÊý  | 
|     isWriteEvent = False # ÊÇ·ñдʹÓÃʼþ  | 
|       | 
|     GameWorld.DebugLog("    ÐÂÊÖ¿¨Ê¹Óûظ´£ºnewGuyCardStr=%s" % (newGuyCardStr), curPlayer.GetPlayerID())  | 
|       | 
|     # ÅжÏÊÇ·ñΪgm¹¤¾ßÉú³ÉµÄп¨  | 
|     if newGuyCardStr.startswith(StoreInDBCardFlag):          | 
|         curCardType = curPlayer.GetNewGuyCardCardType()  | 
|         GameWorld.DebugLog("    GM¹¤¾ßÉú³ÉµÄDBп¨ curCardType=%s" % curCardType)  | 
|         if curCardType <= 0:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_pan_161234")  | 
|             return  | 
|           | 
|         # »ñµÃÎïÆ·ÐÅÏ¢  | 
|         StoreInDBCardData = ReadChConfig.GetEvalChConfig("StoreInDBCardData")  | 
|         cardTypeInfo = StoreInDBCardData.get(curCardType)  | 
|         if cardTypeInfo == None:  | 
|             return  | 
|           | 
|         itemInfo, notifyMsg, dailyGetCnt, validTime = cardTypeInfo  | 
|               | 
|         # Íæ¼ÒÒÑÓùý¸ÃÀàÐÍ¿¨  | 
|         if not dailyGetCnt and GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardState, curCardType):  | 
|             PlayerControl.NotifyCode(curPlayer, notifyMsg)  | 
|             return   | 
|           | 
|     else:  | 
|         curCardType = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_QueryNewGuyCardType)  | 
|         GameWorld.DebugLog("    Ëã·¨Éú³ÉµÄ¿¨ curCardType=%s" % (curCardType))  | 
|           | 
|         # »ñÈ¡¿¨µÄkey  | 
|         newGuyCardkeyDict = ReadChConfig.GetEvalChConfig("NewGuyCardKey")  | 
|         cardTypeInfo = newGuyCardkeyDict.get(curCardType)  | 
|         if cardTypeInfo == None:  | 
|             return  | 
|           | 
|         dailyGetCnt = cardTypeInfo[Def_NCard_RepeatCnt]  | 
|         itemInfo = cardTypeInfo[Def_NCard_ItemInfo]  | 
|         validTime = cardTypeInfo[Def_NCard_ValidTime]  | 
|         isWriteEvent = cardTypeInfo[Def_NCard_WriteEvent]  | 
|       | 
|     if validTime != "" and GameWorld.GetPastSeconds(validTime) >= 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_795514")  | 
|         return  | 
|           | 
|     if itemInfo == None:  | 
|         GameWorld.ErrLog('QueryNewGuyCardResult-> Get new guy card item info error:None')  | 
|         return  | 
|       | 
|     # ²»¿ÉÖØ¸´ÁìÈ¡µÄ¿¨, ÉèÖøÄÖÖ¿¨ÒÑÁìÈ¡¹ý  | 
|     if not dailyGetCnt:  | 
|         GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardState, curCardType, 1)  | 
|     else:  | 
|         repeatGotNumKey = ChConfig.Def_Player_Dict_UseNewGuyCardNum % curCardType  | 
|         repeatGotNum = curPlayer.NomalDictGetProperty(repeatGotNumKey)  | 
|         if repeatGotNum >= dailyGetCnt:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_lwh_372238")  | 
|             return  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, repeatGotNumKey, repeatGotNum + 1)  | 
|       | 
|     #¸øÓèÎïÆ·  | 
|     itemID, itemCnt, isBand = itemInfo  | 
|     if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem]):  | 
|         #±³°ü¿Õ¼ä²»×ã  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])  | 
|         return  | 
|       | 
|     #PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [itemID, itemCnt]) # »ñµÃÎïÆ·Ìáʾ  | 
|     curPlayer.SendUpdateNewGuyCardState(newGuyCardStr, True, '', curCardType, validTime) # ¸ü¸ÄÐÂÊÖ¿¨Ê¹ÓÃ״̬  | 
|     DoUseReport(curPlayer, newGuyCardStr, curCardType, itemID, itemCnt, isWriteEvent) # ¼ÇÂ¼Íæ¼ÒʹÓÃÐÂÊÖ¿¨  | 
|       | 
|     GameWorld.DebugLog("    ÐÂÊÖ¿¨Ê¹ÓÃOK£¡newGuyCardStr=%s,curCardType=%s,dailyGetCnt=%s,itemID=%s,itemCnt=%s"   | 
|                        % (newGuyCardStr, curCardType, dailyGetCnt, itemID, itemCnt))  | 
|     return  | 
|   | 
|   | 
| ## Ê¹ÓÃÐÂÊÖ¿¨¼Ç¼»ã±¨  | 
| def DoUseReport(curPlayer, newGuyCardStr, curCardType, itemID, itemCnt, isWriteEvent=False):  | 
|     DataRecordPack.DR_UseNewGuyCard(curPlayer, newGuyCardStr, curCardType, itemID, itemCnt)  | 
|     #===========================================================================  | 
|     # playerName = curPlayer.GetPlayerName()  | 
|     # eventParam = "RoleID=%s,LV=%s,LVEx=%s,CreateRoleTime=%s,CardStr=%s,CardType=%s,ItemID=%s,ItemCount=%s" \  | 
|     #                % (playerName, curPlayer.GetLV(), curPlayer.GetLVEx(), curPlayer.GetCreateRoleTime(), \  | 
|     #                   newGuyCardStr, curCardType, itemID, itemCnt)  | 
|     # EventReport.EventReport(5015, eventParam, curPlayer)  | 
|     #   | 
|     # if isWriteEvent:  | 
|     #    itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|     #    itemName = itemID if not itemData else itemData.GetName()  | 
|     #    EventReport.WriteEvent_custom_events(curPlayer, EventReport.Def_Custom_Events_NewbieCard % curCardType, itemName)  | 
|     #===========================================================================  | 
|     return  | 
|   | 
| ## ÐÂÊÖ¿¨OnDay  | 
| #  @param curPlayer  | 
| #  @return  | 
| def NewGuyCardOnday(curPlayer):  | 
|     # Ëã·¨Éú³ÉµÄÐÂÊÖ¿¨  | 
|     NewGuyCardKeyDict = ReadChConfig.GetEvalChConfig("NewGuyCardKey")  | 
|     for cardType, cardData in NewGuyCardKeyDict.items():  | 
|         if cardData[Def_NCard_RepeatCnt] <= 0:  | 
|             continue  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardNum % cardType, 0)  | 
|       | 
|     # ²åÈëdbµÄÐÂÊÖ¿¨  | 
|     StoreInDBCardDataDict = ReadChConfig.GetEvalChConfig("StoreInDBCardData")  | 
|     for dbCardType, dbCardData in StoreInDBCardDataDict.items():  | 
|         if dbCardData[2] <= 0:  | 
|             continue  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_UseNewGuyCardNum % dbCardType, 0)  | 
|           | 
|     return  | 
|   | 
| def OnGMTGiveMediaCardAwardItem(curPlayer, cardType, cardCode, cardState):  | 
|     '''  | 
|     GM¹¤¾ß·¢·ÅýÌ忨½±ÀøÎïÆ·, ÕâÀïÖ»×ö·¢·Å½±ÀøÂß¼£¬¿¨µÄºÏ·¨ÐÔ¼°Ê¹ÓüǼÔÚýÌ忨ÖÐÐÄ·þÎñÆ÷ÅÐ¶Ï  | 
|     @param cardType: Ã½Ì忨ÖÐÐÄ·þÎñÆ÷ÉèÖõĿ¨ÀàÐÍ  | 
|     @param cardCode: Ã½Ì忨Âë  | 
|     @param cardState: ¸ÃÍæ¼Òµ±Ç°¿¨ÀàÐÍʹÓÃ״̬£¬ 0 ²»¿ÉÓã¬1.¿ÉÓ÷¢·Å½±Àø £¬2.Òѱ»ËûÈËʹÓà  | 
|     '''  | 
|     if cardState == 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_161234")  | 
|         return  | 
|     if cardState == 2:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_pan_543685")  | 
|         return  | 
|       | 
|     if cardState != 1:  | 
|         GameWorld.DebugLog("¸ÃýÌ忨״̬²»´¦Àí: cardState=%s" % cardState)  | 
|         return  | 
|       | 
|     if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseMediaCardState, cardType):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_admin_327925")  | 
|         return  | 
|       | 
|     platform = GameWorld.GetPlayerPlatform(curPlayer)  | 
|     MediaCardDict = ReadChConfig.GetEvalChConfig("MediaCard")  | 
|     commMediaCardDict, platformMediaCardDict = MediaCardDict  | 
|       | 
|     cardInfo = None  | 
|     if cardType in commMediaCardDict:  | 
|         cardInfo = commMediaCardDict[cardType]  | 
|     elif platform in platformMediaCardDict:  | 
|         curPlatformCardDict = platformMediaCardDict[platform]  | 
|         if cardType in curPlatformCardDict:  | 
|             cardInfo = curPlatformCardDict[cardType]  | 
|               | 
|     if cardInfo == None:  | 
|         GameWorld.ErrLog("ÕÒ²»µ½¸ÃýÌ忨ÀàÐÍÅäÖÃ, cardType=%s,platform=%s" % (cardType, platform))  | 
|         return  | 
|     awardItemMark, isWriteEvent = cardInfo  | 
|     MediaCardAwardItemDict = ReadChConfig.GetEvalChConfig("MediaCardAwardItem")  | 
|     if awardItemMark not in MediaCardAwardItemDict:  | 
|         GameWorld.ErrLog("ÕÒ²»µ½¸ÃýÌ忨ÎïÆ·Àñ°üÆ·ÖÖ¿âÅäÖÃ, cardType=%s,platform=%s,awardItemMark=%s"   | 
|                          % (cardType, platform, awardItemMark))  | 
|         return  | 
|     awardItemList = MediaCardAwardItemDict[awardItemMark]  | 
|       | 
|     packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, len(awardItemList))  | 
|     if len(awardItemList) > packSpace:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  | 
|         return  | 
|       | 
|     # ÉèÖÃÒÑʹÓùý¸ÃÀàÐÍ¿¨, ·¢·Å½±Àø  | 
|     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_UseMediaCardState, cardType, 1)  | 
|       | 
|     succGiveItemList = []  | 
|     for itemInfo in awardItemList:  | 
|         itemID, itemCount, itemBind = itemInfo[:3]  | 
|         isAppoint = itemInfo[3] if len(itemInfo) > 3 else 0  | 
|           | 
|         if isAppoint:  | 
|             isOK = ItemControler.GivePlayerAppointItem(curPlayer, itemID, False)  | 
|         else:  | 
|             isOK = ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])  | 
|         if isOK:  | 
|             succGiveItemList.append(itemInfo)  | 
|               | 
|     DataRecordPack.DR_UseMediaCard(curPlayer, cardCode, cardType, succGiveItemList)  | 
|     #if isWriteEvent:  | 
|     #    EventReport.WriteEvent_custom_events(curPlayer, EventReport.Def_Custom_Events_MediaCard % cardType, cardCode)  | 
|     return  | 
|   |