From ea3322e8435e77cffc35dfc7bf852ead7bc0dcf0 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Tue, 4 Aug 2026 17:20:37 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20fiche=20v=C3=A9hicule=20(caract=C3=A9ri?= =?UTF-8?q?stiques)=20et=20capacit=C3=A9s=20de=20totem=20de=20groupe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - véhicule : fiabilité 1-10, type véhicule/monture, distance, vitesse (croisière/pointe), entretien, réserve d'effort - nettoyage du tableau d'entretien à la soumission - fiche de groupe : section capacités de totem (création type totem + liste) --- module/applications/sheets/group-sheet.mjs | 11 +++- module/applications/sheets/item-sheets.mjs | 22 +++++++ module/models/vehicle.mjs | 25 +++++++- templates/actor/appv2/group-info.hbs | 28 ++++++++- templates/item/item-vehicle-sheet.hbs | 71 +++++++++++++++++----- 5 files changed, 138 insertions(+), 19 deletions(-) diff --git a/module/applications/sheets/group-sheet.mjs b/module/applications/sheets/group-sheet.mjs index f5b1438..f9a0b20 100644 --- a/module/applications/sheets/group-sheet.mjs +++ b/module/applications/sheets/group-sheet.mjs @@ -11,7 +11,8 @@ export default class VermineGroupSheetV2 extends VermineBaseActorSheet { deleteMember: VermineGroupSheetV2.#onDeleteMember, deleteEncounter: VermineGroupSheetV2.#onDeleteEncounter, deleteObjective: VermineGroupSheetV2.#onDeleteObjective, - addObjective: VermineGroupSheetV2.#onAddObjective + addObjective: VermineGroupSheetV2.#onAddObjective, + createTotemAbility: VermineGroupSheetV2.#onCreateTotemAbility } } @@ -67,7 +68,8 @@ export default class VermineGroupSheetV2 extends VermineBaseActorSheet { case "main": break case "info": context.tab = context.tabs.info - context.abilities = doc.itemTypes.ability + context.abilities = doc.itemTypes.ability.filter(i => i.system.type !== "totem") + context.totem_abilities = doc.itemTypes.ability.filter(i => i.system.type === "totem") context.specialties = doc.itemTypes.specialty context.backgrounds = doc.itemTypes.background context.traumas = doc.itemTypes.trauma @@ -135,4 +137,9 @@ export default class VermineGroupSheetV2 extends VermineBaseActorSheet { objectives[type].push("") this.document.update({ "system.objectives": objectives }) } + + static async #onCreateTotemAbility(event, target) { + const name = game.i18n.localize("ITEMS.new_ability") + await this.document.createEmbeddedDocuments("Item", [{ name, type: "ability", system: { type: "totem" } }]) + } } diff --git a/module/applications/sheets/item-sheets.mjs b/module/applications/sheets/item-sheets.mjs index cf35e16..951ab61 100644 --- a/module/applications/sheets/item-sheets.mjs +++ b/module/applications/sheets/item-sheets.mjs @@ -22,6 +22,28 @@ export class VermineDefenseSheetV2 extends VermineBaseItemSheet { export class VermineVehicleSheetV2 extends VermineBaseItemSheet { static DEFAULT_OPTIONS = { classes: ["vehicle"], position: { width: 520 } } static PARTS = { main: { template: "systems/vermine2047/templates/item/item-vehicle-sheet.hbs", scrollable: [""] } } + + async _prepareContext() { + const context = await super._prepareContext() + // Compétences d'Entretien possibles (mécanique, technologie, artisanat, animalisme…) + const maintenanceKeys = ["mecanical", "technology", "crafting", "animalism", "environment", "wildlife", "flora", "repulsion", "toxics"] + const current = this.document.system.maintenance || [] + context.maintenanceSkills = maintenanceKeys.map(key => ({ + key, + label: game.i18n.localize("SKILLS." + key + ".name"), + checked: current.includes(key) + })) + return context + } + + /** @override - nettoie le tableau d'Entretien (retire les cases non cochées). */ + _prepareSubmitData(event, form, formData, updateData) { + const result = super._prepareSubmitData(event, form, formData, updateData) + if (Array.isArray(result?.system?.maintenance)) { + result.system.maintenance = result.system.maintenance.filter(v => typeof v === "string" && v.trim() !== "") + } + return result + } } // ── Capacité ────────────────────────────────────────────────────────── diff --git a/module/models/vehicle.mjs b/module/models/vehicle.mjs index 58bc219..78ae47f 100644 --- a/module/models/vehicle.mjs +++ b/module/models/vehicle.mjs @@ -1,7 +1,9 @@ import { baseItemSchema } from "./_shared.mjs" /** - * DataModel pour les items de type "vehicle" (véhicules). + * DataModel pour les items de type "vehicle" (véhicules et montures). + * Caractéristiques : Rareté, Fiabilité, Distance, Vitesse (croisière/pointe), + * Entretien (compétences) et Réserve d'Effort (montures). * @augments {foundry.abstract.TypeDataModel} */ export default class VermineVehicleData extends foundry.abstract.TypeDataModel { @@ -14,6 +16,27 @@ export default class VermineVehicleData extends foundry.abstract.TypeDataModel { const reqInt = { required: true, nullable: false, integer: true } return { ...baseItemSchema(), + // Fiabilité étendue (1-10) pour les véhicules + reliability: new fields.NumberField({ ...reqInt, initial: 5, min: 1, max: 10 }), + // Type : "vehicle" (véhicule) ou "mount" (monture) + kind: new fields.StringField({ required: true, nullable: false, initial: "vehicle" }), + // Distance : km parcourus avec un "plein" + distance: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }), + // Vitesse : croisière / pointe (durée de la pointe) + speed: new fields.SchemaField({ + cruise: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }), + top: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }), + topDuration: new fields.StringField({ required: true, nullable: false, initial: "10 min" }) + }), + // Entretien : compétences nécessaires (clés de CONFIG.VERMINE.skills) + maintenance: new fields.ArrayField(new fields.StringField({ required: true, nullable: false, initial: "" })), + // Réserve d'Effort (montures) + effortReserve: new fields.SchemaField({ + value: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }), + min: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }), + max: new fields.NumberField({ ...reqInt, initial: 0, min: 0 }) + }), + // Mobilité (héritée) mobility: new fields.NumberField({ ...reqInt, initial: 3, min: 0 }) } } diff --git a/templates/actor/appv2/group-info.hbs b/templates/actor/appv2/group-info.hbs index 1aa504e..5a3329c 100644 --- a/templates/actor/appv2/group-info.hbs +++ b/templates/actor/appv2/group-info.hbs @@ -44,7 +44,7 @@
    {{#each abilities as |item id|}} - {{#if (ne item.type 'totem')}} + {{#if (ne item.system.type 'totem')}}
  1. {{item.name}} @@ -60,6 +60,32 @@
+ {{!-- Group Totem Abilities --}} +
+

+ {{ localize 'VERMINE.totem_abilities' }} + {{#if isEditMode}} + + {{/if}} +

+
    + {{#each totem_abilities as |item id|}} +
  1. +
    + {{item.name}} + {{item.system.level.value}} + {{item.system.learn.threshold}}/{{item.system.learn.hindrance}} +
    +
    + {{#if @root.isEditMode}} + + {{/if}} +
    +
  2. + {{/each}} +
+
+ {{!-- Specialties --}}

diff --git a/templates/item/item-vehicle-sheet.hbs b/templates/item/item-vehicle-sheet.hbs index 97e639b..e28fa38 100644 --- a/templates/item/item-vehicle-sheet.hbs +++ b/templates/item/item-vehicle-sheet.hbs @@ -1,23 +1,64 @@
-{{> "systems/vermine2047/templates/item/partials/header.hbs"}} + {{> "systems/vermine2047/templates/item/partials/header.hbs"}} +
+ {{> "systems/vermine2047/templates/item/partials/traits.hbs"}} -
- {{> "systems/vermine2047/templates/item/partials/traits.hbs"}} +
+

{{ localize "VERMINE.vehicle_specs" }}

+
+
+ + +
+
+ +
+ km +
+
+ +
+ + / + +
+ +
+
-
-
- -
- -
-
+
+
+ +
+
+ / +
+
+
+
+ +
+
+
+
+ +
+ {{#each maintenanceSkills}} + + {{/each}} +
+
+
-
- {{> "systems/vermine2047/templates/item/partials/physicalItems.hbs"}} - - - + {{> "systems/vermine2047/templates/item/partials/physicalItems.hbs"}} +