blob: f1aa45bb882ad78a74732600b036423bdef81117 (
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
|
import _ from 'lodash';
import Tile, { Feature } from "../Tile/Tile";
const { Road, Town, Empty } = Feature;
export default class Board {
cells: Tile[];
constructor(cells?: Tile[]) {
if (cells) this.cells = cells;
else this.cells = [new Tile(Road, [Town, Road, Empty, Road])]
}
print() {
this.cells.forEach(cell => cell.print());
}
getAttachments(cell: Tile) {
return _.flatten(this.cells.map(attachTo => attachTo.getAttachments(cell)));
}
getLegalMoves(cell: Tile) {
const attachments = this.getAttachments(cell);
console.log(attachments);
}
}
|