Exemplo n.º 1
0
        private void ProcessDecision(string[] parts, Guid roundId)
        {
            //"Decision-Chris-Call",
            //  "Decision-David-Reraise-20",
            var          name         = parts[1];
            DecisionType decisionType = DecisionType.Undefined;
            int          chips        = 0;

            switch (parts[2])
            {
            case "Check":
                decisionType = DecisionType.Check;
                break;

            case "Call":
                decisionType = DecisionType.Call;
                break;

            case "Raise":
                decisionType = DecisionType.Raise;
                chips        = int.Parse(parts[3]);
                break;

            case "Reraise":
                decisionType = DecisionType.Reraise;
                chips        = int.Parse(parts[3]);
                break;

            case "Fold":
                decisionType = DecisionType.Fold;
                break;

            case "AllIn":
                decisionType = DecisionType.AllIn;
                chips        = int.Parse(parts[3]);
                break;

            case "AllInRaise":
                decisionType = DecisionType.AllInRaise;
                chips        = int.Parse(parts[3]);
                break;
            }

            var request = new NotifyDecisionRequest()
            {
                Decision   = new Decision(decisionType, chips),
                PlayerName = name,
                RoundId    = roundId
            };

            _rm.NotifyDecision(request);
        }
Exemplo n.º 2
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)
            });
        }
Exemplo n.º 3
0
        public IActionResult NotifyDecision([FromBody] NotifyDecisionRequest request)
        {
            var response = RoundManager.Instance.NotifyDecision(request);

            return(Ok(response));
        }