Ajout tirage de la force des rencontres avec /tmrr, ajout de bouton pour appliquer complètement les blessures

This commit is contained in:
LeRatierBretonnien 2024-01-28 20:41:00 +01:00
parent f7eae3ac1e
commit 34183cd1a7
5 changed files with 53 additions and 8 deletions

View File

@ -21,6 +21,11 @@ export class RdDBaseActorSangSheet extends RdDBaseActorReveSheet {
this.html.find('.creer-blessure-grave').click(async event => RdDItemBlessure.createBlessure(this.actor, 4)); this.html.find('.creer-blessure-grave').click(async event => RdDItemBlessure.createBlessure(this.actor, 4));
this.html.find('.creer-blessure-critique').click(async event => RdDItemBlessure.createBlessure(this.actor, 6)); this.html.find('.creer-blessure-critique').click(async event => RdDItemBlessure.createBlessure(this.actor, 6));
this.html.find('.subir-blessure-contusion').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 2));
this.html.find('.subir-blessure-legere').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 2));
this.html.find('.subir-blessure-grave').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 4));
this.html.find('.subir-blessure-critique').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 6));
this.html.find('.jet-vie').click(async event => this.actor.jetDeVie()) this.html.find('.jet-vie').click(async event => this.actor.jetDeVie())
this.html.find('.jet-endurance').click(async event => await this.jetEndurance()) this.html.find('.jet-endurance').click(async event => await this.jetEndurance())

View File

@ -1,6 +1,7 @@
import { RdDItem } from "../item.js"; import { RdDItem } from "../item.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDTimestamp } from "../time/rdd-timestamp.js"; import { RdDTimestamp } from "../time/rdd-timestamp.js";
import { ChatUtility } from "../chat-utility.js";
const BASE_TACHE_SOIN_BLESSURE = { const BASE_TACHE_SOIN_BLESSURE = {
type: "tache", type: "tache",
@ -14,10 +15,10 @@ const TACHES_SOIN_BLESSURE = {
} }
const definitionsBlessures = [ const definitionsBlessures = [
{ type: "contusion", gravite: 0, label: 'Contusion/éraflure', max: 100, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/eraflure.webp" }, { type: "contusion", gravite: 0, endurance: "1d4", vie: 0, label: 'Contusion/éraflure', max: 100, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/eraflure.webp" },
{ type: "legere", gravite: 2, label: 'Légère', max: 5, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" }, { type: "legere", gravite: 2, endurance: "1d6", vie: 0, label: 'Légère', max: 5, 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: "grave", gravite: 4, endurance: "2d6", vie: -2, label: 'Grave', max: 2, 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: "critique", gravite: 6, endurance: "-100", vie: -4, label: 'Critique', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "mort", gravite: 8, label: '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" }
] ]
@ -40,6 +41,32 @@ export class RdDItemBlessure extends RdDItem {
} }
return mergeObject(duplicate(BASE_TACHE_SOIN_BLESSURE), tache) return mergeObject(duplicate(BASE_TACHE_SOIN_BLESSURE), tache)
} }
static async applyFullBlessure(actor, gravite) {
const definition = RdDItemBlessure.getDefinition(gravite)
let lostEndurance = 0
let lostVie = 0
if (definition.endurance) {
lostEndurance = new Roll(definition.endurance).roll({async: false}).total;
actor.santeIncDec("endurance", -Number(lostEndurance));
}
if (definition.vie) {
lostVie = definition.vie
actor.santeIncDec("vie", definition.vie)
}
await this.createBlessure(actor, gravite)
ChatMessage.create({
content: `Blessure ${definition.label} appliquée à ${actor.name}`+
`<br>Perte d'endurance : ${lostEndurance}`+
`<br>Perte de Vie : ${lostVie}`,
whisper: ChatUtility.getWhisperRecipientsAndGMs(actor.name)
});
}
static async createBlessure(actor, gravite, localisation = '', attacker) { static async createBlessure(actor, gravite, localisation = '', attacker) {
const definition = RdDItemBlessure.getDefinition(gravite) const definition = RdDItemBlessure.getDefinition(gravite)
const blessure = { const blessure = {

View File

@ -39,6 +39,8 @@ export class TMRRencontres {
const frequence = it => it.system.frequence[codeTerrain]; const frequence = it => it.system.frequence[codeTerrain];
const row = await this.table.getRandom(frequence, filtreMauvaise, forcedRoll); const row = await this.table.getRandom(frequence, filtreMauvaise, forcedRoll);
if (row) { if (row) {
console.log("DORM", row);
//row.document.system.computedForce = new Roll(row.document.system.formula).roll({async: false}).total;
await CompendiumTableHelpers.tableRowToChatMessage(row); await CompendiumTableHelpers.tableRowToChatMessage(row);
} }

View File

@ -1,8 +1,14 @@
<h4>blessures</h4> <h4>Blessures</h4>
<div> <div>
<a class="chat-card-button creer-blessure-legere" data-tooltip="Ajouter une blessure légère"><i class="fas fa-plus-circle"></i> légère</a> <a class="chat-card-button creer-blessure-legere" data-tooltip="Ajouter une légère"><i class="fas fa-plus-circle"></i> légère</a>
<a class="chat-card-button creer-blessure-grave" data-tooltip="Ajouter une blessure grave"><i class="fas fa-plus-circle"></i> grave</a> <a class="chat-card-button creer-blessure-grave" data-tooltip="Ajouter une grave"><i class="fas fa-plus-circle"></i> grave</a>
<a class="chat-card-button creer-blessure-critique" data-tooltip="Ajouter une blessure critque"><i class="fas fa-plus-circle"></i> critique</a> <a class="chat-card-button creer-blessure-critique" data-tooltip="Ajouter une critique"><i class="fas fa-plus-circle"></i> critique</a>
</div>
<div>
<a class="chat-card-button subir-blessure-contusion" data-tooltip="Subir une contusion (avec perte d'Endurance)"><i class="fas fa-swords"></i> contusion</a>
<a class="chat-card-button subir-blessure-legere" data-tooltip="Subir une légère (avec perte d'Endurance)"><i class="fas fa-swords"></i> légère</a>
<a class="chat-card-button subir-blessure-grave" data-tooltip="Subir une grave (avec perte d'Endurance/Vie)"><i class="fas fa-swords"></i> grave</a>
<a class="chat-card-button subir-blessure-critique" data-tooltip="Subir une critique (avec perte d'Endurance/Vie)"><i class="fas fa-swords"></i> critique</a>
</div> </div>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">

View File

@ -5,6 +5,11 @@
<div> <div>
<img class="chat-icon" src="{{document.img}}" data-tooltip="{{document.name}}" /> <img class="chat-icon" src="{{document.img}}" data-tooltip="{{document.name}}" />
<p>{{linkCompendium document.pack document.id document.name}}</p> <p>{{linkCompendium document.pack document.id document.name}}</p>
{{#if document.system.formule}}
<div class="poesie-extrait">
[[/r {{document.system.formule}}]]
</div>
{{/if}}
{{#if document.system.description}} {{#if document.system.description}}
<div class="poesie-extrait"> <div class="poesie-extrait">
{{{document.system.description}}} {{{document.system.description}}}