static void Main(string[] args) { ICustomBot bot = null; Console.WriteLine("Please, select telegram or console bot type"); string inputValue = ""; while (bot == null) { inputValue = Console.ReadLine(); if (!String.IsNullOrWhiteSpace(inputValue)) { if (inputValue.ToLower() == "console") { bot = new ConsoleBot(); ((ConsoleBot)bot).OnInputValue += ConsoleRead; ((ConsoleBot)bot).OnOutputValue += ConsoleWrite; } else if (inputValue.ToLower() == "telegram") { bot = new TelegramBot(); ((TelegramBot)bot).OnLog += TelegramLog; } } } bot.Start(); if (inputValue == "telegram") { Console.ReadKey(); } bot.Run(); bot.Stop(); }
/// <summary>Play the match.</summary> /// <param name="player1"> /// Player 1. /// </param> /// <param name="player2"> /// Player 2. /// </param> private RoundResult PlayMatch(Bot player1, Bot player2) { using (var bot1 = ConsoleBot.Create(player1, BotLocations[player1.Info], CreateWriter(player1, player2))) { using (var bot2 = ConsoleBot.Create(player2, BotLocations[player2.Info], CreateWriter(player2, player1))) { return(PlayMatch(bot1, bot2)); } } }
public Extension(MainWindow MainWindowParent) { this.MainWindowParent = MainWindowParent; // Set main window. //Add extension event handlers OnDataInterceptEvent += Extension_OnDataInterceptEvent; OnDoubleClickEvent += Extension_OnDoubleClickEvent; OnConnectedEvent += Extension_OnConnectedEvent; OnCriticalErrorEvent += Extension_OnCriticalErrorEvent; // ConsoleBot = new ConsoleBot(this, "VB example"); // Instantiate a new ConsoleBot ConsoleBot.OnMessageReceived += ConsoleBot_OnMessageReceived; //Add ConsoleBot event handler }
public Extension(MainWindow MainWindowParent) { this.MainWindowParent = MainWindowParent; // Set main window. Ext = new GeodeExtension("ConsoleBotCSharp", "Geode examples.", "Lilith", true, false); // Instantiate extension //Add extension event handlers Ext.OnDataInterceptEvent += Extension_OnDataInterceptEvent; Ext.OnDoubleClickEvent += Extension_OnDoubleClickEvent; Ext.OnConnectedEvent += Extension_OnConnectedEvent; Ext.OnCriticalErrorEvent += Extension_OnCriticalErrorEvent; // Ext.Start(); // Start extension ConsoleBot = new ConsoleBot(Ext, "VB example"); // Instantiate a new ConsoleBot ConsoleBot.OnMessageReceived += ConsoleBot_OnMessageReceived; //Add ConsoleBot event handler }
/// <summary>Play the match.</summary> /// <param name="player1"> /// Player 1. /// </param> /// <param name="player2"> /// Player 2. /// </param> public RoundResult PlayMatch(ConsoleBot bot1, ConsoleBot bot2) { var bots = new Dictionary <PlayerType, ConsoleBot>() { { PlayerType.player1, bot1 }, { PlayerType.player2, bot2 }, }; var state = CreateState(); ApplySettings(bots); while (state.StartNewRound(this.Rnd)) { StartNewRound(bots, state); var lastaction = RunSubRounds(bots, state, state.OnButton); var pot = state.ApplyRoundResult(lastaction.GetResult()); SendResult(bots, state, pot, lastaction); if (bot1.TimedOut || bot2.TimedOut) { break; } } if (bot1.TimedOut) { state.Player2.Stack = state.Chips; state.Player1.Stack = 0; log.ErrorFormat("{0} timed out.", bot1.Bot.FullName); } else if (bot2.TimedOut) { state.Player1.Stack = state.Chips; state.Player2.Stack = 0; log.ErrorFormat("{0} timed out.", bot2.Bot.FullName); } var finalResult = state.Player1.Stack - state.Player2.Stack - state.BigBlind > 0 ? RoundResult.Player1Wins : RoundResult.Player2Wins; bot1.SetFinalResult(finalResult); bot2.SetFinalResult(finalResult); bot1.Bot.ElapsedMilliseconds += bot1.ElapsedMilliseconds; bot2.Bot.ElapsedMilliseconds += bot2.ElapsedMilliseconds; return(finalResult); }
public Extension(MainWindow MainWindowParent) { this.MainWindowParent = MainWindowParent; // Set main window. //Add extension event handlers OnDataInterceptEvent += Extension_OnDataInterceptEvent; OnDoubleClickEvent += Extension_OnDoubleClickEvent; OnConnectedEvent += Extension_OnConnectedEvent; OnCriticalErrorEvent += Extension_OnCriticalErrorEvent; // //Add gates hotkeys Key[] BindingKeys = { Key.D1, Key.D2, Key.D3, Key.D4, Key.D5, Key.D6, Key.D7, Key.D8, Key.D9, Key.D0 }; foreach (Key BindingKey in BindingKeys) { new HotKey(BindingKey, KeyModifier.Shift, OnHotKeyHandler); } // ConsoleBot = new ConsoleBot(this, "HotKeyGate"); // Instantiate a new ConsoleBot ConsoleBot.OnMessageReceived += ConsoleBot_OnMessageReceived; //Add ConsoleBot event handler }