Sonné est un StatusEffect

This commit is contained in:
Vincent Vandemeulebrouck 2021-06-30 01:01:24 +02:00
parent e74f6b14d3
commit c857def360
9 changed files with 49 additions and 59 deletions

View File

@ -527,9 +527,6 @@ export class RdDActorSheet extends ActorSheet {
html.find('#endurance-moins').click(async event => { html.find('#endurance-moins').click(async event => {
this.actor.santeIncDec("endurance", -1); 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 => { html.find('#ptreve-actuel-plus').click(async event => {
this.actor.reveActuelIncDec(1); this.actor.reveActuelIncDec(1);
}); });

View File

@ -428,7 +428,7 @@ export class RdDActor extends Actor {
if (niveauSurprise > 1) { if (niveauSurprise > 1) {
return 'totale'; return 'totale';
} }
if (niveauSurprise == 1 || this.getSonne()) { if (niveauSurprise == 1) {
return 'demi'; return 'demi';
} }
return ''; return '';
@ -1509,28 +1509,30 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getSonneRound() { async finDeRound(options = {terminer:false}) {
return Misc.templateData(this).sante.sonne?.round ?? -1; 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 });
async verifierSonneRound(round) { }
if (this.getSonne()) { else {
if (round > this.getSonneRound() + 1) { await effect.delete();
await this.setSonne(false, -1); // Nettoyer l'état sonné }
ChatMessage.create({ content: `${this.name} n'est plus sonné ce round !` }); ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.data.label))} !` });
} }
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async setSonne(sonne = true) { async setSonne(sonne = true) {
if (!game.combat || this.isEntiteCauchemar()) { if (this.isEntiteCauchemar()) {
return; return;
} }
await this.setStatusEffect("EFFECT.StatusStunned", sonne, { if (!game.combat && sonne){
duration: (sonne && game.combat) ? { rounds: 2 } : undefined 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); const result = await this._jetEndurance(endurance);
if (result.roll.total == 1) { if (result.roll.total == 1) {
ChatMessage.create({ content: await this._gainXpConstitutionJetEndurance() }); ChatMessage.create({ content: await this._gainXpConstitutionJetEndurance() });
} }
sante.sonne.value ||= result.sonne;
return result; 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")) { if (name == 'fatigue' && !ReglesOptionelles.isUsing("appliquer-fatigue")) {
return; return;
} }
@ -1650,7 +1651,7 @@ export class RdDActor extends Actor {
//console.log("New value ", inc, minValue, result.newValue); //console.log("New value ", inc, minValue, result.newValue);
let fatigue = 0; let fatigue = 0;
if (name == "endurance" && !this.isEntiteCauchemar()) { 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--; sante.vie.value--;
result.perteVie = true; result.perteVie = true;
} }
@ -1660,14 +1661,13 @@ export class RdDActor extends Actor {
} }
const perte = compteur.value - result.newValue; const perte = compteur.value - result.newValue;
result.perte = perte; result.perte = perte;
if (perte > 1 && !options.ethylisme) { if (perte > 1) {
// Peut-être sonné si 2 points d'endurance perdus d'un coup // 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.sonne = testIsSonne.sonne;
result.jetEndurance = testIsSonne.roll.total; result.jetEndurance = testIsSonne.roll.total;
} else if (inc > 0) { } else if (inc > 0) {
await this.setSonne(false); await this.setSonne(false);
sante.sonne.value = false;
} }
if (sante.fatigue && inc < 0) { // Each endurance lost -> fatigue lost if (sante.fatigue && inc < 0) { // Each endurance lost -> fatigue lost
fatigue = perte; fatigue = perte;
@ -1934,7 +1934,7 @@ export class RdDActor extends Actor {
ethylisme.nb_doses = 0; ethylisme.nb_doses = 0;
let perte = await RdDDice.rollTotal("1d6", { showDice: true }); 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) { if (!ethylisme.jet_moral) {
ethylismeData.jetMoral = await this._jetMoral('heureuse'); ethylismeData.jetMoral = await this._jetMoral('heureuse');
@ -3229,7 +3229,7 @@ export class RdDActor extends Actor {
const perteVie = this.isEntiteCauchemar() const perteVie = this.isEntiteCauchemar()
? { newValue: 0 } ? { newValue: 0 }
: await this.santeIncDec("vie", - encaissement.vie); : 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(); this.computeEtatGeneral();

View File

@ -13,6 +13,10 @@ export class Misc {
return text.charAt(0).toUpperCase() + text.slice(1); return text.charAt(0).toUpperCase() + text.slice(1);
} }
static lowerFirst(text) {
return text.charAt(0).toLowerCase() + text.slice(1);
}
static toSignedString(number) { static toSignedString(number) {
const value = parseInt(number) const value = parseInt(number)
const isPositiveNumber = value != NaN && value > 0; const isPositiveNumber = value != NaN && value > 0;

View File

@ -38,6 +38,9 @@ export class RdDCombatManager extends Combat {
Hooks.on("getCombatTrackerEntryContext", (html, options) => { Hooks.on("getCombatTrackerEntryContext", (html, options) => {
RdDCombatManager.pushInitiativeOptions(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) { for (let combatant of this.data.combatants) {
if (combatant.actor) { if (combatant.actor) {
combatant.actor.verifierSonneRound(this.current.round); await combatant.actor.finDeRound(options);
} }
else { else {
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`) 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 = {}) { async rollInitiative(ids, formula = undefined, messageOptions = {}) {
console.log(`${game.data.system.data.title} | Combat.rollInitiative()`, ids, formula, messageOptions); console.log(`${game.data.system.data.title} | Combat.rollInitiative()`, ids, formula, messageOptions);

View File

@ -8,8 +8,9 @@ export class RdDEncaisser extends Dialog {
constructor(html, actor) { constructor(html, actor) {
// Common conf // Common conf
const buttonsCreatures = { const buttonsCreatures = {
"mortel": { label: "mortel", callback: html => this.performEncaisser("mortel") }, "mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") },
"non-mortel": { label: "non-mortel", callback: html => this.performEncaisser("non-mortel") }, "non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") },
"sonne": { label: "Sonné", callback: html => this.actor.setSonne() },
}; };
const buttonsEntitesCauchemar = { const buttonsEntitesCauchemar = {
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") } "cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") }

View File

@ -1,6 +1,6 @@
const rddStatusEffects = [ 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: 'bleeding', label: 'EFFECT.StatusBleeding', icon: 'icons/svg/blood.svg' },
{ rdd: true, id: 'prone', label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.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' }, { rdd: true, id: 'grappling', tint: '#33cc33', label: 'EFFECT.StatusGrappling', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },

View File

@ -164,11 +164,6 @@
"value": 10, "value": 10,
"label": "Endurance", "label": "Endurance",
"derivee": false "derivee": false
},
"sonne": {
"value": false,
"round": -1,
"label": "Sonné"
} }
}, },
"blessures": { "blessures": {
@ -374,10 +369,6 @@
"value": 0, "value": 0,
"label": "Fatigue", "label": "Fatigue",
"derivee": true "derivee": true
},
"sonne": {
"value": false,
"label": "Sonné"
} }
}, },
"blessures": { "blessures": {

View File

@ -82,10 +82,6 @@
<input type="text" name="data.sante.endurance.max" value="{{data.sante.endurance.max}}" data-dtype="Number" /> <input type="text" name="data.sante.endurance.max" value="{{data.sante.endurance.max}}" data-dtype="Number" />
</span> </span>
</li> </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"> <li class="flexrow list-item" data-attribute="etat">
<span class="competence-label" name="data.compteurs.etat.label">Etat Général</span> <span class="competence-label" name="data.compteurs.etat.label">Etat Général</span>
<input type="text" value="{{data.compteurs.etat.value}}" disabled /> <input type="text" value="{{data.compteurs.etat.value}}" disabled />

View File

@ -37,12 +37,6 @@
<a id="fatigue-plus">+</a> <a id="fatigue-plus">+</a>
</label> </label>
</li> </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> <li>
<label class="ctn-reve"> <label class="ctn-reve">
<span class="ptreve-actuel"><a>Rêve</a></span> <span class="ptreve-actuel"><a>Rêve</a></span>