| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| #  | 
| ##@package AILoginIn  | 
| # @todo: ×Ô¶¯×é¶Ó£¬¼Ó°ï»á£¬¼ÓºÃÓÑ  | 
| #  | 
| # @author:whx  | 
| # @date 2012-01-13 15:30  | 
| # @version 1.0  | 
|   | 
| # ¼òҪ˵Ã÷ ×Ô¶¯×é¶Ó£¬¼Ó°ï»á£¬¼ÓºÃÓÑ  | 
| # ÏêϸÃèÊö None  | 
|   | 
| import base64  | 
| from AI.AIBase import *  | 
| from Protocol.PacketsSend import tagCJoinFriendAnswer  | 
| from Protocol.PacketsSend import tagCTeamReq  | 
| from Protocol.PacketsSend import tagAskJoinFamilyReply  | 
| import logging  | 
| import datetime  | 
| import time  | 
|   | 
| from Robot.PlayerData import PlayerData  | 
|   | 
| VER = "2012-01-13 15:30"  | 
|   | 
|   | 
| ## µÇ½µÄʱºò¿ªÆô  | 
| #  | 
| # ¼Ì³ÐAIBase  | 
| class AIAutoAnswer(AIBase):  | 
|       | 
|     ## ËùÓÐAI±ØÐë²ÉÓÃÕâÖй̶¨µÄ³õʼ»¯ÔÐÍ£¬ÒÔ±ãAIMgr×Ô¶¯¼ÓÔØ  | 
|     #  @param None : None  | 
|     #  @return bool  | 
|     #  @remarks ´ËAI²»ÐèÒªÖÜÆÚÐÔ±»µ÷Óã¬ËùÒÔÉèÖÃΪ²»ÆôÓÃTimer  | 
|     def __init__(self, robot):  | 
|         #´ËAI²»ÐèÒªÖÜÆÚÐÔ±»µ÷Óã¬ËùÒÔÉèÖÃΪ²»ÆôÓÃTimer  | 
|         AIBase.__init__(self, robot, 0, False, False)  | 
|         self.SetActive(True)  | 
|         self.MapID = 0  | 
|   | 
|       | 
|     ## ÏòAIMgr×¢²áÏûÏ¢»Øµ÷º¯Êý  | 
|     #  @param None : None  | 
|     #  @return bool  | 
|     #  @remarks   | 
|     def _RegisterPacket(self, aiMgr):  | 
|         #ÊÇ·ñ¼ÓΪºÃÓÑ  | 
|         aiMgr.RegNetMsg(0x1101, self.AskJoinFriend, True)  | 
|         #ÊÇ·ñ×é¶Ó  | 
|         aiMgr.RegNetMsg(0x0901, self.OnInviteTeam, True)  | 
|         #ÊÇ·ñ¼ÓÈë°ï»á  | 
|         aiMgr.RegNetMsg(0x0F04, self.OnInviteFamily, True)  | 
|           | 
|       | 
|     ## ÊÇ·ñ¼ÓΪºÃÓÑ  | 
|     #  @param packData : ·â°ü¶ÔÏó  | 
|     #  @return None  | 
|     #  @remarks None  | 
|     def AskJoinFriend(self, packData):  | 
|           | 
|         queryName = packData.LeaderName  # ÑûÇëÈ˵ÄÃû×Ö  | 
|         queryID = packData.LeaderID  # ÑûÇëÈ˵ÄID  | 
|           | 
|         self.SendPackJoinFriend(queryID)  | 
|           | 
|         return  | 
|       | 
|       | 
|     ## ÊÇ·ñ×é¶Ó  | 
|     #  @param packData : ·â°ü¶ÔÏó  | 
|     #  @return None  | 
|     #  @remarks None  | 
|     def OnInviteTeam(self, packData):  | 
|         headerName = packData.Name  # ÑûÇëÈ˵ÄÃû×Ö  | 
|         headerID = packData.LeaderID  # ÑûÇëÈ˵ÄID  | 
|         teamType = packData.TeamType  # ×é¶ÓÀàÐÍ£¨1£ºÆÕͨ×é¶Ó£»2£ºÈÙÓþ×é¶Ó£©  | 
|           | 
|         #·¢°ü½ÓÊÜ×é¶Ó  | 
|         self.SendPackJoinTeam(headerID, teamType)  | 
|           | 
|         return  | 
|       | 
|       | 
|     ## ÊÇ·ñ¼ÓÈë°ï»á  | 
|     #  @param packData : ·â°ü¶ÔÏó  | 
|     #  @return None  | 
|     #  @remarks None  | 
|     def OnInviteFamily(self, packData):  | 
|         shaikhName = packData.LeaderName  # ÑûÇëÈ˵ÄÃû×Ö  | 
|         shaikhID = packData.LeaderID  # ÑûÇëÈ˵ÄID  | 
|         familyName = packData.FamilyName  # ¼Ò×åÃû  | 
|         familyID = packData.FamilyID  # ¼Ò×åID  | 
|           | 
|         #·¢°ü½ÓÊܼÓÈë°ï»á  | 
|         self.SendPackJoinFamily(shaikhID)  | 
|           | 
|         return  | 
|           | 
|       | 
|     ## ·¢°ü½ÓÊܼÓÈë°ï»á  | 
|     #  @param tagId : Ä¿±êid  | 
|     #  @return None  | 
|     #  @remarks None  | 
|     def SendPackJoinFamily(self, tagId):  | 
|         joinFamily = tagAskJoinFamilyReply()  | 
|         joinFamily.TagPlayerID = tagId  | 
|         joinFamily.IsOK = 1  | 
|           | 
|         self.robot.Send(joinFamily)  | 
|           | 
|           | 
|     ## ·¢°ü½ÓÊÜ×é¶Ó  | 
|     #  @param tagId : Ä¿±êid  | 
|     #  @return None  | 
|     #  @remarks None  | 
|     def SendPackJoinTeam(self, tagId, teamType):  | 
|         joinTeam = tagCTeamReq()  | 
|         joinTeam.PlayerID = tagId  | 
|         joinTeam.TeamType = teamType  # ÆÕͨ×é¶Ó  | 
|         joinTeam.Type = 1  # ½ÓÊÜÆÕͨ×é¶ÓÑûÇë  | 
|           | 
|         self.robot.Send(joinTeam)  | 
|       | 
|       | 
|     ## ·¢°ü½ÓÊܼÓΪºÃÓÑ  | 
|     #  @param tagId : Ä¿±êid  | 
|     #  @return None  | 
|     #  @remarks None  | 
|     def SendPackJoinFriend(self, tagId):  | 
|         joinFriend = tagCJoinFriendAnswer()  | 
|         joinFriend.Clear()  | 
|         joinFriend.TagID = tagId  | 
|         joinFriend.Answer = 1  # ½ÓÊܼÓΪºÃÓÑ  | 
|         self.robot.Send(joinFriend)  | 
|           | 
|       | 
|       | 
|       | 
|       | 
|           |