예제 #1
0
        public DecisionResponse GetDecision(Guid roundId)
        {
            if (!Rounds.ContainsKey(roundId))
            {
                throw new InvalidOperationException($"Round with {roundId} not found!");
            }

            var round = Rounds[roundId];

            var player = round.GetCurrentPlayer();

            if (player.Index != RoundSetups[roundId].HeroIndex)
            {
                throw new InvalidOperationException($"Current player {player.Name} is not Hero: {round.Players[RoundSetups[roundId].HeroIndex]}");
            }

            if (!Brains.ContainsKey(roundId))
            {
                throw new InvalidOperationException($"Brain with {roundId} not found!");
            }

            var brain = Brains[roundId];

            var decision = brain.GetDecision(round, RoundSetups[roundId]);

            round.RecordMove(new Move(player, decision, round.StageEnum));
            round.MoveToNextPlayer();

            return(new DecisionResponse
            {
                Decision = decision,
                Action = GetExpectedAction(round)
            });
        }
예제 #2
0
        private Round GetRound(Guid roundId)
        {
            if (!Rounds.ContainsKey(roundId))
            {
                throw new InvalidOperationException($"Round with {roundId} not found!");
            }

            return(Rounds[roundId]);
        }
예제 #3
0
        public DummyResponse NotifyRiver(NotifyRiverRequest request)
        {
            if (!Rounds.ContainsKey(request.RoundId))
            {
                throw new InvalidOperationException($"Round with {request.RoundId} not found!");
            }

            var round = Rounds[request.RoundId];

            round.River = request.River;
            round.MoveToNextStage();

            return(new DummyResponse()
            {
                Action = new ExpectedAction
                {
                    Action = ExpectedActionEnum.Decision,
                    PlayerName = round.GetCurrentPlayer().Name
                }
            });
        }
예제 #4
0
        public DummyResponse NotifyHeroHoles(NotifyHeroHolesRequest request)
        {
            if (!Rounds.ContainsKey(request.RoundId))
            {
                throw new InvalidOperationException($"Round with {request.RoundId} not found!");
            }

            var round = Rounds[request.RoundId];

            round.StageEnum = StageEnum.Preflop;
            var roundSetup = RoundSetups[request.RoundId];

            roundSetup.Hole1 = request.Holes[0];
            roundSetup.Hole2 = request.Holes[1];

            return(new DummyResponse()
            {
                Action = new ExpectedAction
                {
                    Action = ExpectedActionEnum.Decision,
                    PlayerName = round.GetCurrentPlayer().Name
                }
            });
        }
예제 #5
0
        public DummyResponse NotifyDecision(NotifyDecisionRequest request)
        {
            if (!Rounds.ContainsKey(request.RoundId))
            {
                throw new InvalidOperationException($"Round with {request.RoundId} not found!");
            }

            var round  = Rounds[request.RoundId];
            var player = round.GetCurrentPlayer();

            if (!string.Equals(player.Name, request.PlayerName))
            {
                throw new InvalidOperationException($"Turn for {player.Name} but received decision from {request.PlayerName}.");
            }

            round.RecordMove(new Move(player, request.Decision, round.StageEnum));

            round.MoveToNextPlayer();

            return(new DummyResponse()
            {
                Action = GetExpectedAction(round)
            });
        }