Class CityState
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.city.impl.CityState
-
@Component @Scope("prototype") public class CityState extends java.lang.ObjectThis class encapsulates state information used by CityEngine about one city. This class i player private since it should not be used by any other class than CityEngine.- Author:
- Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 29, 2011
-
-
Constructor Summary
Constructors Constructor Description CityState(ICity city, IShipyard shipard, TavernState tavern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.property.ObjectProperty<ECityState>cityEventProperty()Property holding the corrent city event, may be null.java.util.Set<java.util.Map.Entry<IWare,java.lang.Double>>consumedEntries()Get the consumed entries as a set.voiddailyUpdate(ch.sahits.game.event.data.ClockTickPostDayChange dayChange)Update the missing wares.javafx.beans.binding.BooleanBindingfamineBinding()Binding indicating if there is a famine.java.util.Optional<IWare>findMostNeededWare()Find the ware which is consumed the most and which is missing for the longest time.java.util.Optional<IWare>findWareWithMostSurplus()Find the ware that the city sells near the minimal price.doublegetConsumedAmount(EWare ware)Retrieve the amount that is consumed so far.javafx.beans.binding.ObjectBinding<IWare>longestMissingWaresBinding()Retrieve the ware that is missing the longest.voidreplaceConsumedAmount(IWare ware, double amount)Set the amount of the ware that is consumed.
-
-
-
Constructor Detail
-
CityState
public CityState(ICity city, IShipyard shipard, TavernState tavern)
-
-
Method Detail
-
dailyUpdate
public void dailyUpdate(ch.sahits.game.event.data.ClockTickPostDayChange dayChange)
Update the missing wares.- Parameters:
dayChange- event indicating a day change
-
longestMissingWaresBinding
public javafx.beans.binding.ObjectBinding<IWare> longestMissingWaresBinding()
Retrieve the ware that is missing the longest.- Returns:
- ware binding for the ware missing longest
-
famineBinding
public javafx.beans.binding.BooleanBinding famineBinding()
Binding indicating if there is a famine.- Returns:
- boolean binding for the famine
-
cityEventProperty
public javafx.beans.property.ObjectProperty<ECityState> cityEventProperty()
Property holding the corrent city event, may be null.- Returns:
- binding of the city event state
-
consumedEntries
public java.util.Set<java.util.Map.Entry<IWare,java.lang.Double>> consumedEntries()
Get the consumed entries as a set.- Returns:
- set of entries of wares and their consumption
-
replaceConsumedAmount
public void replaceConsumedAmount(IWare ware, double amount)
Set the amount of the ware that is consumed. If there is already an amount stored for the ware it is overidden.- Parameters:
ware- to be consumedamount- to be consumed
-
getConsumedAmount
public double getConsumedAmount(EWare ware)
Retrieve the amount that is consumed so far.- Parameters:
ware- which should be checked for consumption.- Returns:
- consumed amount.
-
findMostNeededWare
public java.util.Optional<IWare> findMostNeededWare()
Find the ware which is consumed the most and which is missing for the longest time.- Returns:
- Optional ware
-
findWareWithMostSurplus
public java.util.Optional<IWare> findWareWithMostSurplus()
Find the ware that the city sells near the minimal price.- Returns:
- Optional ware
-
-