Sonné est un StatusEffect
This commit is contained in:
parent
e74f6b14d3
commit
c857def360
@ -527,9 +527,6 @@ export class RdDActorSheet extends ActorSheet {
|
||||
html.find('#endurance-moins').click(async event => {
|
||||
this.actor.santeIncDec("endurance", -1);
|
||||
});
|
||||
html.find('.data-sante-sonne').click(async event => {
|
||||
this.actor.setSonne(event.currentTarget.checked);
|
||||
});
|
||||
html.find('#ptreve-actuel-plus').click(async event => {
|
||||
this.actor.reveActuelIncDec(1);
|
||||
});
|
||||
|
@ -428,7 +428,7 @@ export class RdDActor extends Actor {
|
||||
if (niveauSurprise > 1) {
|
||||
return 'totale';
|
||||
}
|
||||
if (niveauSurprise == 1 || this.getSonne()) {
|
||||
if (niveauSurprise == 1) {
|
||||
return 'demi';
|
||||
}
|
||||
return '';
|
||||
@ -1509,28 +1509,30 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSonneRound() {
|
||||
return Misc.templateData(this).sante.sonne?.round ?? -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async verifierSonneRound(round) {
|
||||
if (this.getSonne()) {
|
||||
if (round > this.getSonneRound() + 1) {
|
||||
await this.setSonne(false, -1); // Nettoyer l'état sonné
|
||||
ChatMessage.create({ content: `${this.name} n'est plus sonné ce round !` });
|
||||
async finDeRound(options = {terminer:false}) {
|
||||
for (let effect of this.getActiveEffects()) {
|
||||
if (effect.duration.type !== 'none' && (effect.duration.remaining <= 0 || options.terminer)) {
|
||||
if (effect.data.origin) {
|
||||
await effect.update({ 'disabled': true });
|
||||
}
|
||||
else {
|
||||
await effect.delete();
|
||||
}
|
||||
ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.data.label))} !` });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setSonne(sonne = true) {
|
||||
if (!game.combat || this.isEntiteCauchemar()) {
|
||||
if (this.isEntiteCauchemar()) {
|
||||
return;
|
||||
}
|
||||
await this.setStatusEffect("EFFECT.StatusStunned", sonne, {
|
||||
duration: (sonne && game.combat) ? { rounds: 2 } : undefined
|
||||
});
|
||||
if (!game.combat && sonne){
|
||||
ui.notifications.info("Le personnage est hors combat, il ne reste donc pas sonné");
|
||||
return;
|
||||
}
|
||||
await this.setStatusEffect("EFFECT.StatusStunned", sonne);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1557,12 +1559,11 @@ export class RdDActor extends Actor {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async testSiSonne(sante, endurance) {
|
||||
async testSiSonne(endurance) {
|
||||
const result = await this._jetEndurance(endurance);
|
||||
if (result.roll.total == 1) {
|
||||
ChatMessage.create({ content: await this._gainXpConstitutionJetEndurance() });
|
||||
}
|
||||
sante.sonne.value ||= result.sonne;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1631,7 +1632,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async santeIncDec(name, inc, options = { isCritique: false, ethylisme: false }) {
|
||||
async santeIncDec(name, inc, isCritique = false) {
|
||||
if (name == 'fatigue' && !ReglesOptionelles.isUsing("appliquer-fatigue")) {
|
||||
return;
|
||||
}
|
||||
@ -1650,7 +1651,7 @@ export class RdDActor extends Actor {
|
||||
//console.log("New value ", inc, minValue, result.newValue);
|
||||
let fatigue = 0;
|
||||
if (name == "endurance" && !this.isEntiteCauchemar()) {
|
||||
if (result.newValue == 0 && inc < 0 && !options.isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie
|
||||
if (result.newValue == 0 && inc < 0 && !isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie
|
||||
sante.vie.value--;
|
||||
result.perteVie = true;
|
||||
}
|
||||
@ -1660,14 +1661,13 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
const perte = compteur.value - result.newValue;
|
||||
result.perte = perte;
|
||||
if (perte > 1 && !options.ethylisme) {
|
||||
if (perte > 1) {
|
||||
// Peut-être sonné si 2 points d'endurance perdus d'un coup
|
||||
const testIsSonne = await this.testSiSonne(sante, result.newValue);
|
||||
const testIsSonne = await this.testSiSonne(result.newValue);
|
||||
result.sonne = testIsSonne.sonne;
|
||||
result.jetEndurance = testIsSonne.roll.total;
|
||||
} else if (inc > 0) {
|
||||
await this.setSonne(false);
|
||||
sante.sonne.value = false;
|
||||
}
|
||||
if (sante.fatigue && inc < 0) { // Each endurance lost -> fatigue lost
|
||||
fatigue = perte;
|
||||
@ -1934,7 +1934,7 @@ export class RdDActor extends Actor {
|
||||
ethylisme.nb_doses = 0;
|
||||
|
||||
let perte = await RdDDice.rollTotal("1d6", { showDice: true });
|
||||
ethylismeData.perteEndurance = await this.santeIncDec("endurance", -perte, { ethylisme: true });
|
||||
ethylismeData.perteEndurance = await this.santeIncDec("endurance", -perte);
|
||||
|
||||
if (!ethylisme.jet_moral) {
|
||||
ethylismeData.jetMoral = await this._jetMoral('heureuse');
|
||||
@ -3229,7 +3229,7 @@ export class RdDActor extends Actor {
|
||||
const perteVie = this.isEntiteCauchemar()
|
||||
? { newValue: 0 }
|
||||
: await this.santeIncDec("vie", - encaissement.vie);
|
||||
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, { critiques: encaissement.critiques > 0 });
|
||||
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, encaissement.critiques > 0);
|
||||
|
||||
this.computeEtatGeneral();
|
||||
|
||||
|
@ -13,6 +13,10 @@ export class Misc {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
static lowerFirst(text) {
|
||||
return text.charAt(0).toLowerCase() + text.slice(1);
|
||||
}
|
||||
|
||||
static toSignedString(number) {
|
||||
const value = parseInt(number)
|
||||
const isPositiveNumber = value != NaN && value > 0;
|
||||
|
@ -38,6 +38,9 @@ export class RdDCombatManager extends Combat {
|
||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||
RdDCombatManager.pushInitiativeOptions(html, options);
|
||||
});
|
||||
Hooks.on("preDeleteCombat", (combat, html, id) => {
|
||||
combat.onPreDeleteCombat()
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -48,10 +51,22 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
cleanSonne() {
|
||||
async nextRound() {
|
||||
this.cleanItemUse();
|
||||
await this.finDeRound();
|
||||
return await super.nextRound();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onPreDeleteCombat() {
|
||||
await this.finDeRound({ terminer: true });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async finDeRound(options = { terminer: false }) {
|
||||
for (let combatant of this.data.combatants) {
|
||||
if (combatant.actor) {
|
||||
combatant.actor.verifierSonneRound(this.current.round);
|
||||
await combatant.actor.finDeRound(options);
|
||||
}
|
||||
else {
|
||||
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
|
||||
@ -59,14 +74,6 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async nextRound() {
|
||||
//console.log('New round !');s
|
||||
this.cleanItemUse();
|
||||
this.cleanSonne();
|
||||
return super.nextRound();
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
|
||||
console.log(`${game.data.system.data.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
|
||||
|
@ -8,8 +8,9 @@ export class RdDEncaisser extends Dialog {
|
||||
constructor(html, actor) {
|
||||
// Common conf
|
||||
const buttonsCreatures = {
|
||||
"mortel": { label: "mortel", callback: html => this.performEncaisser("mortel") },
|
||||
"non-mortel": { label: "non-mortel", callback: html => this.performEncaisser("non-mortel") },
|
||||
"mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") },
|
||||
"non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") },
|
||||
"sonne": { label: "Sonné", callback: html => this.actor.setSonne() },
|
||||
};
|
||||
const buttonsEntitesCauchemar = {
|
||||
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") }
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
const rddStatusEffects = [
|
||||
{ rdd: true, id: 'stun', label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg' },
|
||||
{ rdd: true, id: 'stun', label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg', "duration.rounds": 1 },
|
||||
{ rdd: true, id: 'bleeding', label: 'EFFECT.StatusBleeding', icon: 'icons/svg/blood.svg' },
|
||||
{ rdd: true, id: 'prone', label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg' },
|
||||
{ rdd: true, id: 'grappling', tint: '#33cc33', label: 'EFFECT.StatusGrappling', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
||||
|
@ -164,11 +164,6 @@
|
||||
"value": 10,
|
||||
"label": "Endurance",
|
||||
"derivee": false
|
||||
},
|
||||
"sonne": {
|
||||
"value": false,
|
||||
"round": -1,
|
||||
"label": "Sonné"
|
||||
}
|
||||
},
|
||||
"blessures": {
|
||||
@ -374,10 +369,6 @@
|
||||
"value": 0,
|
||||
"label": "Fatigue",
|
||||
"derivee": true
|
||||
},
|
||||
"sonne": {
|
||||
"value": false,
|
||||
"label": "Sonné"
|
||||
}
|
||||
},
|
||||
"blessures": {
|
||||
|
@ -82,10 +82,6 @@
|
||||
<input type="text" name="data.sante.endurance.max" value="{{data.sante.endurance.max}}" data-dtype="Number" />
|
||||
</span>
|
||||
</li>
|
||||
<li class="flexrow list-item" data-attribute="sonne">
|
||||
<span class="competence-label" name="data.sante.sonne.label">Sonné</span>
|
||||
<input type="checkbox" name="data.sante.sonne.value" value="{{data.sante.sonne.value}}" {{#if data.sante.sonne.value}}checked{{/if}} />
|
||||
</li>
|
||||
<li class="flexrow list-item" data-attribute="etat">
|
||||
<span class="competence-label" name="data.compteurs.etat.label">Etat Général</span>
|
||||
<input type="text" value="{{data.compteurs.etat.value}}" disabled />
|
||||
|
@ -37,12 +37,6 @@
|
||||
<a id="fatigue-plus">+</a>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="ctn-sonne">
|
||||
Sonné :
|
||||
<input class="resource-content data-sante-sonne" type="checkbox" {{#if data.sante.sonne.value}}checked{{/if}} />
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="ctn-reve">
|
||||
<span class="ptreve-actuel"><a>Rêve</a></span>
|
||||
|
Loading…
Reference in New Issue
Block a user