Merge VK branch

This commit is contained in:
sladecraven 2020-12-01 08:28:41 +01:00
commit fcc7c4202e
5 changed files with 70 additions and 24 deletions

View File

@ -100,7 +100,7 @@ export class RdDActorSheet extends ActorSheet {
// Gestion du lock/unlock des zones éditables (carac+compétences) // Gestion du lock/unlock des zones éditables (carac+compétences)
data.data.editCaracComp = this.options.editCaracComp; data.data.editCaracComp = this.options.editCaracComp;
data.data.lockUnlockText = (this.options.editCaracComp) ? "Bloquer" : "Debloquer"; data.data.lockUnlockText = (this.options.editCaracComp) ? "Bloquer" : "Débloquer";
// low is normal, this the base used to compute the grid. // low is normal, this the base used to compute the grid.
data.data.fatigue = { data.data.fatigue = {
@ -118,7 +118,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async displayDialogEncaisser( ) { async displayDialogEncaisser( ) {
let data = { ajustementsConditions: CONFIG.RDD.ajustementsConditions /* techniquement on peut encaisser à +20 */ }; let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() };
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data ); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data );
new RdDEncaisser(html, this.actor ).render(true); new RdDEncaisser(html, this.actor ).render(true);
} }
@ -160,6 +160,12 @@ export class RdDActorSheet extends ActorSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if (game.user.isGM) {
$(".gm-only").show();
} else {
$(".gm-only").hide();
}
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
@ -176,11 +182,16 @@ export class RdDActorSheet extends ActorSheet {
this.confirmerSuppression( li ); this.confirmerSuppression( li );
}); });
// Update Inventory Item html.find('#encaisser-direct').click(ev => {
html.find('.encaisser-direct').click(ev => {
this.displayDialogEncaisser() this.displayDialogEncaisser()
}); });
html.find('#remise-a-neuf').click(ev => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
});
// Blessure control // Blessure control
html.find('.blessure-control').click(ev => { html.find('.blessure-control').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
@ -234,24 +245,24 @@ export class RdDActorSheet extends ActorSheet {
this.actor.rollArme( armeName, competenceName); this.actor.rollArme( armeName, competenceName);
}); });
// Display TMR, normal // Display TMR, normal
html.find('.visu-tmr a').click((event) => { html.find('#visu-tmr').click((event) => {
this.actor.displayTMR( "visu"); this.actor.displayTMR( "visu");
}); });
// Display TMR, normal // Display TMR, normal
html.find('.monte-tmr a').click((event) => { html.find('#monte-tmr').click((event) => {
this.actor.displayTMR( "normal" ); this.actor.displayTMR( "normal" );
}); });
// Display TMR, fast // Display TMR, fast
html.find('.monte-tmr-rapide a').click((event) => { html.find('#monte-tmr-rapide').click((event) => {
this.actor.displayTMR( "rapide" ); this.actor.displayTMR( "rapide" );
}); });
html.find('.dormir-une-heure').click((event) => { html.find('#dormir-une-heure').click((event) => {
this.actor.dormir(1); this.actor.dormir(1);
}); });
html.find('.dormir-chateau-dormant').click((event) => { html.find('#dormir-chateau-dormant').click((event) => {
this.actor.dormirChateauDormant(); this.actor.dormirChateauDormant();
}); });

View File

