Add solo Expeditions, the second Guilde des Veilleurs quest of Sokko TCG
- Every catalog card carries expedition tags and every collection a stat profile, validated at load; twelve destinations live server-side so hidden ones stay secret. - Pure rules compute card power, per-slot requirements, roles, dangers, the long-trip malus, the score (one more star never raises it) and loot proportional to the chosen duration. - A simulator script and a balance test guard the design thresholds; agent docs and a new-card skill explain how to tag new cards. - Migration 8 adds Éclats d'étoile, expedition settings stored as one validated JSON, daily destinations, expeditions, members and slots, and rebuilds gift_packs so a pack can come from an expedition. - Players launch a solo expedition from the Guild, see an exact preview, and claim their loot when it returns; the card sheet shows cards away on an expedition. - Administration › Guilde tunes every value with server-side bounds, toggles destinations and cancels running expeditions; expeditions stay closed until an administrator opens them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ef213cf4f
commit
8bb1d53d70
46 changed files with 4752 additions and 213 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import { useState } from "react";
|
||||
import { ApplyActions } from "./adminSettingForm.jsx";
|
||||
import { inRange, MAX_VALUE, parse, shopSettingSaver } from "./adminSettings.js";
|
||||
import { ExpeditionSettings } from "./ExpeditionSettings.jsx";
|
||||
|
||||
// Carte du jour : la partie du jour (joueurs et gagnants), puis la récompense d'une victoire.
|
||||
function DailyQuestSettings({ setting, daily, busy, save }) {
|
||||
|
|
@ -31,7 +32,10 @@ export function AdminGuild({ dashboard, busy, runMutation, refreshDashboard }) {
|
|||
const save = shopSettingSaver(setting, runMutation, refreshDashboard);
|
||||
return <div className="nebula-admin-shop-page">
|
||||
{setting
|
||||
? <DailyQuestSettings key={setting.dailyReward} setting={setting} daily={dashboard.daily} busy={busy} save={save} />
|
||||
? <>
|
||||
<DailyQuestSettings key={setting.dailyReward} setting={setting} daily={dashboard.daily} busy={busy} save={save} />
|
||||
{dashboard.expeditionSettings && <ExpeditionSettings dashboard={dashboard} busy={busy} runMutation={runMutation} refreshDashboard={refreshDashboard} />}
|
||||
</>
|
||||
: <div className="nds-empty-state" aria-busy="true"><p>Chargement des quêtes…</p></div>}
|
||||
</div>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
|
|||
import { loadAdminHistory } from "../cardsApi.js";
|
||||
import { summarizeReward } from "../rewardText.js";
|
||||
import { DATE_FORMATTER, formatDuration } from "./adminFormat.js";
|
||||
import { expeditionSettingLabel, formatSettingValue } from "./expeditionSettingFields.js";
|
||||
|
||||
const EVENT_LABELS = {
|
||||
recharge_updated: "Recharge modifiée",
|
||||
|
|
@ -15,7 +16,9 @@ const EVENT_LABELS = {
|
|||
campaign_created: "Campagne créée",
|
||||
campaign_revoked: "Campagne révoquée",
|
||||
campaign_extended: "Campagne prolongée",
|
||||
account_deleted: "Compte joueur supprimé"
|
||||
account_deleted: "Compte joueur supprimé",
|
||||
expedition_settings_updated: "Expéditions modifiées",
|
||||
expedition_cancelled: "Expédition annulée"
|
||||
};
|
||||
|
||||
const collectionName = (entry, catalog) => catalog.collections.find((item) => item.id === entry.entityId)?.name || entry.entityId;
|
||||
|
|
@ -51,6 +54,8 @@ function eventDetail(entry, catalog) {
|
|||
case "campaign_created": return `${campaignName || entry.entityId} · ${summarizeReward(details.reward, catalog)}`;
|
||||
case "campaign_extended": return `${campaignName || entry.entityId} · ${details.expiresAt == null ? "sans expiration" : `jusqu’au ${DATE_FORMATTER.format(details.expiresAt)}`}`;
|
||||
case "campaign_revoked": return campaignName || entry.entityId;
|
||||
case "expedition_settings_updated": return (details.changes || []).map((item) => change(expeditionSettingLabel(item.path), formatSettingValue(item.previous), formatSettingValue(item.next))).filter(Boolean).join(" · ");
|
||||
case "expedition_cancelled": return details.destinationId;
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
128
website/src/features/cards/admin/ExpeditionSettings.jsx
Normal file
128
website/src/features/cards/admin/ExpeditionSettings.jsx
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
// Rôle : règle les Expéditions depuis Administration › Guilde : un panneau par groupe de réglages, les destinations, et le suivi du jour.
|
||||
import { useState } from "react";
|
||||
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
|
||||
import { cancelExpedition, updateExpeditionSettings } from "../cardsApi.js";
|
||||
import { DATE_FORMATTER } from "./adminFormat.js";
|
||||
import { ApplyActions } from "./adminSettingForm.jsx";
|
||||
import { inRange, parse } from "./adminSettings.js";
|
||||
import { EXPEDITION_SETTING_GROUPS } from "./expeditionSettingFields.js";
|
||||
|
||||
const readPath = (source, path) => path.split(".").reduce((value, key) => value?.[key], source);
|
||||
|
||||
function writePath(target, path, value) {
|
||||
const keys = path.split(".");
|
||||
keys.slice(0, -1).reduce((node, key) => node[key], target)[keys.at(-1)] = value;
|
||||
}
|
||||
|
||||
const toDraft = (value) => (typeof value === "boolean" ? value : Array.isArray(value) ? value.map(String) : String(value));
|
||||
const fromDraft = (value) => (typeof value === "boolean" ? value : Array.isArray(value) ? value.map(parse) : parse(value));
|
||||
const validValue = (field, value) => (field.kind === "bool" ? typeof value === "boolean" : (Array.isArray(value) ? value : [value]).every((item) => inRange(item, field.min, field.max)));
|
||||
|
||||
// Un panneau : brouillon de ses réglages, vérifiés avec les bornes du serveur ; les contraintes entre réglages sont vérifiées par le serveur.
|
||||
function SettingsGroup({ group, settings, schema, busy, save }) {
|
||||
const fields = group.fields.map((field) => ({ ...field, ...schema.find((item) => item.path === field.path) }));
|
||||
const initial = () => Object.fromEntries(fields.map((field) => [field.path, toDraft(readPath(settings, field.path))]));
|
||||
const [draft, setDraft] = useState(initial);
|
||||
const values = Object.fromEntries(fields.map((field) => [field.path, fromDraft(draft[field.path])]));
|
||||
const invalid = fields.filter((field) => !validValue(field, values[field.path]));
|
||||
const changed = !invalid.length && fields.some((field) => JSON.stringify(values[field.path]) !== JSON.stringify(readPath(settings, field.path)));
|
||||
const set = (path, value) => setDraft((current) => ({ ...current, [path]: value }));
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-group" aria-labelledby={`nebula-admin-expedition-${group.id}`}>
|
||||
<div className="nds-section-heading nebula-admin-panel-heading"><h3 id={`nebula-admin-expedition-${group.id}`}>{group.title}</h3></div>
|
||||
<p className="nebula-form-help">{group.help}</p>
|
||||
<div className="nebula-admin-expedition-fields">{fields.map((field) => {
|
||||
const value = draft[field.path];
|
||||
if (field.kind === "bool") return <div key={field.path} className="nebula-admin-expedition-field">
|
||||
<span>{field.label}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant={value ? "primary" : "secondary"} type="button" aria-pressed={value} aria-label={field.label} disabled={busy} onClick={() => set(field.path, !value)}>{value ? "Oui" : "Non"}</button>
|
||||
</div>;
|
||||
if (Array.isArray(value)) return <fieldset key={field.path} className="nebula-admin-expedition-field">
|
||||
<legend>{field.label}</legend>
|
||||
<div className="nebula-admin-expedition-items">{value.map((item, index) => <label key={index}><span>{field.items?.[index] ?? index + 1}</span>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min={field.min} max={field.max} step="1" value={item} disabled={busy} onChange={(event) => set(field.path, value.map((current, position) => (position === index ? event.target.value : current)))} />
|
||||
</label>)}</div>
|
||||
</fieldset>;
|
||||
return <label key={field.path} className="nebula-admin-expedition-field"><span>{field.label}</span>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min={field.min} max={field.max} step="1" value={value} disabled={busy} onChange={(event) => set(field.path, event.target.value)} />
|
||||
</label>;
|
||||
})}</div>
|
||||
{invalid.length > 0 && <p className="nebula-form-help" role="alert">{invalid.map((field) => `${field.label} : entier de ${field.min.toLocaleString("fr-FR")} à ${field.max.toLocaleString("fr-FR")}`).join(" · ")}</p>}
|
||||
<ApplyActions
|
||||
busy={busy}
|
||||
changed={changed}
|
||||
onCancel={() => setDraft(initial())}
|
||||
onApply={() => save((next) => fields.forEach((field) => writePath(next, field.path, values[field.path])))}
|
||||
confirmTitle={`Appliquer les réglages « ${group.title} » ?`}
|
||||
confirmMessage="Les nouveaux réglages s’appliquent aux prochains départs. Les expéditions en route gardent ceux de leur départ."
|
||||
/>
|
||||
</section>;
|
||||
}
|
||||
|
||||
// Destinations : proposées ou non, et poids dans le tirage du jour. Leurs textes vivent dans le fichier du serveur.
|
||||
function DestinationSettings({ settings, destinations, busy, save }) {
|
||||
const initial = () => Object.fromEntries(destinations.map((destination) => [destination.id, { active: settings.destinations[destination.id].active, weight: String(settings.destinations[destination.id].weight) }]));
|
||||
const [draft, setDraft] = useState(initial);
|
||||
const invalid = destinations.filter((destination) => !inRange(parse(draft[destination.id].weight), 0, 100));
|
||||
const changed = !invalid.length && destinations.some((destination) => draft[destination.id].active !== settings.destinations[destination.id].active || parse(draft[destination.id].weight) !== settings.destinations[destination.id].weight);
|
||||
const set = (id, changes) => setDraft((current) => ({ ...current, [id]: { ...current[id], ...changes } }));
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-group" aria-labelledby="nebula-admin-expedition-destinations">
|
||||
<div className="nds-section-heading nebula-admin-panel-heading"><h3 id="nebula-admin-expedition-destinations">Destinations</h3></div>
|
||||
<p className="nebula-form-help">Une destination retirée n’est plus tirée ; le poids règle sa fréquence parmi les destinations proposées. Les destinations cachées ne sont jamais tirées.</p>
|
||||
<ul className="nebula-admin-expedition-destinations">{destinations.map((destination) => <li key={destination.id} className="nds-list-row">
|
||||
<strong>{destination.name}{destination.hidden && <span className="nds-badge" data-variant="neutral">Cachée</span>}</strong>
|
||||
<button className="nds-button" data-size="sm" data-variant={draft[destination.id].active ? "primary" : "secondary"} type="button" aria-pressed={draft[destination.id].active} aria-label={`${destination.name} proposée`} disabled={busy} onClick={() => set(destination.id, { active: !draft[destination.id].active })}>{draft[destination.id].active ? "Proposée" : "Retirée"}</button>
|
||||
<label><span>Poids</span><input className="nds-input" type="number" inputMode="numeric" min="0" max="100" step="1" value={draft[destination.id].weight} disabled={busy} aria-label={`Poids de ${destination.name}`} onChange={(event) => set(destination.id, { weight: event.target.value })} /></label>
|
||||
</li>)}</ul>
|
||||
{invalid.length > 0 && <p className="nebula-form-help" role="alert">Poids : entier de 0 à 100.</p>}
|
||||
<ApplyActions
|
||||
busy={busy}
|
||||
changed={changed}
|
||||
onCancel={() => setDraft(initial())}
|
||||
onApply={() => save((next) => destinations.forEach((destination) => { next.destinations[destination.id] = { active: draft[destination.id].active, weight: parse(draft[destination.id].weight) }; }))}
|
||||
confirmTitle="Appliquer les destinations ?"
|
||||
confirmMessage="Le changement vaut pour les prochains tirages : les destinations déjà proposées aujourd’hui restent jusqu’à minuit."
|
||||
/>
|
||||
</section>;
|
||||
}
|
||||
|
||||
function ExpeditionsToday({ today, destinations, busy, onCancel }) {
|
||||
const [cancelling, setCancelling] = useState(null);
|
||||
const name = (id) => destinations.find((destination) => destination.id === id)?.name || id;
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-group" aria-labelledby="nebula-admin-expedition-today">
|
||||
<div className="nds-section-heading nebula-admin-panel-heading"><h3 id="nebula-admin-expedition-today">Aujourd’hui</h3></div>
|
||||
<p className="nebula-admin-guild-today"><strong>{today.launches}</strong> départ{today.launches > 1 ? "s" : ""} · <strong>{today.running}</strong> en route · <strong>{today.returnedUnclaimed}</strong> butin{today.returnedUnclaimed > 1 ? "s" : ""} à récupérer.</p>
|
||||
{today.runningList.length > 0 && <ul className="nebula-admin-expedition-destinations">{today.runningList.map((expedition) => <li key={expedition.id} className="nds-list-row">
|
||||
<strong>{name(expedition.destinationId)} · {"★".repeat(expedition.stars)}</strong>
|
||||
<span>{expedition.creatorName} · retour le {DATE_FORMATTER.format(expedition.returnsAt)}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => setCancelling(expedition)}>Annuler</button>
|
||||
</li>)}</ul>}
|
||||
{cancelling && <ConfirmModal
|
||||
title="Annuler cette expédition ?"
|
||||
message={`L’expédition vers ${name(cancelling.destinationId)} de ${cancelling.creatorName} s’arrête : les cartes sont libérées, sans butin.`}
|
||||
confirmLabel="Annuler l’expédition"
|
||||
onClose={async (confirmed) => {
|
||||
const target = cancelling;
|
||||
setCancelling(null);
|
||||
if (confirmed) await onCancel(target.id);
|
||||
}}
|
||||
/>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function ExpeditionSettings({ dashboard, busy, runMutation, refreshDashboard }) {
|
||||
const { settings, schema, destinations, updatedAt } = dashboard.expeditionSettings;
|
||||
const save = async (apply) => {
|
||||
const next = structuredClone(settings);
|
||||
apply(next);
|
||||
if (await runMutation(() => updateExpeditionSettings(next))) await refreshDashboard();
|
||||
};
|
||||
const cancel = async (id) => {
|
||||
if (await runMutation(() => cancelExpedition(id))) await refreshDashboard();
|
||||
};
|
||||
return <div className="nebula-admin-expeditions" aria-labelledby="nebula-admin-expeditions-title">
|
||||
<h2 id="nebula-admin-expeditions-title">Expéditions</h2>
|
||||
<ExpeditionsToday today={dashboard.expeditionsToday} destinations={destinations} busy={busy} onCancel={cancel} />
|
||||
{EXPEDITION_SETTING_GROUPS.map((group) => <SettingsGroup key={`${group.id}-${updatedAt}`} group={group} settings={settings} schema={schema} busy={busy} save={save} />)}
|
||||
<DestinationSettings key={`destinations-${updatedAt}`} settings={settings} destinations={destinations} busy={busy} save={save} />
|
||||
</div>;
|
||||
}
|
||||
99
website/src/features/cards/admin/expeditionSettingFields.js
Normal file
99
website/src/features/cards/admin/expeditionSettingFields.js
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
// Rôle : libellés et regroupement des réglages des Expéditions pour l'administration et son historique.
|
||||
// Les bornes viennent du schéma du serveur (tableau de bord) ; un test vérifie que chaque réglage du schéma a ici son libellé.
|
||||
|
||||
const STARS = ["1 ★", "2 ★", "3 ★", "4 ★", "5 ★"];
|
||||
const STATS_IN_ORDER = ["principale", "2e stat", "3e stat", "4e stat"];
|
||||
|
||||
export const EXPEDITION_SETTING_GROUPS = [
|
||||
{
|
||||
id: "general",
|
||||
title: "Général",
|
||||
help: "Ouverture, destinations proposées chaque jour, durées et règles du solo.",
|
||||
fields: [
|
||||
{ path: "enabled", label: "Expéditions ouvertes aux joueurs" },
|
||||
{ path: "day.destinationsPerDay", label: "Destinations proposées par jour" },
|
||||
{ path: "day.avoidRepeatDays", label: "Jours avant qu’une destination revienne" },
|
||||
{ path: "durations.hours", label: "Durées proposées (heures)", items: ["Courte", "Moyenne", "Longue"] },
|
||||
{ path: "solo.cards", label: "Cartes en solo" },
|
||||
{ path: "solo.maxConcurrent", label: "Expéditions solo en même temps" },
|
||||
{ path: "solo.minStars", label: "Étoile minimale en solo" },
|
||||
{ path: "solo.maxStars", label: "Étoile maximale en solo" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "power",
|
||||
title: "Puissance et rôles",
|
||||
help: "Puissance de base de chaque rareté, gain par niveau et plafond commun ; multiplicateur du rôle d’une place.",
|
||||
fields: [
|
||||
{ path: "power.rare", label: "Puissance de base d’une rare" },
|
||||
{ path: "power.epic", label: "Puissance de base d’une épique" },
|
||||
{ path: "power.legendary", label: "Puissance de base d’une légendaire" },
|
||||
{ path: "power.mythic", label: "Puissance de base d’une mythique" },
|
||||
{ path: "power.perLevel", label: "Gain de Puissance par niveau" },
|
||||
{ path: "power.cap", label: "Plafond de Puissance" },
|
||||
{ path: "roles.multiplierPct", label: "Multiplicateur du rôle (%)" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "requirements",
|
||||
title: "Exigences",
|
||||
help: "Exigence d’une stat par place : elle est multipliée par le nombre de places, plus les places dont le rôle double cette stat.",
|
||||
fields: [
|
||||
...STARS.map((stars, index) => ({ path: `requirements.star${index + 1}`, label: `Exigences par place en ${stars}`, items: STATS_IN_ORDER })),
|
||||
{ path: "requirements.conditionMissPct", label: "Baisse du score si la condition de 3 ★ manque (%)" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "score",
|
||||
title: "Score, durée et dangers",
|
||||
help: "Paliers, rendement au-delà de 100 %, malus des longues expéditions et des dangers, et ce que l’Endurance en efface.",
|
||||
fields: [
|
||||
{ path: "score.successPct", label: "Seuil de Réussite (%)" },
|
||||
{ path: "score.triumphPct", label: "Seuil de Triomphe (%)" },
|
||||
{ path: "score.capPct", label: "Plafond du score (%)" },
|
||||
{ path: "score.mainWeight", label: "Poids de la stat principale" },
|
||||
{ path: "score.otherWeight", label: "Poids des autres stats" },
|
||||
{ path: "score.overflowPct", label: "Valeur d’un point au-delà de 100 % (%)" },
|
||||
{ path: "score.overflowSpanPct", label: "Dépassement pris en compte (%)" },
|
||||
{ path: "durations.malusPct", label: "Malus de durée (%)", items: ["Courte", "Moyenne", "Longue"] },
|
||||
{ path: "durations.endurancePerSlot", label: "Endurance par place qui efface le malus de durée" },
|
||||
{ path: "danger.malusPct", label: "Malus d’un danger (%)" },
|
||||
{ path: "danger.shieldMaxPct", label: "Part du malus que l’Endurance peut effacer (%)" },
|
||||
{ path: "danger.endurancePerSlot", label: "Endurance par place pour le bouclier complet" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "loot",
|
||||
title: "Butin",
|
||||
help: "Butin par heure (proportionnel à la durée choisie), multiplié par la difficulté et le palier ; la Fortune n’améliore que la chance de paquet.",
|
||||
fields: [
|
||||
{ path: "loot.eclatsPerHourCents", label: "Éclats par heure (en centièmes : 200 = 2)" },
|
||||
{ path: "loot.stardustPerHourCents", label: "Poussière par heure (en centièmes : 25 = 0,25)" },
|
||||
{ path: "loot.packPerHourPermille", label: "Chance de paquet par heure (‰)" },
|
||||
{ path: "loot.maxPacks", label: "Paquets au plus par expédition" },
|
||||
{ path: "loot.difficultyPct", label: "Multiplicateur de difficulté (%)", items: STARS },
|
||||
{ path: "loot.tierPct", label: "Multiplicateur du palier (%)", items: ["Retour difficile", "Réussite", "Triomphe"] },
|
||||
{ path: "loot.fortunePerPointPct", label: "Bonus de paquet par point de Fortune par place (%)" },
|
||||
{ path: "loot.fortuneCapPct", label: "Bonus de Fortune maximal (%)" },
|
||||
{ path: "loot.bonusSlotPct", label: "Multiplicateur des destinations bonus (%)", items: ["5e destination", "6e destination"] }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const LABELS = new Map(EXPEDITION_SETTING_GROUPS.flatMap((group) => group.fields.map((field) => [field.path, field.label])));
|
||||
|
||||
// Libellé d'un réglage dans l'historique ; une destination se nomme par son nom.
|
||||
export function expeditionSettingLabel(path, destinations = []) {
|
||||
const destination = path.match(/^destinations\.([^.]+)\.(active|weight)$/);
|
||||
if (destination) {
|
||||
const name = destinations.find((item) => item.id === destination[1])?.name || destination[1];
|
||||
return `${name} · ${destination[2] === "active" ? "proposée" : "poids"}`;
|
||||
}
|
||||
return LABELS.get(path) || path;
|
||||
}
|
||||
|
||||
export function formatSettingValue(value) {
|
||||
if (typeof value === "boolean") return value ? "oui" : "non";
|
||||
if (Array.isArray(value)) return value.join(" / ");
|
||||
return value ?? "—";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue