Ajout des blessures sur encaissement

This commit is contained in:
Vincent Vandemeulebrouck 2023-03-14 02:38:21 +01:00
parent d0475e8677
commit 3e189cbe5f
20 changed files with 304 additions and 417 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
icons/sante/eraflure.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
icons/sante/mort.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -153,43 +153,18 @@ export class RdDActorSheet extends RdDBaseActorSheet {
this.createEmptyTache(); this.createEmptyTache();
}); });
this.html.find('.creer-tache-blessure-legere').click(async event => { this.html.find('.creer-tache-blessure-legere').click(async event => {
RdDItemBlessure.createTacheSoinBlessure(this.actor, 'legere'); RdDItemBlessure.createTacheSoinBlessure(this.actor, 2);
}); });
this.html.find('.creer-tache-blessure-grave').click(async event => { this.html.find('.creer-tache-blessure-grave').click(async event => {
RdDItemBlessure.createTacheSoinBlessure(this.actor, 'grave'); RdDItemBlessure.createTacheSoinBlessure(this.actor, 4);
}); });
this.html.find('.creer-tache-blessure-critique').click(async event => { this.html.find('.creer-tache-blessure-critique').click(async event => {
RdDItemBlessure.createTacheSoinBlessure(this.actor, 'critique'); RdDItemBlessure.createTacheSoinBlessure(this.actor, 6);
}); });
this.html.find('.creer-une-oeuvre').click(async event => { this.html.find('.creer-une-oeuvre').click(async event => {
this.selectTypeOeuvreToCreate(); this.selectTypeOeuvreToCreate();
}); });
// Blessure control
this.html.find('.blessure-control').click(async event => {
const tr = this.html.find(event.currentTarget).parents(".item");
let btype = tr.data("blessure-type");
let index = tr.data('blessure-index');
let active = this.html.find(event.currentTarget).data('blessure-active');
//console.log(btype, index, active);
await this.actor.manageBlessureFromSheet(btype, index, active);
});
// Blessure data
this.html.find('.blessure-soins').change(async event => {
const tr = this.html.find(event.currentTarget).parents(".item");
let btype = tr.data('blessure-type');
let index = tr.data('blessure-index');
let psoins = tr.find('.blessure-premiers_soins').val();
let pcomplets = tr.find('.blessure-soins_complets').val();
let jours = tr.find('.blessure-jours').val();
let loc = tr.find('.blessure-localisation').val();
let psdone = tr.find('.blessure-psdone:checked').val();
let scdone = tr.find('.blessure-scdone:checked').val();
console.log(btype, index, psoins, pcomplets, jours, loc, psdone, scdone);
await this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc, psdone, scdone);
});
this.html.find('.blessure-premierssoins-done').change(async event => { this.html.find('.blessure-premierssoins-done').change(async event => {
const blessure = this.getBlessure(event); const blessure = this.getBlessure(event);
await blessure?.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } }); await blessure?.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } });

View File

