public SimRoundResult(SimRoundPlayerInfo firstPlayer, SimRoundPlayerInfo secondPlayer, SimRoundPlayerInfo lastWinningPlayer) : this(firstPlayer, secondPlayer) { this.FirstPlayer = firstPlayer; this.SecondPlayer = secondPlayer; this.LastWinner = lastWinningPlayer; }
private static SimPlayerAction GetPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context) { var action = playerInfo.Player.GetTurn(context.DeepClone()); var isActionValid = SimPlayerActionValidator.Instance.IsValid(action, context, playerInfo.Cards); if (!isActionValid) { throw new InternalGameException($"Invalid action played from {playerInfo.Player.Name}"); } return(action); }
public SimTrick( SimRoundPlayerInfo firstToPlay, SimRoundPlayerInfo secondToPlay, ISimStateManager stateManager, IDeck deck, IGameRules gameRules) { this.firstToPlay = firstToPlay; this.secondToPlay = secondToPlay; this.stateManager = stateManager; this.deck = deck; this.gameRules = gameRules; }
private void CallStartRoundAndDealCardsSimulation(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints, ICollection <Card> currentCards) { var cards = new List <Card>(); // TODO: 6 should be constant foreach (var card in currentCards) { cards.Add(card); player.Cards.Add(card); } player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints); }
public SimRound( ISimPlayer firstPlayer, ISimPlayer secondPlayer, IGameRules gameRules, PlayerPosition firstToPlay = PlayerPosition.FirstPlayer) { this.gameRules = gameRules; this.deck = new SimDeck(); this.stateManager = new SimStateManager(); this.firstPlayer = new SimRoundPlayerInfo(firstPlayer); this.secondPlayer = new SimRoundPlayerInfo(secondPlayer); this.firstToPlay = firstToPlay; }
private void CallStartRoundAndDealCards(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints) { var cards = new List <Card>(); // TODO: 6 should be constant for (var i = 0; i < 6; i++) { if (this.deck.CardsLeft == 0) { break; } var card = this.deck.GetNextCard(); cards.Add(card); player.Cards.Add(card); } player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints); }
private SimPlayerAction GetFirstPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context) { while (true) { var action = GetPlayerAction(playerInfo, context); switch (action.Type) { case PlayerActionType.ChangeTrump: { var oldTrumpCard = this.deck.TrumpCard; var nineOfTrump = new Card(oldTrumpCard.Suit, CardType.Nine); this.deck.ChangeTrumpCard(nineOfTrump); context.TrumpCard = nineOfTrump; // Only swap cards from the local cards list (player should swap its own cards) playerInfo.Cards.Remove(nineOfTrump); playerInfo.Cards.Add(oldTrumpCard); continue; } case PlayerActionType.CloseGame: { this.stateManager.State.Close(); context.State = this.stateManager.State; playerInfo.GameCloser = true; continue; } case PlayerActionType.PlayCard: { if (action.Announce != Announce.None) { playerInfo.Announces.Add(action.Announce); } return(action); } } } }
private void GiveCardToPlayer(SimRoundPlayerInfo player) { var card = this.deck.GetNextCard(); player.AddCard(card); }
private void CallStartRoundAndDealCardsSimulation(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints, ICollection<Card> currentCards) { var cards = new List<Card>(); // TODO: 6 should be constant foreach (var card in currentCards) { cards.Add(card); player.Cards.Add(card); } player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints); }
private SimPlayerAction GetFirstPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context) { while (true) { var action = GetPlayerAction(playerInfo, context); switch (action.Type) { case PlayerActionType.ChangeTrump: { var oldTrumpCard = this.deck.TrumpCard; var nineOfTrump = new Card(oldTrumpCard.Suit, CardType.Nine); this.deck.ChangeTrumpCard(nineOfTrump); context.TrumpCard = nineOfTrump; // Only swap cards from the local cards list (player should swap its own cards) playerInfo.Cards.Remove(nineOfTrump); playerInfo.Cards.Add(oldTrumpCard); continue; } case PlayerActionType.CloseGame: { this.stateManager.State.Close(); context.State = this.stateManager.State; playerInfo.GameCloser = true; continue; } case PlayerActionType.PlayCard: { if (action.Announce != Announce.None) { playerInfo.Announces.Add(action.Announce); } return action; } } } }
public SimRoundResult(SimRoundPlayerInfo firstPlayer, SimRoundPlayerInfo secondPlayer) { this.FirstPlayer = firstPlayer; this.SecondPlayer = secondPlayer; }
private void CallStartRoundAndDealCards(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints) { var cards = new List<Card>(); // TODO: 6 should be constant for (var i = 0; i < 6; i++) { if (this.deck.CardsLeft == 0) { break; } var card = this.deck.GetNextCard(); cards.Add(card); player.Cards.Add(card); } player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints); }
private static SimPlayerAction GetPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context) { var action = playerInfo.Player.GetTurn(context.DeepClone()); var isActionValid = SimPlayerActionValidator.Instance.IsValid(action, context, playerInfo.Cards); if (!isActionValid) { throw new InternalGameException($"Invalid action played from {playerInfo.Player.Name}"); } return action; }