Package de.aikiit.game.kaiser
Class KaiserEngine
java.lang.Object
de.aikiit.game.kaiser.KaiserEngine
This class encapsulates the game's logics and operations on its attributes.
As the game is based on rounds
In each round there is a chance for famine-induced loss, which is handled in
Apart from these automated things the player can:
startNewRound()
starts a new round and performs calculations based on the player's actions.
In each round there is a chance for famine-induced loss, which is handled in
processFamine()
based on an underlying random probability factor.
Apart from these automated things the player can:
buyLand(Long)
buy new landsellLand(Long)
sell existing landcultivate(Long)
cultivate land in order to achieve new yieldsfeedToPopulation(Long)
give food to your population
finishRoundAfterActions()
.-
Constructor Summary
ConstructorDescriptionDefault constructor to start a game with the given default settings. -
Method Summary
Modifier and TypeMethodDescriptionlong
Performs an act of buying land (new land is acquired by reducing the supplies according to the current land price).(package private) void
void
Performs an act of using your area and people to cultivate, plant crops for the upcoming season/next round.void
feedToPopulation
(Long feed) Performs an act of using supplies to feed your population.void
Perform "round"-final calculations such as number of people that died adapt overall (internal) death statistics refresh internal famine quotientCalculates the available area per person in the current game.(package private) BigDecimal
getRandomNumberUntil
(int threshold) Helper method to retrieve a new random number without any comma (scale=0).void
Evaluate internally, if a famine is happening in the current round.(package private) void
Explicitly trigger the recalculation of the given internal famine calculation factor.void
Performs an act of selling land (resulting in an increase of supplies as the land is sold to the current land price).(package private) void
setArea
(BigDecimal area) (package private) void
setQ
(BigDecimal q) (package private) void
setSupplies
(BigDecimal supplies) void
Starts a new round in performs initial calculations before user actions are taken into account.
-
Constructor Details
-
KaiserEngine
public KaiserEngine()Default constructor to start a game with the given default settings.
-
-
Method Details
-
startNewRound
public void startNewRound()Starts a new round in performs initial calculations before user actions are taken into account. -
getRandomNumberUntil
Helper method to retrieve a new random number without any comma (scale=0).- Parameters:
threshold
- number is greater than 0 and at most threshold.- Returns:
- a new random number.
-
processFamine
public void processFamine()Evaluate internally, if a famine is happening in the current round. If so this method performs all necessary calculations/reductions within the currently running game. -
refreshFamineQuotient
void refreshFamineQuotient()Explicitly trigger the recalculation of the given internal famine calculation factor. -
setQ
-
setSupplies
-
setArea
-
getAreaPerCapita
Calculates the available area per person in the current game.- Returns:
- area per capita, called L in original. Land ownership?
-
buyLand
Performs an act of buying land (new land is acquired by reducing the supplies according to the current land price). You cannot buy more than you can afford.- Parameters:
buy
- how many hectares you want to buy. Negative input is ignored.- Returns:
- the given number of hectares.
0
means that the player does not want to buy anything, which will trigger the possibility to sell land.
-
sellLand
Performs an act of selling land (resulting in an increase of supplies as the land is sold to the current land price). You cannot sell more than you have.- Parameters:
sell
- how many hectares you want to sell. Negative input is ignored.
-
feedToPopulation
Performs an act of using supplies to feed your population. You cannot give more than you have.- Parameters:
feed
- how many dzt you want to feed
-
cultivate
Performs an act of using your area and people to cultivate, plant crops for the upcoming season/next round. You cannot give more than you have.- Parameters:
cultivate
- how many hectares you want to use for agricultural purposes. Negative input is ignored. An input of0
will trigger a recalculation of the current land price.
-
calculateNewPrice
void calculateNewPrice() -
finishRoundAfterActions
public void finishRoundAfterActions()Perform "round"-final calculations such as- number of people that died
- adapt overall (internal) death statistics
- refresh internal famine quotient
-