Cap collection destinations in the daily expedition draw and always give a Watchers' starter destination
The daily draw now proposes at most day.maxCollectionDestinations (default 2) destinations linked to a collection, unless the player lacks other destinations to fill the day. The starter destination card is now granted to any player without a Watchers' Logbooks destination, even if they already own collection destination cards from packs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e3749d60b6
commit
3dcc0b6f12
9 changed files with 74 additions and 14 deletions
|
|
@ -396,6 +396,9 @@ export function bonusSlotLevel(slot, settings, dailyHighest) {
|
|||
}
|
||||
|
||||
// Tirage du jour d'un joueur : parmi les destinations visibles et proposées, limitées à `allowedIds` (ses destinations débloquées).
|
||||
// Au plus `day.maxCollectionDestinations` destinations liées à une collection (`rewardCollectionId`), pour qu'un joueur qui a surtout
|
||||
// des cartes de destination de paquets ne voie pas que celles-là. Plafond souple : le tirage préfère une destination récente à une
|
||||
// destination de collection de trop, et ne dépasse le plafond que s'il n'a pas d'autre moyen de remplir ses places.
|
||||
export function drawExpeditionDay(destinations, settings, recentIds, random, allowedIds = null) {
|
||||
const candidates = destinations
|
||||
.filter((destination) => !destination.hidden && (!allowedIds || allowedIds.has(destination.id)))
|
||||
|
|
@ -404,13 +407,22 @@ export function drawExpeditionDay(destinations, settings, recentIds, random, all
|
|||
const count = Math.min(settings.day.destinationsPerDay, candidates.length);
|
||||
const recent = new Set(recentIds);
|
||||
const fresh = candidates.filter((entry) => !recent.has(entry.destination.id));
|
||||
let pool = fresh.length >= count ? fresh : candidates;
|
||||
const picked = [];
|
||||
while (picked.length < count && pool.length) {
|
||||
const entry = weightedPick(pool, random);
|
||||
picked.push(entry.destination);
|
||||
pool = pool.filter((item) => item !== entry);
|
||||
const pool = fresh.length >= count ? fresh : candidates;
|
||||
const maxCollection = settings.day.maxCollectionDestinations ?? count;
|
||||
const linked = (entry) => entry.destination.rewardCollectionId != null;
|
||||
const chosen = [];
|
||||
for (const [source, capped] of [[pool, true], [candidates, true], [pool, false], [candidates, false]]) {
|
||||
let rest = source.filter((entry) => !chosen.includes(entry));
|
||||
while (chosen.length < count) {
|
||||
const full = capped && chosen.filter(linked).length >= maxCollection;
|
||||
const allowed = full ? rest.filter((entry) => !linked(entry)) : rest;
|
||||
if (!allowed.length) break;
|
||||
const entry = weightedPick(allowed, random);
|
||||
chosen.push(entry);
|
||||
rest = rest.filter((item) => item !== entry);
|
||||
}
|
||||
}
|
||||
const picked = chosen.map((entry) => entry.destination);
|
||||
// Un niveau de chaque, du plus facile au nombre de destinations tirées (2 destinations : niveaux 1 et 2), répartis au hasard ;
|
||||
// au-delà du nombre de niveaux, la suite recommence.
|
||||
const levels = Array.from({ length: Math.max(1, Math.min(levelCount(settings), picked.length)) }, (_, index) => index);
|
||||
|
|
|
|||
|
|
@ -294,14 +294,15 @@ export class ExpeditionService {
|
|||
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. La page la présente une fois (`starterCard`), jusqu'à `markStarterSeen`.
|
||||
// Carte de destination de départ : offerte une fois, au hasard parmi celles des Expéditions, à un joueur qui n'en a aucune des
|
||||
// Expéditions (celles des paquets de collection ne comptent pas : sans elle, son tirage du jour ne proposerait que des
|
||||
// destinations de collection). À appeler dans une transaction. La page la présente une fois (`starterCard`), jusqu'à `markStarterSeen`.
|
||||
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;
|
||||
if (editions.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 });
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ export const DEFAULT_EXPEDITION_SETTINGS = Object.freeze({
|
|||
enabled: false,
|
||||
// Alertes Discord (messages privés envoyés par le bot) : chaque joueur choisit encore lesquelles il reçoit.
|
||||
alerts: { enabled: true },
|
||||
day: { destinationsPerDay: 4, avoidRepeatDays: 1 },
|
||||
// Destinations du jour : nombre, jours pendant lesquels une destination tirée ne revient pas si possible, et destinations liées à une
|
||||
// collection au plus (plafond souple : dépassé seulement quand le joueur n'a pas assez d'autres destinations pour remplir son tirage).
|
||||
day: { destinationsPerDay: 4, avoidRepeatDays: 1, maxCollectionDestinations: 2 },
|
||||
durations: { hours: [2, 6, 12], malusPct: [0, 0, 15], endurancePerSlot: 12 },
|
||||
// Étoiles des destinations : celles du niveau le plus bas, puis une de plus par niveau, sans dépasser le maximum. Elles ne dépendent
|
||||
// pas du nombre de joueurs.
|
||||
|
|
@ -97,6 +99,7 @@ export const EXPEDITION_SETTINGS_SCHEMA = Object.freeze([
|
|||
{ path: "alerts.enabled", kind: "bool" },
|
||||
int("day.destinationsPerDay", 1, 8),
|
||||
int("day.avoidRepeatDays", 0, 7),
|
||||
int("day.maxCollectionDestinations", 0, 8),
|
||||
ints("durations.hours", 3, 1, 48),
|
||||
ints("durations.malusPct", 3, 0, 50),
|
||||
int("durations.endurancePerSlot", 1, 1000),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue