Exemplo n.º 1
0
 public void Add(IPlayer entity)
 {
     using (var db = new LiteDatabase(_filePath))
     {
         var players = db.GetCollection <TexasHoldemPlayer>("players");
         TexasHoldemPlayer player = entity as TexasHoldemPlayer;
         players.Insert(player);
     }
 }
Exemplo n.º 2
0
        private void CheckForNextState()
        {
            Log.debug("Twitch Game: checking round " + controller.game.round.ToString());

            switch (controller.game.round)
            {
            case Games.TexasHoldem <TwitchUser> .Round.PreFlop:
                // Do nothing
                break;

            case Games.TexasHoldem <TwitchUser> .Round.Flop:
                if (controller.SetState(this, typeof(HoldemStatePlayFlop)))
                {
                    timer.Stop();
                    return;
                }
                break;

            case Games.TexasHoldem <TwitchUser> .Round.Turn:
                if (controller.SetState(this, typeof(HoldemStatePlayTurn)))
                {
                    timer.Stop();
                    return;
                }
                break;

            case Games.TexasHoldem <TwitchUser> .Round.River:
                if (controller.SetState(this, typeof(HoldemStatePlayRiver)))
                {
                    timer.Stop();
                    return;
                }
                break;

            case Games.TexasHoldem <TwitchUser> .Round.GameOver:
                if (controller.SetState(this, typeof(HoldemStateEndOfGame)))
                {
                    timer.Stop();
                    return;
                }
                break;

            default:
                Debug.Fail();
                break;
            }

            if (controller.game.currentPlayer != null && controller.game.currentPlayer.idObject.id != lastKnownPlayer?.idObject.id)
            {
                Log.debug("Twitch Game: Player changed, up now is: " + controller.game.currentPlayer.idObject.name);
                lastKnownPlayer = controller.game.currentPlayer;
                PlayerChanged();
                timer.Start();
            }
        }
Exemplo n.º 3
0
 public void Setup()
 {
     mockPlayers    = new IPlayer[2];
     mockPlayers[0] = new TexasHoldemPlayer()
     {
         BitcoinAddress = "msPJhg9GPzMN6twknwmSQvrUKZbZnk51Tv"
     };
     mockPlayers[1] = new TexasHoldemPlayer()
     {
         BitcoinAddress = "mhSW3EUNoVkD1ZQV1ZpnxdRMBjo648enyo"
     };
 }
Exemplo n.º 4
0
        public HoldemStatePlay(TwitchHoldem controller) : base(controller)
        {
            AddCommand(controller.room, "call", CallCommand, "Call...", null, false, null, false);
            AddCommand(controller.room, "raise", RaiseCommand, "Raise...", null, false, null, false);
            AddCommand(controller.room, "check", CheckCommand, "Check...", null, false, null, false);
            AddCommand(controller.room, "fold", FoldCommand, "Fold...", null, false, null, false);
            AddCommand(controller.room, "bet", BetCommand, "Bet...", null, false, null, false);
            AddCommand(controller.room, "allin", AllInCommand, "Bet or Raise all in...", null, false, null, false);

            timer = new TimerSet(new TimeSpan[] { TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30) }, new Action[] { WarningTimer, WarningTimer, FinalTimer });

            lastKnownPlayer = controller.game.currentPlayer;
            PlayerChanged();
            timer.Start();
            playersLookingToFold.Clear();
        }
Exemplo n.º 5
0
        public PlayerRepository()
        {
            TexasHoldemPlayer alice = new BitPoker.Models.TexasHoldemPlayer()
            {
                BitcoinAddress = "msPJhg9GPzMN6twknwmSQvrUKZbZnk51Tv",
                //LastSeen = DateTime.UtcNow.AddSeconds(-5),
                IPAddress = "https://www.bitpoker.io/api/players/msPJhg9GPzMN6twknwmSQvrUKZbZnk51Tv",
                //Latency = new TimeSpan(0, 0, 0, 0, 200)
            };

            TexasHoldemPlayer bob = new TexasHoldemPlayer()
            {
                BitcoinAddress = "mhSW3EUNoVkD1ZQV1ZpnxdRMBjo648enyo",
                //LastSeen = DateTime.UtcNow.AddSeconds(-1),
                IPAddress = "https://www.bitpoker.io/api/players/mhSW3EUNoVkD1ZQV1ZpnxdRMBjo648enyo",
                //Latency = new TimeSpan(0, 0, 0, 0, 200)
            };

            _mocks.Add(alice);
            _mocks.Add(bob);
        }