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
107
services/cards/expedition-simulation.js
Normal file
107
services/cards/expedition-simulation.js
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
// Rôle : simule les Expéditions Sokko TCG sur toutes les équipes possibles pour vérifier l'équilibre (script et test d'équilibrage).
|
||||
// Module pur : il appelle les mêmes règles que le serveur, sans base ni hasard.
|
||||
import { cardRarity } from "./daily.js";
|
||||
import {
|
||||
cardExpeditionData, cardPower, evaluateTeam, EXPEDITION_RARITIES, expectedLoot, maxLevel, MAX_STARS, soloRoles, splitPower, TIER_IDS
|
||||
} from "./expedition-rules.js";
|
||||
|
||||
// Cartes jouables : chaque carte rare ou mieux à sa rareté, plus une mythique virtuelle pour chaque légendaire.
|
||||
export function simulationCards(catalog) {
|
||||
const cards = [];
|
||||
for (const card of catalog.cards) {
|
||||
const rarity = cardRarity(catalog, card.id);
|
||||
if (!EXPEDITION_RARITIES.includes(rarity)) continue;
|
||||
const data = cardExpeditionData(catalog, card.id);
|
||||
cards.push({ ...data, rarity });
|
||||
if (rarity === "legendary") cards.push({ ...data, rarity: "mythic" });
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
const atLevel = (card, level, settings) => {
|
||||
const power = cardPower(card.rarity, level, settings);
|
||||
return { ...card, level, power, stats: splitPower(power, card.profile) };
|
||||
};
|
||||
|
||||
const entryFor = (destination) => ({ condition: destination.conditions[0], dangers: destination.dangers.slice(0, 2) });
|
||||
|
||||
// Meilleur score d'une paire sur une destination : les deux façons de placer les cartes sur les deux rôles du solo.
|
||||
export function bestPairScore(first, second, destination, stars, durationIndex, settings) {
|
||||
const roles = soloRoles(destination, 2);
|
||||
let best = null;
|
||||
for (const [a, b] of [[first, second], [second, first]]) {
|
||||
const result = evaluateTeam({
|
||||
destination, entry: entryFor(destination), stars, durationIndex,
|
||||
slots: [{ ...a, role: roles[0] }, { ...b, role: roles[1] }]
|
||||
}, settings);
|
||||
if (!best || result.scorePct > best.scorePct) best = result;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
function pairsOf(cards, filter) {
|
||||
const pairs = [];
|
||||
for (let i = 0; i < cards.length; i += 1) {
|
||||
for (let j = i + 1; j < cards.length; j += 1) {
|
||||
if (cards[i].cardId !== cards[j].cardId && filter(cards[i], cards[j])) pairs.push([cards[i], cards[j]]);
|
||||
}
|
||||
}
|
||||
return pairs;
|
||||
}
|
||||
|
||||
// Rapport complet : meilleur score de chaque carte en 2 ★, extrêmes par rareté et étoiles, butin par heure, écart rare / mythique au plafond.
|
||||
export function simulate(catalog, destinations, settings) {
|
||||
const visible = destinations.filter((destination) => !destination.hidden);
|
||||
const base = simulationCards(catalog);
|
||||
const atZero = base.map((card) => atLevel(card, 0, settings));
|
||||
const atMax = base.map((card) => atLevel(card, maxLevel(card.rarity, settings), settings));
|
||||
|
||||
// 1. Chaque carte doit atteindre Réussite en 2 ★ quelque part, avec un partenaire de même rareté, au niveau 0.
|
||||
const cardBest = atZero.map((card) => {
|
||||
let best = { scorePct: 0, destinationId: null, partnerId: null };
|
||||
for (const partner of atZero) {
|
||||
if (partner.cardId === card.cardId || partner.rarity !== card.rarity) continue;
|
||||
for (const destination of visible) {
|
||||
const result = bestPairScore(card, partner, destination, 2, 0, settings);
|
||||
if (result.scorePct > best.scorePct) best = { scorePct: result.scorePct, destinationId: destination.id, partnerId: partner.cardId };
|
||||
}
|
||||
}
|
||||
return { cardId: card.cardId, rarity: card.rarity, ...best };
|
||||
});
|
||||
|
||||
// 2. Score par rareté (paires de même rareté), étoiles et niveau : minimum, médiane et maximum sur toutes les destinations.
|
||||
const byRarity = [];
|
||||
for (const [label, cards] of [["niveau 0", atZero], ["niveau max", atMax]]) {
|
||||
for (const rarity of EXPEDITION_RARITIES) {
|
||||
const pairs = pairsOf(cards, (a, b) => a.rarity === rarity && b.rarity === rarity);
|
||||
for (let stars = 1; stars <= MAX_STARS; stars += 1) {
|
||||
const scores = [];
|
||||
for (const [a, b] of pairs) for (const destination of visible) scores.push(bestPairScore(a, b, destination, stars, 0, settings).scorePct);
|
||||
scores.sort((x, y) => x - y);
|
||||
byRarity.push({ level: label, rarity, stars, min: scores[0] ?? 0, median: scores[Math.floor(scores.length / 2)] ?? 0, max: scores.at(-1) ?? 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Triomphe en 4 ★ au niveau maximum : part des destinations où au moins une paire de rares au plafond triomphe.
|
||||
const maxRares = atMax.filter((card) => card.rarity === "rare");
|
||||
const triumphDestinations = visible.filter((destination) => pairsOf(maxRares, () => true)
|
||||
.some(([a, b]) => bestPairScore(a, b, destination, 4, 0, settings).tier === "triumph")).length;
|
||||
|
||||
// 4. Butin espéré par heure, pour chaque durée, étoile et palier.
|
||||
const lootPerHour = [];
|
||||
for (let stars = 1; stars <= MAX_STARS; stars += 1) {
|
||||
for (const tier of TIER_IDS) {
|
||||
const perHour = settings.durations.hours.map((hours) => expectedLoot({ hours, stars, tier, fortune: 0, slotCount: 2 }, settings).eclats / hours);
|
||||
lootPerHour.push({ stars, tier, perHour });
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
cardBest,
|
||||
byRarity,
|
||||
triumphShareAt4: visible.length ? triumphDestinations / visible.length : 0,
|
||||
lootPerHour,
|
||||
rareVsMythicAtMax: { rare: cardPower("rare", maxLevel("rare", settings), settings), mythic: cardPower("mythic", maxLevel("mythic", settings), settings) }
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue