/// <see cref="IPlayer.DevelopProperty"/> public void DevelopProperty(DevelopableLand property) { if (propertiesOwned.Contains(property)) { int developCost = property.GetDevelopCost(); if (developCost <= cash) { try // attempt to develop property and propagate errors to front end { property.Develop(); cash = cash - developCost; } catch (DevelopableLandException e) { throw new HumanPlayerException(e.Message); } } else { throw new DevelopableLandException("Player doesn't have enough cash to develop the property!"); } } else { throw new DevelopableLandException("Cannot develop a property that you don't own!"); } }
public bool OwnsAllColour(Colour group) { // check through all player's owned properties and count the number of [group] colour owned int groupCount = 0; foreach (IProperty property in propertiesOwned) { if (property is DevelopableLand) { // if property colour matches the group colour we want, increment count DevelopableLand land = (DevelopableLand)property; if (land.GetColourGroup() == group) { groupCount++; } } } // all groups have 3 properties except Brown and Deep Blue if (group == Colour.Brown || group == Colour.DeepBlue) { return(groupCount == 2); } else { return(groupCount == 3); } }
/// <see cref="IPlayer.UndevelopProperty"/> public void UndevelopProperty(DevelopableLand property) { // check if player owns this property if (propertiesOwned.Contains(property)) { int developCost = property.GetDevelopCost(); try // attempt to undevelop and propagate errors to front end { property.Undevelop(); cash = cash + developCost; } catch (DevelopableLandException e) { throw new HumanPlayerException(e.Message); } } else { throw new HumanPlayerException("Cannot undevelop a property that you don't own!"); } }
public void Undevelop(DevelopableLand property) { playerTakingTurn.UndevelopProperty(property); }
public void Develop(DevelopableLand property) { // TODO: need to check for development difference playerTakingTurn.DevelopProperty(property); }