@ -26,7 +26,7 @@ import { DialogConsommer } from "./dialog-item-consommer.js";
import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RollDataAjustements } from "./rolldata-ajustements.js";
import { RdDPossession } from "./rdd-possession.js"; import { RdDPossession } from "./rdd-possession.js";
import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { ENTITE_INCARNE, ENTITE_NONINCARNE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { RdDConfirm } from "./rdd-confirm.js"; import { RdDConfirm } from "./rdd-confirm.js";
import { DialogValidationEncaissement } from "./dialog-validation-encaissement.js"; import { DialogValidationEncaissement } from "./dialog-validation-encaissement.js";
import { RdDRencontre } from "./item/rencontre.js"; import { RdDRencontre } from "./item/rencontre.js";
@ -46,7 +46,6 @@ const POSSESSION_SANS_DRACONIC = {
} }
}; };
const PAS_DE_BLESSURE = { "active": false, "psdone": false, "scdone": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": "" };
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre'] export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -403,7 +402,7 @@ export class RdDActor extends RdDBaseActor {
} }
await this._recupereChance(); await this._recupereChance();
await this.transformerStress(); await this.transformerStress();
this.bonusRecuperationPotion = 0; // Reset potion await this.setBonusPotionSoin(0);
} }
await this.resetInfoSommeil() await this.resetInfoSommeil()
ChatMessage.create(message); ChatMessage.create(message);
@ -414,11 +413,8 @@ export class RdDActor extends RdDBaseActor {
const maladiesPoisons = this._maladiePoisons(message); const maladiesPoisons = this._maladiePoisons(message);
const isMaladeEmpoisonne = maladiesPoisons.length > 0; const isMaladeEmpoisonne = maladiesPoisons.length > 0;
this._messageRecuperationMaladiePoisons(maladiesPoisons, message); this._messageRecuperationMaladiePoisons(maladiesPoisons, message);
const blessures = duplicate(this.system.blessures);
await this._recupererBlessures(message, "legere", blessures.legeres.liste.filter(b => b.active), [], isMaladeEmpoisonne); await this._recuperationBlessures(message, isMaladeEmpoisonne);
await this._recupererBlessures(message, "grave", blessures.graves.liste.filter(b => b.active), blessures.legeres.liste, isMaladeEmpoisonne);
await this._recupererBlessures(message, "critique", blessures.critiques.liste.filter(b => b.active), blessures.graves.liste, isMaladeEmpoisonne);
await this.update({ "system.blessures": blessures });
await this._recupererVie(message, isMaladeEmpoisonne); await this._recupererVie(message, isMaladeEmpoisonne);
} }
@ -460,7 +456,7 @@ export class RdDActor extends RdDBaseActor {
await this._recupereChance(); await this._recupereChance();
await this.transformerStress(); await this.transformerStress();
await this.retourSeuilDeReve(message); await this.retourSeuilDeReve(message);
this.bonusRecuperationPotion = 0; // Reset potion await this.setBonusPotionSoin(0);
await this.retourSust(message); await this.retourSust(message);
await this.verifierPotionsEnchantees(); await this.verifierPotionsEnchantees();
if (message.content != "") { if (message.content != "") {
@ -523,65 +519,36 @@ export class RdDActor extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _recupererBlessures(message, type, liste, moindres, isMaladeEmpoisonne) { async _recuperationBlessures(message, isMaladeEmpoisonne) {
if (!this.bonusRecuperationPotion) this.bonusRecuperationPotion = 0; const timestamp = game.system.rdd.calendrier.getTimestamp()
let count = 0; const blessures = this.filterItems(it => it.gravite > 0, 'blessure').sort(Misc.ascending(it => it.system.gravite))
const definitions = RdDUtility.getDefinitionsBlessures();
let definition = definitions.find(d => d.type == type); Promise.all(blessures.map(b => b.recuperationBlessure({
for (let blessure of liste) { actor: this,
if (blessure.jours >= definition.facteur) { timestamp,
let rolled = await this._jetRecuperationConstitution(Misc.toInt(blessure.soins_complets) + this.bonusRecuperationPotion, message); message,
blessure.soins_complets = 0; isMaladeEmpoisonne,
if (!isMaladeEmpoisonne && rolled.isSuccess && this._retrograderBlessure(type, blessure, moindres)) { blessures
message.content += ` -- une blessure ${type} cicatrise`; })));
count++; await this.supprimerBlessures(filterToDelete);
}
else if (rolled.isETotal) {
message.content += ` -- une blessure ${type} s'infecte (temps de guérison augmenté de ${definition.facteur} jours, perte de vie)`;
blessure.jours = 0;
await this.santeIncDec("vie", -1);
}
else {
blessure.jours++;
message.content += ` -- une blessure ${type} reste stable`;
}
}
else {
blessure.jours++;
}
}
} }
/* -------------------------------------------- */ async supprimerBlessures(filterToDelete) {
_retrograderBlessure(type, blessure, blessuresMoindres) { const toDelete = this.filterItems(filterToDelete, 'blessure')
if (type != "legere") { .map(it => it.id);
let retrograde = blessuresMoindres.find(b => !b.active); await this.deleteEmbeddedDocuments('Item', toDelete);
if (!retrograde) {
return false;
}
mergeObject(retrograde, { "active": true, "psdone": blessure.psdone, "scdone": blessure.scdone, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": blessure.loc });
}
this._supprimerBlessure(blessure);
return true;
}
/* -------------------------------------------- */
_supprimerBlessure(blessure) {
mergeObject(blessure, PAS_DE_BLESSURE);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _recupererVie(message, isMaladeEmpoisonne) { async _recupererVie(message, isMaladeEmpoisonne) {
const tData = this.system const tData = this.system
let blessures = [].concat(tData.blessures.legeres.liste).concat(tData.blessures.graves.liste).concat(tData.blessures.critiques.liste); let blessures = this.filterItems(it => it.system.gravite > 0, 'blessure');
let nbBlessures = blessures.filter(b => b.active); if (blessures.length > 0) {
return
}
let vieManquante = tData.sante.vie.max - tData.sante.vie.value; let vieManquante = tData.sante.vie.max - tData.sante.vie.value;
if (nbBlessures == 0 && vieManquante > 0) { if (vieManquante > 0) {
let bonusSoins = 0; let rolled = await this.jetRecuperationConstitution(bonusSoins, message)
for (let b of blessures) {
bonusSoins = Math.max(bonusSoins, Misc.toInt(b.soins_complets));
}
let rolled = await this._jetRecuperationConstitution(bonusSoins, message)
if (!isMaladeEmpoisonne && rolled.isSuccess) { if (!isMaladeEmpoisonne && rolled.isSuccess) {
const gain = Math.min(rolled.isPart ? 2 : 1, vieManquante); const gain = Math.min(rolled.isPart ? 2 : 1, vieManquante);
message.content += " -- récupération de vie: " + gain; message.content += " -- récupération de vie: " + gain;
@ -598,7 +565,7 @@ export class RdDActor extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _jetRecuperationConstitution(bonusSoins, message = undefined) { async jetRecuperationConstitution(bonusSoins, message = undefined) {
let difficulte = Misc.toInt(bonusSoins) + Math.min(0, this.system.sante.vie.value - this.system.sante.vie.max); let difficulte = Misc.toInt(bonusSoins) + Math.min(0, this.system.sante.vie.value - this.system.sante.vie.max);
let rolled = await RdDResolutionTable.roll(this.system.carac.constitution.value, difficulte); let rolled = await RdDResolutionTable.roll(this.system.carac.constitution.value, difficulte);
if (message) { if (message) {
@ -623,17 +590,13 @@ export class RdDActor extends RdDBaseActor {
const updates = { const updates = {
'system.sante.endurance.value': this.system.sante.endurance.max 'system.sante.endurance.value': this.system.sante.endurance.max
}; };
if (!this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) { if (this.isPersonnage() || this.isCreature()) {
if (this.system.blessures) { await this.supprimerBlessures(it => true);
updates['system.blessures.legeres.liste'] = [PAS_DE_BLESSURE, PAS_DE_BLESSURE, PAS_DE_BLESSURE, PAS_DE_BLESSURE, PAS_DE_BLESSURE];
updates['system.blessures.graves.liste'] = [PAS_DE_BLESSURE, PAS_DE_BLESSURE];
updates['system.blessures.critiques.liste'] = [PAS_DE_BLESSURE];
}
updates['system.sante.vie.value'] = this.system.sante.vie.max; updates['system.sante.vie.value'] = this.system.sante.vie.max;
updates['system.sante.fatigue.value'] = 0; updates['system.sante.fatigue.value'] = 0;
if (this.isPersonnage()) { }
updates['system.compteurs.ethylisme'] = { value: 1, nb_doses: 0, jet_moral: false }; if (this.isPersonnage()) {
} updates['system.compteurs.ethylisme'] = { value: 1, nb_doses: 0, jet_moral: false };
} }
await this.update(updates); await this.update(updates);
await this.removeEffects(e => e.flags.core.statusId !== STATUSES.StatusDemiReve); await this.removeEffects(e => e.flags.core.statusId !== STATUSES.StatusDemiReve);
@ -1147,35 +1110,31 @@ export class RdDActor extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
computeResumeBlessure(blessures = undefined) { computeResumeBlessure() {
blessures = blessures ?? this.system.blessures; const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure')
if (!blessures) {
return "Pas de blessures possibles";
}
let nbLegeres = this.countBlessures(blessures.legeres.liste);
let nbGraves = this.countBlessures(blessures.graves.liste);
let nbCritiques = this.countBlessures(blessures.critiques.liste);
let resume = "Blessures:"; const nbLegeres = blessures.filter(it => it.isLegere()).length;
if (nbCritiques > 0 || nbGraves > 0 || nbLegeres > 0) { const nbGraves = blessures.filter(it => it.isGrave()).length;
if (nbLegeres > 0) { const nbCritiques = blessures.filter(it => it.isCritique()).length;
resume += " " + nbLegeres + " légère" + (nbLegeres > 1 ? "s" : "");
} if (nbLegeres + nbGraves + nbCritiques == 0) {
if (nbGraves > 0) {
if (nbLegeres > 0)
resume += ",";
resume += " " + nbGraves + " grave" + (nbGraves > 1 ? "s" : "");
}
if (nbCritiques > 0) {
if (nbGraves > 0 || nbLegeres > 0)
resume += ",";
resume += " une CRITIQUE !";
}
return resume;
}
else {
return "Aucune blessure"; return "Aucune blessure";
} }
let resume = "Blessures:";
if (nbLegeres > 0) {
resume += " " + nbLegeres + " légère" + (nbLegeres > 1 ? "s" : "");
}
if (nbGraves > 0) {
if (nbLegeres > 0)
resume += ",";
resume += " " + nbGraves + " grave" + (nbGraves > 1 ? "s" : "");
}
if (nbCritiques > 0) {
if (nbGraves > 0 || nbLegeres > 0)
resume += ",";
resume += " une CRITIQUE !";
}
return resume;
} }
recompute() { recompute() {
@ -1384,11 +1343,11 @@ export class RdDActor extends RdDBaseActor {
ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.system.label))} !` }); ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.system.label))} !` });
} }
} }
if (this.type == 'personnage') { if (this.isPersonnage() || this.isCreature()) {
// Gestion blessure graves : -1 pt endurance const nbGraves = this.filterItems(it => it.isGrave(), 'blessure').length
let nbGraves = this.countBlessuresNonSoigneeByName('graves');
if (nbGraves > 0) { if (nbGraves > 0) {
await this.santeIncDec("endurance", -1); // Gestion blessure graves : -1 pt endurance par blessure grave
await this.santeIncDec("endurance", - nbGraves);
} }
} }
} }
@ -1419,20 +1378,8 @@ export class RdDActor extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
countBlessures(blessuresListe) { countBlessures(filter = it => !it.isContusion()) {
return blessuresListe.filter(b => b.active).length return this.filterItems(filter, 'blessure').length
}
/* -------------------------------------------- */
countBlessuresByName(name) {
return this.countBlessures(this.system.blessures[name].liste);
}
countBlessuresNonSoigneeByName(name) {
if (this.system.blessures) {
let blessures = this.system.blessures[name].liste;
return blessures.filter(b => b.active && !b.psdone).length;
}
return 0;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1583,40 +1530,15 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
_computeEnduranceMax() { _computeEnduranceMax() {
let blessures = this.system.blessures; const diffVie = this.system.sante.vie.max - this.system.sante.vie.value;
let diffVie = this.system.sante.vie.max - this.system.sante.vie.value; const maxEndVie = this.system.sante.endurance.max - (diffVie * 2);
let maxEndVie = this.system.sante.endurance.max - (diffVie * 2); const nbGraves = this.countBlessures(it => it.isGraves()) > 0
let nbGraves = this.countBlessures(blessures.graves.liste); const nbCritiques = this.countBlessures(it => it.isCritique()) > 0
let nbCritiques = this.countBlessures(blessures.critiques.liste); const maxEndGraves = Math.floor(this.system.sante.endurance.max / (2 * nbGraves));
let maxEndGraves = Math.floor(this.system.sante.endurance.max / (2 * nbGraves)); const maxEndCritiques = nbCritiques > 0 ? 1 : this.system.sante.endurance.max;
let maxEndCritiques = nbCritiques > 0 ? 1 : this.system.sante.endurance.max;
return Math.max(0, Math.min(maxEndVie, maxEndGraves, maxEndCritiques)); return Math.max(0, Math.min(maxEndVie, maxEndGraves, maxEndCritiques));
} }
/* -------------------------------------------- */
async manageBlessureFromSheet(gravite, index) {
let listBlessures = duplicate(this.system.blessures);
let blessure = listBlessures[gravite + "s"].liste[index];
blessure.active = !blessure.active;
if (!blessure.active) {
this._supprimerBlessure(blessure);
}
await this.update({ 'system.blessures': listBlessures });
}
/* -------------------------------------------- */
async setDataBlessureFromSheet(gravite, index, psoins, pcomplets, jours, loc, psdone, scdone) {
let listBlessures = duplicate(this.system.blessures);
let blessure = listBlessures[gravite + "s"].liste[index];
blessure.psdone = psdone;
blessure.scdone = scdone;
blessure.premiers_soins = psoins;
blessure.soins_complets = pcomplets;
blessure.jours = jours;
blessure.loc = loc;
await this.update({ 'system.blessures': listBlessures });
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async jetDeMoral(situation, messageReussi = undefined, messageManque = undefined) { async jetDeMoral(situation, messageReussi = undefined, messageManque = undefined) {
const jetMoral = await this._jetDeMoral(situation); const jetMoral = await this._jetDeMoral(situation);
@ -2388,10 +2310,9 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async creerTacheDepuisLivre(item, options = { renderSheet: true }) { async creerTacheDepuisLivre(item, options = { renderSheet: true }) {
// TODO: déplacer vers Item pour livres
const nomTache = "Lire " + item.name; const nomTache = "Lire " + item.name;
const filterTacheLecture = it => it.name == nomTache; const filterTacheLecture = it => it.type == 'tache' && it.name == nomTache;
let tachesExistantes = this.filterItems(filterTacheLecture, 'tache'); let tachesExistantes = this.filterItems(filterTacheLecture);
if (tachesExistantes.length == 0) { if (tachesExistantes.length == 0) {
const tache = { const tache = {
name: nomTache, type: 'tache', name: nomTache, type: 'tache',
@ -2407,14 +2328,14 @@ export class RdDActor extends RdDBaseActor {
} }
} }
await this.createEmbeddedDocuments('Item', [tache], options); await this.createEmbeddedDocuments('Item', [tache], options);
tachesExistantes = this.filterItems(filterTacheLecture, 'tache'); tachesExistantes = this.filterItems(filterTacheLecture);
} }
return tachesExistantes.length > 0 ? tachesExistantes[0] : undefined; return tachesExistantes.length > 0 ? tachesExistantes[0] : undefined;
} }
blessuresASoigner() { blessuresASoigner() {
// TODO or not TODO: filtrer les blessures poour lesquels on ne peut plus faire de premiers soins? // TODO or not TODO: filtrer les blessures poour lesquels on ne peut plus faire de premiers soins?
return this.filterItems(it => it.system.gravite > 0 && !(it.system.premierssoins.done && it.system.soinscomplets.done), 'blessure') return this.filterItems(it => it.system.gravite > 0 && it.system.gravite <= 6 && !(it.system.premierssoins.done && it.system.soinscomplets.done), 'blessure')
} }
async getTacheBlessure(blesse, blessure) { async getTacheBlessure(blesse, blessure) {
@ -3155,8 +3076,8 @@ export class RdDActor extends RdDBaseActor {
tache: Math.max(0, tache.system.points_de_tache_courant) tache: Math.max(0, tache.system.points_de_tache_courant)
} }
}) })
if (bonus>=0) { if (bonus >= 0) {
await tache.delete() await this.deleteEmbeddedDocuments('Item', [tache.id])
} }
} }
} }
@ -3311,11 +3232,11 @@ export class RdDActor extends RdDBaseActor {
async _appliquerEncaissement(encaissement, show) { async _appliquerEncaissement(encaissement, show) {
let santeOrig = duplicate(this.system.sante); let santeOrig = duplicate(this.system.sante);
this.ajouterBlessure(encaissement); // Will upate the result table const blessure = await this.ajouterBlessure(encaissement); // Will upate the result table
const perteVie = this.isEntite() const perteVie = this.isEntite()
? { newValue: 0 } ? { newValue: 0 }
: await this.santeIncDec("vie", -encaissement.vie); : await this.santeIncDec("vie", -encaissement.vie);
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, encaissement.critiques > 0); const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, blessure?.isCritique());
mergeObject(encaissement, { mergeObject(encaissement, {
alias: this.name, alias: this.name,
@ -3325,6 +3246,7 @@ export class RdDActor extends RdDBaseActor {
jetEndurance: perteEndurance.jetEndurance, jetEndurance: perteEndurance.jetEndurance,
endurance: santeOrig.endurance.value - perteEndurance.newValue, endurance: santeOrig.endurance.value - perteEndurance.newValue,
vie: this.isEntite() ? 0 : (santeOrig.vie.value - perteVie.newValue), vie: this.isEntite() ? 0 : (santeOrig.vie.value - perteVie.newValue),
blessure: blessure,
show: show ?? {} show: show ?? {}
}); });
@ -3344,73 +3266,33 @@ export class RdDActor extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
ajouterBlessure(encaissement) { async ajouterBlessure(encaissement) {
if (this.type == 'entite') return; // Une entité n'a pas de blessures if (this.isEntite()) return; // Une entité n'a pas de blessures
if (encaissement.legeres + encaissement.graves + encaissement.critiques == 0) return; if (encaissement.gravite < 0) return;
if (encaissement.gravite > 0) {
while (this.countBlessures(it => it.system.gravite == encaissement.gravite) >= RdDItemBlessure.maxBlessures(encaissement.gravite) && encaissement.gravite <= 6) {
// Aggravation
encaissement.gravite += 2
if (encaissement.gravite > 2) {
encaissement.vie += 2;
}
}
}
const endActuelle = Number(this.system.sante.endurance.value); const endActuelle = Number(this.system.sante.endurance.value);
let blessures = duplicate(this.system.blessures); const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg.loc.label);
if (blessure.isCritique()) {
let count = encaissement.legeres; encaissement.endurance = endActuelle;
// Manage blessures
while (count > 0) {
let legere = blessures.legeres.liste.find(it => !it.active);
if (legere) {
this._setBlessure(legere, encaissement);
count--;
}
else {
encaissement.graves += count;
encaissement.legeres -= count;
break;
}
} }
count = encaissement.graves; if (blessure.isMort()) {
while (count > 0) { this.setEffect(STATUSES.StatusComma, true);
let grave = blessures.graves.liste.find(it => !it.active); encaissement.mort = true;
if (grave) { ChatMessage.create({
this._setBlessure(grave, encaissement); content: `<img class="chat-icon" src="icons/svg/skull.svg" alt="charge" />
count--; <strong>${this.name} vient de succomber à une seconde blessure critique ! Que les Dragons gardent son Archétype en paix !</strong>`
} });
else {
encaissement.critiques += count;
encaissement.graves -= count;
encaissement.endurance = endActuelle;
encaissement.vie = 4;
break;
}
} }
return blessure;
count = encaissement.critiques;
while (count > 0) {
let critique = blessures.critiques.liste[0];
if (!critique.active) {
this._setBlessure(critique, encaissement);
count--;
} else {
// TODO: status effect dead
this.setEffect(STATUSES.StatusComma, true);
ChatMessage.create({
content: `<img class="chat-icon" src="icons/svg/skull.svg" alt="charge" />
<strong>${this.name} vient de succomber à une seconde blessure critique ! Que les Dragons gardent son Archétype en paix !</strong>`
});
encaissement.critiques -= count;
encaissement.mort = true;
break;
}
}
encaissement.endurance = Math.max(encaissement.endurance, -endActuelle);
this.update({ "system.blessures": blessures });
}
/* -------------------------------------------- */
_setBlessure(blessure, encaissement) {
blessure.active = true;
blessure.psdone = false;
blessure.scdone = false;
blessure.loc = encaissement.locName;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -3643,42 +3525,28 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async buildPotionGuerisonList(pointsGuerison) { async buildPotionGuerisonList(pointsGuerison) {
let pointsGuerisonInitial = pointsGuerison; const pointsGuerisonInitial = pointsGuerison;
let myData = this.system; const blessures = this.filterItems(it => it.isLegere() || it.isGrave() || it.isCritique()).sort(Misc.descending(it => it.system.gravite))
const blessures = duplicate(myData.blessures); const ids = []
let guerisonData = { list: [], pointsConsommes: 0 } const guerisonData = { list: [], pointsConsommes: 0 }
for (let blessure of blessures) {
console.log(blessures); if (pointsGuerison >= blessure.system.gravite) {
for (let critique of blessures.critiques.liste) { pointsGuerison -= blessure.system.gravite;
if (critique.active && pointsGuerison >= 6) { guerisonData.list.push(`1 Blessure ${blessure.system.labelGravite} (${blessure.system.gravite} points)`);
pointsGuerison -= 6; ids.push(blessure.id)
critique.active = false;
guerisonData.list.push("1 Blessure Critique (6 points)");
} }
} }
for (let grave of blessures.graves.liste) { if (ids.length > 0) {
if (grave.active && pointsGuerison >= 4) { await this.supprimerBlessures(it => ids.includes(it.id));
pointsGuerison -= 4;
grave.active = false;
guerisonData.list.push("1 Blessure Grave (4 points)");
}
} }
for (let legere of blessures.legeres.liste) { if (blessures.length == ids.length) {
if (legere.active && pointsGuerison >= 2) { let pvManquants = this.system.sante.vie.max - this.system.sante.vie.value;
pointsGuerison -= 2; let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2));
legere.active = false; pointsGuerison -= pvSoignees * 2;
guerisonData.list.push("1 Blessure Légère (2 points)"); guerisonData.list.push(pvSoignees + " Points de Vie soignés");
} await this.santeIncDec('vie', +pvSoignees, false);
} }
await this.update({ "system.blessures": blessures });
let pvManquants = myData.sante.vie.max - myData.sante.vie.value;
let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2));
pointsGuerison -= pvSoignees * 2;
guerisonData.list.push(pvSoignees + " Points de Vie soignés");
await this.santeIncDec('vie', +pvSoignees, false);
guerisonData.pointsConsommes = pointsGuerisonInitial - pointsGuerison; guerisonData.pointsConsommes = pointsGuerisonInitial - pointsGuerison;
return guerisonData; return guerisonData;
} }
@ -3697,7 +3565,7 @@ export class RdDActor extends RdDBaseActor {
} }
} }
if (!potionData.system.magique || potionData.rolled.isSuccess) { if (!potionData.system.magique || potionData.rolled.isSuccess) {
this.bonusRecuperationPotion = potionData.system.herbeBonus; await this.setBonusPotionSoin(potionData.system.herbeBonus);
} }
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name), whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
@ -3705,6 +3573,10 @@ export class RdDActor extends RdDBaseActor {
}); });
} }
async setBonusPotionSoin(bonus) {
await this.update({ 'sante.bonusPotion': bonus });
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async consommerPotionRepos(potionData) { async consommerPotionRepos(potionData) {
potionData.alias = this.name; potionData.alias = this.name;

View File

@ -1,4 +1,6 @@
import { RdDItem } from "../item.js"; import { RdDItem } from "../item.js";
import { Misc } from "../misc.js";
import { RdDTimestamp } from "../rdd-timestamp.js";
const BASE_TACHE_SOIN_BLESSURE = { const BASE_TACHE_SOIN_BLESSURE = {
type: "tache", type: "tache",
@ -6,20 +8,30 @@ const BASE_TACHE_SOIN_BLESSURE = {
system: { carac: "dexterite", competence: "Chirurgie", periodicite: "1 round", fatigue: 0, } system: { carac: "dexterite", competence: "Chirurgie", periodicite: "1 round", fatigue: 0, }
} }
const TACHES_SOIN_BLESSURE = { const TACHES_SOIN_BLESSURE = {
'critique': { name: 'Blessure critique', system: { difficulte: -6, points_de_tache: 6 } },
'grave': { name: 'Blessure grave', system: { difficulte: -4, points_de_tache: 4 } },
'legere': { name: 'Blessure légère', system: { difficulte: -2, points_de_tache: 2 } },
6: { name: 'Blessure critique', system: { difficulte: -6, points_de_tache: 6 } }, 6: { name: 'Blessure critique', system: { difficulte: -6, points_de_tache: 6 } },
4: { name: 'Blessure grave', system: { difficulte: -4, points_de_tache: 4 } }, 4: { name: 'Blessure grave', system: { difficulte: -4, points_de_tache: 4 } },
2: { name: 'Blessure légère', system: { difficulte: -2, points_de_tache: 2 } }, 2: { name: 'Blessure légère', system: { difficulte: -2, points_de_tache: 2 } },
} }
const definitionsBlessures = [
{ type: "contusion", gravite: 0, labelGravite: 'Contusion/éraflure', max: 100, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/eraflure.webp" },
{ type: "legere", gravite: 2, labelGravite: 'Légère', max: 5, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "grave", gravite: 4, labelGravite: 'Grave', max: 2, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "critique", gravite: 6, labelGravite: 'Critique', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "mort", gravite: 8, labelGravite: 'Mort', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/mort.webp" }
]
export class RdDItemBlessure extends RdDItem { export class RdDItemBlessure extends RdDItem {
static get defaultIcon() { static get defaultIcon() {
return "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp"; return "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp";
} }
prepareDerivedData() {
super.prepareDerivedData();
this.system.labelGravite = this.getLabelGravite()
}
static prepareTacheSoin(gravite) { static prepareTacheSoin(gravite) {
const tache = TACHES_SOIN_BLESSURE[gravite] const tache = TACHES_SOIN_BLESSURE[gravite]
if (!tache) { if (!tache) {
@ -28,7 +40,22 @@ export class RdDItemBlessure extends RdDItem {
} }
return mergeObject(duplicate(BASE_TACHE_SOIN_BLESSURE), tache) return mergeObject(duplicate(BASE_TACHE_SOIN_BLESSURE), tache)
} }
static async createBlessure(actor, gravite, localisation) {
const definition = RdDItemBlessure.getDefinition(gravite)
const blessure = {
name: definition.labelGravite,
type: 'blessure',
img: definition.icon,
system: {
gravite: gravite,
difficulte: - gravite,
localisation: localisation
}
}
const blessures = await actor.createEmbeddedDocuments('Item', [blessure])
return blessures[0]
}
static async createTacheSoinBlessure(actor, gravite) { static async createTacheSoinBlessure(actor, gravite) {
const tache = RdDItemBlessure.prepareTacheSoin(gravite) const tache = RdDItemBlessure.prepareTacheSoin(gravite)
@ -51,6 +78,54 @@ export class RdDItemBlessure extends RdDItem {
} }
} }
async setSoinsBlessure(systemUpdate = {}) {
systemUpdate = mergeObject(systemUpdate, this.system, { overwrite: false }),
systemUpdate.soinscomplets.done = systemUpdate.premierssoins.done && systemUpdate.soinscomplets.done
await this.update({
img: this.getImgSoins(systemUpdate.gravite, systemUpdate.soinscomplets.done),
system: systemUpdate
});
}
async recuperationBlessure({ actor, timestamp, message, isMaladeEmpoisonne, blessures }) {
if (this.parent != actor || actor == undefined) {
return;
}
if (new RdDTimestamp(this.system.fin).isAfterIndexDate(timestamp)) {
// attente periode
return
}
if (this.system.gravite > 0) {
const update = { premierssoins: { bonus: 0 }, soinscomplets: { bonus: 0 } }
const gravite = this.system.gravite;
const graviteMoindre = gravite - 2;
const moindres = blessures.filter(it => it.system.gravite == graviteMoindre, 'blessures').length
const labelGravite = RdDItemBlessure.getLabelGravite(gravite);
let rolled = await actor.jetRecuperationConstitution(Misc.toInt(this.system.soinscomplets.bonus) + actor.system.sante.bonusPotion, message);
if (rolled.isETotal) {
message.content += ` -- une blessure ${labelGravite} s'infecte (temps de guérison augmenté de ${definition.facteur} jours, perte de vie)`;
mergeObject(update, { fin: { indexDate: timestamp.addJours(gravite).indexDate } });
await actor.santeIncDec("vie", -1);
}
else {
if (!isMaladeEmpoisonne && rolled.isSuccess && this.peutRetrograder(graviteMoindre, moindres)) {
message.content += ` -- une blessure ${labelGravite} cicatrise`;
mergeObject(update, { gravite: graviteMoindre, fin: { indexDate: timestamp.addJours(graviteMoindre).indexDate } });
}
else {
message.content += ` -- une blessure ${labelGravite} reste stable`;
}
}
await this.update(update);
}
}
peutRetrograder(graviteMoindre, moindres) {
return moindres < RdDItemBlessure.getDefinition(graviteMoindre).max
}
async calculerFinPeriodeTemporel(debut) { async calculerFinPeriodeTemporel(debut) {
return await debut.nouveauJour().addJours(this.system.gravite); return await debut.nouveauJour().addJours(this.system.gravite);
} }
@ -61,34 +136,42 @@ export class RdDItemBlessure extends RdDItem {
} }
} }
prepareDerivedData() { getImgSoins(gravite, soins) {
super.prepareDerivedData(); let img = 'blessure'
this.system.labelGravite = this.getLabelGravite() if (gravite > 6) {
} img = 'mort'
}
async setSoinsBlessure(systemUpdate = {}) { if (gravite <= 0) {
systemUpdate = mergeObject(systemUpdate, this.system, { overwrite: false }), img = 'eraflure'
systemUpdate.soinscomplets.done = systemUpdate.premierssoins.done && systemUpdate.soinscomplets.done }
await this.update({ return `systems/foundryvtt-reve-de-dragon/icons/sante/${soins ? 'blessure-soins' : img}.webp`
img: this.getImgSoins(systemUpdate.soinscomplets.done),
system: systemUpdate
});
}
getImgSoins(soins) {
return `systems/foundryvtt-reve-de-dragon/icons/sante/${soins ? 'blessure-soins' : 'blessure'}.webp`
} }
getLabelGravite() { getLabelGravite() {
if (this.system.gravite >= 6) { return RdDItemBlessure.getDefinition(this.system.gravite).labelGravite
return 'Critique'
}
if (this.system.gravite >= 4) {
return 'Grave'
}
if (this.system.gravite >= 2) {
return 'Légère'
}
return 'Contusion/éraflure'
} }
}
static getDefinition(gravite) {
return definitionsBlessures.sort(Misc.ascending(it => it.gravite))
.find(it => it.gravite >= gravite);
}
static maxBlessures(gravite) {
return RdDItemBlessure.getDefinition(gravite).max
}
isContusion() {
return this.system.gravite <= 0
}
isLegere() {
return this.system.gravite > 0 && this.system.gravite <= 2
}
isGrave() {
return this.system.gravite > 2 && this.system.gravite <= 4
}
isCritique() {
return this.system.gravite > 4 && this.system.gravite <= 6
}
isMort() {
return this.system.gravite > 6
}
}

View File

@ -28,7 +28,7 @@ export class RdDBonus {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static dmg(rollData, dmgActor, isCauchemar = false) { static dmg(rollData, dmgActor, isEntiteIncarnee = false) {
let dmg = { total: 0 }; let dmg = { total: 0 };
if (rollData.arme && rollData.arme.name.toLowerCase() == "esquive") { if (rollData.arme && rollData.arme.name.toLowerCase() == "esquive") {
// Specific case management // Specific case management
@ -41,7 +41,7 @@ export class RdDBonus {
dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used); dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used);
dmg.dmgActor = rollData.selectedCarac ? RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac.label, dmg.dmgArme) : 0; dmg.dmgActor = rollData.selectedCarac ? RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac.label, dmg.dmgArme) : 0;
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere; dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere;
dmg.mortalite = RdDBonus._calculMortalite(rollData, isCauchemar) dmg.mortalite = RdDBonus._calculMortalite(rollData, isEntiteIncarnee)
} }
return dmg; return dmg;
} }
@ -62,11 +62,8 @@ export class RdDBonus {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _calculMortalite(rollData, isCauchemar) { static _calculMortalite(rollData, isEntiteIncarnee) {
if (isCauchemar) { return isEntiteIncarnee ? "entiteincarnee"
return "cauchemar";
}
return isCauchemar ? "cauchemar"
: rollData.dmg?.mortalite : rollData.dmg?.mortalite
?? rollData.arme?.system.mortalite ?? rollData.arme?.system.mortalite
?? "mortel"; ?? "mortel";

View File

@ -1295,13 +1295,8 @@ export class RdDCombat {
blessuresStatus: actor.computeResumeBlessure(), blessuresStatus: actor.computeResumeBlessure(),
SConst: actor.getSConst(), SConst: actor.getSConst(),
actorId: actor.id, actorId: actor.id,
isGrave: false, isGrave: actor.countBlessures(it => it.isGraves()) > 0,
isCritique: false isCritique: actor.countBlessures(it => it.isCritique()) > 0
}
if (actor.countBlessuresNonSoigneeByName("critiques") > 0) { // Pour éviter le cumul grave + critique
formData.isCritique = true;
} else if (actor.countBlessuresNonSoigneeByName("graves") > 0) {
formData.isGrave = true;
} }
ChatUtility.createChatWithRollMode(actor.name, { ChatUtility.createChatWithRollMode(actor.name, {

View File

@ -30,9 +30,9 @@ export class RdDEncaisser extends Dialog {
}; };
} }
else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])) { else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])) {
dialogConf.default = "cauchemar" dialogConf.default = "entiteincarnee"
dialogConf.buttons = { dialogConf.buttons = {
"cauchemar": { label: "Cauchemar", callback: html => this.performEncaisser("cauchemar") } "entiteincarnee": { label: "Entité incarnée", callback: html => this.performEncaisser("entiteincarnee") }
} }
} }
@ -70,7 +70,6 @@ export class RdDEncaisser extends Dialog {
total: Number(this.modifier), total: Number(this.modifier),
ajustement: Number(this.modifier), ajustement: Number(this.modifier),
encaisserSpecial: this.encaisserSpecial, encaisserSpecial: this.encaisserSpecial,
loc: { result: 0, label: "" },
mortalite: mortalite mortalite: mortalite
} }
}); });

