Let players choose how their cards spend level points with vocations or free points, and sell the Parchemin d'oubli
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
18bcf435b5
commit
7d331d1a3f
24 changed files with 473 additions and 60 deletions
|
|
@ -365,6 +365,15 @@ export function createCardsApiHandler({
|
|||
json(res, 200, service.expeditions.equip(session.player.id, { editionId: body.editionId, slot: body.slot, equipmentEditionId: body.equipmentEditionId ?? null }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "PUT" && url.pathname === "/api/cards/progress/plan") {
|
||||
const body = await readBody(req);
|
||||
json(res, 200, service.expeditions.setCardPlan(session.player.id, { editionId: body.editionId, plan: body.plan, allocation: body.allocation ?? null }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/shop/oblivion") {
|
||||
json(res, 200, service.expeditions.buyOblivion(session.player.id, { count: (await readBody(req)).count }));
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -392,6 +392,12 @@ const MIGRATIONS = [
|
|||
created_at INTEGER NOT NULL,
|
||||
PRIMARY KEY (player_id, day)
|
||||
) STRICT;
|
||||
`,
|
||||
// Plan de progression d'une carte : comment ses points de niveau se répartissent (collection, vocation ou libre) et,
|
||||
// en libre, les points placés par le joueur. NULL : jamais choisi (le premier choix est gratuit).
|
||||
`
|
||||
ALTER TABLE card_progress ADD COLUMN plan TEXT CHECK (plan IS NULL OR plan IN ('collection', 'leader', 'guardian', 'seeker', 'navigator', 'free'));
|
||||
ALTER TABLE card_progress ADD COLUMN allocation_json TEXT CHECK (allocation_json IS NULL OR json_valid(allocation_json));
|
||||
`
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ export const equipmentMethods = {
|
|||
},
|
||||
|
||||
// Une carte prête à partir : stats de sa Puissance, plus ses équipements (dans ses emplacements ouverts) et leurs synergies.
|
||||
loadout(editionId, level, equipped, settings, engravings = null) {
|
||||
const data = editionExpeditionData(this.cards.catalog, editionId, level, settings);
|
||||
// `progress` : { level, plan, allocation } de la carte chez le joueur.
|
||||
loadout(editionId, progress, equipped, settings, engravings = null) {
|
||||
const data = editionExpeditionData(this.cards.catalog, editionId, progress?.level ?? 0, settings, progress);
|
||||
if (!data) return null;
|
||||
const slots = unlockedSlots(data.power, settings);
|
||||
const items = (equipped || []).filter((item) => item.slot < slots).map((item) => ({ slot: item.slot, ...this.equipmentItem(item.equipmentEditionId, engravings) })).filter((item) => item.editionId);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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.
|
||||
// Rôle : améliorations des cartes Sokko TCG pour les Expéditions : niveaux par Éclats ou doublon, expérience de terrain, plans de progression
|
||||
// (vocation ou points libres, changés avec un Parchemin d'oubli), pont depuis la poussière et achat de Parchemins.
|
||||
// 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";
|
||||
import { allocationError, cardExpeditionData, clampAllocation, editionExpeditionData, gainProgress, levelPoints, maxLevel, maxStatPoints, PLAN_IDS, planStats, splitPower, STAT_IDS, upgradeCost, VOCATION_IDS } from "./expedition-rules.js";
|
||||
|
||||
function fail(status, code, message) {
|
||||
throw Object.assign(new Error(message), { status, code });
|
||||
|
|
@ -8,16 +9,20 @@ function fail(status, code, message) {
|
|||
|
||||
// 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;
|
||||
// Au plus ce nombre de Parchemins d'oubli par achat.
|
||||
export const MAX_OBLIVION_PER_PURCHASE = 100;
|
||||
|
||||
const readAllocation = (json) => (json ? JSON.parse(json) : null);
|
||||
|
||||
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 }]));
|
||||
return new Map(this.db.prepare("SELECT edition_id, level, field_xp, plan, allocation_json FROM card_progress WHERE player_id = ?").all(playerId)
|
||||
.map((row) => [row.edition_id, { level: row.level, fieldXp: row.field_xp, plan: row.plan, allocation: readAllocation(row.allocation_json) }]));
|
||||
},
|
||||
|
||||
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 };
|
||||
const row = this.db.prepare("SELECT level, field_xp, plan, allocation_json FROM card_progress WHERE player_id = ? AND edition_id = ?").get(playerId, editionId);
|
||||
return { level: row?.level ?? 0, fieldXp: row?.field_xp ?? 0, plan: row?.plan ?? null, allocation: readAllocation(row?.allocation_json) };
|
||||
},
|
||||
|
||||
writeProgress(playerId, editionId, { level, fieldXp }) {
|
||||
|
|
@ -32,11 +37,12 @@ export const progressMethods = {
|
|||
const equipment = this.equipmentOf(playerId);
|
||||
const engravings = this.engravingsOf(playerId);
|
||||
return this.cards.collectionOf(playerId).map((entry) => {
|
||||
const progress = levels.get(entry.editionId) || { level: 0, fieldXp: 0 };
|
||||
const data = this.loadout(entry.editionId, progress.level, equipment.get(entry.editionId), settings, engravings);
|
||||
const progress = levels.get(entry.editionId) || { level: 0, fieldXp: 0, plan: null, allocation: null };
|
||||
const data = this.loadout(entry.editionId, progress, equipment.get(entry.editionId), settings, engravings);
|
||||
if (!data) return null;
|
||||
return {
|
||||
editionId: entry.editionId, level: progress.level, fieldXp: progress.fieldXp, power: data.power, baseStats: data.baseStats, stats: data.stats,
|
||||
plan: this.planView(data, progress, settings),
|
||||
maxLevel: maxLevel(data.rarity, settings), nextCost: upgradeCost(data.rarity, progress.level, settings), spare: entry.spare,
|
||||
slots: data.slots, maxSlots: settings.equipment.maxPerCard, tags: data.tags, equipment: data.equipment,
|
||||
slotPowers: [0, settings.equipment.secondSlotPower, settings.equipment.thirdSlotPower].slice(0, settings.equipment.maxPerCard)
|
||||
|
|
@ -44,6 +50,68 @@ export const progressMethods = {
|
|||
}).filter(Boolean);
|
||||
},
|
||||
|
||||
// Plan de progression d'une carte : plan choisi, points de niveau (placés en libre), plafond par stat, et les stats que donnerait
|
||||
// chaque vocation (sans équipement) pour l'aperçu. `paid` : changer de plan coûterait un Parchemin d'oubli.
|
||||
planView(data, progress, settings) {
|
||||
const profile = cardExpeditionData(this.cards.catalog, data.cardId).profile;
|
||||
const points = levelPoints(data.rarity, data.level, settings);
|
||||
const plan = progress.plan ?? "collection";
|
||||
const preview = (id) => planStats(data.rarity, data.level, profile, { plan: id }, settings);
|
||||
return {
|
||||
id: plan, points, maxStatPoints: maxStatPoints(points, settings), paid: plan !== "collection",
|
||||
allocation: plan === "free" ? clampAllocation(progress.allocation, points, settings) : null,
|
||||
levelBase: splitPower(data.power - points, profile),
|
||||
previews: Object.fromEntries(["collection", ...VOCATION_IDS].map((id) => [id, preview(id)]))
|
||||
};
|
||||
},
|
||||
|
||||
// Change le plan de progression d'une carte. Tant qu'elle suit sa collection, choisir est gratuit ; ensuite, changer de plan
|
||||
// ou retirer des points placés en libre consomme un Parchemin d'oubli (ajouter des points en libre reste gratuit).
|
||||
setCardPlan(playerId, { editionId, plan, allocation = null } = {}) {
|
||||
const settings = this.settings;
|
||||
if (!PLAN_IDS.includes(plan)) fail(400, "PLAN_INVALID", "Plan de progression inconnu.");
|
||||
this.cards.database.transaction(() => {
|
||||
if (!this.cards.collectionOf(playerId).some((entry) => entry.editionId === editionId)) 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 ont un plan de progression.");
|
||||
if (this.busyEditions(playerId).has(editionId)) fail(409, "EXPEDITION_CARD_BUSY", "Cette carte est en expédition : son plan ne change pas avant son retour.");
|
||||
const progress = this.progressOf(playerId, editionId);
|
||||
const points = levelPoints(data.rarity, progress.level, settings);
|
||||
const current = progress.plan ?? "collection";
|
||||
let next = null;
|
||||
if (plan === "free") {
|
||||
const error = allocationError(allocation, points, settings);
|
||||
if (error) fail(400, "ALLOCATION_INVALID", error);
|
||||
next = Object.fromEntries(STAT_IDS.map((stat) => [stat, allocation[stat] ?? 0]));
|
||||
}
|
||||
const placed = current === "free" ? clampAllocation(progress.allocation, points, settings) : null;
|
||||
if (plan === current && (plan !== "free" || STAT_IDS.every((stat) => next[stat] === placed[stat]))) return;
|
||||
const onlyAdds = plan === "free" && current === "free" && STAT_IDS.every((stat) => next[stat] >= placed[stat]);
|
||||
const paid = current !== "collection" && !onlyAdds;
|
||||
if (paid) this.consumeItemInTx(playerId, "oblivion");
|
||||
this.db.prepare(`INSERT INTO card_progress(player_id, edition_id, level, field_xp, plan, allocation_json, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(player_id, edition_id) DO UPDATE SET plan = excluded.plan, allocation_json = excluded.allocation_json, updated_at = excluded.updated_at`)
|
||||
.run(playerId, editionId, progress.level, progress.fieldXp, plan === "collection" ? null : plan, next ? JSON.stringify(next) : null, this.now());
|
||||
this.cards.audit(playerId, "card_plan_changed", editionId, { plan, ...(next ? { allocation: next } : {}), oblivion: paid });
|
||||
});
|
||||
return { progress: this.cardProgressView(playerId, settings).find((item) => item.editionId === editionId), state: this.cards.getState(playerId) };
|
||||
},
|
||||
|
||||
// Achète des Parchemins d'oubli avec de la poussière d'étoiles, au prix réglé dans la boutique.
|
||||
buyOblivion(playerId, { count = 1 } = {}) {
|
||||
const settings = this.settings;
|
||||
if (!Number.isInteger(count) || count < 1 || count > MAX_OBLIVION_PER_PURCHASE) fail(400, "PURCHASE_INVALID", `Nombre de Parchemins invalide : un entier entre 1 et ${MAX_OBLIVION_PER_PURCHASE}.`);
|
||||
const cost = count * settings.progression.oblivionPrice;
|
||||
this.cards.database.transaction(() => {
|
||||
this.cards.refreshRecharge(playerId);
|
||||
const paid = this.db.prepare("UPDATE players SET stardust = stardust - ? WHERE id = ? AND stardust >= ?").run(cost, playerId, cost);
|
||||
if (!paid.changes) fail(409, "NOT_ENOUGH_STARDUST", "Pas assez de poussière d’étoiles.");
|
||||
this.addItemsInTx(playerId, Array.from({ length: count }, () => "oblivion"));
|
||||
this.cards.audit(playerId, "oblivion_bought", "shop", { count, stardust: cost });
|
||||
});
|
||||
return this.cards.getState(playerId);
|
||||
},
|
||||
|
||||
// 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;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,67 @@ export function maxLevel(rarity, settings) {
|
|||
return Math.ceil((settings.power.cap - base) / settings.power.perLevel);
|
||||
}
|
||||
|
||||
// Plan de progression d'une carte : comment se répartissent ses points de niveau (la Puissance gagnée au-delà de celle de sa rareté).
|
||||
// « collection » : comme sa base, selon le profil de la collection (le défaut) ; une vocation (leader, guardian, seeker, navigator) :
|
||||
// la stat de son rôle au plafond, le reste partagé entre deux stats secondaires ; « free » : les points placés par le joueur.
|
||||
export const PLAN_IDS = Object.freeze(["collection", "leader", "guardian", "seeker", "navigator", "free"]);
|
||||
export const VOCATION_IDS = Object.freeze(["leader", "guardian", "seeker", "navigator"]);
|
||||
const VOCATION_SECONDARY = Object.freeze({ leader: ["endurance", "orientation"], guardian: ["bravoure", "orientation"], seeker: ["endurance", "orientation"], navigator: ["fortune", "endurance"] });
|
||||
|
||||
// Points de niveau d'une carte : sa Puissance au-delà de celle de sa rareté (plafond compris).
|
||||
export function levelPoints(rarity, level, settings) {
|
||||
const base = settings.power[rarity];
|
||||
if (!Number.isInteger(base)) return 0;
|
||||
return cardPower(rarity, level, settings) - Math.min(settings.power.cap, base);
|
||||
}
|
||||
|
||||
// Au plus ce nombre de points de niveau dans une même stat.
|
||||
export const maxStatPoints = (points, settings) => Math.floor((points * settings.plans.maxStatPct) / 100);
|
||||
|
||||
// Répartition d'une vocation, en pourcentages : la stat de son rôle au plafond, le reste partagé entre ses deux stats secondaires.
|
||||
export function vocationProfile(plan, settings) {
|
||||
const max = settings.plans.maxStatPct;
|
||||
const [first, second] = VOCATION_SECONDARY[plan];
|
||||
return { ...Object.fromEntries(STAT_IDS.map((stat) => [stat, 0])), [STAT_BY_ROLE[plan]]: max, [first]: Math.ceil((100 - max) / 2), [second]: Math.floor((100 - max) / 2) };
|
||||
}
|
||||
|
||||
// Points placés en libre, ramenés dans les règles du moment (un réglage abaissé ne casse pas une répartition) : chaque stat au plafond,
|
||||
// puis le surplus retiré de la plus haute.
|
||||
export function clampAllocation(allocation, points, settings) {
|
||||
const cap = maxStatPoints(points, settings);
|
||||
const result = Object.fromEntries(STAT_IDS.map((stat) => [stat, Math.max(0, Math.min(cap, Math.floor(Number(allocation?.[stat]) || 0)))]));
|
||||
let excess = STAT_IDS.reduce((sum, stat) => sum + result[stat], 0) - points;
|
||||
while (excess > 0) {
|
||||
const top = STAT_IDS.reduce((best, stat) => (result[stat] > result[best] ? stat : best));
|
||||
result[top] -= 1;
|
||||
excess -= 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Erreur d'une répartition libre envoyée par un joueur, ou null.
|
||||
export function allocationError(allocation, points, settings) {
|
||||
if (!allocation || typeof allocation !== "object") return "Répartition des points invalide.";
|
||||
if (Object.keys(allocation).some((key) => !STAT_IDS.includes(key))) return "Répartition des points invalide.";
|
||||
const values = STAT_IDS.map((stat) => allocation[stat] ?? 0);
|
||||
if (values.some((value) => !Number.isInteger(value) || value < 0)) return "Chaque stat reçoit un nombre entier de points.";
|
||||
if (values.reduce((sum, value) => sum + value, 0) > points) return `Cette carte n’a que ${points} points à placer.`;
|
||||
const cap = maxStatPoints(points, settings);
|
||||
if (values.some((value) => value > cap)) return `Une stat ne peut pas recevoir plus de ${cap} points.`;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Stats d'une carte selon son plan : la base de sa rareté suit le profil de sa collection, ses points de niveau suivent son plan.
|
||||
// Sans plan (ou « collection »), toute la Puissance suit le profil, comme avant les plans.
|
||||
export function planStats(rarity, level, profile, progress, settings) {
|
||||
const power = cardPower(rarity, level, settings);
|
||||
const plan = progress?.plan;
|
||||
if (!plan || plan === "collection" || !PLAN_IDS.includes(plan)) return splitPower(power, profile);
|
||||
const points = levelPoints(rarity, level, settings);
|
||||
const extra = plan === "free" ? clampAllocation(progress.allocation, points, settings) : splitPower(points, vocationProfile(plan, settings));
|
||||
return addStats(splitPower(power - points, profile), extra);
|
||||
}
|
||||
|
||||
// Répartit la Puissance selon le profil (pourcentages), au plus grand reste : la somme des stats vaut exactement la Puissance.
|
||||
export function splitPower(power, profile) {
|
||||
const raw = STAT_IDS.map((stat) => (power * profile[stat]) / 100);
|
||||
|
|
@ -60,13 +121,14 @@ export function cardExpeditionData(catalog, cardId) {
|
|||
}
|
||||
|
||||
// Ce qu'une édition apporte à une expédition : rareté de l'édition (une mythique garde la sienne), Puissance et stats.
|
||||
export function editionExpeditionData(catalog, editionId, level, settings) {
|
||||
// `progress` : { plan, allocation } de la carte chez le joueur (voir planStats), ou null.
|
||||
export function editionExpeditionData(catalog, editionId, level, settings, progress = null) {
|
||||
const edition = catalog.editions.find((item) => item.id === editionId);
|
||||
if (!edition) return null;
|
||||
const data = cardExpeditionData(catalog, edition.cardId);
|
||||
if (!data?.profile || !EXPEDITION_RARITIES.includes(edition.rarity)) return null;
|
||||
const power = cardPower(edition.rarity, level, settings);
|
||||
return { ...data, editionId, rarity: edition.rarity, level, power, stats: splitPower(power, data.profile) };
|
||||
return { ...data, editionId, rarity: edition.rarity, level, power, stats: planStats(edition.rarity, level, data.profile, progress, settings) };
|
||||
}
|
||||
|
||||
export const isExpeditionCard = (catalog, cardId) => EXPEDITION_RARITIES.includes(cardRarity(catalog, cardId)) && Boolean(cardExpeditionData(catalog, cardId));
|
||||
|
|
@ -422,7 +484,8 @@ export function teamSynergy({ destination, slots, cohesionPct: cohesion = 0, bel
|
|||
return { affinity, resonances, cohesionPct: cohesion, bellPct, totalPct: Math.min(settings.score.synergyCapPct, totalPct) };
|
||||
}
|
||||
|
||||
export const ITEM_IDS = Object.freeze(["fragment", "engraving", "plan", "anchor", "guideStar", "skyChart"]);
|
||||
// Le Parchemin d'oubli (oblivion) s'achète en boutique : sans poids de tirage, il ne sort jamais du butin.
|
||||
export const ITEM_IDS = Object.freeze(["fragment", "engraving", "plan", "anchor", "guideStar", "skyChart", "oblivion"]);
|
||||
// Partie cachée du butin : elle ne s'ouvre qu'avec assez d'Orientation moyenne par place.
|
||||
export const HIDDEN_ITEMS = Object.freeze(["fragment", "engraving", "plan"]);
|
||||
|
||||
|
|
|
|||
|
|
@ -144,10 +144,10 @@ export class ExpeditionService {
|
|||
const equipment = this.equipmentOf(playerId);
|
||||
const engravings = this.engravingsOf(playerId);
|
||||
return this.cards.visibleCollection(playerId, pending?.id).map((entry) => {
|
||||
const data = this.loadout(entry.editionId, levels.get(entry.editionId)?.level ?? 0, equipment.get(entry.editionId), settings, engravings);
|
||||
const data = this.loadout(entry.editionId, levels.get(entry.editionId), equipment.get(entry.editionId), settings, engravings);
|
||||
if (!data) return null;
|
||||
const busyEntry = busy.get(entry.editionId);
|
||||
return { ...data, busy: Boolean(busyEntry), busyUntil: busyEntry?.returnsAt ?? null };
|
||||
return { ...data, plan: levels.get(entry.editionId)?.plan ?? null, busy: Boolean(busyEntry), busyUntil: busyEntry?.returnsAt ?? null };
|
||||
}).filter(Boolean);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ export const DEFAULT_EXPEDITION_SETTINGS = Object.freeze({
|
|||
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 },
|
||||
// expérience de terrain par retour d'expédition (% d'un niveau), taux du pont depuis la poussière (poussières pour 1 Éclat)
|
||||
// et prix en poussière d'un Parchemin d'oubli (changer le plan de progression d'une carte).
|
||||
progression: { costFactor: 2, costOffset: 35, duplicateLevels: 1, fieldXpPct: 10, stardustPerEclat: 3, oblivionPrice: 150 },
|
||||
// Plans de progression : part maximale des points de niveau d'une carte dans une même stat (atteinte par les vocations).
|
||||
plans: { maxStatPct: 60 },
|
||||
// Équipements : emplacements au plus, Puissance qui ouvre le 2e et le 3e, points ajoutés quand une commune partage une étiquette avec sa carte.
|
||||
equipment: { maxPerCard: 3, secondSlotPower: 70, thirdSlotPower: 100, synergyBonus: 2 },
|
||||
// Synergies de score : Affinité avec la destination, Résonances (Écho, Lignée, Étoiles sœurs) et nombre de cartes d'un même thème.
|
||||
|
|
@ -101,6 +104,8 @@ export const EXPEDITION_SETTINGS_SCHEMA = Object.freeze([
|
|||
int("progression.duplicateLevels", 0, 12),
|
||||
int("progression.fieldXpPct", 0, 100),
|
||||
int("progression.stardustPerEclat", 1, 1000),
|
||||
int("progression.oblivionPrice", 1, 100000),
|
||||
int("plans.maxStatPct", 25, 100),
|
||||
int("equipment.maxPerCard", 0, 3),
|
||||
int("equipment.secondSlotPower", 1, 300),
|
||||
int("equipment.thirdSlotPower", 1, 300),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// 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
|
||||
cardExpeditionData, cardPower, evaluateTeam, EXPEDITION_RARITIES, expectedLoot, maxLevel, MAX_STARS, planStats, ROLE_BY_STAT, 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.
|
||||
|
|
@ -25,14 +25,18 @@ const atLevel = (card, level, settings) => {
|
|||
|
||||
const entryFor = (destination) => ({ condition: destination.conditions[0], dangers: destination.dangers.slice(0, 2) });
|
||||
|
||||
// Carte construite pour une place : ses points de niveau suivent la vocation du rôle de la place.
|
||||
const builtFor = (card, role, settings) => ({ ...card, stats: planStats(card.rarity, card.level, card.profile, { plan: ROLE_BY_STAT[role] }, settings) });
|
||||
|
||||
// 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) {
|
||||
// `built` : chaque carte a la vocation de sa place (une équipe construite pour la destination).
|
||||
export function bestPairScore(first, second, destination, stars, durationIndex, settings, built = false) {
|
||||
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] }]
|
||||
slots: [{ ...(built ? builtFor(a, roles[0], settings) : a), role: roles[0] }, { ...(built ? builtFor(b, roles[1], settings) : b), role: roles[1] }]
|
||||
}, settings);
|
||||
if (!best || result.scorePct > best.scorePct) best = result;
|
||||
}
|
||||
|
|
@ -71,12 +75,13 @@ export function simulate(catalog, destinations, settings) {
|
|||
|
||||
// 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]]) {
|
||||
// « niveau max, vocations » : les mêmes paires, chaque carte avec la vocation de sa place (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 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);
|
||||
for (const [a, b] of pairs) for (const destination of visible) scores.push(bestPairScore(a, b, 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 });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,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", "card_upgraded", "eclats_converted", "item_used", "destination_starter"
|
||||
"gift_created", "gift_joined", "gift_completed", "gift_cancelled", "daily_won", "expedition_completed", "expedition_cancelled_by_guild", "expedition_dissolved", "card_upgraded", "eclats_converted", "item_used", "destination_starter", "card_plan_changed", "oblivion_bought"
|
||||
]);
|
||||
const DEV_STARDUST = 1000;
|
||||
const DELETED_PLAYER_NAME = "Joueur supprimé";
|
||||
|
|
@ -502,7 +502,7 @@ export class CardsService {
|
|||
player: publicPlayer(player), recharge, collection, favorites,
|
||||
wallet: { stardust: player.stardust, purchasedOpenings: player.purchased_openings, eclats: player.eclats },
|
||||
// Le Pont des Veilleurs (poussière vers Éclats) est vendu en boutique, au taux réglé dans les Expéditions.
|
||||
shop: { stardustValues: shop.stardustValues, openingPrice: shop.openingPrice, shopPackPrice: shop.shopPackPrice, shopPackShare: shop.shopPackShare, dailyReward: shop.dailyReward, stardustPerEclat: this.expeditions.settings.progression.stardustPerEclat },
|
||||
shop: { stardustValues: shop.stardustValues, openingPrice: shop.openingPrice, shopPackPrice: shop.shopPackPrice, shopPackShare: shop.shopPackShare, dailyReward: shop.dailyReward, stardustPerEclat: this.expeditions.settings.progression.stardustPerEclat, oblivionPrice: this.expeditions.settings.progression.oblivionPrice },
|
||||
daily: this.dailySummary(playerId),
|
||||
expeditions: this.expeditions.summary(playerId),
|
||||
cardProgress: this.expeditions.cardProgressView(playerId),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue