aboutsummaryrefslogtreecommitdiff
path: root/src/Tile/Tile.ts
blob: 5bc6a7a728dff816879402c48252915c9e25e04f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export enum Direction {
  North,
  East,
  South,
  West
}

export enum Feature {
  Grass = 'G',
  Road = 'R',
  Town = 'T',
  River = 'I',
  Church = 'C',
}


// Abstract Tile data
export default class Tile {
  center: Feature;
  sides: [Feature, Feature, Feature, Feature];
  shield?: boolean;

  public constructor(
    center: Feature,
    sides: [Feature, Feature, Feature, Feature],
    shield = false
  ) {
    this.center = center;
    this.sides = sides;
    this.shield = shield;
  }

  getSide(direction: Direction) {
    return this.sides[((direction % 4) + 4) % 4];
  }

  print() {
    console.log( ` ${this.getSide(Direction.North)} \n${this.getSide(Direction.West)}${this.center}${this.getSide(Direction.East)}\n ${this.getSide(Direction.South)} `);
  }
}