Ajout de l'origine d'une blessure
En combat, indication de l'origine des blessures
This commit is contained in:
parent
9cf14f8b75
commit
c57f140c54
@ -3209,10 +3209,6 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.validerEncaissement(rollData, show);
|
|
||||||
}
|
|
||||||
|
|
||||||
async validerEncaissement(rollData, show) {
|
|
||||||
if (ReglesOptionelles.isUsing('validation-encaissement-gr') && !game.user.isGM) {
|
if (ReglesOptionelles.isUsing('validation-encaissement-gr') && !game.user.isGM) {
|
||||||
RdDBaseActor.remoteActorCall({
|
RdDBaseActor.remoteActorCall({
|
||||||
actorId: this.id,
|
actorId: this.id,
|
||||||
@ -3223,18 +3219,18 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
const armure = await this.computeArmure(rollData);
|
const armure = await this.computeArmure(rollData);
|
||||||
if (ReglesOptionelles.isUsing('validation-encaissement-gr')) {
|
if (ReglesOptionelles.isUsing('validation-encaissement-gr')) {
|
||||||
DialogValidationEncaissement.validerEncaissement(this, rollData, armure, show, (encaissement, show) => this._appliquerEncaissement(encaissement, show));
|
DialogValidationEncaissement.validerEncaissement(this, rollData, armure, show, (encaissement, show) => this._appliquerEncaissement(encaissement, show, attacker));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: SHOW_DICE });
|
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: SHOW_DICE });
|
||||||
await this._appliquerEncaissement(encaissement, show)
|
await this._appliquerEncaissement(encaissement, show, attacker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _appliquerEncaissement(encaissement, show) {
|
async _appliquerEncaissement(encaissement, show, attacker) {
|
||||||
let santeOrig = duplicate(this.system.sante);
|
let santeOrig = duplicate(this.system.sante);
|
||||||
|
|
||||||
const blessure = await this.ajouterBlessure(encaissement); // Will upate the result table
|
const blessure = await this.ajouterBlessure(encaissement, attacker); // Will update 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);
|
||||||
@ -3268,7 +3264,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async ajouterBlessure(encaissement) {
|
async ajouterBlessure(encaissement, attacker = undefined) {
|
||||||
if (this.isEntite()) return; // Une entité n'a pas de blessures
|
if (this.isEntite()) return; // Une entité n'a pas de blessures
|
||||||
if (encaissement.gravite < 0) return;
|
if (encaissement.gravite < 0) return;
|
||||||
if (encaissement.gravite > 0) {
|
if (encaissement.gravite > 0) {
|
||||||
@ -3281,7 +3277,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const endActuelle = Number(this.system.sante.endurance.value);
|
const endActuelle = Number(this.system.sante.endurance.value);
|
||||||
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg.loc.label);
|
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg.loc.label, attacker);
|
||||||
if (blessure.isCritique()) {
|
if (blessure.isCritique()) {
|
||||||
encaissement.endurance = endActuelle;
|
encaissement.endurance = endActuelle;
|
||||||
}
|
}
|
||||||
@ -3534,7 +3530,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
for (let blessure of blessures) {
|
for (let blessure of blessures) {
|
||||||
if (pointsGuerison >= blessure.system.gravite) {
|
if (pointsGuerison >= blessure.system.gravite) {
|
||||||
pointsGuerison -= blessure.system.gravite;
|
pointsGuerison -= blessure.system.gravite;
|
||||||
guerisonData.list.push(`1 Blessure ${blessure.system.labelGravite} (${blessure.system.gravite} points)`);
|
guerisonData.list.push(`1 Blessure ${blessure.system.label} (${blessure.system.gravite} points)`);
|
||||||
ids.push(blessure.id)
|
ids.push(blessure.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export class DialogValidationEncaissement extends Dialog {
|
|||||||
constructor(html, actor, rollData, armure, encaissement, show, onEncaisser) {
|
constructor(html, actor, rollData, armure, encaissement, show, onEncaisser) {
|
||||||
// Common conf
|
// Common conf
|
||||||
let buttons = {
|
let buttons = {
|
||||||
"valider": { label: "Valider", callback: html => this.validerEncaissement() },
|
"valider": { label: "Valider", callback: html => this.onValider() },
|
||||||
"annuler": { label: "Annuler", callback: html => { } },
|
"annuler": { label: "Annuler", callback: html => { } },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export class DialogValidationEncaissement extends Dialog {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async validerEncaissement() {
|
async onValider() {
|
||||||
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: SHOW_DICE, forceDiceResult: this.forceDiceResult});
|
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: SHOW_DICE, forceDiceResult: this.forceDiceResult});
|
||||||
this.onEncaisser(this.encaissement, this.show)
|
this.onEncaisser(this.encaissement, this.show)
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ const TACHES_SOIN_BLESSURE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const definitionsBlessures = [
|
const definitionsBlessures = [
|
||||||
{ type: "contusion", gravite: 0, labelGravite: 'Contusion/éraflure', max: 100, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/eraflure.webp" },
|
{ type: "contusion", gravite: 0, label: '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: "legere", gravite: 2, label: '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: "grave", gravite: 4, label: '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: "critique", gravite: 6, label: '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" }
|
{ type: "mort", gravite: 8, label: 'Mort', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/mort.webp" }
|
||||||
]
|
]
|
||||||
|
|
||||||
export class RdDItemBlessure extends RdDItem {
|
export class RdDItemBlessure extends RdDItem {
|
||||||
@ -29,7 +29,7 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
|
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
super.prepareDerivedData();
|
super.prepareDerivedData();
|
||||||
this.system.labelGravite = this.getLabelGravite()
|
this.system.label = this.getLabelGravite()
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareTacheSoin(gravite) {
|
static prepareTacheSoin(gravite) {
|
||||||
@ -40,19 +40,19 @@ 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 = '') {
|
static async createBlessure(actor, gravite, localisation = '', attacker) {
|
||||||
const definition = RdDItemBlessure.getDefinition(gravite)
|
const definition = RdDItemBlessure.getDefinition(gravite)
|
||||||
const blessure = {
|
const blessure = {
|
||||||
name: definition.labelGravite,
|
name: definition.label,
|
||||||
type: 'blessure',
|
type: 'blessure',
|
||||||
img: definition.icon,
|
img: definition.icon,
|
||||||
system: {
|
system: {
|
||||||
gravite: gravite,
|
gravite: gravite,
|
||||||
difficulte: - gravite,
|
difficulte: - gravite,
|
||||||
localisation: localisation
|
localisation: localisation,
|
||||||
|
origine: attacker?.name ?? ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const blessures = await actor.createEmbeddedDocuments('Item', [blessure])
|
const blessures = await actor.createEmbeddedDocuments('Item', [blessure])
|
||||||
return blessures[0]
|
return blessures[0]
|
||||||
}
|
}
|
||||||
@ -100,12 +100,12 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
const gravite = this.system.gravite;
|
const gravite = this.system.gravite;
|
||||||
const graviteMoindre = gravite - 2;
|
const graviteMoindre = gravite - 2;
|
||||||
const moindres = blessures.filter(it => it.system.gravite == graviteMoindre, 'blessures').length
|
const moindres = blessures.filter(it => it.system.gravite == graviteMoindre, 'blessures').length
|
||||||
const labelGravite = this.getLabelGravite();
|
const label = this.getLabelGravite();
|
||||||
|
|
||||||
let rolled = await actor.jetRecuperationConstitution(this.system.soinscomplets.bonus, message);
|
let rolled = await actor.jetRecuperationConstitution(this.system.soinscomplets.bonus, message);
|
||||||
|
|
||||||
if (rolled.isETotal) {
|
if (rolled.isETotal) {
|
||||||
message.content += ` -- une blessure ${labelGravite} s'infecte (temps de guérison augmenté de ${gravite} jours, perte de vie)`;
|
message.content += ` -- une blessure ${label} s'infecte (temps de guérison augmenté de ${gravite} jours, perte de vie)`;
|
||||||
await actor.santeIncDec("vie", -1);
|
await actor.santeIncDec("vie", -1);
|
||||||
mergeObject(update, {
|
mergeObject(update, {
|
||||||
system: { fin: { indexDate: timestamp.addJours(gravite).indexDate } }
|
system: { fin: { indexDate: timestamp.addJours(gravite).indexDate } }
|
||||||
@ -113,13 +113,13 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!isMaladeEmpoisonne && rolled.isSuccess && this.peutRetrograder(graviteMoindre, moindres)) {
|
if (!isMaladeEmpoisonne && rolled.isSuccess && this.peutRetrograder(graviteMoindre, moindres)) {
|
||||||
message.content += ` -- une blessure ${labelGravite} cicatrise`;
|
message.content += ` -- une blessure ${label} cicatrise`;
|
||||||
mergeObject(update, {
|
mergeObject(update, {
|
||||||
system: { gravite: graviteMoindre, fin: { indexDate: timestamp.addJours(graviteMoindre).indexDate } }
|
system: { gravite: graviteMoindre, fin: { indexDate: timestamp.addJours(graviteMoindre).indexDate } }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message.content += ` -- une blessure ${labelGravite} reste stable`;
|
message.content += ` -- une blessure ${label} reste stable`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.update(update);
|
await this.update(update);
|
||||||
@ -152,7 +152,7 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getLabelGravite() {
|
getLabelGravite() {
|
||||||
return RdDItemBlessure.getDefinition(this.system.gravite).labelGravite
|
return RdDItemBlessure.getDefinition(this.system.gravite).label
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDefinition(gravite) {
|
static getDefinition(gravite) {
|
||||||
@ -178,4 +178,22 @@ export class RdDItemBlessure extends RdDItem {
|
|||||||
isMort() {
|
isMort() {
|
||||||
return this.system.gravite > 6
|
return this.system.gravite > 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getProprietes() {
|
||||||
|
return [
|
||||||
|
RdDItem.propertyIfDefined('Causée par', this.system.origine, this.system.origine),
|
||||||
|
`<b>Heure et Date</b>: ${new RdDTimestamp(this.system.temporel.debut).formatDateHeure()}`,
|
||||||
|
RdDItem.propertyIfDefined('Blessé', this.parent?.name, this.parent),
|
||||||
|
`<b>Localisation</b>: ${this.system.localisation}`,
|
||||||
|
`<b>Gravité</b>: ${RdDItemBlessure.getDefinition(this.system.gravite).label}`,
|
||||||
|
`<b>Difficulté des soins</b>: ${this.system.difficulte}`,
|
||||||
|
(this.system.soinscomplets.done ?
|
||||||
|
`<b>Bonus soins complets</b>: ${this.system.soinscomplets.bonus}` :
|
||||||
|
(this.system.premierssoins.done ?
|
||||||
|
`<b>Bonus premiers soins</b>: ${this.system.premierssoins.bonus}` :
|
||||||
|
`<b>Points de tâche</b>: ${this.system.premierssoins.tache}`
|
||||||
|
)
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,8 +452,7 @@ class _10_7_0_MigrationBlessures extends Migration {
|
|||||||
fin: { indexDate: datePremiereRecup.indexDate, indexMinute: 0 },
|
fin: { indexDate: datePremiereRecup.indexDate, indexMinute: 0 },
|
||||||
premierssoins: { done: blessure.psdone, bonus: blessure.premiers_soins },
|
premierssoins: { done: blessure.psdone, bonus: blessure.premiers_soins },
|
||||||
soinscomplets: { done: blessure.scdone, bonus: blessure.soins_complets },
|
soinscomplets: { done: blessure.scdone, bonus: blessure.soins_complets },
|
||||||
localisation: blessure.localisation,
|
localisation: blessure.localisation
|
||||||
jours: blessure.jours
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,15 @@ export class RdDTimestamp {
|
|||||||
this.indexMinute = indexMinute ?? 0
|
this.indexMinute = indexMinute ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) }
|
||||||
|
get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) }
|
||||||
|
get jour() { return (this.indexDate % RDD_JOURS_PAR_AN) % RDD_JOURS_PAR_MOIS }
|
||||||
|
get heure() { return Math.floor(this.indexMinute / RDD_MINUTES_PAR_HEURES) }
|
||||||
|
get minute() { return this.indexMinute % RDD_MINUTES_PAR_HEURES }
|
||||||
|
get round() { return ROUNDS_PAR_MINUTE * (this.indexMinute - Math.floor(this.indexMinute)) }
|
||||||
|
get angleHeure() { return this.indexMinute / RDD_MINUTES_PAR_JOUR * 360 - 45 }
|
||||||
|
get angleMinute() { return this.indexMinute / RDD_MINUTES_PAR_HEURES * 360 + 45 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convertit le timestamp en une structure avec les informations utiles
|
* Convertit le timestamp en une structure avec les informations utiles
|
||||||
* pour afficher la date et l'heure
|
* pour afficher la date et l'heure
|
||||||
@ -244,15 +253,6 @@ export class RdDTimestamp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) }
|
|
||||||
get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) }
|
|
||||||
get jour() { return (this.indexDate % RDD_JOURS_PAR_AN) % RDD_JOURS_PAR_MOIS }
|
|
||||||
get heure() { return Math.floor(this.indexMinute / RDD_MINUTES_PAR_HEURES) }
|
|
||||||
get minute() { return this.indexMinute % RDD_MINUTES_PAR_HEURES }
|
|
||||||
get round() { return ROUNDS_PAR_MINUTE * (this.indexMinute - Math.floor(this.indexMinute)) }
|
|
||||||
get angleHeure() { return this.indexMinute / RDD_MINUTES_PAR_JOUR * 360 - 45 }
|
|
||||||
get angleMinute() { return this.indexMinute / RDD_MINUTES_PAR_HEURES * 360 + 45}
|
|
||||||
|
|
||||||
formatDate() {
|
formatDate() {
|
||||||
const jour = this.jour + 1;
|
const jour = this.jour + 1;
|
||||||
const mois = RdDTimestamp.definition(this.mois).label;
|
const mois = RdDTimestamp.definition(this.mois).label;
|
||||||
@ -260,6 +260,10 @@ export class RdDTimestamp {
|
|||||||
return `${jour} ${mois}` + (annee ? ' ' + annee : '');
|
return `${jour} ${mois}` + (annee ? ' ' + annee : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formatDateHeure() {
|
||||||
|
return `${RdDTimestamp.definition(this.heure).label}, ${this.formatDate()}`;
|
||||||
|
}
|
||||||
|
|
||||||
nouveauJour() { return new RdDTimestamp({ indexDate: this.indexDate + 1, indexMinute: 0 }) }
|
nouveauJour() { return new RdDTimestamp({ indexDate: this.indexDate + 1, indexMinute: 0 }) }
|
||||||
|
|
||||||
nouvelleHeure() {
|
nouvelleHeure() {
|
||||||
|
@ -620,7 +620,7 @@
|
|||||||
"bonus": 0
|
"bonus": 0
|
||||||
},
|
},
|
||||||
"localisation": "",
|
"localisation": "",
|
||||||
"jours": 0
|
"origine": ""
|
||||||
},
|
},
|
||||||
"maladie": {
|
"maladie": {
|
||||||
"templates": ["description", "temporel"],
|
"templates": ["description", "temporel"],
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<li class="item item-blessure flexrow list-item blessure-active-{{lowercase system.labelGravite}}" data-item-id="{{id}}">
|
<li class="item item-blessure flexrow list-item blessure-active-{{lowercase system.label}}" data-item-id="{{id}}">
|
||||||
<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.label}}
|
||||||
</span>
|
</span>
|
||||||
{{#if (gt system.gravite 6)}}
|
{{#if (gt system.gravite 6)}}
|
||||||
<span class="flexrow"></span>
|
<span class="flexrow"></span>
|
||||||
@ -30,7 +30,8 @@
|
|||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span>
|
<span>
|
||||||
{{system.localisation}}
|
{{#if system.origine}}<span>Par {{system.origine}}</span>{{/if}}
|
||||||
|
{{#if system.localisation}}<span>{{system.localisation}}</span>{{/if}}
|
||||||
</span>
|
</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>
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
<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>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="system.origine">Causée par</label>
|
||||||
|
<input class="attribute-value" type="text" name="system.origine" value="{{system.origine}}" data-dtype="String"/>
|
||||||
|
</div>
|
||||||
{{#if (lt system.gravite 7)}}
|
{{#if (lt system.gravite 7)}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="system.difficulte">Difficulté des soins</label>
|
<label for="system.difficulte">Difficulté des soins</label>
|
||||||
@ -35,7 +39,6 @@
|
|||||||
<label for="system.premierssoins.tache">Points de tâches</label>
|
<label for="system.premierssoins.tache">Points de tâches</label>
|
||||||
<input class="attribute-value number-x" type="text" name="system.premierssoins.tache" value="{{system.premierssoins.tache}}" data-dtype="Number"/>
|
<input class="attribute-value number-x" type="text" name="system.premierssoins.tache" value="{{system.premierssoins.tache}}" data-dtype="Number"/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if system.premierssoins.done}}
|
{{#if system.premierssoins.done}}
|
||||||
|
Loading…
Reference in New Issue
Block a user