diff --git a/module/actor-sheet.js b/module/actor-sheet.js index ef20bd34..eb2c0bdd 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -304,6 +304,11 @@ export class RdDActorSheet extends ActorSheet { let musiqueId = li.data('item-id'); this.actor.rollMusique(musiqueId); }); + html.find('.oeuvre-label a').click((event) => { + const li = $(event.currentTarget).parents(".item"); + let oeuvreId = li.data('item-id'); + this.actor.rollOeuvre(oeuvreId); + }); html.find('.jeu-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); let jeuId = li.data('item-id'); diff --git a/module/actor.js b/module/actor.js index 80a3dfbd..34bf85ac 100644 --- a/module/actor.js +++ b/module/actor.js @@ -278,6 +278,9 @@ export class RdDActor extends Actor { getMusique(id) { return this.data.items.find(item => item.type == 'musique' && item._id == id); } + getOeuvre(id, type = 'oeuvre') { + return this.data.items.find(item => item.type == type && item._id == id); + } getJeu(id) { return this.data.items.find(item => item.type == 'jeu' && item._id == id); } @@ -2041,20 +2044,21 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async _rollArt(artData, selectedCarac, competence, oeuvre) { + async _rollArt(artData, selectedCarac, oeuvre, callBackResult = r =>this._resultArt(r)) { mergeObject(artData, { oeuvre: oeuvre, - competence: duplicate(competence), - diffLibre: -oeuvre.data.niveau, + art: oeuvre.type, + competence: duplicate(this.getCompetence(oeuvre.data.competence ?? artData.art)), + diffLibre: - (oeuvre.data.niveau ??0), diffConditions: 0, - use: { libre: false, conditions: true, }, + use: { libre: false, conditions: true }, selectedCarac: duplicate(this.data.data.carac[selectedCarac]), forceCarac: {} }); artData.competence.data.defaut_carac = selectedCarac; artData.forceCarac[selectedCarac] = duplicate(this.data.data.carac[selectedCarac]); - console.log("rollArtiste !!!", artData); + console.log("rollArt !!!", artData); const dialog = await RdDRoll.create(this, artData, { html: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${artData.art}.html` }, { name: `jet-${artData.art}`, @@ -2077,85 +2081,66 @@ export class RdDActor extends Actor { RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); } + /* -------------------------------------------- */ + async rollChant(id) { + const artData = { art: 'chant', verbe: 'Chanter' }; + const oeuvre = duplicate(this.getChant(id)); + await this._rollArt(artData, "ouie", oeuvre); + } /* -------------------------------------------- */ async rollDanse(id) { - const oeuvre = duplicate(this.getDanse(id)); - const competence = this.getCompetence("danse"); - const selectedCarac = this._getCaracDanse(oeuvre, competence); const artData = { art: 'danse', verbe: 'Danser' }; - await this._rollArt(artData, selectedCarac, competence, oeuvre); + const oeuvre = duplicate(this.getOeuvre(id, artData.art)); + const selectedCarac = this._getCaracDanse(oeuvre,); + await this._rollArt(artData, selectedCarac, oeuvre); } - _getCaracDanse(oeuvre, competence) { + _getCaracDanse(oeuvre) { if (oeuvre.data.agilite) { return "agilite"; } else if (oeuvre.data.apparence) { return "apparence"; } + const competence = this.getCompetence(oeuvre.data.competence); return competence.data.defaut_carac; } /* -------------------------------------------- */ async rollMusique(id) { - const oeuvre = duplicate(this.getMusique(id)); - const competence = this.getCompetence("musique"); - const selectedCarac = "ouie"; const artData = { art: 'musique', verbe: 'Jouer' }; - await this._rollArt(artData, selectedCarac, competence, oeuvre); + const oeuvre = duplicate(this.getOeuvre(id, artData.art)); + await this._rollArt(artData, "ouie", oeuvre); } /* -------------------------------------------- */ async rollRecetteCuisine(id) { - const oeuvre = duplicate(this.getRecetteCuisine(id)); - const competence = this.getCompetence("cuisine"); - const selectedCarac = 'odoratgout'; const artData = { art: 'cuisine', verbe: 'Cuisiner' }; - await this._rollArt(artData, selectedCarac, competence, oeuvre); + const oeuvre = duplicate(this.getRecetteCuisine(id)); + await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r) ); } - + + /* -------------------------------------------- */ + async _resultRecetteCuisine(artData) { + const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.data.niveau : artData.competence.data.niveau); + artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.data.niveau) + artData.rolled.ptQualite; + artData.exotismeFinal = Math.min(Math.min(artData.qualiteFinale, -Math.abs(artData.oeuvre.data.exotisme??0)), 0); + console.log("OEUVRE", artData.art, artData) + RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); + } + /* -------------------------------------------- */ async rollJeu(id) { - const oeuvre = duplicate(this.getJeu(id)); - const competence = this.getCompetence("jeu"); - const selectedCarac = competence.data.defaut_carac; const artData = { art: 'jeu', verbe: 'Jeu', use: { libre: true, conditions: true, }, }; - await this._rollArt(artData, selectedCarac, competence, oeuvre); + const oeuvre = duplicate(this.getJeu(id)); + await this._rollArt(artData, oeuvre.data?.caraccomp.toLowerCase() ?? 'chance', oeuvre); } - - /* -------------------------------------------- */ - async rollJeu( id ) { - let jeu = duplicate(this.getJeu(id)); - let competence = duplicate(this.getCompetence("jeu")); - let jeuData = { - competence: competence, - jeu: jeu, - diffLibre: 0, - diffConditions: 0, - use: { libre: true, conditions: true, }, - carac: {} - }; - - console.log("rollJeu !!!", jeuData); + async rollOeuvre(id) { + const artData = { art: 'oeuvre', verbe: 'Interpréter' }; + const oeuvre = duplicate(this.getOeuvre(id)); + await this._rollArt(artData, oeuvre.data.default_carac, oeuvre); + } - const dialog = await RdDRoll.create(this, jeuData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-jeu.html' }, { - name: 'jet-jeu', - label: 'Jeu ' + jeu.name, - height: 600, - callbacks: [ - this.createCallbackExperience(), - { action: r => this._jeuResult(r) } - ] - }); - dialog.render(true); - } - /* -------------------------------------------- */ - async _jeuResult(jeudData) { - console.log("JEU", jeudData) - RdDResolutionTable.displayRollData(jeudData, this.name, 'chat-resultat-jeu.html'); - } - - /* -------------------------------------------- */ async rollMeditation(id) { let meditation = duplicate(this.getMeditation(id)); diff --git a/module/item-sheet.js b/module/item-sheet.js index 5c2dc75c..54931c78 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -49,7 +49,7 @@ export class RdDItemSheet extends ItemSheet { async getData() { let data = super.getData(); data.categorieCompetences = RdDUtility.getCategorieCompetences(); - if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation') { + if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation' || data.item.type == 'oeuvre') { data.caracList = duplicate(game.system.model.Actor.personnage.carac); data.competences = await RdDUtility.loadCompendiumNames( 'foundryvtt-reve-de-dragon.competences' ); } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 7a05c7a3..9d892c9f 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -7,6 +7,7 @@ import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js"; import { RdDItemCompetenceCreature } from "./item-competencecreature.js"; import { RdDItemArme } from "./item-arme.js"; import { RdDItemCompetence } from "./item-competence.js"; +import { Misc } from "./misc.js"; /* -------------------------------------------- */ const categorieCompetences = { @@ -128,18 +129,6 @@ const fatigueMarche = { "tresdifficile": { "4": 4, "6": 6 } } -/* -------------------------------------------- */ -/* Static tables for commands /table */ -const table2func = { - "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open }, - "queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue }, - "ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre }, - "tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR }, - "tete": { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete }, - "souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle }, - "tarot": { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot } -}; - /* -------------------------------------------- */ const definitionsBlessures = [ { type: "legere", facteur: 2 }, @@ -264,6 +253,14 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html' ]; + Handlebars.registerHelper('upperFirst', function (str) { + return Misc.upperFirst(str ?? 'null') + }) + + Handlebars.registerHelper('upper', function (str) { + return str?.toUpperCase() ?? 'NULL' + }) + return loadTemplates(templatePaths); } @@ -319,6 +316,7 @@ export class RdDUtility { data.data.chants = this.checkNull(data.itemsByType['chant']); data.data.danses = this.checkNull(data.itemsByType['danse']); data.data.musiques = this.checkNull(data.itemsByType['musique']); + data.data.oeuvres = this.checkNull(data.itemsByType['oeuvre']); data.data.jeux = this.checkNull(data.itemsByType['jeu']); data.data.recettescuisine = this.checkNull(data.itemsByType['recettecuisine']); data.data.recettesAlchimiques = this.checkNull(data.itemsByType['recettealchimique']); diff --git a/styles/simple.css b/styles/simple.css index dbfe89da..56e0bbc8 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -675,6 +675,7 @@ ul, li { .subacteur-label, .chant-label, .musique-label, +.oeuvre-label, .chant-label, .danse-label, .recette-label, diff --git a/system.json b/system.json index 51b740bd..9cf8a6e1 100644 --- a/system.json +++ b/system.json @@ -6,7 +6,7 @@ "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", - "templateVersion": 90, + "templateVersion": 91, "author": "LeRatierBretonnien", "authors": [ { diff --git a/template.json b/template.json index 79ce365f..8c42ea59 100644 --- a/template.json +++ b/template.json @@ -563,7 +563,7 @@ "Item": { "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique", - "musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison" ], + "musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre" ], "objet": { "description": "", "quantite": 1, @@ -775,6 +775,7 @@ }, "musique": { "niveau": "", + "reference": "", "description": "" }, "danse": { @@ -782,16 +783,19 @@ "agilite": false, "apparence": false, "niveau": "", + "reference": "", "description": "" }, "chant": { "niveau": "", + "reference": "", "description": "" }, "jeu": { "type": "", "base": "", "caraccomp": "", + "reference": "", "description": "" }, "recettecuisine": { @@ -799,6 +803,15 @@ "ingredients": "", "duree": "", "sust": 0, + "exotisme": 0, + "reference": "", + "description": "" + }, + "oeuvre": { + "default_carac": "", + "competence": "", + "niveau": 0, + "reference": "", "description": "" }, "maladie": { @@ -815,7 +828,6 @@ "dommages":"", "description": "" } - } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 2e8873d4..fddb959a 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -650,32 +650,42 @@ {{!-- Connaissances Tab --}}
{{oeuvre.data.reference}}
+ {{/if}} + +{{else if oeuvre.data.reference}} +{{oeuvre.data.reference}}
+ +{{/if}} + diff --git a/templates/chat-resultat-cuisine.html b/templates/chat-resultat-cuisine.html deleted file mode 100644 index 9a184f50..00000000 --- a/templates/chat-resultat-cuisine.html +++ /dev/null @@ -1,13 +0,0 @@ - -{{oeuvre.data.reference}}
+ {{/if}} + +{{else if oeuvre.data.reference}} +{{oeuvre.data.reference}}
+ +{{/if}} + diff --git a/templates/chat-resultat-jeu.html b/templates/chat-resultat-jeu.html index d1af862c..c8e1736c 100644 --- a/templates/chat-resultat-jeu.html +++ b/templates/chat-resultat-jeu.html @@ -1,4 +1,4 @@ - +{{oeuvre.data.reference}}
+ {{/if}} + +{{else if oeuvre.data.reference}} +{{oeuvre.data.reference}}
+ +{{/if}} + diff --git a/templates/chat-resultat-musique.html b/templates/chat-resultat-musique.html index f39253e0..ffea62b6 100644 --- a/templates/chat-resultat-musique.html +++ b/templates/chat-resultat-musique.html @@ -1,4 +1,4 @@ - +{{oeuvre.data.reference}}
+ {{/if}} + +{{else if oeuvre.data.reference}} +{{oeuvre.data.reference}}
+ +{{/if}} + diff --git a/templates/chat-resultat-oeuvre.html b/templates/chat-resultat-oeuvre.html new file mode 100644 index 00000000..84141952 --- /dev/null +++ b/templates/chat-resultat-oeuvre.html @@ -0,0 +1,29 @@ +{{oeuvre.data.reference}}
+ {{/if}} + +{{else if oeuvre.data.reference}} +{{oeuvre.data.reference}}
+ +{{/if}} + diff --git a/templates/chat-resultat-recettecuisine.html b/templates/chat-resultat-recettecuisine.html new file mode 100644 index 00000000..fa75d72d --- /dev/null +++ b/templates/chat-resultat-recettecuisine.html @@ -0,0 +1,34 @@ + +{{oeuvre.data.reference}}
+ {{/if}} + +{{else if oeuvre.data.reference}} +{{oeuvre.data.reference}}
+ +{{/if}} + diff --git a/templates/dialog-roll-jeu.html b/templates/dialog-roll-jeu.html index 0d062344..0ccf3b77 100644 --- a/templates/dialog-roll-jeu.html +++ b/templates/dialog-roll-jeu.html @@ -1,23 +1,21 @@