@ -391,10 +391,14 @@ export class RdDActor extends Actor {
} }
mergeObject(retrograde, { "active": true, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": blessure.localisation }); mergeObject(retrograde, { "active": true, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": blessure.localisation });
} }
mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }); this._supprimerBlessure(blessure);
return true; return true;
} }
_supprimerBlessure(blessure) {
mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" });
}
async _recupererVie(message) { async _recupererVie(message) {
let blessures = [].concat(this.data.data.blessures.legeres.liste).concat(this.data.data.blessures.graves.liste).concat(this.data.data.blessures.critiques.liste); let blessures = [].concat(this.data.data.blessures.legeres.liste).concat(this.data.data.blessures.graves.liste).concat(this.data.data.blessures.critiques.liste);
let nbBlessures = blessures.filter(b => b.active); let nbBlessures = blessures.filter(b => b.active);
@ -430,6 +434,28 @@ export class RdDActor extends Actor {
return rolled; return rolled;
} }
async remiseANeuf() {
let message = {
whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ),
content : "Remise à neuf de " + this.name
};
const blessures = duplicate(this.data.data.blessures);
for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) {
for (let blessure of listeBlessures) {
this._supprimerBlessure(blessure);
}
}
await this.update( {"data.blessures": blessures } );
await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value);
await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value);
let fatigue = duplicate(this.data.data.sante.fatigue)
fatigue.value = 0;
await this.update( {"data.sante.fatigue": fatigue } );
ChatMessage.create( message );
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async dormir(heures=1) { async dormir(heures=1) {
let message = { let message = {
@ -890,12 +916,15 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async santeIncDec(name, inc, isCritique = false ) { async santeIncDec(name, inc, isCritique = false) {
const sante = duplicate(this.data.data.sante); const sante = duplicate(this.data.data.sante);
let data = sante[name]; let data = sante[name];
let minValue = 0; let minValue = 0;
if (this.type == 'personnage') if (this.type == 'personnage') {
minValue = name == "vie" ? Number(-this.data.data.attributs.sconst.value) : 0; // TODO: les animaux/humanoïdes on théoriquement aussi un sconst, mais la SPA n'est pas passé par là
minValue = name == "vie" ? -Number(this.data.data.attributs.sconst.value) : 0;
}
let newValue = Math.max(minValue, Math.min(data.value + inc, data.max)); let newValue = Math.max(minValue, Math.min(data.value + inc, data.max));
//console.log("New value ", inc, minValue, newValue); //console.log("New value ", inc, minValue, newValue);
@ -1298,9 +1327,8 @@ export class RdDActor extends Actor {
let degatsReel = attackerRoll.degats - armure; let degatsReel = attackerRoll.degats - armure;
let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite); let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite);
if ( this.data.type != 'entite') // Pas de PV chez les entités await this.santeIncDec("vie", result.vie);
await this.santeIncDec("vie", result.vie, (result.critiques > 0) ); await this.santeIncDec("endurance", result.endurance, (result.critiques > 0));
await this.santeIncDec("endurance", result.endurance, (result.critiques > 0) );
result.locName = (attackerRoll.loc) ? attackerRoll.loc.label : "Corps"; result.locName = (attackerRoll.loc) ? attackerRoll.loc.label : "Corps";
this.manageBlessures(result); // Will upate the result table this.manageBlessures(result); // Will upate the result table

View File

@ -28,6 +28,8 @@ const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20,
const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"];
const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10];
const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10];
const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25];
function _buildAllSegmentsFatigue(max) { function _buildAllSegmentsFatigue(max) {
const cycle = [5, 2, 4, 1, 3, 0]; const cycle = [5, 2, 4, 1, 3, 0];
@ -298,6 +300,10 @@ export class RdDUtility {
{ {
return ajustementsConditions; return ajustementsConditions;
} }
static getAjustementsEncaissement()
{
return ajustementsEncaissement;
}
static getDefinitionsBlessures() { static getDefinitionsBlessures() {
return definitionsBlessures; return definitionsBlessures;

View File

@ -58,13 +58,14 @@
</ul> </ul>
<div class="flex-group-center flex-actions-bar"> <div class="flex-group-center flex-actions-bar">
<div> <div>
<span class="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span> <span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span class="dormir-une-heure"><a title="Dormir une heure"><img class="button-img" src="icons/svg/sleep.svg" alt="Dormir une heure"/></a></span> <span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
<span class="dormir-chateau-dormant"><a title="Chateau Dormant"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg" alt="Chateau Dormant"/></a></span> <span id="dormir-une-heure"><a title="Dormir une heure"><img class="button-img" src="icons/svg/sleep.svg" alt="Dormir une heure"/></a></span>
<span class="monte-tmr"><a title="Montée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/></a></span> <span id="dormir-chateau-dormant"><a title="Chateau Dormant"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg" alt="Chateau Dormant"/></a></span>
<span class="monte-tmr-rapide"><a title="Montée accélérée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-rapide.svg" alt="Montée accélérée dans les Terres M&eacute;dianes !"/></a></span> <span id="monte-tmr"><a title="Montée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/></a></span>
<span class="visu-tmr"><a title="Regarder les Terres M&eacute;dianes"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-view.svg" alt="Regarder les Terres M&eacute;dianes"/></a></span> <span id="monte-tmr-rapide"><a title="Montée accélérée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-rapide.svg" alt="Montée accélérée dans les Terres M&eacute;dianes !"/></a></span>
</div> <span id="visu-tmr"><a title="Regarder les Terres M&eacute;dianes"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-view.svg" alt="Regarder les Terres M&eacute;dianes"/></a></span>
</div>
<div class="flexrow"> <div class="flexrow">
<span class="tooltip">Malus de fatigue : {{data.fatigue.malus}} <span class="tooltip">Malus de fatigue : {{data.fatigue.malus}}
<span class="tooltiptext">{{{data.fatigue.html}}}</span> <span class="tooltiptext">{{{data.fatigue.html}}}</span>

View File

@ -4,7 +4,7 @@
<label class="competence-label">Modificateurs aux Dommages:</label> <label class="competence-label">Modificateurs aux Dommages:</label>
<select class="competence-value" name="modificateurDegats" id="modificateurDegats" data-dtype="number"> <select class="competence-value" name="modificateurDegats" id="modificateurDegats" data-dtype="number">
{{#select modificateurDegats}} {{#select modificateurDegats}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsEncaissement as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}