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(); }
internal InterceptorChain(Player player) { this.player = player; interceptors.Add(new FieldInterceptor()); interceptors.Add(new CardInterceptor()); interceptors.Add(new RealityInterceptor()); interceptors.Add(new OfferInterceptor()); interceptors.Add(new JailInterceptor()); interceptors.Add(new LastInterceptor()); }
public bool ShouldCall(Player player) { return player.OwnTurn && !player.IsBankrupted; }
public bool ShouldCall(Player player) { // the players turn and // already moved and // the position is buyable return player.OwnTurn && player.HasMoved && player.Position.Buyable; }
/// <summary> /// Determines whether this interceptor should be called for this state. /// </summary> /// <param name="player">The given player.</param> /// <returns>True if this interceptor should be called.</returns> public bool ShouldCall(Player player) { return player.OwnTurn && player.HasMoved && !player.IsBankrupted && !player.CardUsed && (player.Position.Type == "C" || player.Position.Type == "CC"); }
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 GetOutOfJailCard(Card card, Player player, MonopolyModelContainer ctx) { player.HasJailCard = true; ctx.SaveChanges(); }
private void empty(Card card, Player player, MonopolyModelContainer ctx) { }