diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 57481d92..3ff1225b 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -117,7 +117,8 @@ export class RdDActorSheet extends ActorSheet { data.data.tetes = this._checkNull(data.itemsByType['tete']); data.data.competenceByCategory = data.competenceByCategory; data.data.isGM = game.user.isGM; - + data.bonusmalusTable = CONFIG.RDD.bonusmalus; + return data; } @@ -136,7 +137,7 @@ export class RdDActorSheet extends ActorSheet { const item = this.actor.getOwnedItem(li.data("item-id")); item.sheet.render(true); }); - + // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); @@ -145,6 +146,13 @@ export class RdDActorSheet extends ActorSheet { li.slideUp(200, () => this.render(false)); }); + // Update Inventory Item + html.find('.encaisser-direct').click(ev => { + let result = new Roll("2d10").roll().result; + const item = this.actor.encaisserDommagesHorsCombat(result); + console.log("ENCAISSER:", result); + }); + // Blessure control html.find('.blessure-control').click(ev => { const li = $(ev.currentTarget).parents(".item"); diff --git a/module/actor.js b/module/actor.js index 21348ceb..f93bbbd9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -533,53 +533,54 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ manageBlessures( blessuresData ) { - if ( blessuresData.legeres > 0 || blessuresData.graves > 0 || blessuresData.critiques > 0 ) { - let blessures = duplicate(this.data.data.blessures); - while ( blessuresData.legeres > 0 ) { - let nLegeres = 0; - for (let k=0; k 0 ) - blessuresData.graves += 1; - - - while ( blessuresData.graves > 0) { - let nGraves = 0; - for (let k=0; k 0 ) - blessuresData.critiques = 1; - - 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.liste[0].active = true; - blessures.critiques.liste[0].loc = blessuresData.locName; + // Fast exit + if ( blessuresData.legeres + blessuresData.graves + blessuresData.critiques == 0 ) return; + + let blessures = duplicate(this.data.data.blessures); + // Manage blessures + if ( workData.legeres > 0 ) { + for (let k=0; k 0 ) { + workData.graves += 1; + blessuresData.graves += 1; } + + if ( workData.graves > 0) { + for (let k=0; k 0 ) { + workData.critiques = 1; + blessuresData.critiques = 1; + } + + if ( workData.critiques > 0 ) { + workData.endurance = this.data.data.sante.endurance.value; // Patch with real endurance current value (ie end -> 0 when critique) + blessures.critiques.liste[0].active = true; + blessures.critiques.liste[0].loc = workData.locName; + } + + this.update( { "data.blessures": blessures } ); } /* -------------------------------------------- */ @@ -827,6 +828,7 @@ export class RdDActor extends Actor { 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é : " + + "
Encaissement final : " + degatsReel + "
" + result.legeres + " légères, " + result.graves + " graves et " + result.critiques + " critique." + "
Et perdu : " + @@ -835,6 +837,29 @@ export class RdDActor extends Actor { this.computeEtatGeneral(); this.sheet.render(true); } + + /* -------------------------------------------- */ + encaisserDommagesHorsCombat( degats ) + { + let degatsReel = degats - this.computeArmure("Corps", 0); + console.log("Enciasser dommages", degatsReel); + + let result = RdDUtility.computeBlessuresSante(degatsReel); + this.santeIncDec("vie", result.vie); + this.santeIncDec("endurance", result.endurance); + + result.locName = "Corps"; // Add the localisation namme + this.manageBlessures( result ); // Will upate the result table + ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " + + "
Encaissement final : " + degatsReel + + "
" + 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); + } /* -------------------------------------------- */ parerAttaque( attackerRoll, armeId ) diff --git a/module/rdd-roll-encaisse.js b/module/rdd-roll-encaisse.js new file mode 100644 index 00000000..24577370 --- /dev/null +++ b/module/rdd-roll-encaisse.js @@ -0,0 +1,43 @@ +/** + * Extend the base Dialog entity by defining a custom window to perform roll. + * @extends {Dialog} + */ + +export class RdDEncaisser extends Dialog { + + /* -------------------------------------------- */ + constructor(mode, html, rollData, actor) { + let myButtons = { rollButton: { + label: "Lancer", + callback: html => this.performEncaisser(html, false) + } }; + // Common conf + let dialogConf = { + content: html, + buttons: myButtons, + default: "rollButton" + } + let dialogOptions = { classes: [ "rdddialog"] } + + // Select proper roll dialog template and stuff + dialogConf.title = "Jet d'Encaissement", + dialogOptions.width = 600; + dialogOptions.height = 360; + super(dialogConf, dialogOptions); + + this.mode = mode; + this.rollData = rollData; + this.actor = actor; + } + + /* -------------------------------------------- */ + performEncaisser (html, isReserve=false) { + + } + + /* -------------------------------------------- */ + activateListeners(html) { + super.activateListeners(html); + } + +} diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 767d7632..4c500961 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -401,29 +401,26 @@ export class RdDUtility { static computeBlessuresSante( degats ) { console.log("Degats !!", degats); - let result = { "vie": 0, - "endurance": 0, - "legeres": 0, - "graves": 0, - "critiques": 0 + 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; + let myroll = new Roll("1d4").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 + let myroll = new Roll("1d6").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; + let myroll = new Roll("2d6").roll(); + result.endurance = -myroll.result; result.vie = -2; result.graves = 1; } else { diff --git a/system.json b/system.json index b4a8fbf8..26e4c4e6 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "0.9.22", + "version": "0.9.23", "minimumCoreVersion": "0.6.0", "compatibleCoreVersion": "0.7.5", "templateVersion": 38, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index b4a3edef..3599351c 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -255,6 +255,16 @@ {{!-- Combat Tab --}}
+
+ Encaisser des dommages : + +
Armes compétence