Example #1
0
 public ViberController(
     IBotFactory <IViberBotClient> viberBotFactory,
     IBotService botService,
     ILogger <ViberController> logger)
 {
     this.viberBotFactory = viberBotFactory;
     this.botService      = botService;
     this.logger          = logger;
 }
Example #2
0
        public Game(int rows, int columns, IBotFactory botFactory)
        {
            if (rows < 1 || columns < 1)
            {
                throw new BotGameException($"Invalid board size. minim size 1x1");
            }

            this.board      = new Board(rows, columns);
            this.bots       = new List <IBot>();
            this.botFactory = botFactory;
        }
Example #3
0
 public RoundFactory(
     IBotFactory botFactory,
     ISettings settings,
     ITurnFactory turnFactory,
     IBattlefieldFactory battlefieldFactory,
     IOutput output)
 {
     BotFactory         = botFactory;
     Settings           = settings;
     TurnFactory        = turnFactory;
     BattlefieldFactory = battlefieldFactory;
 }
Example #4
0
 public Round(
     int number,
     IBotFactory botFactory,
     ISettings settings,
     ITurnFactory turnFactory,
     IBattlefieldFactory battlefieldFactory)
 {
     Number             = number;
     BotFactory         = botFactory ?? throw new ArgumentNullException(nameof(botFactory));
     Settings           = settings ?? throw new ArgumentNullException(nameof(settings));
     TurnFactory        = turnFactory ?? throw new ArgumentNullException(nameof(turnFactory));
     BattlefieldFactory = battlefieldFactory ?? throw new ArgumentNullException(nameof(battlefieldFactory));
     Battlefield        = BattlefieldFactory.Create();
     Bots = BotFactory.Create(Battlefield);
     Battlefield.SetRandomly(Bots);
 }
Example #5
0
        public void Initialize(IBotFactory botFactory, int delayBetweenInitsMS = 1100)
        {
            if (_initialized)
            {
                throw new InvalidOperationException("Unable to initialize bot framework a second time.");
            }

            int numFailed = 0;

            for (int i = 0; i < _numBots; ++i)
            {
                if (_terminating)
                {
                    throw new BotException("Received termination signal; initialization has been cancelled");
                }

                try
                {
                    var bot = botFactory.CreateBot(i, _host, _port);
                    bot.WorkCompleted += () => _doneSignal.Release();
                    bot.Initialize();
                    _botsList.Add(bot);
                }
                catch (Exception ex)
                {
                    _outputHandler.OutputBotInitializationFailed(ex.Message);
                    numFailed++;
                    continue;
                }

                _outputHandler.OutputBotInitializationSucceeded(i);
                Thread.Sleep(delayBetweenInitsMS); //minimum for this is 1sec server-side
            }

            if (numFailed > 0)
            {
                _outputHandler.OutputWarnSomeBotsFailed();
                _numBots -= numFailed;
            }
            else if (numFailed == _numBots)
            {
                throw new BotException("All bots failed to initialize. No bots will run.");
            }

            _initialized = true;
        }
Example #6
0
		public void Initialize(IBotFactory botFactory, int delayBetweenInitsMS = 1100)
		{
			if (_initialized)
				throw new InvalidOperationException("Unable to initialize bot framework a second time.");

			int numFailed = 0;
			for (int i = 0; i < _numBots; ++i)
			{
				if (_terminating)
					throw new BotException("Received termination signal; initialization has been cancelled");

				try
				{
					var bot = botFactory.CreateBot(i, _host, _port);
					bot.WorkCompleted += () => _doneSignal.Release();
					bot.Initialize();
					_botsList.Add(bot);
				}
				catch(Exception ex)
				{
					_outputHandler.OutputBotInitializationFailed(ex.Message);
					numFailed++;
					continue;
				}

				_outputHandler.OutputBotInitializationSucceeded(i);
				Thread.Sleep(delayBetweenInitsMS); //minimum for this is 1sec server-side
			}

			if (numFailed > 0)
			{
				_outputHandler.OutputWarnSomeBotsFailed();
				_numBots -= numFailed;
			}
			else if (numFailed == _numBots)
			{
				throw new BotException("All bots failed to initialize. No bots will run.");
			}

			_initialized = true;
		}
Example #7
0
 public BotFarm(string id, IClient client, IBotFactory botFactory, BotFarmOptions options)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     if (botFactory == null)
     {
         throw new ArgumentNullException(nameof(botFactory));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (string.IsNullOrEmpty(id))
     {
         throw new ArgumentException("Id cannot be null or empty.", nameof(id));
     }
     _id         = id;
     _client     = client;
     _botFactory = botFactory;
     _options    = options;
     _logger     = Log.Logger.ForContext("BotFarmId", id);
 }
Example #8
0
 public Program(IBotFactory botConfigurationFactory)
 {
     _botConfigurationFactory = botConfigurationFactory;
 }
 public Test(IBotFactory botFactory,IPokerDatabase pokerDatabase)
 {
     this.botFactory = botFactory;
     this.pokerDatabase = pokerDatabase;
 }
Example #10
0
 public void InitForm()
 {
     produtoLeituraApi = new ProdutoLeituraAPIService();
     botFactory = new BotFactory();
 }
Example #11
0
 public RabbitMQImpl(IBotFactory factory)
 {
     _factory = factory;
 }
Example #12
0
 /// <summary>
 /// raises an instance of Database
 /// </summary>
 /// <param name="botFactory">the factory the database can use to raise IBots</param>
 /// <param name="humanFactory">the factory the database can use to raise IHumans</param>
 public Database(IBotFactory botFactory, IHumanFactory humanFactory)
 {
     this.BotFactory   = botFactory;
     this.HumanFactory = humanFactory;
 }
Example #13
0
 public Test(IBotFactory botFactory, IPokerDatabase pokerDatabase)
 {
     this.botFactory    = botFactory;
     this.pokerDatabase = pokerDatabase;
 }
Example #14
0
 public void TestInitialize()
 {
     this.humanFactory = new HumanFactory();
     this.botFactory   = new BotFactory();
 }
        public SendMessageService(IBotFactory <IViberBotClient> viberBotFactory)
        {
            var botId = 1;

            this.viberBotClient = viberBotFactory.GetClient(botId);
        }