public void SimulateOpponentMatches(OldMatchController.MatchStyleOld style, OldMatchController.MatchStyleOptions options) { var opponents = OpponentHands.Where(i => i.Stars > 0 && i.Cards.HasCards).ToList(); for (int i = 0; i < opponents.Count; i++) { var ind = random.Next(opponents.Count - 1); var tmp = opponents[i]; opponents[i] = opponents[ind]; opponents[ind] = tmp; } List <(OldHandState first, OldHandState second)> matchups = new List <(OldHandState first, OldHandState second)>(); while (opponents.Count > 1) { var first = opponents.First(); var second = opponents.Skip(1).First(); opponents = opponents.Skip(2).ToList(); matchups.Add((first, second)); } foreach (var match in matchups) { SimulateOpponentMatch(style, options, match.first, match.second); } }
public void SimulateOpponentMatch(OldMatchController.MatchStyleOld style, OldMatchController.MatchStyleOptions options, OldHandState first, OldHandState second) { switch (style) { case OldMatchController.MatchStyleOld.AllCards: break; case OldMatchController.MatchStyleOld.Rounds: for (int i = 0; i < options.RoundCount; i++) { if (first.Cards.HasCards == false || second.Cards.HasCards == false) { break; } var firstCard = first.Cards.PickRandom(random); var secondCard = second.Cards.PickRandom(random); if (firstCard == secondCard) { continue; } if (firstCard == CardType.Rock) { if (secondCard == CardType.Paper) { first.Stars--; second.Stars++; } else { first.Stars++; second.Stars--; } } if (firstCard == CardType.Paper) { if (secondCard == CardType.Scissors) { first.Stars--; second.Stars++; } else { first.Stars++; second.Stars--; } } if (firstCard == CardType.Scissors) { if (secondCard == CardType.Rock) { first.Stars--; second.Stars++; } else { first.Stars++; second.Stars--; } } if (first.Stars == 0 || second.Stars == 0) { break; } } break; } }