-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.php
39 lines (32 loc) · 817 Bytes
/
move.php
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
<?php
class Move {
const STARTING_INDEX = 99;
public function __construct($placements) {
Assert::type($placements, 'Placement');
$this->placements = $placements;
}
public function placements() {
return $this->placements;
}
public function length() {
return count($this->placements());
}
public function changeTiles() {
return count($this->placements) === 0;
}
public function lines(Board $board) {
$lines = [];
foreach ($this->placements() as $placement) {
$theseLines = $placement->lines($board);
$lines = array_merge($lines, $theseLines);
}
return(array_unique($lines));
}
public function __toString() {
$a = [];
foreach ($this->placements() as $placement) {
$a[] = "$placement";
}
return implode(', ', $a);
}
}