Package model

Class GameModel

java.lang.Object
model.GameModel
All Implemented Interfaces:
Serializable

public class GameModel extends Object implements Serializable
See Also:
  • Constructor Details

    • GameModel

      public GameModel(int rows, int cols)
  • Method Details

    • initialize

      public void initialize()
      Initializes the settings inside game model.
    • getMap

      public Buildable[][] getMap()
    • getAllBuildable

      public List<Buildable> getAllBuildable()
      Gets everything on the map.
      Returns:
      list of buildable.
    • getMasterRoads

      public List<Road> getMasterRoads()
    • getZoneBuildable

      public List<Buildable> getZoneBuildable()
    • getCityRegistry

      public CityRegistry getCityRegistry()
    • getFacilityBuildable

      public List<Buildable> getFacilityBuildable()
    • addZone

      public void addZone(Zone zone) throws OperationException
      Adds the zone to the city. Updates its effect on satisfaction of other zones as well.
      Parameters:
      zone - the zone reference to be added
      Throws:
      OperationException
    • checkTemporaryDirectView

      public void checkTemporaryDirectView(Buildable buildable)
      If the new buildable blocks the forest view, reverses the effect of the forest.
      Parameters:
      buildable - the new buildable to check.
    • addFacility

      public void addFacility(Facility facility) throws OperationException
      Adds the facility to the city.
      Parameters:
      facility - the facility reference to be added
      Throws:
      OperationException
    • removeBuildable

      public void removeBuildable(Coordinate coordinate) throws OperationException
      removes a buildable completely from the city.
      Parameters:
      coordinate - coordinate of the buildable to remove
      Throws:
      OperationException - if removing empty slot.
    • roadIsEssentialForConnection

      public boolean roadIsEssentialForConnection(Road road)
      Checks if the removal of road will result in lost of existing connection
      Parameters:
      road - th road to be checked
      Returns:
      true if it will cause lost, otherwise false.
    • updateTaxRate

      public void updateTaxRate(double newTaxRate) throws OperationException
      Updates city's tax rate
      Parameters:
      newTaxRate - the new tax rate
      Throws:
      OperationException
    • getCityStatistics

      public CityStatistics getCityStatistics()
      Gets the statistics of the whole city
      Returns:
      statistics
    • queryZoneStatistics

      public Zone queryZoneStatistics(Coordinate coordinate) throws OperationException
      Gets the statistics of a specified zone
      Parameters:
      coordinate - the coordinate of the zone for which statistics should be got
      Returns:
      Zone
      Throws:
      OperationException - when no zone is on the coordinate.
    • queryCityBudget

      public Budget queryCityBudget()
      Gets the budget of the whole city
      Returns:
      budget
    • getCurrentDate

      public Date getCurrentDate()
      Gets the current date in sense of the world of city.
      Returns:
      the date.
    • addToMap

      public void addToMap(Buildable buildable)
      Adds the buildable to the world map, reverse operation of removeFromMap
      Parameters:
      buildable - buildable to be added.
    • printMap

      public String printMap()
      Returns:
      a string, whose prints out will be the map.
    • isPlotAvailable

      public boolean isPlotAvailable(Buildable b)
      Checks if there is space for a certain buildable
      Parameters:
      b - the buildable to be checked
      Returns:
      true if there is space, otherwise, false.
    • regularUpdate

      public void regularUpdate(int dayPass, ICallBack callBack)
      Regular updating of the world.
      Parameters:
      dayPass - the day passed since last updates.
      callBack - a call back function, called after the updating, to synchronize the change to the view.
    • calculateSpend

      public double calculateSpend()
      Getting the total expenses of the city.
      Returns:
      the total pension and maintenance
    • calculateRevenue

      public double calculateRevenue()
      Getting the revenue of the city.
      Returns:
      the amount of tax collected
    • getUnderConstructions

      public List<Zone> getUnderConstructions()
      Gets all zones which status is still under constructed.
      Returns:
      the list