/// <summary> /// Loads contents of the config file. /// Debugs to Console if Error. /// </summary> /// <returns><c>String</c> to parse as class if config file was loaded, <c>null</c> otherwise.</returns> /// <param name="filePath">Path and Name of the file to be loaded.</param> private botConfig loadConfFile(string filePath) { botConfig data = new botConfig(); Debug.WriteLine("Loading config file."); try { if (!File.Exists(filePath)) { File.Create(filePath).Close(); // Create the file for the first time saveConfFile(filePath, dataToJson(data)); // Parse the empty class for the first time and Save It. } using (StreamReader sR = new StreamReader(filePath)) { filePathBackup = filePath; // crear una copia de la path data = JsonConvert.DeserializeObject <botConfig>(sR.ReadLine()); data.configPath = filePathBackup; // volver a escribir la copia tras leer el null isConfigLoaded = true; } } catch (IOException ex) { Debug.WriteLine("loadConfFile Error: " + ex.Message); } return(data); }
static void Main(string[] args) { jerpBot.checkCreateBotStorage(); jerpBot.checkCreateBotDatabase(); logger logGeneral = new logger("log_general.txt"); botConfig tempConfig = new botConfig(); botConnection connConfig; if (tempConfig.loaded && tempConfig.configData.connections.Count > 0) { connConfig = tempConfig.configData.connections[0]; } else { return; } jerpBot botGeneral = new jerpBot(logGeneral, tempConfig); raffle raffleModule = new raffle(botGeneral); quotes quoteModule = new quotes(botGeneral); customCommand customCommandModule = new customCommand(botGeneral); gameCommand gameCommandModule = new gameCommand(botGeneral); counter counterModule = new counter(botGeneral); queueSystem queueModule = new queueSystem(botGeneral); autoShoutout shoutoutModule = new autoShoutout(botGeneral); lurkShoutout lurkShoutModule = new lurkShoutout(botGeneral); messageRoll rollModule = new messageRoll(botGeneral); pollManager pollModule = new pollManager(botGeneral); soundCommands soundManager = new soundCommands(botGeneral); commandAlias aliasManager = new commandAlias(botGeneral); trivia triviaManager = new trivia(botGeneral); hydrateReminder hydrateManager = new hydrateReminder(botGeneral); delaySender delaySendManager = new delaySender(botGeneral); hostMessages hostMessageModule = new hostMessages(botGeneral); streamProfiles streamProfileManager = new streamProfiles(botGeneral); predictionManager streamPredictionManager = new predictionManager(botGeneral); customCommandModule.initTable(); gameCommandModule.initTable(); aliasManager.initTable(); botGeneral.customCommandModule = customCommandModule; botGeneral.gameCommandModule = gameCommandModule; botGeneral.soundCommandModule = soundManager; botGeneral.aliasModule = aliasManager; while (!botGeneral.isReadyToClose) { botGeneral.frame(); } }
public void setBotType(int c) { botConfig botConfig = botType.getBotByType(c); this.distMin = botConfig.distMin; this.distMax = botConfig.distMax;; this.timeBtwnAtks = botConfig.timeBtwnAtks; this.timeHoldingAtk = botConfig.timeHoldingAtk; this.ignoreSec = botConfig.ignoreSec; this.searchRandomPoints = botConfig.searchRandomPoints; typeOfBot = c; }
public static botConfig getBotByType(int i) { botConfig Bot = new botConfig(); switch (i) { case 0: //Default break; case 1: //Shooter Bot.distMin = new Vector2(1f, 0.5f); Bot.distMax = new Vector2(5f, 3f); Bot.timeBtwnAtks = 1f; Bot.timeHoldingAtk = 0.5f; break; case 2: //Jumper Bot.distMin = new Vector2(2f, 0f); Bot.distMax = new Vector2(4f, 5f); Bot.timeBtwnAtks = 4f; Bot.timeHoldingAtk = 1f; break; case 3: //ignora obj secudario Bot.ignoreSec = true; break; case 4: //target player Bot.searchRandomPoints = false; Bot.ignoreSec = true; break; default: break; } return(Bot); }
/// <summary> /// Loads the config from the file path (must include filename in path). /// </summary> public void loadConfig() { this.conf = this.loadConfFile(this.conf.configPath); }
/// <summary> /// Class that converts data to <c>String</c> /// </summary> /// <returns>JSON Parsed string</returns> /// <param name="data">Class to be serialized in JSON</param> private string dataToJson(botConfig data) { return(JsonConvert.SerializeObject(data)); }