Package net.sf.colossus.variant
Class MasterBoard
- java.lang.Object
-
- net.sf.colossus.variant.MasterBoard
-
public class MasterBoard extends java.lang.ObjectThe master board as part of a variant. Instances of this class are immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private intboardParity"parity" of the board, so that hexes are displayed the proper wayprivate java.util.Map<java.lang.String,MasterHex>hexByLabelCacheA cache for faster lookup of hexes using their labels.private inthorizSizeThe number of hexes in the widest section.private static java.util.logging.LoggerLOGGERprivate MasterHex[][]plainHexArrayTODO do something more OO, don't use arrays, foldshowinto it somehow (even using null seems better than the split).private boolean[][]showThe hexes in the horizSize*vertSize array that actually exist are represented by true.private java.util.Set<MasterHex>towerSetA Set of all Tower hexes.private intvertSizeThe number of hexes in the tallest section.
-
Constructor Summary
Constructors Constructor Description MasterBoard(int horizSize, int vertSize, boolean[][] show, MasterHex[][] plainHexArray)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intcomputeBoardParity()java.util.Collection<MasterHex>getAllHexes()Return a set of all hex labels.java.util.Set<java.lang.String>getAllHexLabels()Return a set of all hex labels.intgetBoardParity()MasterHexgetHexByLabel(java.lang.String label)Retrieve a hex by its label.intgetHorizSize()MasterHex[][]getPlainHexArray()boolean[][]getShow()java.util.Set<MasterHex>getTowerSet()intgetVertSize()private voidinitHexByLabelCache()booleanisHexInverted(int i, int j)private voidsetupEntrances(MasterHex[][] h)private voidsetupExits(MasterHex[][] h)private voidsetupHexLabelSides(MasterHex[][] h)If the shortest hexside closest to the center of the board is a short hexside, set the label side to it.private voidsetupNeighbors(MasterHex[][] h)private voidsetupOneExit(MasterHex[][] h, int i, int j, int k)private voidsetupTowerSet()
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
horizSize
private final int horizSize
The number of hexes in the widest section.
-
vertSize
private final int vertSize
The number of hexes in the tallest section.
-
boardParity
private final int boardParity
"parity" of the board, so that hexes are displayed the proper way
-
plainHexArray
private final MasterHex[][] plainHexArray
TODO do something more OO, don't use arrays, foldshowinto it somehow (even using null seems better than the split).
-
show
private final boolean[][] show
The hexes in the horizSize*vertSize array that actually exist are represented by true.
-
towerSet
private final java.util.Set<MasterHex> towerSet
A Set of all Tower hexes.
-
hexByLabelCache
private final java.util.Map<java.lang.String,MasterHex> hexByLabelCache
A cache for faster lookup of hexes using their labels.
-
-
Constructor Detail
-
MasterBoard
public MasterBoard(int horizSize, int vertSize, boolean[][] show, MasterHex[][] plainHexArray)
-
-
Method Detail
-
getBoardParity
public int getBoardParity()
-
getPlainHexArray
public MasterHex[][] getPlainHexArray()
-
getShow
public boolean[][] getShow()
-
getHorizSize
public int getHorizSize()
-
getVertSize
public int getVertSize()
-
computeBoardParity
private int computeBoardParity()
-
setupExits
private void setupExits(MasterHex[][] h)
-
setupOneExit
private void setupOneExit(MasterHex[][] h, int i, int j, int k)
-
setupEntrances
private void setupEntrances(MasterHex[][] h)
-
setupHexLabelSides
private void setupHexLabelSides(MasterHex[][] h)
If the shortest hexside closest to the center of the board is a short hexside, set the label side to it. Else set the label side to the opposite hexside.
-
isHexInverted
public boolean isHexInverted(int i, int j)
-
setupNeighbors
private void setupNeighbors(MasterHex[][] h)
-
initHexByLabelCache
private void initHexByLabelCache()
-
getHexByLabel
public MasterHex getHexByLabel(java.lang.String label)
Retrieve a hex by its label.- Parameters:
label- The label to find the hex for. Valid label, not null.- Returns:
- The label found.
-
getTowerSet
public java.util.Set<MasterHex> getTowerSet()
-
setupTowerSet
private void setupTowerSet()
-
getAllHexLabels
public java.util.Set<java.lang.String> getAllHexLabels()
Return a set of all hex labels.
-
getAllHexes
public java.util.Collection<MasterHex> getAllHexes()
Return a set of all hex labels.
-
-