Give destination cards on the first visit, in expedition loot and to group members

A player with no destination card receives one from the Carnets on their first visit to open expeditions. Expedition loot can hold a Carnets destination card the player does not own yet, and a group member without the card of the group's destination has a strong chance to get it. Both chances are expedition settings, and destination cards never drop as ordinary Carnets cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-16 16:03:52 +01:00
parent 06a4ab6d6a
commit 39dbeb9e2b
11 changed files with 115 additions and 13 deletions

View file

@ -203,7 +203,7 @@ export const groupMethods = {
const multiplierPct = groupLootPct(members.length, settings);
const expected = expectedLoot({ hours: setup.hours, stars: setup.stars, tier: evaluation.tier, fortune: evaluation.stats.fortune, slotCount: setup.roles.length, multiplierPct, bonusSlot: setup.bonusSlot ?? null, powers, group: true }, settings);
const updateReward = this.db.prepare("UPDATE expedition_members SET reward_json = ? WHERE expedition_id = ? AND player_id = ?");
for (const member of members) updateReward.run(JSON.stringify(this.rollReward(expected, settings, { orientationPerSlot: evaluation.stats.orientation / setup.roles.length, powers, destination })), row.id, member.playerId);
for (const member of members) updateReward.run(JSON.stringify(this.rollReward(expected, settings, { orientationPerSlot: evaluation.stats.orientation / setup.roles.length, powers, destination, playerId: member.playerId, group: true })), row.id, member.playerId);
const result = this.resultView(evaluation, { players: members.length, cohesionPct: cohesion, lootPct: multiplierPct, powers }, synergy);
const travel = Math.round(travelHours(setup.hours, powers, settings) * HOUR_MS);
this.db.prepare("UPDATE expeditions SET status = 'running', departs_at = ?, returns_at = ?, duration_ms = ?, result_json = ? WHERE id = ?")

View file

@ -204,7 +204,9 @@ export class ExpeditionService {
// Butin tiré au départ : arrondi au hasard, collection de chaque paquet, objets (la partie cachée demande de l'Orientation),
// cartes des Carnets de la destination, puis ce qu'ajoutent les pouvoirs (Carte au trésor, Filet à étoiles filantes).
rollReward(expected, settings, { orientationPerSlot = 0, powers = [], destination = null } = {}) {
// Cartes de destination : avec `playerId`, une chance d'en rapporter une qu'il n'a pas, et, dans un groupe (`group`), une forte
// chance d'obtenir celle de la destination s'il ne l'a pas.
rollReward(expected, settings, { orientationPerSlot = 0, powers = [], destination = null, playerId = null, group = false } = {}) {
const random = (max) => this.random(max);
const loot = rollLoot(expected, settings, random);
const packs = [];
@ -222,15 +224,52 @@ export class ExpeditionService {
for (let index = roundStochastic(expected.cards, random); index > 0 && fromDestination.length; index -= 1) cards.push(this.pickLogbookEdition(fromDestination, random));
const anyLogbook = this.logbookEditions();
if (powers.includes("starNet") && anyLogbook.length && random(100) < settings.powers.starNetCardPct) cards.push(this.pickLogbookEdition(anyLogbook, random));
if (playerId) cards.push(...this.rollDestinationCards(playerId, destination, settings, { group, random }));
return { eclats: loot.eclats, stardust: loot.stardust, packs, items, cards };
}
// Éditions des cartes de destination illustrées ; avec `expeditionOnly`, seulement celles des collections des Expéditions.
destinationCardEditions({ expeditionOnly = false } = {}) {
const expeditionCollections = new Set(this.cards.catalog.collections.filter((collection) => collection.packCategory === "expedition").map((collection) => collection.id));
return this.cards.catalog.editions.filter((edition) => {
const card = this.cards.index.cards.get(edition.cardId);
return card?.kind === "destination" && card.image && !edition.promotional && (!expeditionOnly || expeditionCollections.has(card.collectionId));
});
}
ownedCardIds(playerId) {
return new Set(this.db.prepare("SELECT edition_id FROM collection_cards WHERE player_id = ?").all(playerId).map((row) => this.cards.index.editions.get(row.edition_id)?.cardId));
}
rollDestinationCards(playerId, destination, settings, { group, random }) {
const owned = this.ownedCardIds(playerId);
const cards = [];
const joined = group && this.destinationCardEditions().find((edition) => this.cards.index.cards.get(edition.cardId).destinationId === destination?.id);
if (joined && !owned.has(joined.cardId) && random(100) < settings.destinationCards.groupJoinPct) cards.push(joined.id);
const missing = this.destinationCardEditions({ expeditionOnly: true }).filter((edition) => !owned.has(edition.cardId) && !cards.includes(edition.id));
if (missing.length && random(100) < settings.destinationCards.dropPct) cards.push(missing[random(missing.length)].id);
return cards;
}
// Carte de destination de départ : offerte une fois, au hasard parmi celles des Expéditions, à un joueur qui n'en a aucune.
// À appeler dans une transaction.
grantStarterDestination(playerId) {
const editions = this.destinationCardEditions({ expeditionOnly: true });
if (!editions.length) return;
if (this.db.prepare("SELECT 1 FROM audit_log WHERE player_id = ? AND event_type = 'destination_starter' LIMIT 1").get(playerId)) return;
const owned = this.ownedCardIds(playerId);
if (this.destinationCardEditions().some((edition) => owned.has(edition.cardId))) return;
const edition = editions[this.random(editions.length)];
this.cards.addCard(playerId, edition.id);
this.cards.audit(playerId, "destination_starter", edition.cardId, { editionId: edition.id });
}
// Éditions standard des cartes des Carnets (rare ou mieux) déjà illustrées ; sans `cardIds`, toutes celles des collections des Expéditions.
logbookEditions(cardIds = null) {
const expeditionCollections = new Set(this.cards.catalog.collections.filter((collection) => collection.packCategory === "expedition").map((collection) => collection.id));
return this.cards.catalog.editions.filter((edition) => {
const card = this.cards.index.cards.get(edition.cardId);
return card?.image && !edition.promotional && edition.rarity !== "mythic" && edition.rarity !== "common" && expeditionCollections.has(card.collectionId) && (!cardIds || cardIds.includes(card.id));
return card?.image && card.kind !== "destination" && !edition.promotional && edition.rarity !== "mythic" && edition.rarity !== "common" && expeditionCollections.has(card.collectionId) && (!cardIds || cardIds.includes(card.id));
});
}
@ -324,7 +363,7 @@ export class ExpeditionService {
if (busy) fail(409, "EXPEDITION_CARD_BUSY", "Cette carte est déjà en expédition.");
if (this.activeCount(playerId, "solo") >= settings.solo.maxConcurrent) fail(409, "EXPEDITION_LIMIT", "Récupérez d’abord le butin de votre expédition en cours.");
const now = this.now();
const reward = this.rollReward(plan.expected, settings, { orientationPerSlot: plan.evaluation.stats.orientation / plan.slots.length, powers: plan.powers, destination: plan.resolved.destination });
const reward = this.rollReward(plan.expected, settings, { orientationPerSlot: plan.evaluation.stats.orientation / plan.slots.length, powers: plan.powers, destination: plan.resolved.destination, playerId });
const travel = travelHours(plan.hours, plan.powers, settings);
const { destination } = plan.resolved;
const setup = {
@ -409,6 +448,7 @@ export class ExpeditionService {
};
// Fermées : le joueur peut encore récupérer le butin de ses expéditions, mais aucune destination n'est tirée.
if (!settings.enabled) return { ...base, day: dailyDayKey(now), destinations: [], cards: [] };
this.cards.database.transaction(() => this.grantStarterDestination(playerId));
const { day, entries } = this.today(settings, playerId);
// Progression : destinations débloquées par les cartes de destination, sur toutes les destinations visibles.
const unlocked = { count: this.unlockedDestinationIds(playerId).size, total: this.destinations.filter((destination) => !destination.hidden).length };

View file

@ -28,6 +28,9 @@ export const DEFAULT_EXPEDITION_SETTINGS = Object.freeze({
stormLanternDangerPct: 50, stormLanternExtraHours: 1, fogBellSynergyPct: 10, fogBellSoloLootPct: 20 },
// Cartes des Carnets des Veilleurs rapportées d'expédition (chance par heure, multipliée comme le butin) et au plus par expédition.
carnets: { cardPerHourPermille: 20, maxCards: 1 },
// Cartes de destination : chance d'en rapporter une que le joueur n'a pas (Carnets des Veilleurs), et chance d'obtenir la carte
// de la destination d'un groupe rejoint sans l'avoir. Une carte de destination de départ est offerte une fois.
destinationCards: { dropPct: 10, groupJoinPct: 60 },
items: {
chancePerHourPermille: 50, maxPerExpedition: 2, orientationPerSlot: 15, fragmentsForMap: 4, hiddenLootPct: 150,
weights: { fragment: 30, engraving: 10, plan: 10, anchor: 15, guideStar: 20, skyChart: 5 }
@ -113,6 +116,8 @@ export const EXPEDITION_SETTINGS_SCHEMA = Object.freeze([
int("powers.fogBellSoloLootPct", 0, 90),
int("carnets.cardPerHourPermille", 0, 1000),
int("carnets.maxCards", 0, 3),
int("destinationCards.dropPct", 0, 100),
int("destinationCards.groupJoinPct", 0, 100),
int("items.chancePerHourPermille", 0, 1000),
int("items.maxPerExpedition", 0, 5),
int("items.orientationPerSlot", 0, 1000),

View file

@ -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"
"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"
]);
const DEV_STARDUST = 1000;
const DELETED_PLAYER_NAME = "Joueur supprimé";