-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpiece.php
More file actions
64 lines (52 loc) · 1.37 KB
/
piece.php
File metadata and controls
64 lines (52 loc) · 1.37 KB
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
<?php
class Piece {
private $posX;
private $posY;
private $pId;
//private $isKing;
private $moveX;
private $moveY;
public function __construct($x,$y,$direction,$id) {
$this->moveY = array(-1,1); // move options on x-axis
$this->moveX = array($direction); // move options on y-axis
$this->posX = $x;
$this->posY = $y;
$this->pId = $id;
//$this->isKing = false;
}
public function getPosX() {
return $this->posX;
}
public function getPosY() {
return $this->posY;
}
public function getId() {
return $this->pId;
}
public function getDirection() {
return $this->moveX;
}
public function setPos($x,$y) {
$this->posX = $x;
$this->posY = $y;
}
public function king() {
$this->moveX = array(-1,1); // piece is able to move positive & negative on y-axis
}
/*
public function possibleMoves() {
foreach ($this->moveY as $dirY) {
foreach ($this->moveX as $dirX) {
//$this->moveX;
}
}
if ($this->posX > 8 || $this->posX < 1 || $this->posY > 8 || $this->posY < 1) {
// Invalid Move!
}
//elseif(This Square Is Occupied)
}
public function makeKing() {
$this->moveY = array(-1,1);
}
*/
} // End class definition