|
@@ -9,6 +9,10 @@ import pathgame.gameplay.Player;
|
|
|
*/
|
|
|
public class Tile
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+ */
|
|
|
public static class TileBuilder
|
|
|
{
|
|
|
private int energyCost = 2;
|
|
@@ -25,65 +29,114 @@ public class Tile
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @return a new tile builder
|
|
|
+ */
|
|
|
public static TileBuilder create()
|
|
|
{
|
|
|
return new TileBuilder();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param energyCost the base energy cost of the tile.
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder setEnergyCost(int energyCost)
|
|
|
{
|
|
|
this.energyCost = energyCost;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param forestReplaceChance the chance that the tile can be replaced by forest.
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder setForestReplaceChance(float forestReplaceChance)
|
|
|
{
|
|
|
this.forestReplaceChance = forestReplaceChance;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param speedUp a function.
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder setSpeedUp(Function<Player, Integer> speedUp)
|
|
|
{
|
|
|
this.speedUp = speedUp;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder noTown()
|
|
|
{
|
|
|
this.canHostTown = false;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder noMovement()
|
|
|
{
|
|
|
this.blocksMovement = true;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param type a tile type
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder setType(TileType type)
|
|
|
{
|
|
|
this.type = type;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder pathHost()
|
|
|
{
|
|
|
this.canHostPath = true;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder path()
|
|
|
{
|
|
|
this.path = true;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param type a render type
|
|
|
+ * @return the tile builder
|
|
|
+ */
|
|
|
public TileBuilder setRenderType(TileRenderType type)
|
|
|
{
|
|
|
this.renderType = type;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @return the built tile.
|
|
|
+ */
|
|
|
public Tile build()
|
|
|
{
|
|
|
return new Tile(energyCost, forestReplaceChance, speedUp, canHostTown, blocksMovement, type, canHostPath, path, renderType);
|
|
@@ -155,6 +208,11 @@ public class Tile
|
|
|
return id;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param p a player
|
|
|
+ * @return the energy cost of a player on this tile
|
|
|
+ */
|
|
|
public int getEnergyCost(Player p)
|
|
|
{
|
|
|
return energyCost - speedUp.apply(p);
|