alles fertig

This commit is contained in:
Hikyu
2026-07-10 21:21:19 +02:00
parent a35e6a99cb
commit 91c3266d86
24 changed files with 842 additions and 369 deletions
-35
View File
@@ -1,35 +0,0 @@
Default to using Bun instead of Node.js.
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
- Use `bun test` instead of `jest` or `vitest`
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
- Bun automatically loads .env, so don't use dotenv.
## APIs
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
- `arangojs` for ArangoDB. ArangoDB has no built-in Bun client.
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
- `WebSocket` is built-in. Don't use `ws`.
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
- Bun.$`ls` instead of execa.
## Datenmodell (ArangoDB als Key-Value)
ArangoDB ist multimodal, wir nutzen es hier bewusst als reinen Key-Value-Store,
damit der Vergleich direkt zu Redis passt. Alles liegt in einer Collection `kv`.
Jedes Dokument hat den Redis-Key als `_key` und den Wert im Feld `value`.
- `player:{id}` -> value = Objekt
- `player:{id}:weapon` / `:armor` / `:talisman` -> value = Array mit item_ids
- `item:{id}`, `enemy:{id}`, `region:{id}` -> value = Objekt
- `region:{id}:items` / `:enemies`, `enemy:{id}:items` -> value = Array mit ids
- `weapon:{id}`, `armor:{id}`, `shield:{id}`, `talisman:{id}`, `item_effect:{id}`, `item_type:{id}` -> value = Objekt
## Coding Style Preferences
- Write everything WITHOUT comments.
-8
View File
@@ -1,8 +0,0 @@
# Projekt-Dokumentation: Entwicklungsreihenfolge
1. Projekt init (gleicher Aufbau wie client-redit)
2. Docker compose mit arangodb
3. Einfache verbindung (arangojs)
4. ArangoDB getestet (mit save und document)
5. Init-Skript (db/init.ts) mit ~100 statischen Entitäten erstellt (gleiche Daten wie Redis, aber als Key-Value-Dokumente in einer Collection)
6. Client (index.ts) aktualisiert Player-Daten live und liest statische Gegner-Daten
+5 -5
View File
@@ -41,12 +41,12 @@ async function readSingle(_i: number) {
}
async function readRegion(_i: number) {
const region = await getVal("region:1");
const region = await getVal("bench:region:1");
void region?.name;
const enemyIds = (await getVal("region:1:enemies")) || [];
const itemIds = (await getVal("region:1:items")) || [];
for (const id of enemyIds) await getVal(`enemy:${id}`);
for (const id of itemIds) await getVal(`item:${id}`);
const enemyIds = (await getVal("bench:region:1:enemies")) || [];
const itemIds = (await getVal("bench:region:1:items")) || [];
for (const id of enemyIds) await getVal(`bench:enemy:${id}`);
for (const id of itemIds) await getVal(`bench:item:${id}`);
}
async function writeRegion(_i: number) {