BGS lets the only human of a game against bots take back their last saved move (protocol 0.10.0). Both viewers show an "Undo my move" control with the turn tools (an icon in the mobile action tray's title bar) while BGS reports it available on that player's live board: never to spectators, nor in replays, planning, BGS analysis or tutorials, nor while a queued plan awaits the server. It asks BGS to undo; when the earlier state arrives, selections made on the later board are dropped with the turn being composed. Back still steps through the turn being composed, locally. - @boardgamers/protocol 0.8.1 -> 0.10.0 (added to minimumReleaseAgeExclude) - "Undo my move" in all 16 locales - unit tests, a browser smoke test of both bundles, and BGS-like undo in the local premove preview - viewer 5.20.58, old-ui 1.0.21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
145 lines
4.6 KiB
HTML
145 lines
4.6 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
<title>Gaia Project · Premoves preview</title>
|
|
<link rel="stylesheet" href="/bundle.css" />
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
}
|
|
.preview-tools {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 10px 16px;
|
|
background: #123a5a;
|
|
color: #fff;
|
|
flex-wrap: wrap;
|
|
}
|
|
.preview-tools a {
|
|
color: #cceaff;
|
|
}
|
|
.preview-tools strong {
|
|
margin-right: auto;
|
|
}
|
|
.preview-tools button {
|
|
border: 1px solid #82a9c7;
|
|
background: transparent;
|
|
color: #fff;
|
|
border-radius: 5px;
|
|
padding: 5px 10px;
|
|
}
|
|
#error {
|
|
color: #902b20;
|
|
background: #fff2e9;
|
|
padding: 10px;
|
|
}
|
|
#error:empty {
|
|
display: none;
|
|
}
|
|
#button-gallery {
|
|
padding: 12px;
|
|
}
|
|
#button-gallery h1 {
|
|
font-size: 22px;
|
|
}
|
|
#button-gallery h2 {
|
|
font-size: 18px;
|
|
margin: 22px 0 12px;
|
|
}
|
|
#button-gallery .gallery-buttons {
|
|
position: static !important;
|
|
max-height: none !important;
|
|
overflow: visible !important;
|
|
padding: 0;
|
|
box-shadow: none;
|
|
}
|
|
.gallery-grid {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
}
|
|
.gallery-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
max-width: 100%;
|
|
}
|
|
.gallery-item small {
|
|
max-width: 145px;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header class="preview-tools">
|
|
<strong>Gaia Project · Local premove preview</strong><a id="other" target="_blank">Other player's view ↗</a
|
|
><button id="opponent">Play opponent's turn</button><button id="reset">Reset position</button
|
|
><button id="theme">Light / dark</button>
|
|
</header>
|
|
<div id="error" role="alert"></div>
|
|
<div id="app"></div>
|
|
<script src="/vue.js"></script>
|
|
<script src="/bootstrap.js"></script>
|
|
<script src="/bundle.js"></script>
|
|
<script src="/button-gallery.js"></script>
|
|
<script>
|
|
const seat = Number(new URL(location.href).searchParams.get("seat") ?? 1);
|
|
const host = gaiaViewer.launch("#app");
|
|
let revision = -1;
|
|
document.querySelector("#other").href = "/?seat=" + (1 - seat);
|
|
async function send(path, body) {
|
|
const response = await fetch(
|
|
path + "?seat=" + seat,
|
|
body === undefined
|
|
? {}
|
|
: { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }
|
|
);
|
|
const data = await response.json();
|
|
if (data.error) {
|
|
host.store.commit("planError", data.error);
|
|
document.querySelector("#error").textContent = data.error;
|
|
return;
|
|
}
|
|
document.querySelector("#error").textContent = "";
|
|
revision = data.revision;
|
|
host.emit("state", data.state);
|
|
if (data.settings) host.emit("settings", data.settings);
|
|
host.emit("undo:available", data.undoAvailable);
|
|
}
|
|
host.on("fetchState", () => send("/state"));
|
|
host.on("move", (move) => send("/move", { move }));
|
|
host.on("undo", () => send("/undo", {}));
|
|
host.on("update:setting", (setting) => send("/settings", setting));
|
|
host.emit("player", { index: seat });
|
|
host.emit("preferences", { sound: false });
|
|
host.emit("chat:state", { canSend: false, mentions: [] });
|
|
host.emit("chat:messages", []);
|
|
document.querySelector("#opponent").onclick = () => send("/opponent", {});
|
|
document.querySelector("#reset").onclick = () => {
|
|
localStorage.clear();
|
|
send("/reset", {});
|
|
};
|
|
document.querySelector("#theme").onclick = () => {
|
|
const dark = document.documentElement.dataset.theme !== "dark";
|
|
document.documentElement.classList.toggle("dark", dark);
|
|
host.emit("theme", { dark });
|
|
};
|
|
setInterval(async () => {
|
|
const response = await fetch("/state?seat=" + seat);
|
|
const data = await response.json();
|
|
if (data.revision !== revision) {
|
|
revision = data.revision;
|
|
host.emit("state", data.state);
|
|
if (data.settings) host.emit("settings", data.settings);
|
|
host.emit("undo:available", data.undoAvailable);
|
|
}
|
|
}, 1000);
|
|
send("/state").then(() => {
|
|
if (new URL(location.href).searchParams.has("buttons")) showButtonGallery(host);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|