using System; using System.Data; using System.Text; using System.Threading; using System.Collections; using System.Collections.Generic; using Xoa.Virtual.Users; using Xoa.Virtual.Rooms.Bots; using Xoa.Virtual.Rooms; using Ion.Storage; namespace Xoa.Managers { /// /// Provides management for logged in users, aswell for retrieving details such as ID/name and vice versa from the database. /// public static class botManager { public static Hashtable _Bots = new Hashtable(); public static void Init() { DataColumn dLol; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dLol = dbClient.getColumn("SELECT id FROM roombots"); } int[] botIDs = dataHandling.dColToArray(dLol, null); for (int i = 0; i < botIDs.Length; i++) { virtualBot Bot = new virtualBot(botIDs[i]); _Bots.Remove(botIDs[i]); _Bots.Add(botIDs[i], Bot); } Out.WriteLine("Bot System Loaded Successfully"); } public static int getBotID(string userName) { using (DatabaseClient dbClient = Xoa.Eucalypt.dbManager.GetClient()) { return dbClient.getInt("SELECT id FROM roombots WHERE name = '" + userName + "' LIMIT 1"); } } public static virtualBot getBot(int userID) { try { return (virtualBot)_Bots[userID]; } catch { return null; } } /// /// Returns a virtualBot class for a certain Bot. /// /// The username of the bot. public static virtualBot getBot(string userName) { int userID = getBotID(userName); return getBot(userID); } } }