/// <summary> /// Handle the list bots command. This command lists /// information about the available and loaded bots. /// </summary> /// <param name="chatEvent"></param> private void HandleListBotsCommand(ChatEvent chatEvent) { // Create the bot spawn event BotListEvent listEvent = new BotListEvent(); try { // parse the spawn parameters from the message listEvent.PlayerId = chatEvent.PlayerId; // Send the spawn event to the core handler m_core.OnCoreEvent(this, listEvent); } catch (Exception e) { // Create the chat response message ChatPacket response = new ChatPacket(); // Set the response message information response.Event.PlayerId = chatEvent.PlayerId; response.Event.ChatType = ChatTypes.Private; // Set the response message response.Event.Message = e.Message; // Send the exception message to the player m_session.TransmitPacket(response); } }
/// <summary> /// Handle a bot list command to list all bots /// </summary> /// <param name="sender">Sending object</param> /// <param name="listEvent"></param> internal void HandleBotListEvent(object sender, BotListEvent listEvent) { // Send the response message to the bot BotInstance sourceBot = (sender as BotInstance); // Create the chat response packet ChatEvent response = new ChatEvent(); // Set the player Identifier to reply to response.PlayerId = listEvent.PlayerId; response.ChatType = ChatTypes.Private; response.Message = "< ================================================= >"; sourceBot.SendGameEvent(response); response.Message = "< BattleCore Configured Bots >"; sourceBot.SendGameEvent(response); response.Message = "< >"; sourceBot.SendGameEvent(response); response.Message = "< Name Arena Status >"; sourceBot.SendGameEvent(response); response.Message = "< ================================================= >"; sourceBot.SendGameEvent(response); foreach (BotInstance bot in m_activeBots.Values) { // Only list the bots configured for the same server if (bot.Settings.SessionSettings.ServerAddress == sourceBot.Settings.SessionSettings.ServerAddress) { // List the bot status as active response.Message = "< " + bot.Settings.SessionSettings.UserName.PadRight(24) + bot.Settings.SessionSettings.InitialArena.PadRight(16) + "ACTIVE >"; sourceBot.SendGameEvent(response); } } foreach (BotInstance bot in m_availableBots.Values) { // Only list the bots configured for the same server if (bot.Settings.SessionSettings.ServerAddress == sourceBot.Settings.SessionSettings.ServerAddress) { // List the bot as inactive response.Message = "< " + bot.Settings.SessionSettings.UserName.PadRight(24) + bot.Settings.SessionSettings.InitialArena.PadRight(16) + " >"; sourceBot.SendGameEvent(response); } } // Send the response message to the bot response.Message = "< ================================================= >"; sourceBot.SendGameEvent(response); }