Commits

Joeri Sykora committed 72dea32

javadoc of entity objects

Comments (0)

Files changed (13)

genesia/src/main/java/net/sertik/genesia/entity/Building.java

 package net.sertik.genesia.entity;
 
 /**
+ * Contains the definition and the requirements of a single Building. Buildings
+ * objects itself won't be part of a game, instead a Construction object is
+ * used to specify built buildings in the game world.
  *
  * @author joeri
  */
   private int stone;
   private boolean requiresArchitect;
 
+	/**
+	 * The name of the building.
+	 *
+	 * @return the name of the building
+	 */
   public String getName() {
     return name;
   }
     this.name = name;
   }
 
+	/**
+	 * Returns the amount of gold required to start the construction of this
+	 * building.
+	 *
+	 * @return the amount of gold needed to build this building
+	 */
   public int getGold() {
     return gold;
   }
     this.gold = gold;
   }
 
+	/**
+	 * Returns the amount of metal required to start the construction of this
+	 * building.
+	 *
+	 * @return the amount of metal needed to build this building
+	 */
   public int getMetal() {
     return metal;
   }
     this.metal = metal;
   }
 
+	/**
+	 * Specifies whether this building requires an available architect during
+	 * construction.
+	 *
+	 * @return true when an architect is required to build this building
+	 */
   public boolean getRequiresArchitect() {
     return requiresArchitect;
   }
     this.requiresArchitect = requiresArchitect;
   }
 
+	/**
+	 * Returns the amount of stone required to start the construction of this
+	 * building.
+	 *
+	 * @return the amount of stone needed to build this building
+	 */
   public int getStone() {
     return stone;
   }
     this.stone = stone;
   }
 
+	/**
+	 * Returns the amount of wood required to start the construction of this
+	 * building.
+	 *
+	 * @return the amount of wood needed to build this building
+	 */
   public int getWood() {
     return wood;
   }

genesia/src/main/java/net/sertik/genesia/entity/Construction.java

 package net.sertik.genesia.entity;
 
 /**
+ * A Construction is an actual building being constructed in the game world. In
+ * order to be able to start a construction, the player will need the required
+ * resources of the building.
  *
  * @author joeri
  */
 public class Construction implements GameObject {
+	public enum Stage {
+		GROUNDBREAKING, HALFWAY, NEAR_COMPLETION, FINISHED
+	}
+
   private Tile location;
   private Building building;
-  private int stage;
+  private Stage stage;
 
   @Override
   public String getName() {
     return building == null ? null : building.getName();
   }
 
+	/**
+	 * Returns the building that this construction represents.
+	 *
+	 * @return the building representing this construction
+	 */
   public Building getBuilding() {
     return building;
   }
     this.building = building;
   }
 
-  public int getStage() {
+	/**
+	 * Returns the stage of the construction process. A construction doesn't have
+	 * to go through every stage, although Stage.GROUNDBREAKING and
+	 * Stage.FINISHED will always be part of the construction process. A
+	 * construction can process to the next stage when a season ends and
+	 * an architect was present during the construction.
+	 *
+	 * @return the stage of the construction process
+	 */
+  public Stage getStage() {
     return stage;
   }
 
-  public void setStage(int stage) {
+  public void setStage(Stage stage) {
     this.stage = stage;
   }
 
+	/**
+	 * Defines the location of the construction within the game world.
+	 *
+	 * @return the location of this construction in the game world
+	 */
   public Tile getTile() {
     return location;
   }

genesia/src/main/java/net/sertik/genesia/entity/GameObject.java

 package net.sertik.genesia.entity;
 
 /**
+ * A GameObject is the smallest level of the game world. A Tile will contain
+ * one or more GameObject instances. This can be a construction, a recruit or
+ * a simple scenery object.
  *
  * @author joeri
  */
 public interface GameObject {
+	/**
+	 * The name that will be used in the game screen.
+	 *
+	 * @return 
+	 */
   public String getName();
 }

genesia/src/main/java/net/sertik/genesia/entity/Inhabitant.java

 package net.sertik.genesia.entity;
 
 /**
+ * An Inhabitant defines a settler that comes to live in a certain Land. In
+ * order for an settler to become an inhabitant of a land, this land will need
+ * to fulfill a few criteria. For instance, it requires a vacant house,
+ * plenty of food and water, no epidemics, etc.
+ * A second way to attract inhabitants is by natural birth, when two
+ * inhabitants decide to live together and have babies. After a certain age,
+ * these children will become old enough to be able to start a job.
  *
  * @author joeri
  */
 public class Inhabitant {
-  private Construction house;
-  private int trade;
-  private int age;
+	public enum Trade {
+		SETTLER,
+		ARCHITECT,
+		BLACKSMITH,
+		CARPENTER,
+		EXPLORER,
+		FARMER,
+		INVENTOR,
+		WOODCUTTER
+	}
 
-  public int getAge() {
-    return age;
-  }
+	private Construction house;
+	private Trade trade;
+	private int age;
 
-  public void setAge(int age) {
-    this.age = age;
-  }
+	/**
+	 * Returns the age in years of an inhabitant. At a certain age they will die
+	 * and young and older people will also be more vulnerable for diseases.
+	 * The age also defines when an inhabitant is eligible for a job.
+	 *
+	 * @return the age of the inhabitant
+	 */
+	public int getAge() {
+		return age;
+	}
 
-  public Construction getHouse() {
-    return house;
-  }
+	public void setAge(int age) {
+		this.age = age;
+	}
 
-  public void setHouse(Construction house) {
-    this.house = house;
-  }
+	/**
+	 * Returns the house this inhabitant lives in and therefor also defines
+	 * in which land they live in.
+	 *
+	 * @return the house of the inhabitant
+	 */
+	public Construction getHouse() {
+		return house;
+	}
 
-  public int getTrade() {
-    return trade;
-  }
+	public void setHouse(Construction house) {
+		this.house = house;
+	}
 
-  public void setTrade(int trade) {
-    this.trade = trade;
-  }
+	/**
+	 * Returns the job of the inhabitant.
+	 *
+	 * @return the job of the inhabitant
+	 */
+	public Trade getTrade() {
+		return trade;
+	}
+
+	public void setTrade(Trade trade) {
+		this.trade = trade;
+	}
 }

genesia/src/main/java/net/sertik/genesia/entity/Land.java

 import java.util.List;
 
 /**
+ * A land consists of a series of tiles and a land is in its turn part of
+ * the game world. A land can be owned by a player, but can also be without
+ * an owner.
  *
  * @author joeri
  */
   private Player owner;
   private List<Tile> tiles = new LinkedList<>();
 
+	/**
+	 * The name for this land.
+	 *
+	 * @return the name of the land
+	 */
   public String getName() {
     return name;
   }
     this.name = name;
   }
 
+	/**
+	 * The World where this land resides in.
+	 *
+	 * @return the world the land is in
+	 */
 	public World getWorld() {
 		return world;
 	}
 		this.world = world;
 	}
 
+	/**
+	 * Returns the x-coordinate of the land.
+	 *
+	 * @return the x-coordinate of the land
+	 */
   public int getX() {
     return x;
   }
     this.x = x;
   }
 
+	/**
+	 * Returns the y-coordinate of the land.
+	 *
+	 * @return the y-coordinate of the land
+	 */
   public int getY() {
     return y;
   }
     this.y = y;
   }
 
+	/**
+	 * Gets the player that is the owner of this land. The owner can be
+	 * <code>null</code> if this land has no owner.
+	 *
+	 * @return the owner of the land
+	 */
   public Player getOwner() {
     return owner;
   }
     this.owner = owner;
   }
 
+	/**
+	 * Returns all the tiles that are part of this land.
+	 *
+	 * @return a list of tiles that are part of the land
+	 */
   public List<Tile> getTiles() {
     return tiles;
   }

genesia/src/main/java/net/sertik/genesia/entity/Player.java

   private Color color;
   private List<Land> lands;
 
+	private long gold;
+
   public boolean getComputer() {
     return computer;
   }
   public void setLands(List<Land> lands) {
     this.lands = lands;
   }
+
+	public long getGold() {
+		return gold;
+	}
+
+	public void setGold(long gold) {
+		this.gold = gold;
+	}
 }

genesia/src/main/java/net/sertik/genesia/entity/Recruit.java

 package net.sertik.genesia.entity;
 
 /**
+ * A recruit is an actual unit being recruited in the game. In order to be
+ * able to recruit a unit, the player will need the required gold and have
+ * an unemployed inhabitant available.
  *
  * @author joeri
  */
   private Unit unit;
   private Tile location;
 
+	/**
+	 * Returns the player that owns the recruit. In contrast to Buildings,
+	 * where the owner is decided by the owner of the Land that building is
+	 * located in, a recruit is always owned by the same player that recruited
+	 * it in the first place.
+	 *
+	 * @return the player that owns the recruit
+	 */
   public Player getOwner() {
     return owner;
   }
     this.owner = owner;
   }
 
+	/**
+	 * Returns the unit that this recruit represents.
+	 *
+	 * @return the unit representing this recruit
+	 */
   public Unit getUnit() {
     return unit;
   }
     this.unit = unit;
   }
 
+	/**
+	 * Defines the location of the recruit within the game world.
+	 *
+	 * @return the location of this recruit in the game world
+	 */
   public Tile getLocation() {
     return location;
   }

genesia/src/main/java/net/sertik/genesia/entity/Scenery.java

 package net.sertik.genesia.entity;
 
 /**
+ * A Scenery is an object that is not directly controlled by a Player. It can be
+ * a simple patch of flowers, but can also be a resource that can be used by
+ * players, for instance a tree.
  *
  * @author Joeri
  */
 public class Scenery implements GameObject {
+	/**
+	 * This is a special Scenery object that is used to identify which
+	 * tile is currently hovered over by the mouse.
+	 */
 	public static final Scenery HOVER_TILE = new Scenery("SYSTEM_HoverTile");
 
   private String name;

genesia/src/main/java/net/sertik/genesia/entity/Tile.java

 import java.util.Objects;
 
 /**
+ * A Tile defines what GameObjects are placed at a certain location in a
+ * certain land.
  *
  * @author joeri
  */
   private Land land;
   private List<GameObject> objects = new LinkedList<>();
 
+	/**
+	 * Returns the x-coordinate of the tile.
+	 * 
+	 * @return the x-coordinate of the tile
+	 */
   public int getX() {
     return x;
   }
     this.x = x;
   }
 
+	/**
+	 * Returns the y-coordinate of the tile.
+	 *
+	 * @return the y-coordinate of the tile
+	 */
   public int getY() {
     return y;
   }
     this.y = y;
   }
 
+	/**
+	 * Specifies in which Land this tile is situated. The x- and y-coordinate
+	 * are relative within the location of this land.
+	 *
+	 * @return the land this tile is situated in
+	 */
   public Land getLand() {
     return land;
   }
     this.land = land;
   }
 
+	/**
+	 * Defines the list of GameObjects that are placed into this Tile. At least
+	 * one GameObject should be added to this list.
+	 *
+	 * @return a list of GameObjects on this tile
+	 */
   public List<GameObject> getObjects() {
     return objects;
   }

genesia/src/main/java/net/sertik/genesia/entity/Unit.java

 package net.sertik.genesia.entity;
 
 /**
+ * Contains the definition and requirements of a single Unit. Units itself
+ * won't be part of the game world, but will be represented by a Recruit
+ * object instead.
  *
  * @author joeri
  */
   private int defense;
   private int movement;
 
+	/**
+	 * Specifies the basic attack amount for this unit. This will be used as a
+	 * starting point when calculating the actual attack power. The actual
+	 * attack power is for instance influenced by the morale of a recruit or
+	 * the type of weapons that have been discovered.
+	 *
+	 * @return the base attack power
+	 */
   public int getAttack() {
     return attack;
   }
     this.attack = attack;
   }
 
+	/**
+	 * Specifies the basic defense amount for this unit. This will be used as a
+	 * starting point when calculating the actual defense power. The actual
+	 * defense power is for instance influenced by the morale of a recruit or
+	 * the type of weapons that have been discovered.
+	 *
+	 * @return the base defense power
+	 */
   public int getDefense() {
     return defense;
   }
     this.defense = defense;
   }
 
+	/**
+	 * Returns the amount of gold required to recruit this unit into an army.
+	 *
+	 * @return the amount of gold needed to recruit this unit.
+	 */
   public int getGold() {
     return gold;
   }
     this.gold = gold;
   }
 
+	/**
+	 * Returns the total number of movement points available for this unit.
+	 * Movement points will be deducted when moving your recruit. A cavalry
+	 * unit will for instance have more movement points than an infantry unit
+	 * and therefor be able to move further during one turn. At the beginning
+	 * of a turn, the movement points of all recruits will be reset to this
+	 * amount.
+	 *
+	 * @return the total movement points for this unit
+	 */
   public int getMovement() {
     return movement;
   }
     this.movement = movement;
   }
 
+	/**
+	 * The name of the Unit.
+	 *
+	 * @return the name of the unit
+	 */
   public String getName() {
     return name;
   }

genesia/src/main/java/net/sertik/genesia/entity/World.java

 import java.util.List;
 
 /**
+ * The world is the root object of the game. It consists of a series of lands
+ * that are in their turn split up into a number of tiles.
  *
  * @author joeri
  */
 	private int hoverWorldX = -1;
 	private int hoverWorldY = -1;
 
+	/**
+	 * Constructs a new World with the specified number of lands and tiles per
+	 * land.
+	 *
+	 * @param numberLands
+	 * @param numberTilesPerLand 
+	 */
   public World(int numberLands, int numberTilesPerLand) {
     this.numberLands = numberLands;
     this.numberTilesPerLand = numberTilesPerLand;
     this.numberTilesPerLandSqrt = (int) Math.sqrt(numberTilesPerLand);
   }
 
+	/**
+	 * Returns a list of Lands that are part of this World.
+	 *
+	 * @return a list of lands that are part of the world
+	 */
   public List<Land> getLands() {
     return lands;
   }
     this.name = name;
   }
 
+	/**
+	 * Returns the total number of lands in this world.
+	 *
+	 * @return the number of lands of this world
+	 */
 	public int getNumberLands() {
 		return numberLands;
 	}
 		this.numberLands = numberLands;
 	}
 
+	/**
+	 * Returns the number of tiles that exist in each land.
+	 *
+	 * @return the number of tiles per land
+	 */
 	public int getNumberTilesPerLand() {
 		return numberTilesPerLand;
 	}
 		this.numberTilesPerLand = numberTilesPerLand;
 	}
 
+	/**
+	 * Returns the square root of the total number of tiles that will be
+	 * available in the entire world.
+	 *
+	 * @return the square root of the total number of tiles of all lands in this
+	 * world
+	 */
   public int getSizeSqrt() {
     return sizeSqrt;
   }
 
+	/**
+	 * Returns the square root of the number of lands in this world.
+	 *
+	 * @return the square root of the number of lands
+	 */
 	public int getNumberLandsSqrt() {
 		return numberLandsSqrt;
 	}
 
+	/**
+	 * Returns the square root of the number of tiles per land.
+	 *
+	 * @return the square root of the number of tiles per land
+	 */
 	public int getNumberTilesPerLandSqrt() {
 		return numberTilesPerLandSqrt;
 	}
 						worldY < sizeSqrt;
 	}
 
+	/**
+	 * Returns the x-coordinate of the tile where the mouse is currently
+	 * hovering over in world coordinates.
+	 * 
+	 * @return the x-coordinate in the world of the tile that is being hovered
+	 */
 	public int getHoverWorldX() {
 		return hoverWorldX;
 	}
 
+	/**
+	 * Returns the y-coordinate of the tile where the mouse is currently
+	 * hovering over in world coordinates.
+	 * 
+	 * @return the y-coordinate in the world of the tile that is being hovered
+	 */
 	public int getHoverWorldY() {
 		return hoverWorldY;
 	}
 
+	/**
+	 * Sets the current x- and y-coordinates of the tile where the mouse is
+	 * currently hovering over. The coordinates are world coordinates.
+	 *
+	 * @param worldX the x world coordinate of the hovered tile
+	 * @param worldY the y world coordinate of the hovered tile
+	 * @return true when the x- or y-coordinate were different than before this
+	 * call
+	 */
 	public boolean setHoverCoords(int worldX, int worldY) {
 		boolean changed = false;
 		if (isPointWithinBounds(worldX, worldY)) {
 		return changed;
 	}
 
+	/**
+	 * Retrieves the tile that is located at the specified x- and y-coordinate.
+	 * These coordinates are world coordinates.
+	 *
+	 * @param worldX the x world coordinate
+	 * @param worldY the y world coordinate
+	 * @return the tile located at these coordinates
+	 */
   public Tile getTile(int worldX, int worldY) {
     int landX = worldX / numberTilesPerLandSqrt;
     int landY = worldY / numberTilesPerLandSqrt;

genesia/src/main/java/net/sertik/genesia/screen/GameSelection.java

           Player player = new Player();
           player.setComputer(false);
           player.setColor(Player.COLORS[i]);
+					switch (game.getDifficulty()) {
+						case BEGINNER:
+							player.setGold(12000);
+						case NORMAL:
+							player.setGold(10000);
+						case ADVANCED:
+							player.setGold(8000);
+					}
           game.getPlayers().add(player);
         }
         for (int i = totalPlayers; i < 3; i++) {
           player.setComputer(true);
           player.setColor(Player.COLORS[i]);
           player.setName(Player.NAMES[i - totalPlayers]);
+					switch (game.getDifficulty()) {
+						case BEGINNER:
+							player.setGold(8000);
+						case NORMAL:
+							player.setGold(10000);
+						case ADVANCED:
+							player.setGold(12000);
+					}
           game.getPlayers().add(player);
         }
 

genesia/src/main/java/net/sertik/genesia/ui/TileWithDescriptionNode.java

 package net.sertik.genesia.ui;
 
 import javafx.geometry.Pos;
-import javafx.scene.Group;
 import javafx.scene.control.Label;
 import javafx.scene.layout.StackPane;
 import javafx.scene.layout.VBox;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.