Template

public abstract class Template<T> implements Serializable, DeepEquatable

Signifies that an implementing class provides generic details about a specific object. Also provides a means for creating factory methods for specific kinds of game objects.

Author:

Tim

Parameters:
  • <T>

Fields

ID

public final int ID

buildPrerequisites

protected Set<Integer> buildPrerequisites

foodCost

protected int foodCost

goldCost

protected int goldCost

name

protected String name

player

protected int player

timeCost

protected int timeCost

upgradePrerequisites

protected Set<Integer> upgradePrerequisites

woodCost

protected int woodCost

Constructors

Template

public Template(int ID)

Methods

addBuildPrerequisite

public void addBuildPrerequisite(Integer templateID)

Add a building prerequisite (A unit that must be built before this template can be made)

Parameters:
  • templateID

addUpgradePrerequisite

public void addUpgradePrerequisite(Integer templateID)

Add an upgrade prerequisite (An upgrade that must be done before this template can be made)

Parameters:
  • templateID

deprecateOldView

public abstract void deprecateOldView()

equals

public boolean equals(Object o)

getBuildPrerequisites

public Set<Integer> getBuildPrerequisites()

Get the set of template ids of buildings (or units in general) that are required before this template can be made. This list is mutable, changing it will alter the things needed to make this template.

Returns:A set of template ids for prerequisite buildings/units

getFoodCost

public int getFoodCost()

getGoldCost

public int getGoldCost()

getName

public String getName()

getPlayer

public int getPlayer()

getTimeCost

public int getTimeCost()

getUpgradePrerequisites

public Set<Integer> getUpgradePrerequisites()

Get the set of template ids of upgrades that must be researched before this template can be made. This list is mutable, changing it will alter the things needed to make this template.

Returns:A set of template ids for prerequisite upgrades.

getView

public abstract TemplateView getView()

getWoodCost

public int getWoodCost()

hashCode

public int hashCode()

produceInstance

public abstract T produceInstance(IDDistributer idsource)

A factory method that produces copies of a “default” object

setFoodCost

public void setFoodCost(int foodCost)

setGoldCost

public void setGoldCost(int goldCost)

setName

public void setName(String name)

setPlayer

public void setPlayer(int playerid)

setTimeCost

public void setTimeCost(int timeCost)

setWoodCost

public void setWoodCost(int woodCost)