I am trying to create this class called Terrain for a board game I am trying to build in Java, but I will try and make this post as generic as possible so it can be explained in any OOP language, in pseudo code.
This game has 36 hex shaped tiles, each Tile is a different Terrain. Terrain has 8 types, like Swamp, Forest, Mountain etc. Each terrain holds how many moves you can make, it can also hold Creatures and Buildings (which are two different classes), or at least have Creatures and Buildings associated with a specific terrain.
I am not sure I want an enum to represent the 8 types of terrains, or if it is even necessary.
Essentially what I want to be able to do with this class is say something like:
Terrain t0 = new Swamp();
Terrain t1 = new Forest();
And then I want to be able to associate the neighbour's of each terrain with that specific terrain, so something like:
//terrain 0, neighbour 0
t0.n0 = t1;
//terrain 0, neighbour 1
t0.n1 = t7;
//terrain 0, neighbour 2
t0.n2 = t8;
//terrain 0, neighbour 3
t0.n3 = t2;
//terrain 0, neighbour 4
t0.n4 = t23;
//terrain 0, neighbour 5
t0.n5 = t22;
etc.
I think it should be something like:
public class Terrain{
public int moves = 0;
public Terrain(int m){
moves = m;
}
}
I am really not sure what to do with the types of Terrains as I said...
I have worked out by hand what all of the connections for each tiles for the game board should be, but I am not sure how to translate this into code, or into a class for Terrain. If anyone has any suggestions, I would really appreciate it.