static int ComparePlayerWinner(PlayerState first, PlayerState second) { int scoreDifference = second.TotalScore() - first.TotalScore(); if (scoreDifference > 0) { return 1; } if (scoreDifference < 0) { return -1; } return second.numberOfTurnsPlayed - first.numberOfTurnsPlayed; }
public override void EndTurn(PlayerState playerState) { this.victoryPointTotal.IncrementCounter(playerState, playerState.TotalScore()); foreach (Card card in this.cardGameSubset) { this.cardsTotalCount[card].IncrementCounter(playerState, playerState.AllOwnedCards.CountOf(card)); } int totalCoinSpent = this.coinToSpend.GetSumForCurrentGameAndTurn(playerState); for (int i = 1; i < this.oddsOfHittingAtLeastACoinAmount.Length; ++i) { if (totalCoinSpent >= i) { this.oddsOfHittingAtLeastACoinAmount[i].IncrementCounter(playerState, 1); } } }
public int SmallestScoreDifference(PlayerState currentPlayer) { int scoreDiff = 0; int currentScore = currentPlayer.TotalScore(); foreach(var otherPlayer in this.players.AllPlayers) { if (otherPlayer == currentPlayer) continue; int otherScore = otherPlayer.TotalScore(); int diff = currentScore - otherScore; if (scoreDiff == 0 || diff > scoreDiff) scoreDiff = diff; } return scoreDiff; }