// Rules for building: A player can only build houses on a field if certain conditions are met: // 1) He owns all fields of the same color // 2) None of the fields of that color is under mortgage // 3) None of the fields of that color have fewer houses on them than that field // 3) The field has fewer than 5 houses // Rule for selling houses: A house can't be sold on fields which have fewer houses than other fields of the same color // Rules for selling/mortgaging a field: // 1) A field can only be sold/mortgaged if none of the fields of that color have houses build public void OnFieldBought(object sender, FieldBoughtEventArgs e) { if (e.Field.Color == ColorName && Fields.TrueForAll(f => f.Owner == e.NewOwner && !f.UnderMortgage)) { Owner = e.NewOwner; foreach (var field in Fields) { field.CanBuild = true; field.CurrentRent = field.Rent[1]; } } }
public void OnFieldBought(object sender, FieldBoughtEventArgs e) { RentSetter(_fields.TrueForAll(f => f.Owner == e.Field.Owner) ? 1 : 0); }
public void OnFieldBought(object sender, FieldBoughtEventArgs e) { var fields = _fields.Where(f => f.Owner == e.Field.Owner && f.CanMortgage).ToList(); RentSetter(fields, fields.Count); }