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
|
|
@ -5,6 +5,8 @@ import { planRecycling, spareQuantity, validateShopSetting } from "./stardust.js
|
|||
import { FULL_ART_FORMAT, buildPublishedCatalog, createCatalogIndex, holographicFinishIds, legendaryParentEdition, MATCH_HOLO_PALETTE_ID, mythicEditionId, publicCatalog, validateRarityWeights } from "./catalog.js";
|
||||
import { computeStreak, DAILY_REPEAT_WINDOW_DAYS, dailyDayKey, dailyZoom, drawDailyPuzzle, guessHint, isDayKey, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "./daily.js";
|
||||
import { calculateRecharge, pinnedRecharge, drawPack, drawShopPack, MAX_RECHARGE_INTERVAL_MS, MIN_RECHARGE_INTERVAL_MS, spendOpening } from "./game-rules.js";
|
||||
import { DEFAULT_DESTINATIONS_PATH, loadExpeditionDestinations } from "./expedition-content.js";
|
||||
import { ExpeditionService } from "./expedition-service.js";
|
||||
|
||||
const TRANSFER_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
const SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
||||
|
|
@ -35,7 +37,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"
|
||||
"gift_created", "gift_joined", "gift_completed", "gift_cancelled", "daily_won", "expedition_completed", "expedition_cancelled_by_guild"
|
||||
]);
|
||||
const DEV_STARDUST = 1000;
|
||||
const DELETED_PLAYER_NAME = "Joueur supprimé";
|
||||
|
|
@ -45,7 +47,8 @@ const INACTIVE_ACCOUNT_MS = 730 * DAY_MS;
|
|||
const IDEMPOTENCY_TTL_MS = 30 * DAY_MS;
|
||||
|
||||
export class CardsService {
|
||||
constructor({ database, catalog, now = Date.now, random, devPerks = false } = {}) {
|
||||
// `destinations` : destinations des Expéditions validées ; sans elles, celles du dépôt (services/cards/content).
|
||||
constructor({ database, catalog, now = Date.now, random, devPerks = false, destinations = null } = {}) {
|
||||
// Serveur Vite local uniquement : ressources permanentes du compte de développement pour tester le jeu sans attendre.
|
||||
this.devPerks = devPerks;
|
||||
this.database = database;
|
||||
|
|
@ -55,6 +58,7 @@ export class CardsService {
|
|||
this.now = now;
|
||||
this.random = random;
|
||||
this.reloadCatalog();
|
||||
this.expeditions = new ExpeditionService(this, destinations || loadExpeditionDestinations(DEFAULT_DESTINATIONS_PATH, catalog));
|
||||
}
|
||||
|
||||
get rechargeSetting() {
|
||||
|
|
@ -452,17 +456,23 @@ export class CardsService {
|
|||
const history = this.db.prepare("SELECT event_type, entity_id, details_json, created_at FROM audit_log WHERE player_id = ? AND event_type IN (" + PLAYER_HISTORY_EVENTS.map(() => "?").join(", ") + ") ORDER BY created_at DESC LIMIT 100").all(playerId, ...PLAYER_HISTORY_EVENTS)
|
||||
.map((row) => ({ type: row.event_type, entityId: row.entity_id, details: JSON.parse(row.details_json), createdAt: row.created_at }));
|
||||
const transferRows = this.db.prepare("SELECT * FROM transfers WHERE initiator_id = ? OR recipient_id = ? ORDER BY created_at DESC LIMIT 50").all(playerId, playerId);
|
||||
const giftPacks = this.db.prepare(`SELECT g.id, g.collection_id, g.options_json, g.created_at, c.name AS campaign_name
|
||||
FROM gift_packs g JOIN campaigns c ON c.id = g.campaign_id WHERE g.player_id = ? AND g.opening_id IS NULL ORDER BY g.created_at`).all(playerId)
|
||||
.map((row) => ({ id: row.id, collectionId: row.collection_id, campaignName: row.campaign_name, receivedAt: row.created_at, options: JSON.parse(row.options_json) }));
|
||||
// Un paquet offert vient d'une campagne (son nom) ou d'une expédition (le nom de sa destination).
|
||||
const giftPacks = this.db.prepare(`SELECT g.id, g.source, g.collection_id, g.options_json, g.created_at, c.name AS campaign_name, e.setup_json
|
||||
FROM gift_packs g LEFT JOIN campaigns c ON c.id = g.campaign_id LEFT JOIN expeditions e ON e.id = g.expedition_id
|
||||
WHERE g.player_id = ? AND g.opening_id IS NULL ORDER BY g.created_at`).all(playerId)
|
||||
.map((row) => ({
|
||||
id: row.id, source: row.source, collectionId: row.collection_id, receivedAt: row.created_at, options: JSON.parse(row.options_json),
|
||||
campaignName: row.campaign_name ?? null, sourceName: row.source === "expedition" ? JSON.parse(row.setup_json).destination.name : row.campaign_name
|
||||
}));
|
||||
const openingsCount = this.db.prepare("SELECT COUNT(*) AS count FROM openings WHERE player_id = ?").get(playerId).count;
|
||||
const shop = this.shopSetting;
|
||||
const recycling = this.recyclingPlan(owned);
|
||||
return {
|
||||
player: publicPlayer(player), recharge, collection, favorites,
|
||||
wallet: { stardust: player.stardust, purchasedOpenings: player.purchased_openings },
|
||||
wallet: { stardust: player.stardust, purchasedOpenings: player.purchased_openings, eclats: player.eclats },
|
||||
shop: { stardustValues: shop.stardustValues, openingPrice: shop.openingPrice, shopPackPrice: shop.shopPackPrice, shopPackShare: shop.shopPackShare, dailyReward: shop.dailyReward },
|
||||
daily: this.dailySummary(playerId),
|
||||
expeditions: this.expeditions.summary(playerId),
|
||||
recycling: { count: recycling.count, stardust: recycling.stardust },
|
||||
pendingOpening: pending ? this.openingById(pending.id, playerId) : null,
|
||||
rarestPull: this.rarestPull(playerId), stats: { openingsCount },
|
||||
|
|
@ -534,6 +544,8 @@ export class CardsService {
|
|||
rechargeSetting: this.rechargeSetting,
|
||||
shopSetting: this.shopSetting,
|
||||
daily: this.dailyAdminSummary(),
|
||||
expeditionSettings: this.expeditions.adminSettings(),
|
||||
expeditionsToday: this.expeditions.adminSummary(),
|
||||
campaigns: this.campaignSummaries(),
|
||||
editionCampaigns: this.editionCampaignCounts(),
|
||||
// Variations possédées ou citées par une ouverture ou un transfert passés : elles ne peuvent qu'être retirées.
|
||||
|
|
@ -655,7 +667,7 @@ export class CardsService {
|
|||
const editionIds = drawPack(this.catalog, gift.collection_id, this.random, { weights: options.rarityWeights, guarantee: options.guarantee, requireActive: false });
|
||||
const openingId = this.insertOpening(playerId, gift.collection_id, editionIds);
|
||||
this.db.prepare("UPDATE gift_packs SET opening_id = ?, opened_at = ? WHERE id = ?").run(openingId, this.now(), gift.id);
|
||||
this.audit(playerId, "gift_pack_opened", openingId, { collectionId: gift.collection_id, campaignId: gift.campaign_id, cards: editionIds });
|
||||
this.audit(playerId, "gift_pack_opened", openingId, { collectionId: gift.collection_id, campaignId: gift.campaign_id, ...(gift.expedition_id ? { expeditionId: gift.expedition_id } : {}), cards: editionIds });
|
||||
return openingId;
|
||||
});
|
||||
}
|
||||
|
|
@ -860,9 +872,10 @@ export class CardsService {
|
|||
: { sent: transfer.offered_edition_id, received: transfer.requested_edition_id });
|
||||
}
|
||||
this.db.prepare("UPDATE openings SET status = 'completed', completed_at = ? WHERE player_id = ? AND status = 'pending'").run(this.now(), playerId);
|
||||
this.expeditions.forgetPlayer(playerId);
|
||||
for (const table of ["sessions", "collection_cards", "favorites", "idempotency", "daily_attempts"]) this.db.prepare(`DELETE FROM ${table} WHERE player_id = ?`).run(playerId);
|
||||
this.db.prepare("DELETE FROM gift_packs WHERE player_id = ? AND opening_id IS NULL").run(playerId);
|
||||
this.db.prepare(`UPDATE players SET discord_id = ?, display_name = ?, avatar_url = '', is_admin = 0, openings_balance = 0, recharge_anchor = NULL, stardust = 0, purchased_openings = 0, deleted_at = ? WHERE id = ?`)
|
||||
this.db.prepare(`UPDATE players SET discord_id = ?, display_name = ?, avatar_url = '', is_admin = 0, openings_balance = 0, recharge_anchor = NULL, stardust = 0, purchased_openings = 0, eclats = 0, deleted_at = ? WHERE id = ?`)
|
||||
.run(`deleted:${randomUUID()}`, DELETED_PLAYER_NAME, this.now(), playerId);
|
||||
this.audit(playerId, "account_deleted", playerId, auditDetails);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue