Fix dommages

This commit is contained in:
sladecraven 2020-11-07 21:06:37 +01:00
parent bb82f139eb
commit c3ad3158b9
6 changed files with 145 additions and 62 deletions

View File

@ -117,6 +117,7 @@ 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;
}
@ -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");

View File

@ -533,54 +533,55 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
manageBlessures( blessuresData )
{
if ( blessuresData.legeres > 0 || blessuresData.graves > 0 || blessuresData.critiques > 0 ) {
let workData = duplicate(blessuresData);
// Fast exit
if ( blessuresData.legeres + blessuresData.graves + blessuresData.critiques == 0 ) return;
let blessures = duplicate(this.data.data.blessures);
while ( blessuresData.legeres > 0 ) {
let nLegeres = 0;
// Manage blessures
if ( workData.legeres > 0 ) {
for (let k=0; k<blessures.legeres.liste.length; k++) {
let bless = blessures.legeres.liste[k];
if ( !bless.active ){
bless.active = true;
bless.loc = blessuresData.locName;
blessuresData.legeres--;
} else {
nLegeres++;
bless.loc = workData.locName;
workData.legeres--;
}
if (workData.legeres == 0) break;
}
if ( nLegeres == 5) break;
}
if ( blessuresData.legeres > 0 )
if ( workData.legeres > 0 ) {
workData.graves += 1;
blessuresData.graves += 1;
}
while ( blessuresData.graves > 0) {
let nGraves = 0;
if ( workData.graves > 0) {
for (let k=0; k<blessures.graves.liste.length; k++) {
let bless = blessures.graves.liste[k];
if ( !bless.active ) {
bless.active = true;
bless.loc = blessuresData.locName;
blessuresData.graves--;
} else {
nGraves++;
bless.loc = workData.locName;
workData.graves--;
}
if ( workData.graves == 0) break;
}
if ( nGraves == 2) break;
}
if ( blessuresData.graves > 0 )
if ( workData.graves > 0 ) {
workData.critiques = 1;
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)
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 = blessuresData.locName;
blessures.critiques.liste[0].loc = workData.locName;
}
this.update( { "data.blessures": blessures } );
}
}
/* -------------------------------------------- */
async stressTest( ) {
@ -827,6 +828,30 @@ 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é : " +
"<br>Encaissement final : " + degatsReel +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " +
result.critiques + " critique." +
"<br>Et perdu : " +
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } );
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é : " +
"<br>Encaissement final : " + degatsReel +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " +
result.critiques + " critique." +
"<br>Et perdu : " +

View File

@ -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);
}
}

View File

@ -401,28 +401,25 @@ 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();
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();
let myroll = new Roll("1d6").roll();
result.endurance = -myroll.result;
result.legeres = 1
result.legeres = 1;
} else if (degats < 20 ) {
result.type = "blessure grave";
let myroll = new Roll("2d6");
myroll.roll();
let myroll = new Roll("2d6").roll();
result.endurance = -myroll.result;
result.vie = -2;
result.graves = 1;

View File

@ -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,

View File

@ -255,6 +255,16 @@
{{!-- Combat Tab --}}
<div class="tab combat" data-group="primary" data-tab="combat">
<div>
<span class="encaisser-direct"><a>Encaisser des dommages : </a></span>
<select name="degatsmodifier" id="degatsmodifier" data-dtype="String">
{{#select degatsmodifier}}
{{#each bonusmalusTable as |bmvalue key|}}
<option value="{{bmvalue}}"}>{{numberFormat bmvalue decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<header class="competence-header flexrow">
<span class="competence-title">Armes</span>
<span class="competence-title">compétence</span>