diff --git a/RdD.geany b/RdD.geany index 3e22e4ea..6617fa6a 100644 --- a/RdD.geany +++ b/RdD.geany @@ -27,18 +27,18 @@ long_line_behaviour=1 long_line_column=72 [files] -current_page=10 -FILE_NAME_0=8019;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 -FILE_NAME_1=2995;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 -FILE_NAME_2=9441;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 -FILE_NAME_3=6869;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 -FILE_NAME_4=6424;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2 -FILE_NAME_5=4430;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 -FILE_NAME_6=1134;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Factors%2Factor-skills.html;0;2 -FILE_NAME_7=7542;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Factor%2Fsheet%2Fcharacter-sheet.js;0;2 -FILE_NAME_8=705;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2 -FILE_NAME_9=985;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fsimple.js;0;2 -FILE_NAME_10=795;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-arme-sheet.html;0;2 +current_page=7 +FILE_NAME_0=4085;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 +FILE_NAME_1=3814;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 +FILE_NAME_2=10112;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 +FILE_NAME_3=1756;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-roll-dialog.js;0;2 +FILE_NAME_4=4053;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 +FILE_NAME_5=1134;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Factors%2Factor-skills.html;0;2 +FILE_NAME_6=0;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2 +FILE_NAME_7=16055;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 +FILE_NAME_8=543;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-main.js;0;2 +FILE_NAME_9=365;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fsystem.json;0;2 +FILE_NAME_10=309;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fhook-renderChatLog.js;0;2 [VTE] last_dir=/home/sigmar diff --git a/module/actor-sheet.js b/module/actor-sheet.js index d4216936..45f5254e 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -42,10 +42,11 @@ export class RdDActorSheet extends ActorSheet { } list.push(item); } + // Competence per category data.competenceByCategory = {}; if (data.itemsByType.competence) { for (const item of data.itemsByType.competence) { - console.log("Push...", item, item.data.categorie); + //console.log("Push...", item, item.data.categorie); let list = data.competenceByCategory[item.data.categorie]; if (!list) { list = []; @@ -55,6 +56,17 @@ export class RdDActorSheet extends ActorSheet { } } + // Update arme list with niveau from the associated competence + if (data.itemsByType.arme) { + for (const arme of data.itemsByType.arme) { + arme.data.niveau = 0; // Per default, TODO to be fixed + for ( const melee of data.competenceByCategory.melee ) { + if (melee.name == arme.data.competence ) + arme.data.niveau = melee.data.niveau + } + } + } + //endurance.max below 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']); @@ -63,7 +75,7 @@ export class RdDActorSheet extends ActorSheet { data.data.livres = this._checkNull(data.itemsByType['livre']); data.data.potions = this._checkNull(data.itemsByType['potions']); data.data.competenceByCategory = data.competenceByCategory; - + data.data.armes = data.itemsByType.arme; //console.log(">>>>> data update"); return data; @@ -97,48 +109,48 @@ export class RdDActorSheet extends ActorSheet { let compName = event.currentTarget.text; this.actor.rollCompetence( compName); }); + + // Roll Weapon + html.find('.arme-label a').click((event) => { + let armeName = event.currentTarget.text; + this.actor.rollArme( armeName); + }); // On carac change $(".carac-value").change((event) => { let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", ""); - console.log("Value changed :", event, caracName); + //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); + //console.log("Competence changed :", compName); this.actor.updateCompetence( compName, parseInt(event.target.value) ); } ); $("#vie-plus").click((event) => { this.actor.santeIncDec("vie", 1); - this.actor.update({"data.sante.vie.value": this.actor.data.data.sante.vie.value}); this.render(true); }); $("#vie-moins").click((event) => { this.actor.santeIncDec("vie", -1); - this.actor.update({"data.sante.vie.value": this.actor.data.data.sante.vie.value}); this.render(true); }); $("#endurance-plus").click((event) => { this.actor.santeIncDec("endurance", 1); - this.actor.update({"data.sante.endurance.value": this.actor.data.data.sante.endurance.value}); this.render(true); }); $("#endurance-moins").click((event) => { this.actor.santeIncDec("endurance", -1); - this.actor.update({"data.sante.endurance.value": this.actor.data.data.sante.endurance.value}); this.render(true); }); $("#fatigue-plus").click((event) => { this.actor.santeIncDec("fatigue", 1); - this.actor.update({"data.sante.fatigue.value": this.actor.data.data.sante.fatigue.value}); this.render(true); }); $("#fatigue-moins").click((event) => { this.actor.santeIncDec("fatigue", -1); - this.actor.update({"data.sante.fatigue.value": this.actor.data.data.sante.fatigue.value}); this.render(true); }); } diff --git a/module/actor.js b/module/actor.js index 830953be..b039507e 100644 --- a/module/actor.js +++ b/module/actor.js @@ -25,6 +25,9 @@ export class RdDActor extends Actor { return super.create(data, options); } super.create(data, options); + + // Create flags data + await this.setFlag("foundryvtt-reve-de-dragon", "rollData", {} ); } /* -------------------------------------------- */ @@ -48,10 +51,12 @@ export class RdDActor extends Actor { _prepareCharacterData(actorData) { // Initialize empty items RdDUtility.computeCarac(actorData.data); + this.computeEtatGeneral(); } /* -------------------------------------------- */ - performRoll( rollData ) { + async performRoll( rollData ) { + let myroll = new Roll("d100"); myroll.roll(); let quality = "Echec"; @@ -66,38 +71,73 @@ export class RdDActor extends Actor { let xpcomp = (Math.abs(rollData.finalLevel) % 2 == 1) ? xpcarac+1 : xpcarac; xpmsg = "
Points d'expérience gagné ! " + xpcarac + " - " + xpcomp; } - tache = 4; + rollData.pointsDeTache = 4; } else if (result <= (rollData.rollTarget.score /2) ) { quality = "Réussite Significative"; - tache = 2; + rollData.pointsDeTache = 2; } else if (result <= (rollData.rollTarget.score) ) { quality = "Réussite Normale"; - tache = 1; + rollData.pointsDeTache = 1; } else if (result < (rollData.rollTarget.epart) ) { quality = "Echec Normal"; - tache = 0; + rollData.pointsDeTache = 0; } else if (result < (rollData.rollTarget.etotal) ) { quality = "Echec Particulier"; - tache = -2; + rollData.pointsDeTache = -2; } else if (result >= (rollData.rollTarget.etotal) ) { quality = "Echec Total"; - tache = -4; + rollData.pointsDeTache = -4; } - let chatOptions = { "content": "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "
Jet : " + + // Weapon management + let defenseMsg; + let specialStr = "
Points de taches : " + rollData.pointsDeTache; // Per default + if ( rollData.arme ) { // In case of fight, replace the "tache" per dommages + localization. "tache" indicates if result is OK or not + if ( rollData.pointsDeTache > 0 ) { + let myroll = new Roll("2d10"); + myroll.roll(); + rollData.degats = parseInt(myroll.result) + parseInt(rollData.arme.data.dommages) + parseInt(this.data.data.attributs.plusdom.value); + rollData.loc = RdDUtility.getLocalisation(); + for (let target of game.user.targets) { + console.log("Target", target); + specialStr = "
Cible : " + target.actor.data.name; + defenseMsg = { title: "Défense en combat", + content: "Action de défense en combat!
Encaisser !", + whisper: ChatMessage.getWhisperRecipients(target.actor.data.name) }; + } + specialStr += "
Dommages : " + rollData.degats + "
Localisation : " + rollData.loc.label; + } else { + specialStr = "
Echec ! Pas de dommages"; + } + } + + // Save it for fight + await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", undefined ); + await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", rollData ); + console.log("MINE:", this); + + let chatOptions = { content: "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "
Jet : " + rollData.selectedCarac.value + " / " + rollData.finalLevelStr + " - " + rollData.rollTarget.score + "%
Résutat : " + myroll.total + "
" + - "" + quality + "
Points de taches : " + tache + xpmsg, - "title": "Test" + "" + quality + "" + specialStr + xpmsg, + user: game.user._id, + title: "Résultat du test" } ChatMessage.create( chatOptions ); + + if ( defenseMsg ) { // target hit ! + ChatMessage.create( defenseMsg ); + } } /* -------------------------------------------- */ updateCarac( caracName, caracValue ) { - let data = this.data.data; - data.carac[caracName].value = caracValue; // Force update ? - RdDUtility.computeCarac( data ); + //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 ); } /* -------------------------------------------- */ @@ -126,24 +166,27 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - testSiSonne( endurance ) + testSiSonne( sante, endurance ) { let myroll = new Roll("d20"); myroll.roll(); let result = myroll.total; if ( result <= endurance.value) - this.data.data.sante.sonne.value = false; + sante.sonne.value = false; if ( result > endurance.value || result == 20) // 20 is always a failure - this.data.data.sante.sonne.value = true; + sante.sonne.value = true; if (result == 1) { - this.data.data.sante.sonne.value = false; - this.data.data.carac.constitution.xp++; // 1 XP on 1 ! + sante.sonne.value = false; + let xp = parseInt(this.data.data.carac.constitution.xp) + parseInt(1); + this.update( {"data.carac.constitution.xp": xp } ); // +1 XP ! + // TODO : Output to chat } } /* -------------------------------------------- */ - santeIncDec(name, inc ) { - let data = this.data.data.sante[name]; + async santeIncDec(name, inc ) { + const sante = duplicate(this.data.data.sante); + let data = sante[name]; let lastValue = data.value; // Useful for Endurance and Sonné data.value = data.value + inc; if ( data.value > data.max ) data.value = data.max; @@ -151,13 +194,13 @@ export class RdDActor extends Actor { if (name == "endurance") { if ( inc < 0 ) // Each endurance lost -> fatigue lost - this.data.data.sante.fatigue.value = this.data.data.sante.fatigue.value - inc + sante.fatigue.value = sante.fatigue.value - inc // If endurance is 0 -> -1 vie if ( data.value == 0 ) { - this.data.data.sante.vie.value = this.data.data.sante.vie.value - 1; + sante.vie.value = sante.vie.value - 1; } - let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value; + let diffVie = sante.vie.max - sante.vie.value; if ( data.value > data.max - (diffVie*2) ) { data.value = data.max - (diffVie*2); } @@ -167,20 +210,53 @@ export class RdDActor extends Actor { if (data.value > maxEnd ) data.value = maxEnd; if ( blessures.critiques.nombre > 0 && data.value > 1) data.value = 1; - if (lastValue - data.value > 1) this.testSiSonne(data); // Peut-être sonné si 2 points d'endurance perdus d'un coup + if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup } - let diffEndurance = this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; - if ( this.data.data.sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered - this.data.data.sante.fatigue.value = diffEndurance; - - console.log(">>>> NEW VI", name, data.value); - this.computeEtatGeneral(); + let diffEndurance = sante.endurance.max - this.data.data.sante.endurance.value; + if ( sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered + sante.fatigue.value = diffEndurance; + + await this.update( {"data.sante": sante } ); } /* -------------------------------------------- */ - rollArme( armeName ) { - let armeItem = RdDUtility.findCompetence( this.data.items, armeName); + manageBlessures( blessuresData ) + { + let blessures = duplicate(this.data.data.blessures); + if (blessuresData.legeres > 0 ) { + blessures.legeres.nombre += 1; + if ( blessures.legeres.nombre > 5 ) { + blessures.legeres.nombre = 5; + blessuresData.graves += 1; + } else { + blessures.legeres.liste[blessures.legeres.nombre-1].etat = "active"; + blessures.legeres.liste[blessures.legeres.nombre-1].loc = blessuresData.locName; + } + } + if ( blessuresData.graves > 0 ) { + blessures.graves.nombre += 1; + if ( blessures.graves.nombre > 2 ) { + blessures.graves.nombre = 2; + blessuresData.critiques += 1; + } else { + blessures.graves.liste[blessures.graves.nombre-1].etat = "active"; + blessures.graves.liste[blessures.graves.nombre-1].loc = blessuresData.locName; + } + } + if ( blessuresData.critiques > 0 ) { + blessuresData.endurance = this.data.data.sante.endurance.value; // Patch with real endurance current value (ie end -> 0 when critique) + blessures.critiques.nombre = 1; + blessures.critiques.liste[0].etat = "active"; + blessures.critiques.liste[0].loc = blessuresData.locName; + } + if ( blessuresData.legeres > 0 || blessuresData.graves > 0 || blessuresData.critiques > 0 ) + this.update( { "data.blessures": blessures } ); + } + + /* -------------------------------------------- */ + rollArme( armeName ) { + let armeItem = RdDUtility.findCompetence( this.data.items, armeName ); this.rollCompetence( armeItem.data.competence, armeItem ); } @@ -197,11 +273,44 @@ export class RdDActor extends Actor { "bmValue": 0, "finalLevel": 0 } - - let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData); - new RdDRollDialog("competence", html, rollData, this ).render(true); - } + let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData); + if (armeItem) { + new RdDRollDialog("arme", html, rollData, this ).render(true); + } else { + new RdDRollDialog("competence", html, rollData, this ).render(true); + } + } + + /* -------------------------------------------- */ + computeArmure( locData ) + { + /* TODO */ + return 0; + } + + /* -------------------------------------------- */ + encaisserDommages( attackerActor ) + { + let attackerRoll = attackerActor.getFlag("foundryvtt-reve-de-dragon", "rollData"); + console.log("RollData!", attackerActor, attackerRoll); + let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc); + let result = RdDUtility.computeBlessuresSante(degatsReel); + this.santeIncDec("vie", result.vie); + this.santeIncDec("endurance", result.vie); + + result.locName = attackerRoll.loc.label; // Add the localisation namme + this.manageBlessures( result ); // Will upate the result table + ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " + + "
" + result.legeres + " légères, " + result.graves + " graves et " + + result.critiques + " critique." + + "
Et perdu : " + + "
" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } ); + + this.computeEtatGeneral(); + this.sheet.render(true); + } + /* -------------------------------------------- */ /** @override */ getRollData() { diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index d52411ba..7cca52cb 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -28,7 +28,11 @@ export class RdDRollDialog extends Dialog { dialogConf.title = "Test de compétence", dialogOptions.width = 600; dialogOptions.height = 360; - } + } else if (mode == "arme") { + dialogConf.title = "Test de combat/arme", + dialogOptions.width = 600; + dialogOptions.height = 360; + } super(dialogConf, dialogOptions); this.mode = mode; @@ -55,7 +59,8 @@ export class RdDRollDialog extends Dialog { $("#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; - $("#compdialogTitle").text( rollData.competence.name + " - " + niveauStr + " - " + rollData.selectedCarac.label ); + 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 ); $(".table-resolution").remove(); game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11, rollData.selectedCarac.value, rollData.finalLevel ); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 040333c9..39099796 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -74,9 +74,11 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html', //Items 'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html', + 'systems/foundryvtt-reve-de-dragon/templates/item-arme-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html', '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' ]; @@ -214,12 +216,15 @@ export class RdDUtility { data.carac.lancer.value = Math.floor( (parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2); data.sante.vie.max = Math.ceil( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value) /2 ); - data.sante.vie.value = data.sante.vie.max; + if ( data.sante.vie.value > data.sante.vie.max) + data.sante.vie.value = data.sante.vie.max; let endurance = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) ); data.sante.endurance.max = endurance; - data.sante.endurance.value = endurance; + if ( data.sante.endurance.value > endurance) + data.sante.endurance.value = endurance; data.sante.fatigue.max = endurance*2; - data.sante.fatigue.value = 0; + if ( data.sante.fatigue.value > data.sante.fatigue.max ) + data.sante.fatigue.value = data.sante.fatigue.max; data.attributs.sconst.value = 5; // Max ! if ( data.carac.constitution.value < 9 ) @@ -236,9 +241,9 @@ export class RdDUtility { data.attributs.sust.value = 3; //Compteurs - data.compteurs.reve.value = data.carac.reve.value; + //data.compteurs.reve.value = data.carac.reve.value; data.compteurs.reve.max = data.carac.reve.value; - data.compteurs.chance.value = data.carac.chance.value; + //data.compteurs.chance.value = data.carac.chance.value; data.compteurs.chance.max = data.carac.chance.value; } @@ -289,16 +294,57 @@ export class RdDUtility { let myroll = new Roll("d20"); myroll.roll(); let result = myroll.total; - if ( result <= 3 ) return "Jambe, genou, pied, jarret"; - if ( result <= 7 ) return "Hanche, cuisse, fesse"; - if ( result <= 9 ) return "Ventre, reins"; - if ( result <= 12 ) return "Poitrine, dos"; - if ( result <= 14 ) return "Avant-bras, main, coude"; - if ( result <= 18 ) return "Epaule, bras, omoplate"; - if ( result == 19) return "Tête autre"; - if ( result == 20) return "Tête visage"; + let txt = "" + if ( result <= 3 ) txt = "Jambe, genou, pied, jarret"; + else if ( result <= 7 ) txt = "Hanche, cuisse, fesse"; + else if ( result <= 9 ) txt = "Ventre, reins"; + else if ( result <= 12 ) txt = "Poitrine, dos"; + else if ( result <= 14 ) txt = "Avant-bras, main, coude"; + else if ( result <= 18 ) txt = "Epaule, bras, omoplate"; + else if ( result == 19) txt = "Tête autre"; + else if ( result == 20) txt = "Tête visage"; + + return { result: result, label: txt }; } - + + /* -------------------------------------------- */ + static computeBlessuresSante( degats ) + { + console.log("Degats !!", degats); + let result = { "vie": 0, + "endurance": 0, + "legeres": 0, + "graves": 0, + "critiques": 0 + }; + + if ( degats < 11 ) { + result.type = "contusion"; + let myroll = new Roll("1d4"); + myroll.roll(); + result.endurance = - myroll.result; + } else if ( degats < 16 ) { + result.type = "blessure légère"; + let myroll = new Roll("1d6"); + myroll.roll(); + result.endurance = - myroll.result; + result.legeres = 1 + } else if (degats < 20 ) { + result.type = "blessure grave"; + let myroll = new Roll("2d6"); + myroll.roll(); + result.endurance = - myroll.result; + result.vie = -2; + result.graves = 1; + } else { + result.type = "critique"; + result.endurance = -100; // Force endurance to 0 + result.vie = -4 - (degats - 20); + result.critiques = 1; + } + return result; + } + /* -------------------------------------------- */ static currentFatigueMalus( value, max) { @@ -330,4 +376,16 @@ export class RdDUtility { } } + /* -------------------------------------------- */ + static async chatListeners( html ) + { + html.on("click", '#encaisser-button', event => { + event.preventDefault(); + console.log("Encaisser button", event); + let attackerActor = game.actors.get(event.currentTarget.attributes['data-attackerid'].value ); + let defenderActor = game.actors.get(event.currentTarget.attributes['data-defenderid'].value ); + defenderActor.encaisserDommages( attackerActor); + }); + } + } diff --git a/module/simple.js b/module/simple.js deleted file mode 100644 index b4aa0686..00000000 --- a/module/simple.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * RdD system - * Author: LeRatierBretonnien - * Software License: GNU GPLv3 - */ - -/* -------------------------------------------- */ - -/* -------------------------------------------- */ -// Import Modules -import { RdDActor } from "./actor.js"; -import { RdDItemSheet } from "./item-sheet.js"; -import { RdDActorSheet } from "./actor-sheet.js"; -import { RdDUtility } from "./rdd-utility.js"; - -/* -------------------------------------------- */ -/* Foundry VTT Initialization */ -/* -------------------------------------------- */ - -Hooks.once("init", async function() { - console.log(`Initializing Reve de Dragon System`); - - // preload handlebars templates - RdDUtility.preloadHandlebarsTemplates(); - - /** - * Set an initiative formula for the system - * @type {String} - */ - CONFIG.Combat.initiative = { - formula: "1d20", - decimals: 2 - }; - - // Define custom Entity classes - CONFIG.Actor.entityClass = RdDActor; - CONFIG.RDD = {} - CONFIG.RDD.resolutionTable = RdDUtility.buildResolutionTable(); - CONFIG.RDD.level_category = RdDUtility.getLevelCategory(); - CONFIG.RDD.carac_array = RdDUtility.getCaracArray(); - CONFIG.RDD.bonusmalus = RdDUtility.getBonusMalus(); - game.data.RdDUtility = RdDUtility; - - // Register sheet application classes - Actors.unregisterSheet("core", ActorSheet); - Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { makeDefault: true }); - Items.unregisterSheet("core", ItemSheet); - Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true}); - -}); diff --git a/system.json b/system.json index 3ab74e50..a656fba8 100644 --- a/system.json +++ b/system.json @@ -2,19 +2,19 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "L'implémentation de Rêve de Dragon pour FoundryVTT", - "version": 0.6, + "version": "0.7.0", "minimumCoreVersion": "0.6.0", "compatibleCoreVersion": "0.6.0", - "templateVersion": 9, + "templateVersion": 10, "author": "LeRatierBretonnien", - "esmodules": ["module/simple.js"], + "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "styles": ["styles/simple.css"], "packs": [], "languages": [], "gridDistance": 5, "gridUnits": "ft", - "primaryTokenAttribute": "vie", - "secondaryTokenAttribute": "fatigue", + "primaryTokenAttribute": "data.sante.vie", + "secondaryTokenAttribute": "data.sante.fatigue", "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/", "manifest": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/raw/master/system.json", "download": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/-/archive/master/foundryvtt-reve-de-dragon-master.zip", diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 556c35d8..fa0c312a 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -164,11 +164,11 @@ XP
    - {{#each data.competenceByCategory.melee as |comp key|}} + {{#each data.armes as |arme key|}}
  1. - {{comp.name}} - - + {{arme.name}} + {{arme.data.competence}} + {{numberFormat arme.data.niveau decimals=0 sign=true}}
  2. {{/each}}
diff --git a/templates/arme-competence.html b/templates/arme-competence.html index 8b137891..54bf1924 100644 --- a/templates/arme-competence.html +++ b/templates/arme-competence.html @@ -1 +1,17 @@ - + + + + + + + + + + + + + + + + + diff --git a/templates/competence-categorie.html b/templates/competence-categorie.html index 1bf5423c..9d918815 100644 --- a/templates/competence-categorie.html +++ b/templates/competence-categorie.html @@ -1,4 +1,4 @@ - + diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index f6b78db8..8382c9c0 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -20,6 +20,12 @@ {{/select}} +{{#if arme}} +
+ + +
+{{/if}}
diff --git a/templates/item-arme-sheet.html b/templates/item-arme-sheet.html index 3436fb3f..4bf1038c 100644 --- a/templates/item-arme-sheet.html +++ b/templates/item-arme-sheet.html @@ -9,13 +9,11 @@ {{!-- Sheet Body --}}
- +