def testConversion(self): for i in range(100): for j in range(100): h0 = Hex(t=(i, j)) h1 = Hex(i, j) c1 = h1.cube() c2 = h0.cube() h2 = c1.hex() self.assertEqual(h0, h1, f'conversion error: {h0} -> {h1}') self.assertEqual(h0, h1, f'conversion error: {c1} -> {c2}') self.assertEqual(h1, h2, f'conversion error: {h1} -> {c2} -> {h2}')
def __init__(self, position: Hex, terrain: Terrain, geography: int, objective: bool, blockLos: bool, color: str = 'white'): self.terrain = terrain self.geography = geography self.objective = objective self.blockLos = blockLos self.cube = position.cube() self.color = color self.i, self.j = position.tuple() self.x, self.y = pos_to_xy((self.i, self.j))
def scroll(board: GameBoard): x, y = board.shape objectiveMarks = board.getObjectiveMark() for i in range(0, x): for j in range(0, y): p = Hex(i, j) x = p.tuple() index = board.terrain[x] tt = TYPE_TERRAIN[index] h = Hexagon(p, tt, board.geography[x], p.cube() in objectiveMarks, tt.blockLos, tt.color) yield h