Release Creation / build (release) Failing after 1m32s
- VermineTotemDice : influence Humain/Adapté (+1D/-1D par domaine, règles p. 121), gains/pertes via Instincts/Interdits avec limites (3D/totem, 5D total) et règles d'échange. - roll.mjs applique l'influence selon le Totem dominant (au lieu de l'ancienne logique basée sur identity.totem). - Dialogue TotemDiceDialog (instinct Humain/autre totem, interdit Humain, acte grave ±2D) + bouton et ligne d'influence sur la fiche personnage. - Dés de Totem gagnés en cas d'échec à l'apprentissage Dé d'Évolution (dés dépensés, garde capacité vide). - Couleur de texte @color-text-light-2 assombrie (#c9e0c0 → #3f9b55) pour la lisibilité dans tous les dialogues. fix: robustesse et visibilité des évolutions - buyEvolutionDialog : n'efface les Dés d'Évolution que si l'item est créé. - Flag mutation éditable sur la fiche item evolution + badge Adaptation/Mutation dans la liste du personnage. - loseDie : applique aussi la limite totale de 5 dés au gain Adapté. - Case "acte grave" conservée entre les rendus du dialogue.
116 lines
3.4 KiB
JavaScript
116 lines
3.4 KiB
JavaScript
import { VermineExperience } from "../experience.mjs";
|
|
|
|
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
|
|
|
/**
|
|
* Dialogue d'achat d'une Adaptation/Mutation avec les Dés d'Évolution
|
|
* accumulés. Vérifie le coût (niveau 1-4), la limite du Mode de jeu et les
|
|
* restrictions sur les Mutations ; en cas de succès, crée l'item et efface
|
|
* les Dés d'Évolution accumulés.
|
|
*/
|
|
export default class BuyEvolutionDialog extends HandlebarsApplicationMixin(foundry.applications.api.ApplicationV2) {
|
|
|
|
#actor;
|
|
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ["vermine-roll", "buy-evolution"],
|
|
tag: "form",
|
|
window: {
|
|
icon: "fas fa-cart-shopping",
|
|
resizable: false
|
|
},
|
|
position: {
|
|
width: 480,
|
|
height: 460
|
|
},
|
|
actions: {
|
|
buy: BuyEvolutionDialog.#onBuy,
|
|
cancel: BuyEvolutionDialog.#onCancel
|
|
}
|
|
};
|
|
|
|
static PARTS = {
|
|
main: { template: "systems/vermine2047/templates/dialogs/buy-evolution-dialog.hbs", scrollable: [""] }
|
|
};
|
|
|
|
static async create({ actorId }) {
|
|
const actor = await game.actors.get(actorId);
|
|
if (!actor) {
|
|
ui.notifications.warn(game.i18n.localize("VERMINE.error_no_actor_selected"));
|
|
return null;
|
|
}
|
|
return new BuyEvolutionDialog({ actor });
|
|
}
|
|
|
|
constructor(options = {}) {
|
|
super(options);
|
|
this.#actor = options.actor;
|
|
}
|
|
|
|
get title() {
|
|
return game.i18n.localize("VERMINE.buy_evolution");
|
|
}
|
|
|
|
async _prepareContext() {
|
|
const actor = this.#actor;
|
|
const mode = VermineExperience.gameMode();
|
|
const modeLabels = {
|
|
1: game.i18n.localize("VERMINE.mode_survie"),
|
|
2: game.i18n.localize("VERMINE.mode_cauchemar"),
|
|
3: game.i18n.localize("VERMINE.mode_apocalypse")
|
|
};
|
|
const levels = [];
|
|
for (let value = 1; value <= 4; value++) {
|
|
levels.push({ value, cost: value });
|
|
}
|
|
return {
|
|
evolutionDice: actor.system?.experience?.evolution || 0,
|
|
defaultName: game.i18n.localize("ITEMS.new_evolution"),
|
|
levels,
|
|
totalLevels: VermineExperience.evolutionTotalLevels(actor),
|
|
modeMax: VermineExperience.evolutionMaxForMode(mode),
|
|
modeLabel: modeLabels[mode] || ""
|
|
};
|
|
}
|
|
|
|
static async #onCancel(event, target) {
|
|
this.close();
|
|
}
|
|
|
|
static async #onBuy(event, target) {
|
|
const actor = this.#actor;
|
|
const name = this.element.querySelector("#evolution-name")?.value?.trim() || "";
|
|
const cost = parseInt(this.element.querySelector("#evolution-level")?.value, 10) || 0;
|
|
const mutation = this.element.querySelector("#evolution-mutation")?.checked || false;
|
|
|
|
if (!name) {
|
|
ui.notifications.warn(game.i18n.localize("VERMINE.error_evolution_no_name"));
|
|
return;
|
|
}
|
|
|
|
const error = VermineExperience.validateEvolutionPurchase(actor, cost, mutation);
|
|
if (error) {
|
|
ui.notifications.warn(game.i18n.localize(error));
|
|
return;
|
|
}
|
|
|
|
const created = await actor.createEmbeddedDocuments("Item", [{
|
|
name,
|
|
type: "evolution",
|
|
system: {
|
|
level: { value: cost },
|
|
mutation
|
|
}
|
|
}]);
|
|
// N'efface les Dés d'Évolution que si l'item a bien été créé.
|
|
if (!created || created.length === 0) {
|
|
ui.notifications.warn(game.i18n.localize("VERMINE.error_evolution_create"));
|
|
return;
|
|
}
|
|
await actor.update({ "system.experience.evolution": 0 });
|
|
|
|
ui.notifications.info(game.i18n.localize("VERMINE.buy_evolution_done"));
|
|
this.close();
|
|
}
|
|
}
|