Let Sokko TCG players level up cards for Expeditions with Éclats or duplicates
- Each owned rare or better edition keeps a level and field experience; a level costs Éclats by current power, so every rarity reaches the same cap and a rare pays the longer road. - A duplicate of the same edition gives a whole level; every claimed expedition grants field experience to the cards it sent. - A one-way bridge turns stardust into Éclats at an admin-tuned rate. - The card sheet shows level, power, stats and experience with upgrade buttons; expeditions use the upgraded power. - Administration › Guilde tunes the cost formula, duplicate levels, field experience and the bridge rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6b7605d04e
commit
e0ffccd1c8
22 changed files with 373 additions and 10 deletions
|
|
@ -346,3 +346,4 @@
|
|||
{"id":"int-2eb4267321abcd9d03371b62fdd602ef","kind":"field_change","created_at":"2026-11-15T12:58:18.78522507Z","actor":"Shinuwa","issue_id":"sokko-g-v3u4.2","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Étiquettes et profils dans le catalogue + validation, 12 destinations côté serveur + validation, réglages (schéma, défauts, fusion, validation, diff), règles pures, simulateur et test d'équilibrage, docs agent et skill new-card. npm test : 300/300."}}
|
||||
{"id":"int-13028497227d5b47c5cac5cc0d43849f","kind":"field_change","created_at":"2026-11-15T13:19:13.339585179Z","actor":"Shinuwa","issue_id":"sokko-g-v3u4.3","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Expéditions solo livrées : migration 8, service + API, panneau joueur, tuile de Guilde, réglages et suivi en administration, historique, tests Node (309) et e2e (13/13), docs."}}
|
||||
{"id":"int-614b08dc72f5c9257c5a56d344fc9410","kind":"field_change","created_at":"2026-11-15T13:42:33.208763715Z","actor":"Shinuwa","issue_id":"sokko-g-v3u4.4","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Expéditions de groupe : tableau, ouverture, inscription par rôle, départ par le créateur, Veilleur sans rôle, garde-fou d'inscription, cohésion, butin par joueur, réglages admin. npm run check 314/314, e2e cards 13/13."}}
|
||||
{"id":"int-8268aa35e75af62cd990afd91d02ef81","kind":"field_change","created_at":"2026-11-15T13:52:38.41466395Z","actor":"Shinuwa","issue_id":"sokko-g-v3u4.5","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Améliorations : niveaux par Éclats ou doublon, expérience de terrain, pont poussière vers Éclats, progression dans la fiche de carte, réglages admin. npm run check 317/317, e2e cards 13/13."}}
|
||||
|
|
|
|||
|
|
@ -1492,6 +1492,11 @@ cohésion, butin par joueur), puis « Rejoindre » (rôle libre et carte, sous l
|
|||
« Lancer l’expédition » pour le créateur dès le minimum de joueurs, et « Quitter » ou « Dissoudre ».
|
||||
Un sélecteur « Seul / En groupe » (`nds-toolbar` de boutons à `aria-pressed`) précède la préparation ;
|
||||
en groupe, l'équipe se réduit à un rôle choisi et une carte.
|
||||
La fiche d'une carte rare ou mieux ajoute un encadré « Expéditions » : niveau, Puissance et stats,
|
||||
barre `nds-progress` d'expérience de terrain, bouton primaire « Améliorer · N Éclats » et bouton
|
||||
secondaire « Améliorer avec un doublon » quand un doublon est libre. La page des Expéditions place
|
||||
sous son en-tête le Pont des Veilleurs (`nds-panel` compact : nombre d'Éclats, coût en poussière,
|
||||
bouton secondaire « Convertir »).
|
||||
En administration, la section Guilde ajoute sous la Carte du jour un panneau par groupe de réglages
|
||||
des Expéditions (champs en grille, listes de valeurs côte à côte, `ApplyActions`), les destinations
|
||||
(proposée ou retirée, poids) et le suivi du jour avec l'annulation d'une expédition en cours.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ L'interface cible les fenêtres d'ordinateur en plein écran ou en demi-écran.
|
|||
de rareté, une récompense en poussière d'étoiles et un résultat à partager.
|
||||
- Expéditions de Sokko TCG, seconde quête de la Guilde : des cartes rares ou mieux partent, seules ou
|
||||
en groupe de 2 à 4 joueurs (une carte chacun, groupe lancé par son créateur), vers une destination du jour (difficulté, durée, rôles, dangers) et rapportent des Éclats
|
||||
d'étoile, de la poussière et parfois un paquet. Toutes les valeurs se règlent dans
|
||||
d'étoile, de la poussière et parfois un paquet. Les Éclats (ou un doublon) font monter le niveau et
|
||||
la Puissance d'une carte jusqu'à un plafond commun à toutes les raretés ; un pont convertit la
|
||||
poussière en Éclats. Toutes les valeurs se règlent dans
|
||||
l'administration ; `node scripts/simulate-expeditions.mjs` affiche le rapport d'équilibrage.
|
||||
|
||||
## Démarrage
|
||||
|
|
|
|||
|
|
@ -164,6 +164,19 @@ Expéditions (migration 8, règles pures dans `services/cards/expedition-rules.j
|
|||
état, Expéditions, tableau de bord) fait partir le groupe à `recruitUntil` s'il a assez de joueurs,
|
||||
sinon le dissout : `expedition_dissolved` dans l'historique des membres. Un compte supprimé quitte
|
||||
un groupe en formation et renonce à sa part d'une expédition en route.
|
||||
- `card_progress(player_id, edition_id, level, field_xp, updated_at)` (migration 9) : niveau et
|
||||
expérience de terrain (0 à 99 % du niveau suivant) d'une édition possédée. Puissance = base de la
|
||||
rareté + niveau × gain, plafonnée ; une ligne absente vaut le niveau 0. La progression suit
|
||||
l'exemplaire gardé ; le compte supprimé perd ses lignes.
|
||||
- `POST /api/cards/progress/upgrade` (`{ editionId, method: "eclats" | "duplicate" }`) : un niveau
|
||||
contre `costFactor × (Puissance − costOffset)` Éclats, ou `duplicateLevels` niveaux contre un
|
||||
doublon libre de la même édition. `CARD_NOT_OWNED`, `EXPEDITION_CARD_INVALID`, `CARD_MAX_LEVEL`,
|
||||
`NOT_ENOUGH_ECLATS`, `NOT_A_DUPLICATE`, `PENDING_OPENING`, `UPGRADE_METHOD_INVALID` ; `card_upgraded`
|
||||
dans l'historique. Chaque retour d'expédition récupéré donne `fieldXpPct` % de niveau aux cartes envoyées.
|
||||
- `POST /api/cards/eclats/convert` (`{ eclats }`, 1 à 10 000) : pont à sens unique, `stardustPerEclat`
|
||||
poussières par Éclat (`NOT_ENOUGH_STARDUST`, `CONVERT_INVALID`) ; `eclats_converted` dans l'historique.
|
||||
`getState().cardProgress` donne, pour chaque carte jouable, niveau, expérience, Puissance, stats,
|
||||
niveau maximal, coût du suivant et doublons libres.
|
||||
- `POST /api/cards/admin/expeditions/:id/cancel` : libère les cartes sans butin ; `expedition_cancelled`
|
||||
côté administration, `expedition_cancelled_by_guild` dans l'historique du joueur.
|
||||
- `getState().expeditions` : résumé pour la tuile de la Guilde et la fiche de carte (ouverture, en
|
||||
|
|
|
|||
|
|
@ -1900,6 +1900,20 @@ test("an administrator opens expeditions and a player sends a team, then claims
|
|||
await groupCard.getByRole("button", { name: "Dissoudre le groupe", exact: true }).click();
|
||||
await expect(groupCard).toHaveCount(0);
|
||||
await expect(board).toContainText("Aucun groupe ouvert pour le moment");
|
||||
|
||||
// Pont des Veilleurs : 3 poussières pour 1 Éclat ; la fiche de carte montre le niveau, la Puissance et l'expérience gagnée au retour.
|
||||
const bridge = partner.getByRole("form", { name: "Pont des Veilleurs" });
|
||||
await bridge.getByRole("spinbutton", { name: "Éclats à obtenir" }).fill("2");
|
||||
await expect(bridge).toContainText("Coût : 6");
|
||||
await bridge.getByRole("button", { name: "Convertir", exact: true }).click();
|
||||
await expect(partner.getByRole("status").filter({ hasText: "+2 Éclats d’étoile !" })).toBeVisible();
|
||||
await partner.goto("/#/cards/collection");
|
||||
await partner.getByRole("button", { name: "Voir Loup des Aurores", exact: true }).first().click();
|
||||
const progress = partner.getByRole("dialog").getByRole("region", { name: /^Expéditions · niveau 0 \/ 6$/ });
|
||||
await expect(progress).toContainText("Puissance 70");
|
||||
await expect(progress.getByRole("progressbar", { name: "Expérience de terrain" })).toHaveAttribute("aria-valuenow", "10");
|
||||
await expect(progress.getByRole("button", { name: /^Améliorer · 70 Éclats$/ })).toBeVisible();
|
||||
await partner.keyboard.press("Escape");
|
||||
await partner.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Historique", exact: true }).click();
|
||||
await expect(partner.locator(".nebula-history-list li").filter({ hasText: "Expédition terminée" })).toContainText("★ · 2 h");
|
||||
await partnerContext.close();
|
||||
|
|
|
|||
|
|
@ -314,6 +314,15 @@ export function createCardsApiHandler({
|
|||
json(res, 201, body.mode === "group" ? service.expeditions.createGroup(session.player.id, body, requestKey) : service.expeditions.startSolo(session.player.id, body, requestKey));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/progress/upgrade") {
|
||||
const body = await readBody(req);
|
||||
json(res, 200, service.expeditions.upgradeCard(session.player.id, { editionId: body.editionId, method: body.method }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/eclats/convert") {
|
||||
json(res, 200, service.expeditions.convertStardust(session.player.id, { eclats: (await readBody(req)).eclats }));
|
||||
return true;
|
||||
}
|
||||
const expeditionGroup = routeMatch(url.pathname, /^\/api\/cards\/expeditions\/([^/]+)\/(join|leave|depart)$/);
|
||||
if (req.method === "POST" && expeditionGroup) {
|
||||
const [expeditionId, action] = expeditionGroup;
|
||||
|
|
|
|||
|
|
@ -298,6 +298,18 @@ const MIGRATIONS = [
|
|||
DROP TABLE gift_packs;
|
||||
ALTER TABLE gift_packs_next RENAME TO gift_packs;
|
||||
CREATE INDEX gift_packs_player_idx ON gift_packs(player_id, opened_at);
|
||||
`,
|
||||
// Améliorations des Expéditions : niveau et expérience de terrain (en % du niveau suivant) de chaque édition possédée par un joueur.
|
||||
// La progression suit l'exemplaire gardé : seuls les doublons quittent une collection.
|
||||
`
|
||||
CREATE TABLE card_progress (
|
||||
player_id TEXT NOT NULL REFERENCES players(id),
|
||||
edition_id TEXT NOT NULL,
|
||||
level INTEGER NOT NULL DEFAULT 0 CHECK (level >= 0),
|
||||
field_xp INTEGER NOT NULL DEFAULT 0 CHECK (field_xp BETWEEN 0 AND 99),
|
||||
updated_at INTEGER NOT NULL,
|
||||
PRIMARY KEY (player_id, edition_id)
|
||||
) STRICT;
|
||||
`
|
||||
];
|
||||
|
||||
|
|
|
|||
100
services/cards/expedition-progress.js
Normal file
100
services/cards/expedition-progress.js
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// Rôle : améliorations des cartes Sokko TCG pour les Expéditions : niveaux par Éclats ou doublon, expérience de terrain, pont depuis la poussière.
|
||||
// Ces méthodes s'ajoutent à ExpeditionService (Object.assign sur son prototype) et utilisent `this` comme lui.
|
||||
import { editionExpeditionData, gainProgress, maxLevel, upgradeCost } from "./expedition-rules.js";
|
||||
|
||||
function fail(status, code, message) {
|
||||
throw Object.assign(new Error(message), { status, code });
|
||||
}
|
||||
|
||||
// Au plus ce nombre d'Éclats par conversion, pour qu'une faute de frappe ne vide pas un solde de poussière.
|
||||
export const MAX_CONVERT_ECLATS = 10_000;
|
||||
|
||||
export const progressMethods = {
|
||||
levelsOf(playerId) {
|
||||
return new Map(this.db.prepare("SELECT edition_id, level, field_xp FROM card_progress WHERE player_id = ?").all(playerId)
|
||||
.map((row) => [row.edition_id, { level: row.level, fieldXp: row.field_xp }]));
|
||||
},
|
||||
|
||||
progressOf(playerId, editionId) {
|
||||
const row = this.db.prepare("SELECT level, field_xp FROM card_progress WHERE player_id = ? AND edition_id = ?").get(playerId, editionId);
|
||||
return { level: row?.level ?? 0, fieldXp: row?.field_xp ?? 0 };
|
||||
},
|
||||
|
||||
writeProgress(playerId, editionId, { level, fieldXp }) {
|
||||
this.db.prepare(`INSERT INTO card_progress(player_id, edition_id, level, field_xp, updated_at) VALUES (?, ?, ?, ?, ?)
|
||||
ON CONFLICT(player_id, edition_id) DO UPDATE SET level = excluded.level, field_xp = excluded.field_xp, updated_at = excluded.updated_at`)
|
||||
.run(playerId, editionId, level, fieldXp, this.now());
|
||||
},
|
||||
|
||||
// Progression de chaque carte jouable du joueur : niveau, expérience, Puissance, stats, niveau maximal et coût du suivant.
|
||||
cardProgressView(playerId, settings = this.settings) {
|
||||
const levels = this.levelsOf(playerId);
|
||||
return this.cards.collectionOf(playerId).map((entry) => {
|
||||
const progress = levels.get(entry.editionId) || { level: 0, fieldXp: 0 };
|
||||
const data = editionExpeditionData(this.cards.catalog, entry.editionId, progress.level, settings);
|
||||
if (!data) return null;
|
||||
return {
|
||||
editionId: entry.editionId, level: progress.level, fieldXp: progress.fieldXp, power: data.power, stats: data.stats,
|
||||
maxLevel: maxLevel(data.rarity, settings), nextCost: upgradeCost(data.rarity, progress.level, settings), spare: entry.spare
|
||||
};
|
||||
}).filter(Boolean);
|
||||
},
|
||||
|
||||
// Monte une carte d'un niveau avec des Éclats, ou de `duplicateLevels` niveaux en consommant un doublon de la même édition.
|
||||
upgradeCard(playerId, { editionId, method } = {}) {
|
||||
const settings = this.settings;
|
||||
if (!["eclats", "duplicate"].includes(method)) fail(400, "UPGRADE_METHOD_INVALID", "Choisissez des Éclats ou un doublon.");
|
||||
this.cards.database.transaction(() => {
|
||||
const owned = this.cards.collectionOf(playerId).find((entry) => entry.editionId === editionId);
|
||||
if (!owned) fail(404, "CARD_NOT_OWNED", "Vous ne possédez pas cette carte.");
|
||||
const data = editionExpeditionData(this.cards.catalog, editionId, 0, settings);
|
||||
if (!data) fail(400, "EXPEDITION_CARD_INVALID", "Seules les cartes rares, épiques, légendaires et mythiques s’améliorent.");
|
||||
const progress = this.progressOf(playerId, editionId);
|
||||
const cost = upgradeCost(data.rarity, progress.level, settings);
|
||||
if (cost == null) fail(409, "CARD_MAX_LEVEL", "Cette carte a atteint la Puissance maximale.");
|
||||
let next;
|
||||
let details;
|
||||
if (method === "eclats") {
|
||||
const paid = this.db.prepare("UPDATE players SET eclats = eclats - ? WHERE id = ? AND eclats >= ?").run(cost, playerId, cost);
|
||||
if (!paid.changes) fail(409, "NOT_ENOUGH_ECLATS", "Pas assez d’Éclats d’étoile.");
|
||||
next = gainProgress(progress, data.rarity, { levels: 1 }, settings);
|
||||
details = { method, eclats: cost };
|
||||
} else {
|
||||
if (settings.progression.duplicateLevels < 1) fail(409, "UPGRADE_METHOD_INVALID", "Les doublons ne donnent pas de niveau pour le moment.");
|
||||
if (this.db.prepare("SELECT 1 FROM openings WHERE player_id = ? AND status = 'pending'").get(playerId)) fail(409, "PENDING_OPENING", "Terminez d'abord l'ouverture en cours.");
|
||||
if (!owned.spare) fail(409, "NOT_A_DUPLICATE", "Il faut un doublon libre de cette carte.");
|
||||
this.cards.removeDuplicates(playerId, editionId, 1);
|
||||
next = gainProgress(progress, data.rarity, { levels: settings.progression.duplicateLevels }, settings);
|
||||
details = { method };
|
||||
}
|
||||
this.writeProgress(playerId, editionId, next);
|
||||
this.cards.audit(playerId, "card_upgraded", editionId, { ...details, level: next.level, power: editionExpeditionData(this.cards.catalog, editionId, next.level, settings).power });
|
||||
});
|
||||
return { progress: this.cardProgressView(playerId, settings).find((item) => item.editionId === editionId), state: this.cards.getState(playerId) };
|
||||
},
|
||||
|
||||
// Pont à sens unique : de la poussière vers les Éclats, au taux réglé. La conversion inverse n'existe pas.
|
||||
convertStardust(playerId, { eclats } = {}) {
|
||||
const settings = this.settings;
|
||||
if (!Number.isInteger(eclats) || eclats < 1 || eclats > MAX_CONVERT_ECLATS) fail(400, "CONVERT_INVALID", `Nombre d’Éclats invalide : un entier entre 1 et ${MAX_CONVERT_ECLATS.toLocaleString("fr-FR")}.`);
|
||||
const cost = eclats * settings.progression.stardustPerEclat;
|
||||
this.cards.database.transaction(() => {
|
||||
// Compte de développement : son solde figé doit être appliqué avant de vérifier le prix.
|
||||
this.cards.refreshRecharge(playerId);
|
||||
const paid = this.db.prepare("UPDATE players SET stardust = stardust - ?, eclats = eclats + ? WHERE id = ? AND stardust >= ?").run(cost, eclats, playerId, cost);
|
||||
if (!paid.changes) fail(409, "NOT_ENOUGH_STARDUST", "Pas assez de poussière d’étoiles.");
|
||||
this.cards.audit(playerId, "eclats_converted", "bridge", { eclats, stardust: cost });
|
||||
});
|
||||
return this.cards.getState(playerId);
|
||||
},
|
||||
|
||||
// Expérience de terrain : chaque carte du joueur revenue d'expédition gagne une part de niveau.
|
||||
gainFieldXpInTx(playerId, editionIds, settings) {
|
||||
if (!settings.progression.fieldXpPct) return;
|
||||
for (const editionId of editionIds) {
|
||||
const data = editionExpeditionData(this.cards.catalog, editionId, 0, settings);
|
||||
if (!data || !this.cards.quantityOf(playerId, editionId)) continue;
|
||||
this.writeProgress(playerId, editionId, gainProgress(this.progressOf(playerId, editionId), data.rarity, { xpPct: settings.progression.fieldXpPct }, settings));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -279,3 +279,23 @@ export function cohesionPct(playerSlots, settings) {
|
|||
export function groupLootPct(players, settings) {
|
||||
return settings.group.lootPct[Math.min(Math.max(players, 2), 4) - 2];
|
||||
}
|
||||
|
||||
// Coût du niveau suivant en Éclats : il dépend de la Puissance actuelle, pas de la rareté (au moins 1). Null au plafond.
|
||||
export function upgradeCost(rarity, level, settings) {
|
||||
const power = cardPower(rarity, level, settings);
|
||||
if (power >= settings.power.cap) return null;
|
||||
return Math.max(1, settings.progression.costFactor * (power - settings.progression.costOffset));
|
||||
}
|
||||
|
||||
// Ajoute des niveaux et de l'expérience de terrain (en % d'un niveau) sans dépasser le plafond ; au plafond, l'expérience retombe à 0.
|
||||
export function gainProgress({ level, fieldXp }, rarity, { levels = 0, xpPct = 0 }, settings) {
|
||||
const top = maxLevel(rarity, settings);
|
||||
let nextLevel = Math.min(top, level + levels);
|
||||
let nextXp = fieldXp + xpPct;
|
||||
while (nextXp >= 100 && nextLevel < top) {
|
||||
nextLevel += 1;
|
||||
nextXp -= 100;
|
||||
}
|
||||
if (nextLevel >= top) nextXp = 0;
|
||||
return { level: nextLevel, fieldXp: nextXp };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
DEFAULT_EXPEDITION_SETTINGS, diffExpeditionSettings, EXPEDITION_SETTINGS_SCHEMA, mergeExpeditionSettings, validateExpeditionSettings
|
||||
} from "./expedition-settings.js";
|
||||
import { groupMethods } from "./expedition-group.js";
|
||||
import { progressMethods } from "./expedition-progress.js";
|
||||
|
||||
const HOUR_MS = 3_600_000;
|
||||
|
||||
|
|
@ -104,8 +105,9 @@ export class ExpeditionService {
|
|||
eligibleCards(playerId, settings) {
|
||||
const pending = this.db.prepare("SELECT id FROM openings WHERE player_id = ? AND status = 'pending' LIMIT 1").get(playerId);
|
||||
const busy = this.busyEditions(playerId);
|
||||
const levels = this.levelsOf(playerId);
|
||||
return this.cards.visibleCollection(playerId, pending?.id).map((entry) => {
|
||||
const data = editionExpeditionData(this.cards.catalog, entry.editionId, 0, settings);
|
||||
const data = editionExpeditionData(this.cards.catalog, entry.editionId, levels.get(entry.editionId)?.level ?? 0, settings);
|
||||
if (!data) return null;
|
||||
const busyEntry = busy.get(entry.editionId);
|
||||
return { ...data, busy: Boolean(busyEntry), busyUntil: busyEntry?.returnsAt ?? null };
|
||||
|
|
@ -305,6 +307,7 @@ export class ExpeditionService {
|
|||
stars: { min: settings.solo.minStars, max: settings.solo.maxStars, limit: MAX_STARS },
|
||||
soloCards: settings.solo.cards,
|
||||
soloLimit: settings.solo.maxConcurrent,
|
||||
progression: { stardustPerEclat: settings.progression.stardustPerEclat },
|
||||
group: {
|
||||
stars: { min: settings.group.minStars, max: settings.group.maxStars },
|
||||
slots: settings.group.slots, minPlayers: settings.group.minPlayers, limit: settings.group.maxConcurrent,
|
||||
|
|
@ -338,6 +341,7 @@ export class ExpeditionService {
|
|||
const waiting = this.db.prepare("SELECT COUNT(*) AS count FROM expedition_members WHERE expedition_id = ? AND claimed_at IS NULL").get(row.id).count;
|
||||
if (!waiting) this.db.prepare("UPDATE expeditions SET status = 'completed', completed_at = ? WHERE id = ?").run(now, row.id);
|
||||
const editionIds = this.db.prepare("SELECT edition_id FROM expedition_slots WHERE expedition_id = ? AND player_id = ? ORDER BY position").all(row.id, playerId).map((slot) => slot.edition_id);
|
||||
this.gainFieldXpInTx(playerId, editionIds, this.settings);
|
||||
this.cards.audit(playerId, "expedition_completed", row.id, {
|
||||
destinationId: setup.destination.id, destinationName: setup.destination.name, difficulty: row.difficulty, hours: setup.hours,
|
||||
mode: row.mode, players: result.players ?? 1, tier: result.tier, scorePct: result.scorePct, eclats: reward.eclats, stardust: reward.stardust, packs: reward.packs.length, editionIds
|
||||
|
|
@ -426,4 +430,5 @@ export class ExpeditionService {
|
|||
}
|
||||
|
||||
// Expéditions de groupe : tableau de la Guilde, inscription, départ, garde-fou d'inscription (expedition-group.js).
|
||||
Object.assign(ExpeditionService.prototype, groupMethods);
|
||||
// Améliorations : niveaux, expérience de terrain et pont depuis la poussière (expedition-progress.js).
|
||||
Object.assign(ExpeditionService.prototype, groupMethods, progressMethods);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ export const DEFAULT_EXPEDITION_SETTINGS = Object.freeze({
|
|||
group: { slots: 4, minPlayers: 2, maxConcurrent: 2, minStars: 2, maxStars: 5, recruitHours: 12, lootPct: [150, 175, 200], npcStat: 8, cohesionPct: 10 },
|
||||
power: { rare: 40, epic: 55, legendary: 70, mythic: 85, perLevel: 5, cap: 100 },
|
||||
roles: { multiplierPct: 200 },
|
||||
// Améliorations : coût d'un niveau en Éclats = costFactor × (Puissance actuelle − costOffset), niveaux donnés par un doublon,
|
||||
// expérience de terrain par retour d'expédition (% d'un niveau) et taux du pont depuis la poussière (poussières pour 1 Éclat).
|
||||
progression: { costFactor: 2, costOffset: 35, duplicateLevels: 1, fieldXpPct: 10, stardustPerEclat: 3 },
|
||||
// Exigence d'une stat, par place, pour chaque nombre d'étoiles : stat principale, puis seconde, troisième et quatrième.
|
||||
requirements: { star1: [9], star2: [11, 10], star3: [15, 14, 11], star4: [19, 18, 14], star5: [22, 21, 17, 14], conditionMissPct: 25 },
|
||||
danger: { malusPct: 20, shieldMaxPct: 50, endurancePerSlot: 14 },
|
||||
|
|
@ -65,6 +68,11 @@ export const EXPEDITION_SETTINGS_SCHEMA = Object.freeze([
|
|||
int("power.perLevel", 0, 50),
|
||||
int("power.cap", 1, 300),
|
||||
int("roles.multiplierPct", 100, 400),
|
||||
int("progression.costFactor", 0, 100),
|
||||
int("progression.costOffset", 0, 300),
|
||||
int("progression.duplicateLevels", 0, 12),
|
||||
int("progression.fieldXpPct", 0, 100),
|
||||
int("progression.stardustPerEclat", 1, 1000),
|
||||
ints("requirements.star1", 1, 1, 1000),
|
||||
ints("requirements.star2", 2, 1, 1000),
|
||||
ints("requirements.star3", 3, 1, 1000),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const ADMIN_HISTORY_PAGE_SIZE = 50;
|
|||
const PLAYER_HISTORY_EVENTS = Object.freeze([
|
||||
"welcome_opening", "pack_opened", "gift_pack_opened", "cards_recycled", "opening_purchased", "campaign_claimed",
|
||||
"trade_created", "trade_received", "trade_declined", "trade_joined", "trade_completed", "trade_cancelled",
|
||||
"gift_created", "gift_joined", "gift_completed", "gift_cancelled", "daily_won", "expedition_completed", "expedition_cancelled_by_guild", "expedition_dissolved"
|
||||
"gift_created", "gift_joined", "gift_completed", "gift_cancelled", "daily_won", "expedition_completed", "expedition_cancelled_by_guild", "expedition_dissolved", "card_upgraded", "eclats_converted"
|
||||
]);
|
||||
const DEV_STARDUST = 1000;
|
||||
const DELETED_PLAYER_NAME = "Joueur supprimé";
|
||||
|
|
@ -475,6 +475,7 @@ export class CardsService {
|
|||
shop: { stardustValues: shop.stardustValues, openingPrice: shop.openingPrice, shopPackPrice: shop.shopPackPrice, shopPackShare: shop.shopPackShare, dailyReward: shop.dailyReward },
|
||||
daily: this.dailySummary(playerId),
|
||||
expeditions: this.expeditions.summary(playerId),
|
||||
cardProgress: this.expeditions.cardProgressView(playerId),
|
||||
recycling: { count: recycling.count, stardust: recycling.stardust },
|
||||
pendingOpening: pending ? this.openingById(pending.id, playerId) : null,
|
||||
rarestPull: this.rarestPull(playerId), stats: { openingsCount },
|
||||
|
|
@ -875,7 +876,7 @@ export class CardsService {
|
|||
}
|
||||
this.db.prepare("UPDATE openings SET status = 'completed', completed_at = ? WHERE player_id = ? AND status = 'pending'").run(this.now(), playerId);
|
||||
this.expeditions.forgetPlayer(playerId);
|
||||
for (const table of ["sessions", "collection_cards", "favorites", "idempotency", "daily_attempts"]) this.db.prepare(`DELETE FROM ${table} WHERE player_id = ?`).run(playerId);
|
||||
for (const table of ["sessions", "collection_cards", "favorites", "idempotency", "daily_attempts", "card_progress"]) this.db.prepare(`DELETE FROM ${table} WHERE player_id = ?`).run(playerId);
|
||||
this.db.prepare("DELETE FROM gift_packs WHERE player_id = ? AND opening_id IS NULL").run(playerId);
|
||||
this.db.prepare(`UPDATE players SET discord_id = ?, display_name = ?, avatar_url = '', is_admin = 0, openings_balance = 0, recharge_anchor = NULL, stardust = 0, purchased_openings = 0, eclats = 0, deleted_at = ? WHERE id = ?`)
|
||||
.run(`deleted:${randomUUID()}`, DELETED_PLAYER_NAME, this.now(), playerId);
|
||||
|
|
|
|||
|
|
@ -255,6 +255,12 @@ export function validateSiteContent(site) {
|
|||
"cards.guild.expeditionsClaim",
|
||||
"cards.guild.expeditionsOpen",
|
||||
"cards.packs.giftFromExpedition",
|
||||
"cards.expeditions.bridgeTitle",
|
||||
"cards.expeditions.bridgeHelp",
|
||||
"cards.expeditions.bridgeLabel",
|
||||
"cards.expeditions.bridgeCost",
|
||||
"cards.expeditions.bridgeAction",
|
||||
"cards.expeditions.bridged",
|
||||
"cards.guild.expeditionsGroups",
|
||||
"cards.guild.expeditionsForming",
|
||||
"cards.expeditions.modeLabel",
|
||||
|
|
|
|||
|
|
@ -397,3 +397,66 @@ test("the group API opens, joins, leaves and launches through dedicated routes",
|
|||
const leave = await call(handler, { method: "POST", path: `/api/cards/expeditions/${groupId}/leave`, headers });
|
||||
assert.equal(leave.json.error.code, "EXPEDITION_GROUP_DEPARTED");
|
||||
});
|
||||
|
||||
test("cards level up with Éclats or a duplicate, gain field experience and stronger expedition stats", () => {
|
||||
const { clock, service, player, open, rares, database } = expeditionService();
|
||||
open();
|
||||
const [card] = rares;
|
||||
database.transaction(() => service.addCard(player.id, card));
|
||||
database.db.prepare("UPDATE players SET eclats = 25 WHERE id = ?").run(player.id);
|
||||
const before = service.getState(player.id).cardProgress.find((item) => item.editionId === card);
|
||||
assert.deepEqual([before.level, before.power, before.nextCost, before.maxLevel, before.spare], [0, 40, 10, 12, 1]);
|
||||
const upgraded = service.expeditions.upgradeCard(player.id, { editionId: card, method: "eclats" });
|
||||
assert.deepEqual([upgraded.progress.level, upgraded.progress.power, upgraded.progress.nextCost], [1, 45, 20]);
|
||||
assert.equal(upgraded.state.wallet.eclats, 15);
|
||||
assert.throws(() => service.expeditions.upgradeCard(player.id, { editionId: card, method: "eclats" }), (error) => error.code === "NOT_ENOUGH_ECLATS");
|
||||
// Un doublon de la même édition donne un niveau entier, et part de la collection.
|
||||
const byDuplicate = service.expeditions.upgradeCard(player.id, { editionId: card, method: "duplicate" });
|
||||
assert.equal(byDuplicate.progress.level, 2);
|
||||
assert.equal(service.quantityOf(player.id, card), 1);
|
||||
assert.throws(() => service.expeditions.upgradeCard(player.id, { editionId: card, method: "duplicate" }), (error) => error.code === "NOT_A_DUPLICATE");
|
||||
assert.throws(() => service.expeditions.upgradeCard(player.id, { editionId: editionsOf("common")[0], method: "eclats" }), (error) => error.code === "CARD_NOT_OWNED");
|
||||
assert.throws(() => service.expeditions.upgradeCard(player.id, { editionId: card, method: "magic" }), (error) => error.code === "UPGRADE_METHOD_INVALID");
|
||||
const history = service.getState(player.id).history.filter((entry) => entry.type === "card_upgraded");
|
||||
assert.deepEqual(history.map((entry) => entry.details.method).sort(), ["duplicate", "eclats"]);
|
||||
|
||||
// Les expéditions utilisent la Puissance améliorée, et chaque retour donne 10 % de niveau aux cartes envoyées.
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(view.cards.find((item) => item.editionId === card).power, 50);
|
||||
const started = service.expeditions.startSolo(player.id, soloBody(view, [card, rares[1]]), "levelled");
|
||||
clock.now += 2 * HOUR;
|
||||
service.expeditions.claim(player.id, started.expedition.id);
|
||||
const after = service.getState(player.id).cardProgress;
|
||||
assert.equal(after.find((item) => item.editionId === card).fieldXp, 10);
|
||||
assert.equal(after.find((item) => item.editionId === rares[1]).fieldXp, 10);
|
||||
|
||||
// Au plafond, plus de niveau ; la suppression du compte efface la progression.
|
||||
database.db.prepare("UPDATE card_progress SET level = 12 WHERE player_id = ? AND edition_id = ?").run(player.id, card);
|
||||
assert.throws(() => service.expeditions.upgradeCard(player.id, { editionId: card, method: "eclats" }), (error) => error.code === "CARD_MAX_LEVEL");
|
||||
assert.equal(service.getState(player.id).cardProgress.find((item) => item.editionId === card).nextCost, null);
|
||||
service.deleteAccount(player.id);
|
||||
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM card_progress WHERE player_id = ?").get(player.id).count, 0);
|
||||
});
|
||||
|
||||
test("the one-way bridge turns stardust into Éclats at the configured rate", async (t) => {
|
||||
const { service, player, admin, database } = expeditionService();
|
||||
database.db.prepare("UPDATE players SET stardust = 40 WHERE id = ?").run(player.id);
|
||||
const state = service.expeditions.convertStardust(player.id, { eclats: 10 });
|
||||
assert.deepEqual([state.wallet.stardust, state.wallet.eclats], [10, 10]);
|
||||
assert.throws(() => service.expeditions.convertStardust(player.id, { eclats: 4 }), (error) => error.code === "NOT_ENOUGH_STARDUST");
|
||||
assert.throws(() => service.expeditions.convertStardust(player.id, { eclats: 0 }), (error) => error.code === "CONVERT_INVALID");
|
||||
service.expeditions.updateSettings(admin.id, { ...service.expeditions.settings, progression: { ...service.expeditions.settings.progression, stardustPerEclat: 5 } });
|
||||
assert.equal(service.expeditions.convertStardust(player.id, { eclats: 2 }).wallet.stardust, 0);
|
||||
assert.ok(service.getState(player.id).history.some((entry) => entry.type === "eclats_converted" && entry.details.stardust === 30));
|
||||
|
||||
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, devAuth: true, databasePath: ":memory:", env: { NODE_ENV: "test" }, random: () => 0 });
|
||||
t.after(() => handler.close());
|
||||
const login = await call(handler, { method: "POST", path: "/api/cards/auth/dev", body: {} });
|
||||
const headers = { cookie: login.headers["set-cookie"].split(";")[0], "x-csrf-token": login.json.csrfToken };
|
||||
handler.service.db.prepare("UPDATE players SET stardust = 30 WHERE discord_id = 'dev-admin'").run();
|
||||
const converted = await call(handler, { method: "POST", path: "/api/cards/eclats/convert", headers, body: { eclats: 3 } });
|
||||
assert.equal(converted.status, 200);
|
||||
assert.equal(converted.json.wallet.eclats, 3);
|
||||
const upgrade = await call(handler, { method: "POST", path: "/api/cards/progress/upgrade", headers, body: { editionId: "nowhere", method: "eclats" } });
|
||||
assert.equal(upgrade.json.error.code, "CARD_NOT_OWNED");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { prepareVersionedCatalog } from "../services/cards/catalog.js";
|
|||
import { loadExpeditionDestinations, validateExpeditionDestinations } from "../services/cards/expedition-content.js";
|
||||
import {
|
||||
applyHazards, cardPower, drawExpeditionDay, editionExpeditionData, efficiency, evaluateTeam, expectedLoot, maxLevel,
|
||||
requirementsFor, resolveDayEntry, rollLoot, roundStochastic, scoreExpedition, soloRoles, splitPower, STAT_IDS, teamStats
|
||||
requirementsFor, resolveDayEntry, rollLoot, roundStochastic, scoreExpedition, soloRoles, splitPower, STAT_IDS, teamStats, upgradeCost, gainProgress
|
||||
} from "../services/cards/expedition-rules.js";
|
||||
import {
|
||||
DEFAULT_EXPEDITION_SETTINGS, diffExpeditionSettings, EXPEDITION_SETTINGS_SCHEMA, mergeExpeditionSettings, readPath, validateExpeditionSettings
|
||||
|
|
@ -223,3 +223,19 @@ test("the guild shows expeditions when open and flags them once a day or when on
|
|||
assert.deepEqual(guildQuests({ expeditions: { ...summary, enabled: false } }, now), []);
|
||||
assert.equal(guildQuests({ expeditions: { ...summary, enabled: false, returned: 1 } }, now)[0].pending, true);
|
||||
});
|
||||
|
||||
test("a level costs Éclats by current power, so a rare pays the longer road to the same cap", () => {
|
||||
const total = (rarity) => {
|
||||
let sum = 0;
|
||||
for (let level = 0; upgradeCost(rarity, level, settings) != null; level += 1) sum += upgradeCost(rarity, level, settings);
|
||||
return sum;
|
||||
};
|
||||
assert.equal(upgradeCost("rare", 0, settings), 10);
|
||||
assert.equal(upgradeCost("mythic", 0, settings), 100);
|
||||
assert.equal(upgradeCost("rare", 12, settings), null);
|
||||
assert.deepEqual(["rare", "epic", "legendary", "mythic"].map(total), [780, 720, 570, 330]);
|
||||
// Expérience de terrain : 10 % par retour, un niveau tous les 100 %, rien au-delà du plafond.
|
||||
assert.deepEqual(gainProgress({ level: 0, fieldXp: 95 }, "rare", { xpPct: 10 }, settings), { level: 1, fieldXp: 5 });
|
||||
assert.deepEqual(gainProgress({ level: 2, fieldXp: 50 }, "mythic", { levels: 1, xpPct: 60 }, settings), { level: 3, fieldXp: 0 });
|
||||
assert.deepEqual(gainProgress({ level: 11, fieldXp: 0 }, "rare", { levels: 5 }, settings), { level: 12, fieldXp: 0 });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@
|
|||
"intro": "Choisissez une destination du jour, composez une équipe et laissez-la explorer l’archipel pendant quelques heures.",
|
||||
"back": "Retour à la Guilde",
|
||||
"eclatsBalance": "{value} Éclats d’étoile",
|
||||
"eclatsHelp": "Les Éclats d’étoile serviront bientôt à améliorer vos cartes.",
|
||||
"eclatsHelp": "Les Éclats d’étoile améliorent vos cartes : ouvrez une carte rare ou mieux dans la Collection.",
|
||||
"closedTitle": "Les Expéditions sont fermées",
|
||||
"closedText": "Les Veilleurs préparent les prochaines destinations. Revenez bientôt.",
|
||||
"expired": "Les destinations du jour ont changé.",
|
||||
|
|
@ -288,6 +288,12 @@
|
|||
"durationMalus": "Expédition longue : l’Endurance de l’équipe ne suffit pas, toutes les stats baissent.",
|
||||
"expected": "Butin attendu : environ {eclats} Éclats, {stardust} d’étoiles et {pack} % de chance de rapporter un paquet.",
|
||||
"start": "Partir en expédition",
|
||||
"bridgeTitle": "Pont des Veilleurs",
|
||||
"bridgeHelp": "{rate} poussières d’étoiles pour 1 Éclat. Les Éclats ne se reconvertissent pas en poussière.",
|
||||
"bridgeLabel": "Éclats à obtenir",
|
||||
"bridgeCost": "Coût : {cost} d’étoiles",
|
||||
"bridgeAction": "Convertir",
|
||||
"bridged": "+{eclats} Éclats d’étoile !",
|
||||
"modeLabel": "Mode",
|
||||
"modeSolo": "Seul",
|
||||
"modeGroup": "En groupe",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,28 @@
|
|||
// Rôle : affiche la fiche détaillée d'une carte possédée (grand format, favori, recyclage d'un doublon).
|
||||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { recycleDuplicates, setFavorite } from "./cardsApi.js";
|
||||
import { recycleDuplicates, setFavorite, upgradeCard } from "./cardsApi.js";
|
||||
import { readCollection } from "./collectionState.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const STATS = [["bravoure", "Bravoure"], ["endurance", "Endurance"], ["fortune", "Fortune"], ["orientation", "Orientation"]];
|
||||
|
||||
// Expéditions : niveau, Puissance, stats et amélioration d'une carte rare ou mieux (Éclats, ou doublon de la même édition).
|
||||
function CardProgress({ progress, eclats, busy, runMutation }) {
|
||||
const atCap = progress.nextCost == null;
|
||||
return <section className="nebula-card-progress" aria-labelledby="nebula-card-progress-title">
|
||||
<h3 id="nebula-card-progress-title">Expéditions · niveau {progress.level} / {progress.maxLevel}</h3>
|
||||
<p><strong>Puissance {progress.power}</strong> · {STATS.map(([stat, label]) => `${label} ${progress.stats[stat]}`).join(" · ")}</p>
|
||||
{!atCap && <div className="nds-progress" data-size="sm" role="progressbar" aria-label="Expérience de terrain" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress.fieldXp}><span style={{ width: `${progress.fieldXp}%` }} /></div>}
|
||||
{atCap ? <p className="nebula-form-help">Puissance maximale atteinte.</p> : <div className="nds-toolbar">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || eclats < progress.nextCost} onClick={() => runMutation(() => upgradeCard(progress.editionId, "eclats"))}>Améliorer · {formatEclats(progress.nextCost)} Éclats</button>
|
||||
{progress.spare > 0 && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={() => runMutation(() => upgradeCard(progress.editionId, "duplicate"))}>Améliorer avec un doublon</button>}
|
||||
</div>}
|
||||
{!atCap && <p className="nebula-form-help">Vous avez {formatEclats(eclats)} Éclats. Chaque retour d’expédition donne de l’expérience de terrain ({progress.fieldXp} % du niveau suivant).</p>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function CardDetailModal({ catalog, state, entry, runMutation, busy, onClose, onStartTransfer = null }) {
|
||||
const owned = readCollection(state).entries.get(entry.edition.id);
|
||||
const quantity = owned?.quantity || 0;
|
||||
|
|
@ -12,11 +30,13 @@ export function CardDetailModal({ catalog, state, entry, runMutation, busy, onCl
|
|||
const value = state.shop.stardustValues[entry.edition.rarity] ?? 0;
|
||||
const favorites = new Set(state.favorites);
|
||||
const expedition = state.expeditions?.busyEditions?.find((item) => item.editionId === entry.edition.id);
|
||||
const progress = state.cardProgress?.find((item) => item.editionId === entry.edition.id);
|
||||
|
||||
return <Modal dialogClassName="confirm-modal nds-modal nebula-card-detail" labelledBy="nebula-card-detail-title" onRequestClose={onClose}>
|
||||
<div className="nebula-card-detail-layout"><NebulaCard catalog={catalog} entry={entry} size="lg" />
|
||||
<div><p className="eyebrow">{catalog.rarities.find((item) => item.id === entry.edition.rarity)?.label}</p><h2 id="nebula-card-detail-title">{entry.card.name}</h2><p>{entry.card.description}</p>
|
||||
<dl><div><dt>Exemplaires possédés</dt><dd>{quantity}</dd></div><div><dt>Collection</dt><dd>{catalog.collections.find((item) => item.id === entry.card.collectionId)?.name}</dd></div><div><dt>Finitions</dt><dd>{entry.edition.finishIds.map((id) => catalog.finishes.find((item) => item.id === id)?.label).join(" · ")}</dd></div></dl>
|
||||
{progress && <CardProgress progress={progress} eclats={state.wallet.eclats ?? 0} busy={busy} runMutation={runMutation} />}
|
||||
<button className="nds-button" data-variant={favorites.has(entry.edition.id) ? "primary" : "secondary"} type="button" disabled={busy} aria-pressed={favorites.has(entry.edition.id)} onClick={() => runMutation(() => setFavorite(entry.edition.id, !favorites.has(entry.edition.id)))}>{favorites.has(entry.edition.id) ? "Retirer des favoris" : "Ajouter aux favoris"}</button>
|
||||
{spare > 0 && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={() => runMutation(() => recycleDuplicates(entry.edition.id))}>Recycler un doublon (+{formatStardust(value)})</button>}
|
||||
{spare > 0 && onStartTransfer && <>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
// Rôle : présente les Expéditions, quête de la Guilde : expéditions du joueur (retour, butin) et préparation d'une expédition solo.
|
||||
import { useEffect, useState } from "react";
|
||||
import { claimExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, startExpedition } from "./cardsApi.js";
|
||||
import { claimExpedition, convertStardust, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, startExpedition } from "./cardsApi.js";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionGroupCard } from "./ExpeditionGroupCard.jsx";
|
||||
import { ExpeditionPlanner } from "./ExpeditionPlanner.jsx";
|
||||
import { ExpeditionReport } from "./ExpeditionReport.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const COUNTDOWN_TICK_MS = 30_000;
|
||||
|
||||
|
|
@ -19,6 +20,22 @@ const expeditionCall = (call) => async () => {
|
|||
}
|
||||
};
|
||||
|
||||
// Pont des Veilleurs : de la poussière vers les Éclats, au taux réglé ; la conversion inverse n'existe pas.
|
||||
function BridgeForm({ rate, stardust, busy, content, onConvert }) {
|
||||
const [amount, setAmount] = useState("1");
|
||||
const eclats = /^\d+$/.test(amount) ? Number(amount) : 0;
|
||||
const cost = eclats * rate;
|
||||
return <form className="nds-panel nebula-expedition-bridge" aria-labelledby="nebula-expedition-bridge-title" onSubmit={async (event) => { event.preventDefault(); if (await onConvert(eclats)) setAmount("1"); }}>
|
||||
<h3 id="nebula-expedition-bridge-title">{content.bridgeTitle}</h3>
|
||||
<p className="nebula-form-help">{fillTemplate(content.bridgeHelp, { rate })}</p>
|
||||
<div className="nebula-expedition-bridge-row">
|
||||
<label><span>{content.bridgeLabel}</span><input className="nds-input" type="number" inputMode="numeric" min="1" max="10000" step="1" value={amount} disabled={busy} onChange={(event) => setAmount(event.target.value)} /></label>
|
||||
<span className="nebula-form-help">{fillTemplate(content.bridgeCost, { cost: formatStardust(cost) })}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="submit" disabled={busy || eclats < 1 || cost > stardust}>{content.bridgeAction}</button>
|
||||
</div>
|
||||
</form>;
|
||||
}
|
||||
|
||||
export function ExpeditionsPanel({ catalog, state, runMutation, busy, content }) {
|
||||
const [view, setView] = useState(null);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
|
|
@ -59,6 +76,11 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
const claim = async (id) => handle(await runMutation(expeditionCall(() => claimExpedition(id))), content.claimed);
|
||||
const join = async (id, choice) => handle(await runMutation(expeditionCall(() => joinExpedition(id, choice))), content.joined);
|
||||
const leave = async (id) => handle(await runMutation(expeditionCall(() => leaveExpedition(id))), content.left);
|
||||
const convert = async (eclats) => {
|
||||
const result = await runMutation(() => convertStardust(eclats));
|
||||
if (result) setNotice({ variant: "success", text: fillTemplate(content.bridged, { eclats: formatEclats(eclats) }) });
|
||||
return Boolean(result);
|
||||
};
|
||||
const depart = async (id) => handle(await runMutation(expeditionCall(() => departExpedition(id))), content.departed);
|
||||
|
||||
const expired = view.enabled && now >= view.nextDayAt;
|
||||
|
|
@ -75,6 +97,7 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
</div>
|
||||
</div>
|
||||
<p className="nebula-form-help">{content.eclatsHelp}</p>
|
||||
<BridgeForm rate={view.progression.stardustPerEclat} stardust={state.wallet.stardust} busy={busy} content={content} onConvert={convert} />
|
||||
{notice && <p className="nds-inline-notice" data-variant={notice.variant} role="status">{notice.text}</p>}
|
||||
{expired && <div className="nds-inline-notice nebula-daily-expired" data-variant="warning" role="status"><span>{content.expired}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={reload}>{content.reload}</button></div>}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ const EVENT_LABELS = {
|
|||
opening_purchased: "Ouverture achetée",
|
||||
daily_won: "Carte du jour trouvée",
|
||||
expedition_completed: "Expédition terminée",
|
||||
expedition_cancelled_by_guild: "Expédition annulée par la Guilde"
|
||||
expedition_cancelled_by_guild: "Expédition annulée par la Guilde",
|
||||
expedition_dissolved: "Groupe d’expédition dissous",
|
||||
card_upgraded: "Carte améliorée",
|
||||
eclats_converted: "Éclats d’étoile obtenus"
|
||||
};
|
||||
|
||||
// Le journal garde la quantité réellement offerte : les comptes plus anciens n'ont reçu qu'une ouverture.
|
||||
|
|
@ -60,6 +63,9 @@ function HistoryDetail({ entry, catalog }) {
|
|||
return <span>{[`${details.destinationName} · ${"★".repeat(details.difficulty)} · ${details.hours} h`, tier, ...gains].filter(Boolean).join(" · ")}</span>;
|
||||
}
|
||||
if (entry.type === "expedition_cancelled_by_guild") return <span>{details.destinationName} · cartes libérées, sans butin</span>;
|
||||
if (entry.type === "expedition_dissolved") return <span>{details.destinationName} · {details.reason === "creator_left" ? "dissous par son créateur" : "pas assez de joueurs"} · cartes libérées</span>;
|
||||
if (entry.type === "card_upgraded") return <span>{[cardReference(entry.entityId, catalog), `niveau ${details.level}`, `Puissance ${details.power}`, details.method === "duplicate" ? "un doublon utilisé" : `−${details.eclats} Éclats`].join(" · ")}</span>;
|
||||
if (entry.type === "eclats_converted") return <span>+{details.eclats} Éclats · −{formatStardust(details.stardust)} d’étoiles</span>;
|
||||
if (entry.type === "opening_purchased") return <span>−{formatStardust(details.price)} d’étoiles</span>;
|
||||
if (!details.collectionId) return null;
|
||||
const name = catalog.collections.find((item) => item.id === details.collectionId)?.name;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,18 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "roles.multiplierPct", label: "Multiplicateur du rôle (%)" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "progression",
|
||||
title: "Améliorations",
|
||||
help: "Coût d’un niveau en Éclats selon la Puissance actuelle, niveaux donnés par un doublon de la même carte, expérience gagnée à chaque retour et taux du pont depuis la poussière.",
|
||||
fields: [
|
||||
{ path: "progression.costFactor", label: "Éclats par point de Puissance au-dessus du décalage" },
|
||||
{ path: "progression.costOffset", label: "Décalage du coût (Puissance)" },
|
||||
{ path: "progression.duplicateLevels", label: "Niveaux donnés par un doublon" },
|
||||
{ path: "progression.fieldXpPct", label: "Expérience de terrain par retour (% d’un niveau)" },
|
||||
{ path: "progression.stardustPerEclat", label: "Poussières pour 1 Éclat (pont)" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "requirements",
|
||||
title: "Exigences",
|
||||
|
|
|
|||
|
|
@ -203,3 +203,13 @@ export function leaveExpedition(expeditionId) {
|
|||
export function departExpedition(expeditionId) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/depart`, { method: "POST" });
|
||||
}
|
||||
|
||||
// Améliore une carte d'un niveau : `method` vaut « eclats » ou « duplicate » (un doublon de la même édition).
|
||||
export function upgradeCard(editionId, method) {
|
||||
return request("/progress/upgrade", { method: "POST", body: JSON.stringify({ editionId, method }) });
|
||||
}
|
||||
|
||||
// Pont à sens unique : de la poussière vers les Éclats d'étoile.
|
||||
export function convertStardust(eclats) {
|
||||
return request("/eclats/convert", { method: "POST", body: JSON.stringify({ eclats }) });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,3 +88,14 @@
|
|||
.nebula-expedition-group-free { display: grid; place-items: center; min-width: 96px; min-height: 64px; padding: var(--space-2); border: 1px dashed var(--color-border); border-radius: var(--radius-md); }
|
||||
.nebula-expedition-group-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
|
||||
.nebula-expedition-join { display: grid; gap: var(--space-3); justify-self: stretch; padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
|
||||
|
||||
// Pont des Veilleurs et progression d'une carte dans sa fiche.
|
||||
.nds-panel.nebula-expedition-bridge { display: grid; gap: var(--space-2); padding: var(--space-4); }
|
||||
.nebula-expedition-bridge p { margin: 0; }
|
||||
.nebula-expedition-bridge-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2) var(--space-4); }
|
||||
.nebula-expedition-bridge-row label { display: grid; gap: 2px; color: var(--color-text-secondary); font-size: var(--font-size-sm); }
|
||||
.nebula-expedition-bridge-row input { width: 120px; }
|
||||
.nebula-card-progress { display: grid; gap: var(--space-2); margin: var(--space-3) 0; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
|
||||
.nebula-card-progress h3, .nebula-card-progress p { margin: 0; }
|
||||
.nebula-card-progress h3 { font-size: var(--font-size-base); }
|
||||
.nebula-card-progress p { font-size: var(--font-size-sm); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue