No description
  • Rust 47.2%
  • TypeScript 28.1%
  • JavaScript 13.8%
  • Svelte 7%
  • CSS 3.6%
  • Other 0.2%
Find a file
Gregor Zeitlinger c14f97121a
create Remote client (#55)
* remote local client

* remote local client

* remote local client

* remote local client

* controlled players

* remote client state

* get player

* read wasm url dynamically

* add glcanvas dynamically

* clippy
2024-09-28 08:23:27 +02:00
.github/workflows don't replace audit 2023-10-03 14:06:54 +02:00
client create Remote client (#55) 2024-09-28 08:23:27 +02:00
server game api for wasm (#54) 2024-09-27 08:58:25 +02:00
.gitignore create Remote client (#55) 2024-09-28 08:23:27 +02:00
LICENSE Initial commit 2022-12-28 11:56:35 +01:00
README.md create Remote client (#55) 2024-09-28 08:23:27 +02:00

clash

Lines of code

Client

Run native client

  • cd client
  • cargo run.

Run local web client

  • cd client
  • ./build-local.sh local_client
  • cd dist
  • basic-http-server .
  • open http://localhost:4000 in a browser.

Run remote web client locally

  • cd client
  • ./build-remote.sh
  • cd remote_client/dist
  • basic-http-server .
  • google-chrome --disable-web-security --user-data-dir=/tmp http://localhost:8612

Server wrapper

  • cd server
  • cargo install wasm-pack (if you haven't already)
  • ./build-wasm.sh

Notes

Todo

Boardgamers Mono

  • docker run -d -p 27017:27017 mongo:4.4
  • cd apps/api && pnpm seed && echo cron=1 > .env
  • pnpm dev --filter @bgs/api --filter @bgs/game-server --filter @bgs/web --filter @bgs/admin
  • admin: http://localhost:3000 (admin@test.com/password)
  • user: http://localhost:8612/ (user@test.com/password)

old

.tool-versions

nodejs 16.x
pnpm 6.14.1

Bypass npm publish

Index: apps/game-server/app/services/engines.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/apps/game-server/app/services/engines.ts b/apps/game-server/app/services/engines.ts
--- a/apps/game-server/app/services/engines.ts	(revision 741eecd403ed7c5b38b3b98b1e26be8a502cafc0)
+++ b/apps/game-server/app/services/engines.ts	(date 1726905060117)
@@ -7,9 +7,7 @@
 const engines = {};
 
 async function requirePath(name: string, version: number) {
-  const entryPoint = (await GameInfo.findById({ game: name, version }, "engine.entryPoint", { lean: true })).engine
-    .entryPoint;
-  return `../../games/node_modules/${name}_${version}/${entryPoint}`;
+  return `/home/gregor/source/clash/server/pkg`;
 }
 
 export async function getEngine(name: string, version: number): Promise<Engine> {

Set viewer directly

Index: apps/api/app/resources.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/apps/api/app/resources.ts b/apps/api/app/resources.ts
--- a/apps/api/app/resources.ts	(revision 741eecd403ed7c5b38b3b98b1e26be8a502cafc0)
+++ b/apps/api/app/resources.ts	(date 1726922668897)
@@ -31,7 +31,8 @@
 
   const viewer: ViewerInfo =
     gameInfo?.viewer?.alternate?.url && ctx.query.alternate === "1" ? gameInfo?.viewer.alternate : gameInfo.viewer;
-  const viewerUrl = ctx.query.customViewerUrl || viewer.url;
+  const viewerUrl = "/home/gregor/source/clash/client/remote_client/index.js";
 
   ctx.body = `
     <html>
@@ -48,7 +49,9 @@
         </div>
       </body>
       <${"script"} type='text/javascript'>
-        const gameObj = window.${viewer.topLevelVariable}.launch('#app');
+        const gameObj = window.clash.launch('#app');
         window.addEventListener('message', event => {
           console.log('received message from controller', event.data.type, JSON.parse(JSON.stringify(event.data)));
           switch (event.data.type) {

Docs