Offer the destination items under Sokko TCG's destinations of the day
- Each owned item that would add a destination today (guide star, sky chart, or enough treasure map fragments) gets a dashed frame under the destinations: what it does, the difficulty and the loot bonus of the added destination. A click uses the item, as in the bag. - Frames appear only while the item is owned in sufficient number and its slot is still free, and share the destinations' grid. - "1 destinations débloquées" becomes singular. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bffbe36cbe
commit
9d2c561fc6
10 changed files with 94 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// Rôle : objets des Expéditions Sokko TCG : inventaire, ancre (rappel), destinations bonus (étoile guide, carte céleste, carte au trésor),
|
||||
// Rose des vents (nouvelles destinations du jour) et gravure d'une étiquette sur un équipement. Ces méthodes s'ajoutent à ExpeditionService (Object.assign sur son prototype).
|
||||
import { dailyDayKey } from "./daily.js";
|
||||
import { bonusSlotLevel, drawExpeditionDay, ITEM_IDS } from "./expedition-rules.js";
|
||||
import { bonusLootPct, bonusSlotLevel, drawExpeditionDay, ITEM_IDS, starsForLevel } from "./expedition-rules.js";
|
||||
|
||||
function fail(status, code, message) {
|
||||
throw Object.assign(new Error(message), { status, code });
|
||||
|
|
@ -11,6 +11,17 @@ function fail(status, code, message) {
|
|||
const BONUS_ITEMS = Object.freeze({ guideStar: "5", skyChart: "6", fragment: "hidden" });
|
||||
|
||||
export const itemMethods = {
|
||||
// Destinations que chaque objet ajouterait aujourd'hui, pour les proposer sous les destinations du jour : l'objet, le nombre
|
||||
// d'exemplaires qu'il faut, si sa place est déjà prise, et les étoiles et le butin (en %) de la destination ajoutée.
|
||||
bonusOffers(entries, settings) {
|
||||
const dailyHighest = Math.max(0, ...entries.filter((entry) => !entry.bonusSlot).map((entry) => entry.level ?? 0));
|
||||
const used = new Set(entries.map((entry) => entry.bonusSlot).filter(Boolean).map(String));
|
||||
return Object.entries(BONUS_ITEMS).map(([item, slot]) => ({
|
||||
item, slot, used: used.has(slot), required: item === "fragment" ? settings.items.fragmentsForMap : 1,
|
||||
stars: starsForLevel(bonusSlotLevel(slot, settings, dailyHighest), settings), lootPct: bonusLootPct(slot, settings)
|
||||
}));
|
||||
},
|
||||
|
||||
itemsOf(playerId) {
|
||||
const items = Object.fromEntries(ITEM_IDS.map((id) => [id, 0]));
|
||||
for (const row of this.db.prepare("SELECT item_id, quantity FROM player_items WHERE player_id = ?").all(playerId)) items[row.item_id] = row.quantity;
|
||||
|
|
|
|||
|
|
@ -477,7 +477,10 @@ export class ExpeditionService {
|
|||
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 };
|
||||
return { ...base, day, unlocked, starterCard: this.starterCard(playerId), destinations: entries.map((entry) => this.destinationView(entry, settings)), cards: this.eligibleCards(playerId, settings) };
|
||||
return {
|
||||
...base, day, unlocked, starterCard: this.starterCard(playerId), destinations: entries.map((entry) => this.destinationView(entry, settings)),
|
||||
bonusOffers: this.bonusOffers(entries, settings), cards: this.eligibleCards(playerId, settings)
|
||||
};
|
||||
}
|
||||
|
||||
claim(playerId, expeditionId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue