) {
this.config = { ...this.config, ...config };
}
@@ -44,6 +49,11 @@ class Player {
async play() {
this.playing = true;
+ this.callback(this.playing, this.ply);
+
+ if (this.ply === this.game.getMoves().length) {
+ this.first();
+ }
while (true) {
await delay(this.interval);
@@ -57,6 +67,7 @@ class Player {
pause() {
this.playing = false;
+ this.callback(this.playing, this.ply);
}
async prev() {
@@ -82,6 +93,7 @@ class Player {
const ply = this.ply + 1;
if (ply >= this.game.length) {
+ this.pause();
return;
}
diff --git a/src/state.ts b/src/state.ts
index cf075fa..9002681 100644
--- a/src/state.ts
+++ b/src/state.ts
@@ -40,6 +40,7 @@ export type State = {
ply: number;
mobile: boolean;
activeTab: "game" | "load";
+ playing: boolean;
};
const initialState: State = {
@@ -56,6 +57,7 @@ const initialState: State = {
ply: 0,
mobile,
activeTab: "load",
+ playing: false,
};
const [state, setState] = createStore(initialState);
diff --git a/src/ui/components/Controls.tsx b/src/ui/components/Controls.tsx
index 87ec11a..f4ec6f0 100644
--- a/src/ui/components/Controls.tsx
+++ b/src/ui/components/Controls.tsx
@@ -1,7 +1,9 @@
-import { Component } from "solid-js";
+import { Component, Show } from "solid-js";
import { Handlers } from "../../types";
import "./Controls.css";
+import { state } from "../../state";
+
const Controls: Component<{ handlers: Handlers }> = (props) => {
return (
@@ -22,9 +24,11 @@ const Controls: Component<{ handlers: Handlers }> = (props) => {