Class KaiserEngine

java.lang.Object
de.aikiit.game.kaiser.KaiserEngine

public class KaiserEngine extends Object
This class encapsulates the game's logics and operations on its attributes. As the game is based on rounds 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: After user interactions the round is finished in finishRoundAfterActions().
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor to start a game with the given default settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Performs an act of buying land (new land is acquired by reducing the supplies according to the current land price).
    (package private) void
     
    void
    cultivate(Long cultivate)
    Performs an act of using your area and people to cultivate, plant crops for the upcoming season/next round.
    void
    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 quotient
    Calculates 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
    sellLand(Long sell)
    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
     
    (package private) void
     
    (package private) void
     
    void
    Starts a new round in performs initial calculations before user actions are taken into account.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      BigDecimal getRandomNumberUntil(int threshold)
      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

      void setQ(BigDecimal q)
    • setSupplies

      void setSupplies(BigDecimal supplies)
    • setArea

      void setArea(BigDecimal area)
    • getAreaPerCapita

      public BigDecimal getAreaPerCapita()
      Calculates the available area per person in the current game.
      Returns:
      area per capita, called L in original. Land ownership?
    • buyLand

      public long buyLand(Long buy)
      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

      public void sellLand(Long sell)
      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

      public void feedToPopulation(Long feed)
      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

      public void cultivate(Long 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 of 0 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