diff --git a/html/index.php b/html/index.php
new file mode 100644
index 0000000..654c4a6
--- /dev/null
+++ b/html/index.php
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/bB.svg b/html/static/pieces/bB.svg
new file mode 100644
index 0000000..fd71645
--- /dev/null
+++ b/html/static/pieces/bB.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/bK.svg b/html/static/pieces/bK.svg
new file mode 100644
index 0000000..8114d17
--- /dev/null
+++ b/html/static/pieces/bK.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/bN.svg b/html/static/pieces/bN.svg
new file mode 100644
index 0000000..2c2c534
--- /dev/null
+++ b/html/static/pieces/bN.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/bQ.svg b/html/static/pieces/bQ.svg
new file mode 100644
index 0000000..005c223
--- /dev/null
+++ b/html/static/pieces/bQ.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/bR.svg b/html/static/pieces/bR.svg
new file mode 100644
index 0000000..c9339b0
--- /dev/null
+++ b/html/static/pieces/bR.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/w.svg b/html/static/pieces/w.svg
new file mode 100644
index 0000000..9949318
--- /dev/null
+++ b/html/static/pieces/w.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/wB.svg b/html/static/pieces/wB.svg
new file mode 100644
index 0000000..3d7deb0
--- /dev/null
+++ b/html/static/pieces/wB.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/wK.svg b/html/static/pieces/wK.svg
new file mode 100644
index 0000000..08189e8
--- /dev/null
+++ b/html/static/pieces/wK.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/wN.svg b/html/static/pieces/wN.svg
new file mode 100644
index 0000000..005c337
--- /dev/null
+++ b/html/static/pieces/wN.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/wQ.svg b/html/static/pieces/wQ.svg
new file mode 100644
index 0000000..d5c5ee4
--- /dev/null
+++ b/html/static/pieces/wQ.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/pieces/wR.svg b/html/static/pieces/wR.svg
new file mode 100644
index 0000000..c149104
--- /dev/null
+++ b/html/static/pieces/wR.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/html/static/styles.css b/html/static/styles.css
new file mode 100644
index 0000000..df00f08
--- /dev/null
+++ b/html/static/styles.css
@@ -0,0 +1,44 @@
+* {
+ box-sizing: border-box;
+}
+
+.board {
+ width: 400px;
+ height: 400px;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ align-content: flex-start;
+}
+
+.square {
+ width: 12.5%;
+ height: 12.5%;
+}
+
+.square.black {
+ background-color: brown;
+}
+
+.square.white {
+ background-color: lightgoldenrodyellow;
+}
+
+.square.black.hasMoves {
+ background-color: green;
+}
+
+.square.white.hasMoves {
+ background-color: greenyellow;
+}
+
+.piece {
+ width: 100%;
+ height: 100%;
+ position: relative;
+}
+
+.piece img {
+ width: 100%;
+ z-index: 10;
+}
\ No newline at end of file
diff --git a/src/Game/Game.php b/src/Game/Game.php
index bb52522..285c0e7 100644
--- a/src/Game/Game.php
+++ b/src/Game/Game.php
@@ -412,6 +412,14 @@ class Game {
return GameState::DEFAULT;
}
+ public function getPiece(Position $position): Piece|false {
+ return current(array_filter($this->pieces, fn($p) => $p->getPosition()->equals($position)));
+ }
+
+ public function getMovesForPiece(Piece $piece): array {
+ return array_values(array_filter($this->getLegalMoves(), fn($m) => $piece->equals($m->getPiece())));
+ }
+
public function visualize(): string {
$result = " ";
@@ -428,7 +436,7 @@ class Game {
$position = new Position($file, $rank);
$result .= "\033[" . ($position->getSquareColor() == Side::WHITE ? 47 : 100) . "m";
- $piece = current(array_filter($this->pieces, fn($p) => $p->getPosition()->equals($position)));
+ $piece = $this->getPiece($position);
if ($piece) {
if ($piece->getSide() == Side::WHITE) {
$result .= "\033[97m";
diff --git a/src/Game/Move.php b/src/Game/Move.php
index 40960a3..2de89ae 100644
--- a/src/Game/Move.php
+++ b/src/Game/Move.php
@@ -126,6 +126,10 @@ class Move {
return $result;
}
+ public function getPiece(): Piece {
+ return $this->piece;
+ }
+
public function getLong(?Game $game = null): string {
if ($this->isCastles()) {
$result = $this->getCastlesMarker();
diff --git a/src/View/base.php b/src/View/base.php
new file mode 100644
index 0000000..0832937
--- /dev/null
+++ b/src/View/base.php
@@ -0,0 +1,12 @@
+
+
+
+ test
+
+
+
+
+
+
diff --git a/src/View/fragments/board.php b/src/View/fragments/board.php
new file mode 100644
index 0000000..ccc7c31
--- /dev/null
+++ b/src/View/fragments/board.php
@@ -0,0 +1,55 @@
+getSide() == Side::WHITE ? "w" : "b") .
+ $piece->getType()->getShort() .
+ ".svg";
+}
+
+?>
+
+ getPiece($position);
+ $moves = $piece ? $game->getMovesForPiece($piece) : [];
+ ?>
+
">
+
+
+
 ?>)
+
+
+
+
+
diff --git a/src/core.php b/src/core.php
new file mode 100644
index 0000000..5e1901c
--- /dev/null
+++ b/src/core.php
@@ -0,0 +1,5 @@
+