public enum TechType {
NONE, VEGETATION, STRAWBERRIES, BIODOME, LIVESTOCK, BIOMASS;
}
public class VegetationTech implements Tech {
public TechType type = TechType.VEGETATION;
public static Set<TechType> prerequisites
= EnumSet.of(TechType.NONE);
@Override
public Set getPrerequisites() {
return prerequisites;
}
@Override
public TechType getType() {
return type;
}
}
...
public class BiomassTech implements Tech {
public TechType type = TechType.BIOMASS;
public static Set<TechType> prerequisites
= EnumSet.of(TechType.VEGETATION, TechType.LIVESTOCK);
public Set getPrerequisites() {
return prerequisites;
}
public TechType getType() {
return type;
}
}
public class StrawberriesTech implements Tech {
public TechType type = TechType.STRAWBERRIES;
public static Set<TechType> prerequisites
= EnumSet.of(TechType.VEGETATIONLIVESTOCK);
@Override
public Set getPrerequisites() {
return prerequisites;
}
@Override
public TechType getType() {
return type;
}
}
Here you can add as many parameters as you want, such as a thumbnail icon and description string or whatever.
For a building needing a certain tech:
public class StrawberrySilo implements Building {
private static Set<Tech> prerequisites = EnumSet.of(Tech.STRAWBERRIES);
...
}
Then you could schedule research jobs and construction jobs through the Player class:
public class Player {
private Set<Tech> techsKnown;
public Player() {
techsKnown = EnumSet.of(Tech.NONE);
}
public boolean researchTech(Tech tech) {
if (techsKnown.containsAll(tech.prerequisites())) {
addResearchJob(tech, tech.turnsRequired());
return true;
}
return false;
}
...
public void researchJobDone(Tech tech) {
techsKnown.add(tech);
}
public boolean constructBuilding(Building building) {
if (techsKnown.containsAll(building.prerequisites())) {
addConstructionJob(building, building.turnsRequired());
return true;
}
return false;
}
...
}