-
Notifications
You must be signed in to change notification settings - Fork 0
/
knight.ts
40 lines (34 loc) · 945 Bytes
/
knight.ts
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
import { Color } from '../types/color';
import { Piece } from '../base/piece';
import { PieceType } from '../types/piece-type';
import { Move } from '../base/moving-strategy';
import { RegularMove } from '../moves/regular-move';
export class Knight extends Piece {
constructor(protected _color: Color) {
super(_color);
}
get type() {
return PieceType.KNIGHT;
}
get image(): string {
return `${this.color}Knight.png`;
}
get materialValue(): number {
return 3;
}
get isKing(): boolean {
return false;
}
get moves(): Move[] {
return [
new RegularMove(17), // Move up 2, right 1
new RegularMove(15), // Move up 2, left 1
new RegularMove(10), // Move up 1, right 2
new RegularMove(6), // Move up 1, left 2
new RegularMove(-17), // Move down 2, left 1
new RegularMove(-15), // Move down 2, right 1
new RegularMove(-10), // Move down 1, left 2
new RegularMove(-6), // Move down 1, right 2
];
}
}