doc: maj readme
This commit is contained in:
parent
82803ded36
commit
9cc605409e
2 changed files with 3 additions and 157 deletions
|
|
@ -2,10 +2,7 @@
|
||||||
|
|
||||||
This is a game of [Trictrac](https://en.wikipedia.org/wiki/Trictrac) rust implementation.
|
This is a game of [Trictrac](https://en.wikipedia.org/wiki/Trictrac) rust implementation.
|
||||||
|
|
||||||
The project is on its early stages.
|
The project is still on its early stages.
|
||||||
Rules (without "schools") are implemented, as well as a rudimentary terminal interface which allow you to play against a bot which plays randomly.
|
|
||||||
|
|
||||||
Training of AI bots is the work in progress.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
@ -29,9 +26,9 @@ Playing with the cli against the 'random' bot: `cargo run --bin=client_cli -- --
|
||||||
- [x] rules
|
- [x] rules
|
||||||
- [x] command line interface
|
- [x] command line interface
|
||||||
- [x] basic bot (random play)
|
- [x] basic bot (random play)
|
||||||
|
- [ ] web client (in progress)
|
||||||
|
- [ ] network game (in progress)
|
||||||
- [ ] AI bot
|
- [ ] AI bot
|
||||||
- [ ] network game
|
|
||||||
- [ ] web client
|
|
||||||
|
|
||||||
## Code structure
|
## Code structure
|
||||||
|
|
||||||
|
|
|
||||||
151
clients/web-game/dist/index.html
vendored
151
clients/web-game/dist/index.html
vendored
|
|
@ -1,151 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<title>Trictrac</title>
|
|
||||||
|
|
||||||
<script type="module">
|
|
||||||
import init, * as bindings from '/client_web-4248a2b78bb5a03.js';
|
|
||||||
const wasm = await init({ module_or_path: '/client_web-4248a2b78bb5a03_bg.wasm' });
|
|
||||||
|
|
||||||
|
|
||||||
window.wasmBindings = bindings;
|
|
||||||
|
|
||||||
|
|
||||||
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="/style-398501cc5e039e60.css" integrity="sha384-2ThBpr9kkUyidGty3yoW5Ko7K/BgvwfBPFT7LeUlz6UN1/i79c/hWGkSxyb2jQEy"/>
|
|
||||||
<link rel="modulepreload" href="/client_web-4248a2b78bb5a03.js" crossorigin="anonymous" integrity="sha384-RV1mp1Eo8sE16ldXkdWXd7O5F6KPrauzW++dBoewVErNRRjIDRP1Qec4gg8eEwbn"><link rel="preload" href="/client_web-4248a2b78bb5a03_bg.wasm" crossorigin="anonymous" integrity="sha384-cv/IN4k4mpulOZfHv2tWRwdZEY/Fw5cj/wWch7btaCRmegCbsiYD392KpUMFUTLF" as="fetch" type="application/wasm"></head>
|
|
||||||
<body><script>"use strict";
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
const address = '{{__TRUNK_ADDRESS__}}';
|
|
||||||
const base = '{{__TRUNK_WS_BASE__}}';
|
|
||||||
let protocol = '';
|
|
||||||
protocol =
|
|
||||||
protocol
|
|
||||||
? protocol
|
|
||||||
: window.location.protocol === 'https:'
|
|
||||||
? 'wss'
|
|
||||||
: 'ws';
|
|
||||||
const url = protocol + '://' + address + base + '.well-known/trunk/ws';
|
|
||||||
|
|
||||||
class Overlay {
|
|
||||||
constructor() {
|
|
||||||
// create an overlay
|
|
||||||
this._overlay = document.createElement("div");
|
|
||||||
const style = this._overlay.style;
|
|
||||||
style.height = "100vh";
|
|
||||||
style.width = "100vw";
|
|
||||||
style.position = "fixed";
|
|
||||||
style.top = "0";
|
|
||||||
style.left = "0";
|
|
||||||
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
|
|
||||||
style.fontFamily = "sans-serif";
|
|
||||||
// not sure that's the right approach
|
|
||||||
style.zIndex = "1000000";
|
|
||||||
style.backdropFilter = "blur(1rem)";
|
|
||||||
|
|
||||||
const container = document.createElement("div");
|
|
||||||
// center it
|
|
||||||
container.style.position = "absolute";
|
|
||||||
container.style.top = "30%";
|
|
||||||
container.style.left = "15%";
|
|
||||||
container.style.maxWidth = "85%";
|
|
||||||
|
|
||||||
this._title = document.createElement("div");
|
|
||||||
this._title.innerText = "Build failure";
|
|
||||||
this._title.style.paddingBottom = "2rem";
|
|
||||||
this._title.style.fontSize = "2.5rem";
|
|
||||||
|
|
||||||
this._message = document.createElement("div");
|
|
||||||
this._message.style.whiteSpace = "pre-wrap";
|
|
||||||
|
|
||||||
const icon= document.createElement("div");
|
|
||||||
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
|
|
||||||
this._title.prepend(icon);
|
|
||||||
|
|
||||||
container.append(this._title, this._message);
|
|
||||||
this._overlay.append(container);
|
|
||||||
|
|
||||||
this._inject();
|
|
||||||
window.setInterval(() => {
|
|
||||||
this._inject();
|
|
||||||
}, 250);
|
|
||||||
}
|
|
||||||
|
|
||||||
set reason(reason) {
|
|
||||||
this._message.textContent = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
_inject() {
|
|
||||||
if (!this._overlay.isConnected) {
|
|
||||||
// prepend it
|
|
||||||
document.body?.prepend(this._overlay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Client {
|
|
||||||
constructor(url) {
|
|
||||||
this.url = url;
|
|
||||||
this.poll_interval = 5000;
|
|
||||||
this._overlay = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
const ws = new WebSocket(this.url);
|
|
||||||
ws.onmessage = (ev) => {
|
|
||||||
const msg = JSON.parse(ev.data);
|
|
||||||
switch (msg.type) {
|
|
||||||
case "reload":
|
|
||||||
this.reload();
|
|
||||||
break;
|
|
||||||
case "buildFailure":
|
|
||||||
this.buildFailure(msg.data)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ws.onclose = () => this.onclose();
|
|
||||||
}
|
|
||||||
|
|
||||||
onclose() {
|
|
||||||
window.setTimeout(
|
|
||||||
() => {
|
|
||||||
// when we successfully reconnect, we'll force a
|
|
||||||
// reload (since we presumably lost connection to
|
|
||||||
// trunk due to it being killed, so it will have
|
|
||||||
// rebuilt on restart)
|
|
||||||
const ws = new WebSocket(this.url);
|
|
||||||
ws.onopen = () => window.location.reload();
|
|
||||||
ws.onclose = () => this.onclose();
|
|
||||||
},
|
|
||||||
this.poll_interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
reload() {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
buildFailure({reason}) {
|
|
||||||
// also log the console
|
|
||||||
console.error("Build failed:", reason);
|
|
||||||
|
|
||||||
console.debug("Overlay", this._overlay);
|
|
||||||
|
|
||||||
if (!this._overlay) {
|
|
||||||
this._overlay = new Overlay();
|
|
||||||
}
|
|
||||||
this._overlay.reason = reason;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new Client(url).start();
|
|
||||||
|
|
||||||
})()
|
|
||||||
</script></body>
|
|
||||||
</html>
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue