From 1b12dc44c94ac57fb1702ab3d630e4521dc555c7 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Mon, 13 Mar 2023 09:00:49 +0100 Subject: [PATCH] Fiches de PNJ --- lang/fr.json | 3 +- modules/heritiers-actor-pnj-sheet.js | 26 ++ modules/heritiers-actor-sheet.js | 7 +- modules/heritiers-actor.js | 22 +- modules/heritiers-main.js | 3 +- modules/heritiers-utility.js | 6 + system.json | 4 +- template.json | 16 +- templates/actor-pnj-sheet.html | 470 +++++++++++++++++++++++++++ templates/actor-sheet.html | 13 +- templates/partial-utile-skills.html | 20 +- 11 files changed, 567 insertions(+), 23 deletions(-) create mode 100644 modules/heritiers-actor-pnj-sheet.js create mode 100644 templates/actor-pnj-sheet.html diff --git a/lang/fr.json b/lang/fr.json index 450963c..b8d740b 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -1,8 +1,7 @@ { "ACTOR": { "TypePersonnage": "Personnage", - "TypeCellule": "Cellule", - "TypeCreature": "Créature" + "TypePNJ": "PNJ" }, "ITEM": { diff --git a/modules/heritiers-actor-pnj-sheet.js b/modules/heritiers-actor-pnj-sheet.js new file mode 100644 index 0000000..1ab772b --- /dev/null +++ b/modules/heritiers-actor-pnj-sheet.js @@ -0,0 +1,26 @@ +/** + * Extend the basic ActorSheet with some very simple modifications + * @extends {ActorSheet} + */ + +import { HeritiersActorSheet } from "./heritiers-actor-sheet.js"; +import { HeritiersUtility } from "./heritiers-utility.js"; + +/* -------------------------------------------- */ +export class HeritiersActorPNJSheet extends HeritiersActorSheet { + + /** @override */ + static get defaultOptions() { + + return mergeObject(super.defaultOptions, { + classes: ["fvtt-les-heritiers", "sheet", "actor"], + template: "systems/fvtt-les-heritiers/templates/actor-pnj-sheet.html", + width: 780, + height: 840, + tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }], + dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], + editScore: false + }) + } + +} diff --git a/modules/heritiers-actor-sheet.js b/modules/heritiers-actor-sheet.js index 03582a1..a0d2d2e 100644 --- a/modules/heritiers-actor-sheet.js +++ b/modules/heritiers-actor-sheet.js @@ -64,7 +64,8 @@ export class HeritiersActorSheet extends ActorSheet { options: this.options, owner: this.document.isOwner, editScore: this.options.editScore, - isGM: game.user.isGM + isGM: game.user.isGM, + isPNJ: (this.actor.type == "pnj") } this.formData = formData; @@ -141,6 +142,10 @@ export class HeritiersActorSheet extends ActorSheet { const key = $(event.currentTarget).data("rang-key") this.actor.rollRang(key, false) }) + html.find('.roll-root-competence').click((event) => { + const compKey = $(event.currentTarget).data("attr-key") + this.actor.rollRootCompetence(compKey) + }) html.find('.roll-competence').click((event) => { const li = $(event.currentTarget).parents(".item") let compId = li.data("item-id") diff --git a/modules/heritiers-actor.js b/modules/heritiers-actor.js index e2d463e..d9b686c 100644 --- a/modules/heritiers-actor.js +++ b/modules/heritiers-actor.js @@ -46,11 +46,7 @@ export class HeritiersActor extends Actor { } } } - if (data.type == 'creature') { - const skills = await HeritiersUtility.loadCompendium("fvtt-les-heritiers.skills-creatures") - data.items = skills.map(i => i.toObject()) - data.items.push({ name: "Arme naturelle 1", type: 'arme', img: "systems/fvtt-les-heritiers/assets/icons/melee.webp", system: { typearme: "contact", bonusmaniementoff: 0, seuildefense: 0, degats: "0" } }) - data.items.push({ name: "Arme naturelle 2", type: 'arme', img: "systems/fvtt-les-heritiers/assets/icons/melee.webp", system: { typearme: "contact", bonusmaniementoff: 0, seuildefense: 0, degats: "0" } }) + if (data.type == 'pnj') { } return super.create(data, options); @@ -178,19 +174,19 @@ export class HeritiersActor extends Actor { let comp = {} for (let key in game.system.lesheritiers.config.competenceProfil) { if ( game.system.lesheritiers.config.competenceProfil[key].kind == kind) - comp[key] = [] + comp[key] = { skills: [], niveau: this.system.competences[key].niveau } } for (let item of this.items) { if (item.type == "competence") { if (item.system.categorie == "utile" && comp[item.system.profil]) { this.prepareUtileSkill(item) - comp[item.system.profil].push(item) + comp[item.system.profil].skills.push(item) } } } for (let key in comp) { - HeritiersUtility.sortArrayObjectsByName(comp[key]) + HeritiersUtility.sortArrayObjectsByName(comp[key].skills) } return Object.fromEntries(Object.entries(comp).sort()) } @@ -564,6 +560,16 @@ export class HeritiersActor extends Actor { let rollDialog = await HeritiersRollDialog.create(this, rollData) rollDialog.render(true) } + /* -------------------------------------------- */ + async rollRootCompetence(compKey) { + let rollData = this.getCommonRollData() + rollData.mode = "competence" + console.log("Compkey", compKey) + rollData.competence = {name: this.system.competences[compKey].label, system: { niveau: this.system.competences[compKey].niveau }} + console.log("RollDatra", rollData) + let rollDialog = await HeritiersRollDialog.create(this, rollData) + rollDialog.render(true) + } /* -------------------------------------------- */ async rollCompetence(compId) { diff --git a/modules/heritiers-main.js b/modules/heritiers-main.js index 3481d0a..58b9d24 100644 --- a/modules/heritiers-main.js +++ b/modules/heritiers-main.js @@ -11,6 +11,7 @@ import { HeritiersActor } from "./heritiers-actor.js"; import { HeritiersItemSheet } from "./heritiers-item-sheet.js"; import { HeritiersActorSheet } from "./heritiers-actor-sheet.js"; +import { HeritiersActorPNJSheet } from "./heritiers-actor-pnj-sheet.js"; import { HeritiersCreatureSheet } from "./heritiers-creature-sheet.js"; import { HeritiersUtility } from "./heritiers-utility.js"; import { HeritiersCombat } from "./heritiers-combat.js"; @@ -55,7 +56,7 @@ Hooks.once("init", async function () { // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); Actors.registerSheet("fvtt-les-heritiers", HeritiersActorSheet, { types: ["personnage"], makeDefault: true }) - Actors.registerSheet("fvtt-les-heritiers", HeritiersCreatureSheet, { types: ["creature"], makeDefault: true }) + Actors.registerSheet("fvtt-les-heritiers", HeritiersActorPNJSheet, { types: ["pnj"], makeDefault: true }) Items.unregisterSheet("core", ItemSheet); Items.registerSheet("fvtt-les-heritiers", HeritiersItemSheet, { makeDefault: true }) diff --git a/modules/heritiers-utility.js b/modules/heritiers-utility.js index 4cd5be5..d00feee 100644 --- a/modules/heritiers-utility.js +++ b/modules/heritiers-utility.js @@ -337,6 +337,12 @@ export class HeritiersUtility { static async rollHeritiers(rollData) { let actor = this.getActorFromRollData(rollData) + + if ( typeof(rollData.pvMalus) != "number" ) { + ui.notifications.warn("Votre personnage est Moribond(e). Aucun jet autorisé") + return + } + //rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp" rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey]) diff --git a/system.json b/system.json index 3bfc688..43995cc 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-les-heritiers", "description": "Les Héritiers pour FoundryVTT", - "version": "10.0.26", + "version": "10.0.29", "authors": [ { "name": "Uberwald/LeRatierBretonnien", @@ -19,7 +19,7 @@ "gridUnits": "m", "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.26.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.29.zip", "languages": [ { "lang": "fr", diff --git a/template.json b/template.json index 10dedcd..b42a651 100644 --- a/template.json +++ b/template.json @@ -2,7 +2,7 @@ "Actor": { "types": [ "personnage", - "creature" + "pnj" ], "templates": { "biodata": { @@ -145,31 +145,37 @@ "competences": { "aventurier": { "label": "Aventurier", + "niveau": 0, "rang": 0, "pp": 0 }, "combattant": { "label": "Aventurier", + "niveau": 0, "rang": 0, "pp": 0 }, "erudit": { "label": "Erudit", + "niveau": 0, "rang": 0, "pp": 0 }, "gentleman": { "label": "Gentleman", + "niveau": 0, "rang": 0, "pp": 0 }, "roublard": { "label": "Roublard", + "niveau": 0, "rang": 0, "pp": 0 }, "savant": { "label": "Savant", + "niveau": 0, "rang": 0, "pp": 0 } @@ -184,6 +190,8 @@ "demasquee": 0 }, "parade": { + "masquee": 0, + "demasquee": 0, "value": 0 }, "resistancephysique": { @@ -223,6 +231,12 @@ "biodata", "core" ] + }, + "pnj": { + "templates": [ + "biodata", + "core" + ] } }, "Item": { diff --git a/templates/actor-pnj-sheet.html b/templates/actor-pnj-sheet.html new file mode 100644 index 0000000..42a2fd0 --- /dev/null +++ b/templates/actor-pnj-sheet.html @@ -0,0 +1,470 @@ +
+ + {{!-- Sheet Header --}} +
+
+
+ +
+

+
+ +
+
    + {{#each system.caracteristiques as |carac key|}} + {{#if (eq kind "physical")}} +
  • +

    {{carac.label}}

    + + +
  • + {{/if}} + {{/each}} +
+
+ +
+
    + {{#each system.caracteristiques as |carac key|}} + {{#if (eq kind "mental")}} +
  • +

    {{carac.label}}

    + + +
  • + {{/if}} + {{/each}} +
+
+ +
+ +
+ + + + + +    + + + +
+ +
+
+
+ + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
+ + {{!-- Competence Tab --}} +
+ +
+ +
+ +
+ {{#each utileSkillsPhysical as |skillDef keyProfil|}} + {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillDef=skillDef keyProfil=keyProfil isPNJ=true}} + {{/each}} +
+ +
+ {{#each utileSkillsMental as |skillDef keyProfil|}} + {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillDef=skillDef keyProfil=keyProfil isPNJ=true}} + {{/each}} +
+ +
+ +
+
    +
  • + +

    +
    + + + +
     
    +
  • + {{#each futileSkills as |skill key|}} +
  • + {{skill.name}} + + + +
    + + +
    +
  • + {{/each}} +
+
+ +
+ +
+ + {{!-- Equipement Tab --}} +
+ +
    +
  • + +
  • +
  • + + + + + + + + + + +
  • +
  • + + + + + + +
  • +
  • + + + + +
  • +
  • + + + + + +
  • +
  • + + + + + +
  • +
+ +
+ +
+
    +
  • + +

    +
    + + + + + + +
     
    +
    + +
    +
  • + {{#each armes as |arme key|}} +
  • + + {{arme.name}} + + + + + + + {{arme.system.degats}} + + +
     
    + +
  • + {{/each}} +
+
+ +
+
    +
  • + +

    +
    + + + +
     
    +
    + +
    +
  • + {{#each protections as |protection key|}} +
  • + + {{protection.name}} + + +
     
    +
    + + +
    +
  • + {{/each}} +
+
+
+
+ + + {{!-- atouts Tab --}} +
+ +
+
  • + + {{fee.name}} +
     
    +
    + + +
    +
  • +
    + +
    + +
    + +
    + +
    +
      +
    • + +

      +
      +
       
      +
      +
      +
    • + {{#each avantages as |avantage key|}} +
    • + + {{avantage.name}} +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    + +
    +
      +
    • + +

      +
      +
       
      +
      +
      +
    • + {{#each desavantages as |desavantage key|}} +
    • + + {{desavantage.name}} +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    + +
    +
      +
    • + +

      +
      +
       
      +
      +
      +
    • + {{#each atouts as |atout key|}} +
    • + + {{atout.name}} +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    + +
    +
      +
    • + +

      +
      + + + + + + + + + +
       
      +
      +
      +
    • + {{#each pouvoirs as |pouvoir key|}} +
    • + + {{#if pouvoir.system.istest}} + {{pouvoir.name}} + {{else}} + {{pouvoir.name}} + {{/if}} + {{upperFirst pouvoir.system.masquetype}} + {{upperFirst pouvoir.system.pouvoirtype}} + {{upperFirst pouvoir.system.niveau}} + +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    + + +
    +
      +
    • + +

      +
      +
       
      +
      +
      +
    • + {{#each capacites as |capa key|}} +
    • + + {{capa.name}} +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    + +
    +
      +
    • + +

      +
      +
       
      +
      + +
      +
    • + {{#each equipements as |equip key|}} +
    • + + {{equip.name}} +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    + + +
    + +
    + + +
    + +

    Historique

    +
    +
    + {{editor description target="system.biodata.description" button=true owner=owner editable=editable}} +
    + +
    + +
    +
    \ No newline at end of file diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index eac5206..6034603 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -81,14 +81,14 @@
    - {{#each utileSkillsPhysical as |skillList keyProfil|}} - {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillList=skillList keyProfil=keyProfil}} + {{#each utileSkillsPhysical as |skillDef keyProfil|}} + {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillDef=skillDef keyProfil=keyProfil}} {{/each}}
    - {{#each utileSkillsMental as |skillList keyProfil|}} - {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillList=skillList keyProfil=keyProfil}} + {{#each utileSkillsMental as |skillDef keyProfil|}} + {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillDef=skillDef keyProfil=keyProfil}} {{/each}}
    @@ -144,7 +144,10 @@ - + + + +
  • diff --git a/templates/partial-utile-skills.html b/templates/partial-utile-skills.html index f850b7c..fa1f980 100644 --- a/templates/partial-utile-skills.html +++ b/templates/partial-utile-skills.html @@ -1,15 +1,29 @@
    • - -

      + {{#if isPNJ}} + + +

      +
      +
      + {{else}} + +

      + {{/if}} + + {{#if isPNJ}} + + + + {{/if}}
       
    • - {{#each skillList as |skill key|}} + {{#each skillDef.skills as |skill key|}}
    • {{skill.name}}