- Each Primordial has a 45 % specialty and its own 10 % weakness; its emblematic common raises its two strengths with the synergy on its specialty, and its constellation gives Orientation plus its weakness, without penalties. - Commons declare the stat their synergy raises when stats tie and for power commons, so the bonus no longer falls on Bravoure by field order. - Expertise is measured against the solo requirement, so it stays within reach when the group raises each place's requirement. - Missing lore links become playable: the Dragon, Panda and Capybara own their emblems, Turtles and the Reindeer share an identity, and the Bat, the light-current Otters and the Aurora Wolf are recognised at their destinations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
169 lines
9.2 KiB
JavaScript
169 lines
9.2 KiB
JavaScript
// 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 {
|
|
addStats, cardExpeditionData, cardPower, equipmentBonus, evaluateTeam, EXPEDITION_RARITIES, expectedLoot, maxLevel, MAX_STARS, planStats, ROLE_BY_STAT,
|
|
splitPower, teamSynergy, TIER_IDS, unlockedSlots
|
|
} 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);
|
|
const data = cardExpeditionData(catalog, card.id);
|
|
if (!EXPEDITION_RARITIES.includes(rarity) || !data) continue;
|
|
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) });
|
|
|
|
// Carte construite pour une destination : ses points de niveau suivent la vocation de sa stat principale.
|
|
const builtFor = (card, destination, settings) => ({ ...card, stats: planStats(card.rarity, card.level, card.profile, { plan: ROLE_BY_STAT[destination.stats[0]] }, settings) });
|
|
|
|
// Score d'une carte partie seule sur une destination. `built` : la carte a la vocation de la stat principale de la destination.
|
|
export function bestSoloScore(card, destination, stars, durationIndex, settings, built = false) {
|
|
return evaluateTeam({ destination, entry: entryFor(destination), stars, durationIndex, slots: [built ? builtFor(card, destination, settings) : card] }, settings);
|
|
}
|
|
|
|
// Communes à stats du catalogue, prêtes à équiper : { cardId, stats, tags }.
|
|
export function statCommons(catalog) {
|
|
return catalog.cards.filter((card) => card.expedition?.equipment?.stats).map((card) => ({ cardId: card.id, stats: card.expedition.equipment.stats, synergyStat: card.expedition.equipment.synergyStat ?? null, tags: card.expedition.tags }));
|
|
}
|
|
|
|
// Situations d'une destination : chaque condition, avec chaque paire de dangers qui se suivent.
|
|
export function destinationSituations(destination) {
|
|
const situations = [];
|
|
for (const condition of destination.conditions) {
|
|
for (let index = 0; index < destination.dangers.length; index += 1) {
|
|
situations.push({ condition, dangers: [destination.dangers[index], destination.dangers[(index + 1) % destination.dangers.length]] });
|
|
}
|
|
}
|
|
return situations;
|
|
}
|
|
|
|
// Score d'une équipe, synergies de score comprises (Affinité, Résonances, cohésion d'un groupe aux collections toutes différentes).
|
|
export function teamResult(slots, destination, entry, stars, settings) {
|
|
const collections = new Set(slots.map((slot) => slot.collectionId));
|
|
const cohesion = slots.length >= 2 && collections.size === slots.length ? settings.group.cohesionPct : 0;
|
|
const synergyPct = teamSynergy({ destination, slots, cohesionPct: cohesion }, settings).totalPct;
|
|
return evaluateTeam({ destination, entry, stars, durationIndex: 0, slots, synergyPct }, settings);
|
|
}
|
|
|
|
// Place d'une carte à une Puissance donnée : sa vocation (`plan`, ou son profil seul) et ses équipements.
|
|
function slotAt(card, power, plan, items, settings) {
|
|
const base = settings.power[card.rarity];
|
|
const level = Math.ceil((power - base) / settings.power.perLevel);
|
|
const stats = planStats(card.rarity, level, card.profile, plan ? { plan } : null, settings);
|
|
return { ...card, power, stats: addStats(stats, equipmentBonus(items, card.tags, settings).stats) };
|
|
}
|
|
|
|
// Build réfléchi d'une équipe pour une destination : vocations réparties sur les stats exigées (une par carte, dans l'ordre), puis,
|
|
// emplacement par emplacement, la commune qui améliore le plus le score (parmi les plus utiles à ces stats). C'est une
|
|
// approximation gloutonne de ce que ferait un joueur attentif, pas l'optimum.
|
|
export function reflectedBuild(team, power, destination, stars, commons, settings) {
|
|
const plans = team.map((_, index) => ROLE_BY_STAT[destination.stats[index % destination.stats.length]]);
|
|
const items = team.map(() => []);
|
|
const [entry] = destinationSituations(destination);
|
|
const required = destination.stats;
|
|
const candidates = (card) => commons
|
|
.map((item) => ({ item, value: required.reduce((sum, stat) => sum + (equipmentBonus([item], card.tags, settings).stats[stat] || 0), 0) }))
|
|
.sort((a, b) => b.value - a.value).slice(0, 16).map((entry) => entry.item);
|
|
const pools = team.map(candidates);
|
|
for (let slot = 0; slot < unlockedSlots(power, settings); slot += 1) {
|
|
for (let index = 0; index < team.length; index += 1) {
|
|
let best = null;
|
|
let bestScore = -1;
|
|
for (const item of pools[index]) {
|
|
if (items[index].includes(item)) continue;
|
|
items[index].push(item);
|
|
const score = teamResult(team.map((card, other) => slotAt(card, power, plans[other], items[other], settings)), destination, entry, stars, settings).scorePct;
|
|
items[index].pop();
|
|
if (score > bestScore) [best, bestScore] = [item, score];
|
|
}
|
|
if (best) items[index].push(best);
|
|
}
|
|
}
|
|
return team.map((card, index) => slotAt(card, power, plans[index], items[index], settings));
|
|
}
|
|
|
|
// Part des situations réussies par des cartes seules à une Puissance donnée, sans équipement (profil seul) et avec un build réfléchi.
|
|
// `cards` : cartes jouables (simulationCards) ; seules celles dont la rareté atteint cette Puissance comptent.
|
|
export function soloBuildShares(cards, destinations, power, stars, commons, settings) {
|
|
const visible = destinations.filter((destination) => !destination.hidden);
|
|
const eligible = cards.filter((card) => settings.power[card.rarity] <= power);
|
|
let bare = 0;
|
|
let built = 0;
|
|
let total = 0;
|
|
for (const card of eligible) {
|
|
for (const destination of visible) {
|
|
const plain = [slotAt(card, power, null, [], settings)];
|
|
const build = reflectedBuild([card], power, destination, stars, commons, settings);
|
|
for (const entry of destinationSituations(destination)) {
|
|
bare += teamResult(plain, destination, entry, stars, settings).tier !== "struggle";
|
|
built += teamResult(build, destination, entry, stars, settings).tier !== "struggle";
|
|
total += 1;
|
|
}
|
|
}
|
|
}
|
|
return { cards: eligible.length, bare: total ? bare / total : 0, built: total ? built / total : 0 };
|
|
}
|
|
|
|
// Rapport complet, pour des cartes parties seules : 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, seule, au niveau 0.
|
|
const cardBest = atZero.map((card) => {
|
|
let best = { scorePct: 0, destinationId: null };
|
|
for (const destination of visible) {
|
|
const result = bestSoloScore(card, destination, 2, 0, settings);
|
|
if (result.scorePct > best.scorePct) best = { scorePct: result.scorePct, destinationId: destination.id };
|
|
}
|
|
return { cardId: card.cardId, rarity: card.rarity, ...best };
|
|
});
|
|
|
|
// 2. Score par rareté, étoiles et niveau : minimum, médiane et maximum sur toutes les cartes et destinations.
|
|
const byRarity = [];
|
|
// « max+vocat. » : les mêmes cartes, chacune avec la vocation de la stat principale de la destination (plans de progression).
|
|
for (const [label, cards, built] of [["niveau 0", atZero, false], ["niveau max", atMax, false], ["max+vocat.", atMax, true]]) {
|
|
for (const rarity of EXPEDITION_RARITIES) {
|
|
const ofRarity = cards.filter((card) => card.rarity === rarity);
|
|
for (let stars = 1; stars <= MAX_STARS; stars += 1) {
|
|
const scores = [];
|
|
for (const card of ofRarity) for (const destination of visible) scores.push(bestSoloScore(card, destination, stars, 0, settings, built).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 });
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 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: 1 }, settings).eclats / hours);
|
|
lootPerHour.push({ stars, tier, perHour });
|
|
}
|
|
}
|
|
|
|
return {
|
|
cardBest,
|
|
byRarity,
|
|
lootPerHour,
|
|
rareVsMythicAtMax: { rare: cardPower("rare", maxLevel("rare", settings), settings), mythic: cardPower("mythic", maxLevel("mythic", settings), settings) }
|
|
};
|
|
}
|