sokko-g/services/cards
Shinuwa dcb06e439b
Some checks failed
Validate and deploy Sokko G / validate (push) Failing after 26m59s
Validate and deploy Sokko G / deploy (push) Has been skipped
Add the Duel des Constellations mini-game
- Guild quest played with the five companions of the daily team on a
  4x4 sky map: arrows from orientation, attack against defence with no
  hidden roll, combos, nine moves, against a Watcher Guardian or another
  player's ghost team, a few games a day.
- Fortune gives clovers: each card ending in the player's camp adds its
  clovers to the stardust reward (the luck roll was removed).
- Board between both hands, drag and drop or click, capture preview,
  animated duel, auto-started game, side colours, short rules.
- Phone layout with colour-only cards and the duel in the mobile mode.
- Admin settings (opening, games per day, rewards, ghost share),
  migration 35, quest board tile with its illustration, docs and tests
  (rules, service, desktop and phone e2e).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-06 23:08:25 +01:00
..
content Add the Broken Mirror puzzle to the Guild 2026-11-28 13:38:46 +01:00
admin-seed.js Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks 2026-12-01 09:42:13 +01:00
alert-messages.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
api.js Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
backup.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
catalog.js Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone 2026-12-04 23:17:23 +01:00
daily-clues.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
daily-image.js Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks 2026-12-01 09:42:13 +01:00
daily.js Let players finish a daily quest game started before midnight instead of being sent back to the start 2026-12-04 10:12:45 +01:00
database.js Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
discord-alerts.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
duel-rules.js Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
duel-service.js Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
duel-settings.js Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
expedition-alerts.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
expedition-content.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
expedition-equipment.js Add an expedition set workshop to build sets without equipping 2026-12-05 15:40:19 +01:00
expedition-group.js Rebalance expedition powers: Adaptation trades surplus for a big boost on the weakest stat, the storm lantern pays loot per unparried danger, forced march no longer costs loot, the rally bell drops its solo penalty, and tune the loot powers to comparable values 2026-12-05 12:41:08 +01:00
expedition-items.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
expedition-progress.js Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone 2026-12-04 23:17:23 +01:00
expedition-rules.js Rebalance expedition powers: Adaptation trades surplus for a big boost on the weakest stat, the storm lantern pays loot per unparried danger, forced march no longer costs loot, the rally bell drops its solo penalty, and tune the loot powers to comparable values 2026-12-05 12:41:08 +01:00
expedition-service.js Let players switch collection views from clear tiles, filter explorer and equipment pickers with a tag and name autocomplete and multi-stat builds, read card stats as gauges with art badges for affinity, tags and worn commons, see short power effects, and save expedition sets that move shared commons between explorers 2026-12-05 12:05:04 +01:00
expedition-sets.js Add an expedition set workshop to build sets without equipping 2026-12-05 15:40:19 +01:00
expedition-settings.js Rebalance expedition powers: Adaptation trades surplus for a big boost on the weakest stat, the storm lantern pays loot per unparried danger, forced march no longer costs loot, the rally bell drops its solo penalty, and tune the loot powers to comparable values 2026-12-05 12:41:08 +01:00
expedition-simulation.js Rebalance expedition powers: Adaptation trades surplus for a big boost on the weakest stat, the storm lantern pays loot per unparried danger, forced march no longer costs loot, the rally bell drops its solo penalty, and tune the loot powers to comparable values 2026-12-05 12:41:08 +01:00
game-rules.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
mirror-image.js Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks 2026-12-01 09:42:13 +01:00
mirror-rules.js Split dailyShare.js and document the shared exported functions with JSDoc 2026-12-01 13:32:20 +01:00
mirror-service.js Let players finish a daily quest game started before midnight instead of being sent back to the start 2026-12-04 10:12:45 +01:00
mirror-settings.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
progress-reset.js Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone 2026-12-04 23:17:23 +01:00
race-rules.js Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone 2026-12-04 23:17:23 +01:00
README.md Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
rewards.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
service.js Add the Duel des Constellations mini-game 2026-12-06 23:08:25 +01:00
stardust.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00
team-race.js Let players finish a daily quest game started before midnight instead of being sent back to the start 2026-12-04 10:12:45 +01:00
team-rules.js Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone 2026-12-04 23:17:23 +01:00
team-service.js Let players finish a daily quest game started before midnight instead of being sent back to the start 2026-12-04 10:12:45 +01:00
team-settings.js Turn the comments that describe functions into JSDoc so the editor shows them on hover 2026-12-01 11:51:47 +01:00

Serveur de Sokko TCG

Tout ce que le serveur sait du jeu de cartes : comptes Discord, collections, paquets, boutique, échanges, quêtes de la Guilde et administration. Les données vivent dans une base SQLite (node:sqlite, synchrone).

Vue d'ensemble du projet : ARCHITECTURE.md. Tables et formats : docs/STORAGE_SCHEMA.md.

Par où commencer

  1. api.js : toutes les routes /api/cards/*, dans l'ordre où elles sont testées. On y voit la connexion Discord, la session par cookie, la vérification CSRF et les limites de débit, puis l'appel au service pour chaque route. createCardsApiHandler() est appelé par server.mjs (production) et vite.config.js (développement).
  2. service.js (CardsService) : les règles métier. Une seule instance, créée par api.js. Elle crée à son tour les sous-services this.team, this.mirror, this.duel et this.expeditions. getState(playerId) construit tout l'état renvoyé au joueur.
  3. database.js : ouverture de la base et liste MIGRATIONS (une requête par version, appliquée une fois, dans l'ordre).

Comment les fichiers se répartissent

Chaque mécanique suit le même découpage :

Rôle Ce qu'il fait Testable sans base
*-rules.js (et daily.js, stardust.js, game-rules.js) Règles pures : calculs, tirages, scores. Ne lisent ni la base ni l'horloge (on leur passe now et random). Oui
*-settings.js Réglages d'administration : valeurs par défaut, bornes, validation, lecture tolérante d'une valeur stockée. Oui
*-service.js Applique les règles avec la base : lectures, écritures en transaction, journal d'audit. Non
*-image.js Prépare une image envoyée au joueur avec sharp. —
Mécanique Fichiers
Socle (comptes, paquets, boutique, échanges, campagnes) service.js, game-rules.js, stardust.js, rewards.js, catalog.js, admin-seed.js
Carte du jour daily.js, daily-clues.js, daily-image.js, content/daily-clues.json
Expéditions expedition-service.js + expedition-group.js, -progress.js, -equipment.js, -items.js, -alerts.js, -sets.js (sets d'explorateur et d'équipements) ; expedition-rules.js, -settings.js, -content.js, -simulation.js ; content/expedition-destinations.json
Alertes Discord expedition-alerts.js (file des messages), alert-messages.js (contenu), discord-alerts.js (envoi par palico-bot)
Équipe du jour et Course des courants team-service.js + team-race.js ; team-rules.js, race-rules.js, team-settings.js
Miroir brisé mirror-service.js, mirror-rules.js, mirror-settings.js, mirror-image.js, content/mirror-illustrations.json
Duel des Constellations duel-service.js, duel-rules.js (partagé avec le navigateur), duel-settings.js ; la main vient de l'Équipe du jour (team-rules.js)
Sauvegardes backup.js (utilisé par scripts/backup-nebula-cards.mjs)
Reset des améliorations (opération ponctuelle, lors d'un rééquilibrage des profils) progress-reset.js (utilisé par scripts/reset-card-progress.mjs)

À savoir avant de modifier

  • Méthodes ajoutées au prototype. ExpeditionService reçoit les méthodes de expedition-group.js, -progress.js, -equipment.js, -alerts.js, -items.js et -sets.js par Object.assign(ExpeditionService.prototype, …) en fin de expedition-service.js. De même, team-race.js complète TeamService. Une méthode appelée sur this peut donc être définie dans un autre fichier : chercher son nom dans tout le dossier.
  • Les sous-services reçoivent CardsService (this.cards) et l'utilisent pour la base, l'horloge, le journal d'audit et le catalogue.
  • Le catalogue vient de deux sources. website/public/data/cards/catalog.json (cartes, éditions, effets, versionné) et la base (taux de tirage, ouverture des collections, variations mythiques, réglés dans l'administration). catalog.js refuse un catalogue JSON qui déclarerait ce qui appartient à la base.
  • Le contenu secret reste côté serveur. Les destinations cachées et les indices de la Carte du jour sont dans content/, jamais envoyés en entier au navigateur.
  • Règles partagées avec le navigateur. race-rules.js est aussi importé par l'interface (website/src/features/cards/team/raceRun.js, team/RaceLive.jsx) : il ne doit importer aucun module Node (node:*).
  • Valeurs par défaut des réglages. Les réglages (Expéditions, Équipe, Miroir, boutique, recharge) sont stockés en base. Changer un défaut dans le code ne change pas une base existante : la valeur stockée l'emporte. Les valeurs de production se lisent et se règlent dans l'administration, pas dans le code.
  • Suffixe InTx. Une méthode qui se termine par InTx écrit sans ouvrir de transaction : l'appelant doit déjà être dans database.transaction().
  • Pas de tâche planifiée pour le jeu. Une expédition est « revenue » dès que sa date de retour est passée au moment d'une lecture ; les groupes en formation sont réglés à la lecture. Seules tournent la maintenance quotidienne et l'envoi des alertes Discord (api.js).
  • Migrations. On ajoute une requête à la fin de MIGRATIONS, on ne modifie jamais une migration livrée.
  • Suppression de compte. Toute nouvelle donnée de joueur doit être effacée ou anonymisée dans deleteAccount() (service.js) et le forgetPlayer() du sous-service concerné.

Vérifier

npm run test:cards                      # tests Node du TCG
node scripts/simulate-expeditions.mjs   # rapport d'équilibrage des Expéditions
node scripts/team-specialties.mjs       # spécialités des personnages d'équipe
node scripts/simulate-team-race.mjs     # garder ou refaire son équipe, mesuré sur la Course (≈ 3 min)
npm run check:cards                     # lint + tests + parcours Playwright du TCG

Les tests sont dans tests/nebula-cards*.test.mjs. Un nouveau fichier de test du TCG doit être ajouté aux listes lint:cards et test:cards de package.json.