private void ProcessCard(Player player, Card card) { player.LogEvent("Card:", card.GetType().Name); if (card is MoveCard) { var moveCard = (MoveCard)card; player.Location = moveCard.MoveToSquare; } else if (card is MoneyCard) { var moneyCard = (MoneyCard)card; if (moneyCard.Sum > 0) { Bank.Pay(moneyCard.Sum, player, Bank); } else { player.Pay(-moneyCard.Sum, Bank, Bank); } } else if (card is SpecialCard) { bool bPassedGo = false; var specialCard = (SpecialCard)card; switch (specialCard.CardType) { case SpecialCardType.NextUtility: player.Location = FindNextSquareByType(player, typeof(Utility), ref bPassedGo); break; case SpecialCardType.NextStation: player.Location = FindNextSquareByType(player, typeof(Station), ref bPassedGo); break; case SpecialCardType.BackThree: player.Location = Board.AllSquares[player.Location.Order - 3]; break; case SpecialCardType.GoToJail: player.Location = Board.Jail; player.SetInJail(); break; case SpecialCardType.GetOutOfJailFreeChance: case SpecialCardType.GetOutOfJailFreeCommunityChest: player.GetOutOfJailFreeCards.Enqueue(card); break; case SpecialCardType.RepairsChance: { var totalToPay = 0; foreach (var asset in player.Assets) { if (asset is Property) { var property = (Property)asset; var cost = 0; if (property.BuildingCount < 5) { cost = property.BuildingCount * 25; } else { cost = 100; } totalToPay += cost; } } player.Pay(totalToPay, FreeParking, Bank); } break; case SpecialCardType.GiveEachPlayerFifty: foreach (var otherPlayer in ActivePlayers.Excluding(player)) { player.Pay(50, otherPlayer, Bank); } break; case SpecialCardType.ReceiveFiftyFromEachPlayer: foreach (var otherPlayer in ActivePlayers.Excluding(player)) { otherPlayer.Pay(50, player, Bank); } break; case SpecialCardType.RepairsCommunityChest: { var totalToPay = 0; foreach (var asset in player.Assets) { if (asset is Property) { var property = (Property)asset; var cost = 0; if (property.BuildingCount < 5) { cost = property.BuildingCount * 40; } else { cost = 115; } totalToPay += cost; } } player.Pay(totalToPay, FreeParking, Bank); } break; default: break; } if (bPassedGo) { Bank.Pay(200, player, Bank); } } else { throw new ApplicationException("Unknown card type"); } }