Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 1x 1x 1x 972371x 165493x 165493x 165493x 165493x 165493x 248497x 248497x 248497x 248497x 248497x 558381x 558381x 558381x 558381x 558381x 972371x 972371x 1312804x 1312804x 1312804x 1312804x 1312804x 1312804x 1312804x 1312804x 693570x 164842x 186949x 175245x 166534x 278801x 278801x 170718x 278801x 195918x 278801x 178506x 278801x 173428x 278801x | /**
* @author Timo Lehnertz
*/
import { Heading } from "./Heading";
import { TileType } from "./PathTile";
/**
* Immutable OpenSides class representing the open sides of a tile
*/
export class OpenSides {
public readonly northOpen: boolean;
public readonly eastOpen: boolean;
public readonly southOpen: boolean;
public readonly westOpen: boolean;
public constructor(tileType: TileType, rotation: number) {
switch (tileType) {
case TileType.STREIGHT:
this.northOpen = false;
this.eastOpen = true;
this.southOpen = false;
this.westOpen = true;
break;
case TileType.L:
this.northOpen = false;
this.eastOpen = true;
this.southOpen = true;
this.westOpen = false;
break;
case TileType.T:
this.northOpen = true;
this.eastOpen = true;
this.southOpen = false;
this.westOpen = true;
break;
}
while (rotation < 0) {
rotation += 4;
}
for (let i = 0; i < rotation; i++) {
const newNorthOpen: boolean = this.northOpen;
const newEastOpen: boolean = this.eastOpen;
const newSouthOpen: boolean = this.southOpen;
const newWestOpen: boolean = this.westOpen;
this.northOpen = newWestOpen;
this.eastOpen = newNorthOpen;
this.southOpen = newEastOpen;
this.westOpen = newSouthOpen;
}
}
public isOpposingOpen(heading: Heading): boolean {
switch (heading) {
case Heading.NORTH:
return this.southOpen;
case Heading.EAST:
return this.westOpen;
case Heading.SOUTH:
return this.northOpen;
case Heading.WEST:
return this.eastOpen;
}
}
public get headings(): Heading[] {
const headings: Heading[] = [];
if (this.northOpen) {
headings.push(Heading.NORTH);
}
if (this.eastOpen) {
headings.push(Heading.EAST);
}
if (this.southOpen) {
headings.push(Heading.SOUTH);
}
if (this.westOpen) {
headings.push(Heading.WEST);
}
return headings;
}
}
|