diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 2740fcfd..b8a44023 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -55,6 +55,7 @@ export class RdDActorSheet extends ActorSheet { list.push(item); } } + // Force empty arme, at least for Esquive if (data.itemsByType.arme == undefined ) data.itemsByType.arme = []; for (const arme of data.itemsByType.arme) { @@ -75,13 +76,19 @@ export class RdDActorSheet extends ActorSheet { } } - //endurance.max below is normal, this the base used to compute the grid. + data.data.carac.taille.isTaille = true; // To avoid button link; + data.data.nbLegeres = RdDUtility.computeNbBlessures(data.data.blessures, "legeres" ); + data.data.nbGraves = RdDUtility.computeNbBlessures(data.data.blessures, "graves" ); + data.data.nbCritiques = RdDUtility.computeNbBlessures(data.data.blessures, "critiques" ); + + // low is normal, this the base used to compute the grid. data.data.fatigueHTML = "" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "
"; data.data.materiel = this._checkNull(data.itemsByType['objet']); data.data.armes = this._checkNull(data.itemsByType['arme']); data.data.armures = this._checkNull(data.itemsByType['armure']); data.data.livres = this._checkNull(data.itemsByType['livre']); data.data.potions = this._checkNull(data.itemsByType['potions']); + data.data.herbes = this._checkNull(data.itemsByType['potions']); data.data.competenceByCategory = data.competenceByCategory; data.data.armes = data.itemsByType.arme; //console.log(">>>>> data update"); @@ -112,6 +119,12 @@ export class RdDActorSheet extends ActorSheet { li.slideUp(200, () => this.render(false)); }); + // Roll Carac + html.find('.carac-label a').click((event) => { + let caracName = event.currentTarget.attributes.name.value; + this.actor.rollCarac( caracName.toLowerCase() ); + }); + // Roll Skill html.find('.competence-label a').click((event) => { let compName = event.currentTarget.text; @@ -130,12 +143,18 @@ export class RdDActorSheet extends ActorSheet { //console.log("Value changed :", event, caracName); this.actor.updateCarac( caracName, parseInt(event.target.value) ); } ); + // On competence change $(".competence-value").change((event) => { let compName = event.currentTarget.attributes.compname.value; //console.log("Competence changed :", compName); this.actor.updateCompetence( compName, parseInt(event.target.value) ); } ); + // On competence change + $(".competence-xp").change((event) => { + let compName = event.currentTarget.attributes.compname.value; + this.actor.updateCompetenceXP( compName, parseInt(event.target.value) ); + } ); $("#vie-plus").click((event) => { this.actor.santeIncDec("vie", 1); diff --git a/module/actor.js b/module/actor.js index 1ce3fda7..34381641 100644 --- a/module/actor.js +++ b/module/actor.js @@ -154,7 +154,8 @@ export class RdDActor extends Actor { await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", undefined ); await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", rollData ); - let chatOptions = { content: "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "
Jet : " + + let lvl = (rollData.competence) ? rollData.competence.name : rollData.bmValue; + let chatOptions = { content: "Test : " + rollData.selectedCarac.label + " / " + lvl + "
Jet : " + rollData.selectedCarac.value + " / " + rollData.finalLevelStr + " - " + rollData.rollTarget.score + "%
Résutat : " + myroll.total + "
" + "" + quality + "" + specialStr + xpmsg, user: game.user._id, @@ -175,11 +176,8 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ updateCarac( caracName, caracValue ) { - //let data = this.data.data; let caracpath = "data.carac." + caracName + ".value" this.update( { caracpath: caracValue } ); - //data.carac[caracName].value = caracValue; // Force update ? - //RdDUtility.computeCarac( data ); } /* -------------------------------------------- */ @@ -187,11 +185,20 @@ export class RdDActor extends Actor { { let comp = RdDUtility.findCompetence( this.data.items, compName); if ( comp ) { - //console.log("ACTOR", this); - //comp.data.niveau = compValue; const update = {_id: comp._id, 'data.niveau': compValue }; const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity - //console.log("UP", updated); + } else { + console.log("Competence not found", compName); + } + } + + /* -------------------------------------------- */ + async updateCompetenceXP( compName, compValue ) + { + let comp = RdDUtility.findCompetence( this.data.items, compName); + if ( comp ) { + const update = {_id: comp._id, 'data.xp': compValue }; + const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity } else { console.log("Competence not found", compName); } @@ -298,7 +305,21 @@ export class RdDActor extends Actor { if ( blessuresData.legeres > 0 || blessuresData.graves > 0 || blessuresData.critiques > 0 ) this.update( { "data.blessures": blessures } ); } - + /* -------------------------------------------- */ + async rollCarac( caracName ) + { + let rollData = { + "selectedCarac": this.data.data.carac[caracName], + "bonusmalusTable": CONFIG.RDD.bonusmalus, + "etat": this.data.data.compteurs.etat.value, + "finalLevel": 0, + "bmValue": 0 + } + console.log(caracName, rollData); + let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData); + new RdDRollDialog("carac", html, rollData, this ).render(true); + } + /* -------------------------------------------- */ rollArme( armeName ) { diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index a3f346bf..bd4dd751 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -32,6 +32,10 @@ export class RdDRollDialog extends Dialog { dialogConf.title = "Test de combat/arme", dialogOptions.width = 600; dialogOptions.height = 360; + } else if (mode == "carac") { + dialogConf.title = "Test de caractéristique", + dialogOptions.width = 600; + dialogOptions.height = 320; } super(dialogConf, dialogOptions); @@ -54,13 +58,23 @@ export class RdDRollDialog extends Dialog { var rollData = this.rollData; function updateRollResult( rollData ) { - rollData.finalLevel = parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) + parseInt(rollData.etat); + if ( rollData.competence ) + rollData.finalLevel = parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) + parseInt(rollData.etat); + else + rollData.finalLevel = parseInt(rollData.bmValue) + parseInt(rollData.etat); + rollData.finalLevelStr = (rollData.finalLevel >= 0 ) ? "+" + rollData.finalLevel : rollData.finalLevel; $("#roll-param").text( rollData.selectedCarac.value + " / " + rollData.finalLevelStr ); rollData.rollTarget = game.data.RdDUtility.getResolutionField( rollData.selectedCarac.value, rollData.finalLevel); - let niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau; + let armeTitle = ( rollData.arme ) ? " ("+rollData.arme.name+") " : ""; // If a weapon is there, add it in the title - $("#compdialogTitle").text( rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveauStr ); + let niveauStr = ""; + if ( rollData.competence ) { + niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau; + $("#compdialogTitle").text( rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveauStr ); + } else { + $("#compdialogTitle").text( rollData.selectedCarac.label ); + } $(".table-resolution").remove(); game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11, rollData.selectedCarac.value, rollData.finalLevel ); @@ -68,10 +82,12 @@ export class RdDRollDialog extends Dialog { // Setup everything onload $(function() { - // Set the default carac from the competence item - rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac]; // Update html, according to data - $("#carac").val( rollData.competence.data.defaut_carac ); + if (rollData.competence) { + // Set the default carac from the competence item + rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac]; + $("#carac").val( rollData.competence.data.defaut_carac ); + } $("#bonusmalus").val( rollData.bmValue ); updateRollResult(rollData); }); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 16701b98..e6372df2 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -82,7 +82,8 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html', 'systems/foundryvtt-reve-de-dragon/templates/arme-competence.html', // Dialogs - 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html' + 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', + 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' ]; return loadTemplates(templatePaths); @@ -347,6 +348,18 @@ export class RdDUtility { return result; } + /* -------------------------------------------- */ + static computeNbBlessures( blessures, name) + { + let bless = blessures[name]; + console.log(blessures, name, bless); + let nbBlessures = 0; + for (let k=0; k
-
Blessures légères : {{data.blessures.legeres.nombre}}
-
Blessures graves : {{data.blessures.graves.nombre}}
-
Blessure critique : {{data.blessures.critiques.nombre}}
+
Blessures légères : {{data.nbLegeres}}
+
Blessures graves : {{data.nbGraves}}
+
Blessure critique : {{data.nbCritiques}}
@@ -47,9 +47,10 @@ Caractéristiques Compétences Combat + Blessures + Haut-Rêve + Equipement Description - Items - Attributes {{!-- Sheet Body --}} @@ -62,12 +63,16 @@
    {{#each data.carac as |carac key|}}
  1. - {{carac.label}} + {{#if carac.isTaille}} + {{carac.label}} + {{else}} + {{carac.label}} + {{/if}} {{#if carac.derivee}} {{else}} - - + + {{/if}}
  2. {{/each}} @@ -92,81 +97,101 @@ {{!-- Compétences Tab --}}
    -
    - Compétences de base - Niveau - XP -
    -
      - {{#each data.competenceByCategory.generale as |comp key|}} -
    1. - {{comp.name}} - - -
    2. - {{/each}} -
    +
    +
    +
    + Compétences de base +
    +
      + {{#each data.competenceByCategory.generale as |comp key|}} +
    1. + + {{comp.name}} + + +
      + + +
      +
    2. + {{/each}} +
    -
    - Compétences Particulières - Niveau - XP -
    -
      - {{#each data.competenceByCategory.particuliere as |comp key|}} -
    1. - {{comp.name}} - - -
    2. - {{/each}} -
    +
    + Compétences Particulières +
    +
      + {{#each data.competenceByCategory.particuliere as |comp key|}} +
    1. + + {{comp.name}} + + +
      + + +
      +
    2. + {{/each}} +
    +
    + +
    +
    + Compétences Spécialisées +
    +
      + {{#each data.competenceByCategory.specialisee as |comp key|}} +
    1. + + {{comp.name}} + + +
      + + +
      +
    2. + {{/each}} +
    -
    - Compétences Spécialisées - Niveau - XP -
    -
      - {{#each data.competenceByCategory.specialisee as |comp key|}} -
    1. - {{comp.name}} - - -
    2. - {{/each}} -
    - -
    - Connaissances - Niveau - XP -
    -
      - {{#each data.competenceByCategory.connaissance as |comp key|}} -
    1. - {{comp.name}} - - -
    2. - {{/each}} -
    - -
    - Draconic - Niveau - XP -
    -
      - {{#each data.competenceByCategory.draconic as |comp key|}} -
    1. - {{comp.name}} - - -
    2. - {{/each}} -
    +
    + Connaissances +
    +
      + {{#each data.competenceByCategory.connaissance as |comp key|}} +
    1. + + {{comp.name}} + + +
      + + +
      +
    2. + {{/each}} +
    +
    + Draconic +
    +
      + {{#each data.competenceByCategory.draconic as |comp key|}} +
    1. + + {{comp.name}} + + +
      + + +
      +
    2. + {{/each}} +
    +
    +
    {{!-- Combat Tab --}} @@ -178,7 +203,7 @@
      {{#each data.armes as |arme key|}} -
    1. +
    2. {{arme.name}} {{arme.data.competence}} {{numberFormat arme.data.niveau decimals=0 sign=true}} @@ -193,7 +218,7 @@
        {{#each data.competenceByCategory.tir as |comp key|}} -
      1. +
      2. {{comp.name}} @@ -207,7 +232,7 @@
          {{#each data.competenceByCategory.lancer as |comp key|}} -
        1. +
        2. {{comp.name}} @@ -215,13 +240,44 @@ {{/each}}
- - {{!-- Biography Tab --}} -
- {{editor content=data.biographie target="data.biographie" button=true owner=owner editable=editable}} + + {{!-- blessures Tab --}} +
+ Blessures Légeres : +
+ {{#each data.blessures.legeres.liste as |bless key|}} +
  • + + Premiers soins - + Soins complets - + Jours - + Loc. +
  • + {{/each}} +
    + Blessures Graves : +
    + {{#each data.blessures.graves.liste as |bless key|}} +
  • + Premiers soins : {{bless.premiers_soins}} - Soins complets : {{bless.soins_complets}} - Nombre de jours : {{bless.jours}} - Localisation : {{bless.localisation}} +
  • + {{/each}} +
    + Blessure Critique : +
    + {{#each data.blessures.critiques.liste as |bless key|}} +
  • + Premiers soins : {{bless.premiers_soins}} - Soins complets : {{bless.soins_complets}} - Nombre de jours : {{bless.jours}} - Localisation : {{bless.localisation}} +
  • + {{/each}} +
    - {{!-- Owned Items Tab --}} + {{!-- hautreve Tab --}} +
    +
    + + {{!-- Equipment Tab --}}
      {{#each actor.items as |item id|}} @@ -236,6 +292,12 @@ {{/each}}
    + + {{!-- Biography Tab --}} +
    + {{editor content=data.biographie target="data.biographie" button=true owner=owner editable=editable}} +
    +