public Game(string startCommand) { players = new Player[2]; turnCount = 0; var wordInCommand = startCommand.Split(' '); const int cardsStartPositionInCommand = 5; //"Start new game with new deck <card>" - 5 words before cards for (int i = cardsStartPositionInCommand; i < wordInCommand.Length; ++i) { deck.AddCard(CardParser.GetCardFromAbbreviation(wordInCommand[i])); } players[0] = new Player(deck); players[1] = new Player(deck); riskyTurnsCount = 0; }
private string MakeTurn(string command) { string turnStatus = "Good turn"; //"Good turn", if turn is correct, 1, "Bad turn", if turn is incorrect var currentPlayer = players[turnCount % 2]; var nextPlayer = players[(turnCount + 1) % 2]; turnCount++; if (command.Contains("Tell")) { if (command.Contains("rank")) { var rankAndCardsPositionsInHand = CardParser.GetRankAndCardsPositions(command); var rank = rankAndCardsPositionsInHand.Item1; var positions = rankAndCardsPositionsInHand.Item2; turnStatus = TellRankCommand(rank, positions, nextPlayer); } if (command.Contains("color")) { var colorAndCardsPositionsInHand = CardParser.GetColorAndCardsPositions(command); var color = colorAndCardsPositionsInHand.Item1; var positions = colorAndCardsPositionsInHand.Item2; turnStatus = TellColorCommand(color, positions, nextPlayer); } } if (command.Contains("Play")) { var cardPositionInHand = CardParser.GetCardPosition(command); turnStatus = PlayCommand(cardPositionInHand, currentPlayer); } if (command.Contains("Drop")) { var cardPositionInHand = CardParser.GetCardPosition(command); DropCommand(cardPositionInHand, currentPlayer); } return(turnStatus); }