View File

@ -88,10 +88,7 @@ export class RdDTokenHud {
static async addExtensionHudSoins(html, sourceActor) { static async addExtensionHudSoins(html, sourceActor) {
const target = Targets.getTarget({ warn: false }); const target = Targets.getTarget({ warn: false });
if (target?.actor) { if (target?.actor) {
const hudSoins = { const hudSoins = { blessures: target.actor.blessuresASoigner() ?? [] };
targetActor: target.actor,
blessures: target.actor.blessuresASoigner() ?? []
};
if (hudSoins.blessures.length > 0) { if (hudSoins.blessures.length > 0) {
// soins // soins
const controlIconTarget = html.find('.control-icon[data-action=combat]'); const controlIconTarget = html.find('.control-icon[data-action=combat]');

View File

@ -19,7 +19,7 @@ import { RdDRaretes } from "./item/raretes.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
// This table starts at 0 -> niveau -10 // This table starts at 0 -> niveau -10
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 = Misc.intArray(0, -11); const difficultesLibres = Misc.intArray(0, -11);
const ajustementsConditions = Misc.intArray(-10, 11); const ajustementsConditions = Misc.intArray(-10, 11);
const ajustementsEncaissement = Misc.intArray(-10, 26); const ajustementsEncaissement = Misc.intArray(-10, 26);
@ -66,38 +66,31 @@ const fatigueMarche = {
"tresdifficile": { "4": 4, "6": 6 } "tresdifficile": { "4": 4, "6": 6 }
} }
/* -------------------------------------------- */
const definitionsBlessures = [
{ type: "legere", facteur: 2 },
{ type: "grave", facteur: 4 },
{ type: "critique", facteur: 6 }
]
/* -------------------------------------------- */ /* -------------------------------------------- */
const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "Complètement fait", "Ivre mort"]; const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "Complètement fait", "Ivre mort"];
/* -------------------------------------------- */ /* -------------------------------------------- */
const definitionsEncaissement = { const definitionsEncaissement = {
"mortel": [ "mortel": [
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 }, { minimum: undefined, maximum: 0, endurance: "0", vie: "0", gravite: -1},
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", gravite: 0},
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 }, { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", gravite: 2},
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "2", eraflures: 0, legeres: 0, graves: 1, critiques: 0 }, { minimum: 16, maximum: 19, endurance: "2d6", vie: "2", gravite: 4},
{ minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", eraflures: 0, legeres: 0, graves: 0, critiques: 1 }, { minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", gravite: 6},
], ],
"non-mortel": [ "non-mortel": [
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 }, { minimum: undefined, maximum: 0, endurance: "0", vie: "0", gravite: -1},
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", gravite: 0 },
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", gravite: 0 },
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 }, { minimum: 16, maximum: 19, endurance: "2d6", vie: "0", gravite: 2 },
{ minimum: 20, maximum: undefined, endurance: "100", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 }, { minimum: 20, maximum: undefined, endurance: "100", vie: "0", gravite: 2 },
], ],
"cauchemar": [ "entiteincarnee": [
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 }, { minimum: undefined, maximum: 0, endurance: "0", vie: "0", gravite: -1},
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 1, maximum: 10, endurance: "1d4", vie: "0", gravite: 0},
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 11, maximum: 15, endurance: "1d6", vie: "0", gravite: 0 },
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 16, maximum: 19, endurance: "2d6", vie: "0", gravite: 0 },
{ minimum: 20, maximum: undefined, endurance: "3d6 + @over20", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 }, { minimum: 20, maximum: undefined, endurance: "3d6 + @over20", vie: "0", gravite: 0 },
] ]
}; };
@ -139,7 +132,6 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/combat.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/combat.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/blessures.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/blessures.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/blessure.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/blessure.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/blessure.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/maladies-poisons.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/maladies-poisons.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/possessions.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/possessions.html',
@ -474,10 +466,6 @@ export class RdDUtility {
return ajustementsEncaissement; return ajustementsEncaissement;
} }
static getDefinitionsBlessures() {
return definitionsBlessures;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static getSegmentsFatigue(maxEnd) { static getSegmentsFatigue(maxEnd) {
maxEnd = Math.max(maxEnd, 1); maxEnd = Math.max(maxEnd, 1);
@ -618,17 +606,10 @@ export class RdDUtility {
encaissement.dmg.loc.label = encaissement.dmg.loc.label ?? 'Corps;'; encaissement.dmg.loc.label = encaissement.dmg.loc.label ?? 'Corps;';
encaissement.roll = roll; encaissement.roll = roll;
encaissement.armure = armure; encaissement.armure = armure;
encaissement.penetration = rollData.arme?.system.penetration ?? 0;
encaissement.total = jetTotal; encaissement.total = jetTotal;
encaissement.vie = await RdDUtility._evaluatePerte(encaissement.vie, over20); encaissement.vie = await RdDUtility._evaluatePerte(encaissement.vie, over20);
encaissement.endurance = await RdDUtility._evaluatePerte(encaissement.endurance, over20); encaissement.endurance = await RdDUtility._evaluatePerte(encaissement.endurance, over20);
encaissement.penetration = rollData.arme?.system.penetration ?? 0;
encaissement.blessures = (
encaissement.critiques > 0 ? "Critique" :
encaissement.graves > 0 ? "Grave" :
encaissement.legeres > 0 ? "Légère" :
encaissement.eraflures > 0 ? "Contusions/Eraflures" :
'Aucune'
);
return encaissement; return encaissement;
} }

View File

@ -186,7 +186,7 @@ i:is(.fas, .far) {
} }
.system-foundryvtt-reve-de-dragon .sheet-header :is(.header-compteurs,.header-etats,.profile-img, .profile-img-token){ .system-foundryvtt-reve-de-dragon .sheet-header :is(.header-compteurs,.header-etats,.profile-img, .profile-img-token){
padding: 0 3%; padding: 0 0.4rem;
} }
.system-foundryvtt-reve-de-dragon .sheet-header :is(.profile-img, .profile-img-token) { .system-foundryvtt-reve-de-dragon .sheet-header :is(.profile-img, .profile-img-token) {
@ -213,11 +213,13 @@ i:is(.fas, .far) {
} }
.system-foundryvtt-reve-de-dragon .sheet-header .header-compteurs { .system-foundryvtt-reve-de-dragon .sheet-header .header-compteurs {
width: calc(60% - 110px - 1rem);
text-align: right; text-align: right;
max-width: fit-content; max-width: fit-content;
} }
.system-foundryvtt-reve-de-dragon .sheet-header div.header-etats { .system-foundryvtt-reve-de-dragon .sheet-header div.header-etats {
width: calc(40% - 32px - 1rem);
height: 48px; height: 48px;
max-width: fit-content; max-width: fit-content;
flex: initial; flex: initial;

View File

@ -179,7 +179,8 @@
"value": 10, "value": 10,
"label": "Endurance", "label": "Endurance",
"derivee": false "derivee": false
} },
"bonusPotion": 0
}, },
"attributs": { "attributs": {
"plusdom": { "plusdom": {
@ -364,7 +365,8 @@
"value": 0, "value": 0,
"label": "Fatigue", "label": "Fatigue",
"derivee": true "derivee": true
} },
"bonusPotion": 0
}, },
"attributs": { "attributs": {
"sconst": { "sconst": {

View File

@ -2,15 +2,18 @@
<span class="blessure-control"> <span class="blessure-control">
<img class="sheet-competence-img" src="{{img}}" /> <img class="sheet-competence-img" src="{{img}}" />
<i class="fas fa-skull-crossbones"></i> <i class="fas fa-skull-crossbones"></i>
{{system.labelGravite}} ({{system.localisation}}) {{system.labelGravite}}
</span> </span>
{{#if (gt system.gravite 6)}}
<span class="flexrow"></span>
<span class="flexrow"></span>
{{else}}
<span class="flexrow"> <span class="flexrow">
<input type="checkbox" class="blessure-premierssoins-done" name="blessure.{{id}}.premierssoins.done" {{#if system.premierssoins.done}}checked{{/if}}/> <input type="checkbox" class="blessure-premierssoins-done" name="blessure.{{id}}.premierssoins.done" {{#if system.premierssoins.done}}checked{{/if}}/>
{{#if system.premierssoins.done}} {{#if system.premierssoins.done}}
<input type="text" class="blessure-premierssoins-bonus number-x2" name="blessure.{{id}}.premierssoins.bonus" data-dtype="number" value="{{system.premierssoins.bonus}}"/> <input type="text" class="blessure-premierssoins-bonus number-x2" name="blessure.{{id}}.premierssoins.bonus" data-dtype="number" value="{{system.premierssoins.bonus}}"/>
{{else}} {{else}}
<label>{{system.premierssoins.tache}} / {{system.gravite}}</label> <label>{{system.premierssoins.tache}} / {{system.gravite}}</label>
{{/if}} {{/if}}
</span> </span>
<span class="flexrow"> <span class="flexrow">
@ -23,6 +26,10 @@
<label>Difficulté {{system.difficulte}}</label> <label>Difficulté {{system.difficulte}}</label>
{{/if}} {{/if}}
</span> </span>
{{/if}}
<span>
{{system.localisation}}
</span>
<span class="item-controls"> <span class="item-controls">
<a class="item-edit" title="Editer"><i class="fas fa-edit"></i></a> <a class="item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a> <a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>

View File

@ -1,27 +0,0 @@
<li class="item flexrow list-item {{#if blessure.active}}blessure-active-{{gravite}}{{else}}blessure-inactive{{/if}}"
data-blessure-type="{{gravite}}"
data-attribute={{key}}
data-blessure-index="{{key}}"
data-blessure-active="{{blessure.active}}">
<span class="blessure-control" title="Blessure {{title}}">
<i class="fas fa-skull-crossbones" name="blessure-{{gravite}}-{{key}}-active"></i>
{{title}}
</span>
{{#if blessure.active}}
<span class="blessure-soins flexrow">
<input class="blessure-psdone" name="blessure-{{gravite}}-{{key}}-psdone" type="checkbox" name="blessure.psdone" {{#if blessure.psdone}}checked{{/if}}/>
<input class="blessure-premiers_soins" type="text" name="blessure-{{gravite}}-{{key}}-premiers_soins" data-dtype="number" value="{{blessure.premiers_soins}}"/>
</span>
<span class="blessure-soins flexrow">
<input class="blessure-scdone" name="blessure-{{gravite}}-{{key}}-scdone" type="checkbox" name="blessure.scdone" {{#if blessure.scdone}}checked{{/if}}/>
<input class="blessure-soins_complets" type="text" name="blessure-{{gravite}}-{{key}}-soins_complets" data-dtype="number" value="{{blessure.soins_complets}}"/>
</span>
<input class="blessure-jours" type="text" name="blessure-{{gravite}}-{{key}}-jours" name="jours" data-dtype="number" value="{{blessure.jours}}"/>
<input class="blessure-localisation" type="text" name="blessure-{{gravite}}-{{key}}-localisation" data-dtype="String" value="{{blessure.loc}}"/>
{{else}}
<span></span>
<span></span>
<span></span>
<span></span>
{{/if}}
</li>

View File

@ -3,6 +3,7 @@
<span>Blessures</span> <span>Blessures</span>
<span>Premiers soins</span> <span>Premiers soins</span>
<span>Soins complets</span> <span>Soins complets</span>
<span>Loc.</span>
<span>Actions</span> <span>Actions</span>
</li> </li>
{{#each blessures as |blessure|}} {{#each blessures as |blessure|}}

View File

@ -1,4 +1,4 @@
<span> <div>
{{#if effects}} {{#if effects}}
{{#each effects as |effect key|}} {{#each effects as |effect key|}}
<span class="active-effect" data-effect="{{effect.flags.core.statusId}}"> <span class="active-effect" data-effect="{{effect.flags.core.statusId}}">
@ -9,4 +9,4 @@
{{else}} {{else}}
Aucun effet actif Aucun effet actif
{{/if}} {{/if}}
</span> </div>

View File

@ -1,8 +1,8 @@
<div class="flex-group-left header-etats"> <div class="flex-group-left header-etats">
<div class="flexcol"> <div class="flexcol">
<span>{{system.compteurs.etat.label}}: {{system.compteurs.etat.value}}</span> <div>{{system.compteurs.etat.label}}: {{system.compteurs.etat.value}}</div>
<span>Sur-encombrement: {{calc.surenc}}</span> <div>Sur-encombrement: {{calc.surenc}}</div>
<span>{{calc.resumeBlessures}}</span> <div>{{calc.resumeBlessures}}</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/header-effects.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/header-effects.html"}}
</div> </div>
</div> </div>

View File

@ -1,4 +1,5 @@
{{#if isGM}} {{#if isGM}}
{{log this}}
<span> <span>
{{#if (gt endurance 0)}} {{#if (gt endurance 0)}}
De plus, {{alias}} a perdu {{endurance}} points d'endurance De plus, {{alias}} a perdu {{endurance}} points d'endurance
@ -11,7 +12,7 @@
<span> <span>
{{numberFormat dmg.total decimals=0 sign=true}} {{numberFormat dmg.total decimals=0 sign=true}}
{{#if (eq dmg.mortalite 'non-mortel')~}}(coups non mortels) {{#if (eq dmg.mortalite 'non-mortel')~}}(coups non mortels)
{{~else if (eq dmg.mortalite 'cauchemar')}}(entité de cauchemar) {{~else if (eq dmg.mortalite 'entiteincarnee')}}(entité incarnée)
{{~/if}} {{~/if}}
</span> </span>
</h4> </h4>
@ -22,15 +23,16 @@
{{~/unless}}, total: <span class="rdd-roll-echec">{{total}}</span> {{~/unless}}, total: <span class="rdd-roll-echec">{{total}}</span>
<br> <br>
{{alias}} {{alias}}
{{#if (eq dmg.mortalite 'cauchemar')}}subit le coup {{#if (eq dmg.mortalite 'entiteincarnee')}}subit le coup
{{else if eraflures}}subit une contusion
{{else if legeres}}subit une blessure légère
{{else if graves}}subit une blessure grave
{{else if critiques}}subit une blessure critique
{{else if mort}}vient de mourir {{else if mort}}vient de mourir
{{else if blessure}}
{{#if (gt blessure.system.gravite 0)}}subit une blessure {{blessure.system.labelGravite}}
{{else}}subit une contusion
{{~/if~}}
{{else}}s'en sort sans une égratignure {{else}}s'en sort sans une égratignure
{{~/if~}} {{~/if~}}
{{~#unless (eq dmg.mortalite 'cauchemar')}}
{{~#unless (eq dmg.mortalite 'entiteincarnee')}}
{{#if dmg.loc.label}} {{#if dmg.loc.label}}
{{#if (gt roll.total 0)}}({{dmg.loc.label}}){{/if}} {{#if (gt roll.total 0)}}({{dmg.loc.label}}){{/if}}
{{/if}} {{/if}}
@ -39,7 +41,7 @@
{{~#if hasPlayerOwner}}, a perdu {{endurance}} points d'endurance {{~#if hasPlayerOwner}}, a perdu {{endurance}} points d'endurance
{{#if (ne vie 0)}}, <span class="rdd-roll-echec">{{vie}} points de vie</span>{{/if}} {{#if (ne vie 0)}}, <span class="rdd-roll-echec">{{vie}} points de vie</span>{{/if}}
{{/if}} {{/if}}
{{#if (ne dmg.mortalite 'cauchemar')}} {{#if (ne dmg.mortalite 'entiteincarnee')}}
{{#if (gt endurance 1)}}et {{#if (gt endurance 1)}}et
{{#if sonne}}est <strong>sonné</strong><img class="chat-icon" src="icons/svg/stoned.svg" alt="charge" height="16" width="16" /> jusqu'à la fin du prochain round{{else}}n'est pas sonné{{/if}}! {{#if sonne}}est <strong>sonné</strong><img class="chat-icon" src="icons/svg/stoned.svg" alt="charge" height="16" width="16" /> jusqu'à la fin du prochain round{{else}}n'est pas sonné{{/if}}!
{{#if hasPlayerOwner}}Jet d'endurance : Jet d'endurance : {{jetEndurance}} / {{resteEndurance}}{{/if}} {{#if hasPlayerOwner}}Jet d'endurance : Jet d'endurance : {{jetEndurance}} / {{resteEndurance}}{{/if}}

View File

@ -9,19 +9,19 @@
<option value="2">Légère</option> <option value="2">Légère</option>
<option value="4">Grave</option> <option value="4">Grave</option>
<option value="6">Critique</option> <option value="6">Critique</option>
<option value="8">Mort</option>
{{/select}} {{/select}}
</select> </select>
</div> </div>
<div class="form-group">
<label for="system.difficulte">Difficulté des soins</label>
<input class="attribute-value number-x" type="text" name="system.difficulte" value="{{system.difficulte}}" data-dtype="Number"/>
</div>
<div class="form-group"> <div class="form-group">
<label for="system.localisation">Localisation</label> <label for="system.localisation">Localisation</label>
<input class="attribute-value" type="text" name="system.localisation" value="{{system.localisation}}" data-dtype="String"/> <input class="attribute-value" type="text" name="system.localisation" value="{{system.localisation}}" data-dtype="String"/>
</div> </div>
{{#if (lt system.gravite 7)}}
<div class="form-group">
<label for="system.difficulte">Difficulté des soins</label>
<input class="attribute-value number-x" type="text" name="system.difficulte" value="{{system.difficulte}}" data-dtype="Number"/>
</div>
<div class="form-group"> <div class="form-group">
<label for="premierssoins-done">Premiers soins <label for="premierssoins-done">Premiers soins
@ -35,7 +35,7 @@
{{/if}} {{/if}}
</div> </div>
{{#if system.premierssoins.done}} {{#if system.premierssoins.done}}
<div class="form-group"> <div class="form-group">
<label for="soinscomplets-done">Soins complets <label for="soinscomplets-done">Soins complets
@ -46,6 +46,7 @@
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}
{{/if}}
{{#if options.isOwned}} {{#if options.isOwned}}
{{>"systems/foundryvtt-reve-de-dragon/templates/item/temporel.hbs" this labeldebut="Obtenue" labelfin="Prochain jet"}} {{>"systems/foundryvtt-reve-de-dragon/templates/item/temporel.hbs" this labeldebut="Obtenue" labelfin="Prochain jet"}}