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) }); }
private Round GetRound(Guid roundId) { if (!Rounds.ContainsKey(roundId)) { throw new InvalidOperationException($"Round with {roundId} not found!"); } return(Rounds[roundId]); }
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 } }); }
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 } }); }
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) }); }