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,7 +117,8 @@ export class RdDActorSheet extends ActorSheet {
data.data.tetes = this._checkNull(data.itemsByType['tete']); data.data.tetes = this._checkNull(data.itemsByType['tete']);
data.data.competenceByCategory = data.competenceByCategory; data.data.competenceByCategory = data.competenceByCategory;
data.data.isGM = game.user.isGM; data.data.isGM = game.user.isGM;
data.bonusmalusTable = CONFIG.RDD.bonusmalus;
return data; return data;
} }
@ -136,7 +137,7 @@ export class RdDActorSheet extends ActorSheet {
const item = this.actor.getOwnedItem(li.data("item-id")); const item = this.actor.getOwnedItem(li.data("item-id"));
item.sheet.render(true); item.sheet.render(true);
}); });
// Delete Inventory Item // Delete Inventory Item
html.find('.item-delete').click(ev => { html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
@ -145,6 +146,13 @@ export class RdDActorSheet extends ActorSheet {
li.slideUp(200, () => this.render(false)); 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 // 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");

View File

@ -533,53 +533,54 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
manageBlessures( blessuresData ) manageBlessures( blessuresData )
{ {
if ( blessuresData.legeres > 0 || blessuresData.graves > 0 || blessuresData.critiques > 0 ) { let workData = duplicate(blessuresData);
let blessures = duplicate(this.data.data.blessures);
while ( blessuresData.legeres > 0 ) {
let nLegeres = 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++;
}
}
if ( nLegeres == 5) break;
}
if ( blessuresData.legeres > 0 )
blessuresData.graves += 1;
while ( blessuresData.graves > 0) {
let nGraves = 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++;
}
}
if ( nGraves == 2) break;
}
if ( blessuresData.graves > 0 ) // Fast exit
blessuresData.critiques = 1; if ( blessuresData.legeres + blessuresData.graves + blessuresData.critiques == 0 ) return;
if ( blessuresData.critiques > 0 ) { let blessures = duplicate(this.data.data.blessures);
blessuresData.endurance = this.data.data.sante.endurance.value; // Patch with real endurance current value (ie end -> 0 when critique) // Manage blessures
blessures.critiques.liste[0].active = true; if ( workData.legeres > 0 ) {
blessures.critiques.liste[0].loc = blessuresData.locName; for (let k=0; k<blessures.legeres.liste.length; k++) {
let bless = blessures.legeres.liste[k];
if ( !bless.active ){
bless.active = true;
bless.loc = workData.locName;
workData.legeres--;
}
if (workData.legeres == 0) break;
} }
}
this.update( { "data.blessures": blessures } );
if ( workData.legeres > 0 ) {
workData.graves += 1;
blessuresData.graves += 1;
} }
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 = workData.locName;
workData.graves--;
}
if ( workData.graves == 0) break;
}
}
if ( workData.graves > 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 result.locName = attackerRoll.loc.label; // Add the localisation namme
this.manageBlessures( result ); // Will upate the result table this.manageBlessures( result ); // Will upate the result table
ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " + ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " +
"<br>Encaissement final : " + degatsReel +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " + "<br>" + result.legeres + " légères, " + result.graves + " graves et " +
result.critiques + " critique." + result.critiques + " critique." +
"<br>Et perdu : " + "<br>Et perdu : " +
@ -835,6 +837,29 @@ export class RdDActor extends Actor {
this.computeEtatGeneral(); this.computeEtatGeneral();
this.sheet.render(true); 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 : " +
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } );
this.computeEtatGeneral();
this.sheet.render(true);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
parerAttaque( attackerRoll, armeId ) parerAttaque( attackerRoll, armeId )

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,29 +401,26 @@ export class RdDUtility {
static computeBlessuresSante( degats ) static computeBlessuresSante( degats )
{ {
console.log("Degats !!", degats); console.log("Degats !!", degats);
let result = { "vie": 0, let result = { vie: 0,
"endurance": 0, endurance: 0,
"legeres": 0, legeres: 0,
"graves": 0, graves: 0,
"critiques": 0 critiques: 0
}; };
if ( degats < 11 ) { if ( degats < 11 ) {
result.type = "contusion"; result.type = "contusion";
let myroll = new Roll("1d4"); let myroll = new Roll("1d4").roll();
myroll.roll(); result.endurance = -myroll.result;
result.endurance = - myroll.result;
} else if ( degats < 16 ) { } else if ( degats < 16 ) {
result.type = "blessure légère"; result.type = "blessure légère";
let myroll = new Roll("1d6"); let myroll = new Roll("1d6").roll();
myroll.roll(); result.endurance = -myroll.result;
result.endurance = - myroll.result; result.legeres = 1;
result.legeres = 1
} else if (degats < 20 ) { } else if (degats < 20 ) {
result.type = "blessure grave"; result.type = "blessure grave";
let myroll = new Roll("2d6"); let myroll = new Roll("2d6").roll();
myroll.roll(); result.endurance = -myroll.result;
result.endurance = - myroll.result;
result.vie = -2; result.vie = -2;
result.graves = 1; result.graves = 1;
} else { } else {

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.22", "version": "0.9.23",
"minimumCoreVersion": "0.6.0", "minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.5",
"templateVersion": 38, "templateVersion": 38,

View File

@ -255,6 +255,16 @@
{{!-- Combat Tab --}} {{!-- Combat Tab --}}
<div class="tab combat" data-group="primary" data-tab="combat"> <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"> <header class="competence-header flexrow">
<span class="competence-title">Armes</span> <span class="competence-title">Armes</span>
<span class="competence-title">compétence</span> <span class="competence-title">compétence</span>