private void CollectPayCard(Card card, Player player, MonopolyModelContainer ctx) { if (card.Parameters.Contains('|')) { // TODO process params int houseCost = -40; int hotelCost = -115; int houses = player.Realities.Sum(r => r.Houses); int hotels = player.Realities.Sum(r => r.Hotels); player.Money += houseCost * houses + hotelCost * hotels; } else { int amount = Int32.Parse(card.Parameters); if (card.From == "Players") { var players = ctx.Players.Where(p => p.Game.Id == player.Game.Id && p.Id != player.Id); int counter = 0; foreach (var p in players) { counter++; p.Money -= amount; } player.Money += counter * amount; } else { player.Money += amount; } } player.CardUsed = true; ctx.SaveChanges(); }
private void GetOutOfJailCard(Card card, Player player, MonopolyModelContainer ctx) { player.HasJailCard = true; ctx.SaveChanges(); }
private void GotoCard(Card card, Player player, MonopolyModelContainer ctx) { Field newPos = null; int fieldId = 0; switch (card.Parameters) { case "-3": fieldId = player.Position.Id < 3 ? player.Position.Id + 37 : player.Position.Id - 3; newPos = ctx.Fields.SingleOrDefault(f => f.Id == fieldId); break; case "Railway": var railways = ctx.Fields.Where(f => f.Type == "Railway"); foreach (var railway in railways) { if (railway.Id > player.Position.Id) { newPos = railway; break; } } if (newPos == null) { // first railway newPos = ctx.Fields.SingleOrDefault(f => f.Id == 6); } break; case "Utility": fieldId = player.Position.Id < 13 || player.Position.Id > 29 ? 13 : 29; newPos = ctx.Fields.SingleOrDefault(f => f.Id == fieldId); break; default: newPos = ctx.Fields.SingleOrDefault(f => f.Name == card.Parameters); break; } if (player.Position.Id > newPos.Id && newPos.Name != "Jail") { player.Money += 200; } if (newPos.Name == "Jail") { player.JailValue = 1; } player.CardUsed = true; ctx.SaveChanges(); }
private void empty(Card card, Player player, MonopolyModelContainer ctx) { }