forked from public/foundryvtt-reve-de-dragon
Update rules
This commit is contained in:
@ -102,12 +102,54 @@ export class RdDActor extends Actor {
|
||||
data.compteurs.etat.value = state;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
testSiSonne( endurance )
|
||||
{
|
||||
let myroll = new Roll("d20");
|
||||
myroll.roll();
|
||||
let result = myroll.total;
|
||||
if ( result <= endurance.value)
|
||||
this.data.data.sante.sonne.value = false;
|
||||
if ( result > endurance.value || result == 20) // 20 is always a failure
|
||||
this.data.data.sante.sonne.value = true;
|
||||
if (result == 1) {
|
||||
this.data.data.sante.sonne.value = false;
|
||||
this.data.data.carac.constitution.xp++; // 1 XP on 1 !
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
santeIncDec(name, inc ) {
|
||||
let data = this.data.data.sante[name];
|
||||
let lastValue = data.value; // Useful for Endurance and Sonné
|
||||
data.value = data.value + inc;
|
||||
if ( data.value > data.max ) data.value = data.max;
|
||||
if ( data.value < 0 ) data.value = 0;
|
||||
|
||||
if (name == "endurance") {
|
||||
if ( inc < 0 ) // Each endurance lost -> fatigue lost
|
||||
this.data.data.sante.fatigue = this.data.data.sante.fatigue + inc
|
||||
let diffEndurance = data.max - data.value;
|
||||
if ( this.data.data.sante.fatigue < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered
|
||||
this.data.data.sante.fatigue = diffEndurance;
|
||||
|
||||
// If endurance is 0 -> -1 vie
|
||||
if ( data.value == 0 ) {
|
||||
this.data.data.sante.vie.value = this.data.data.sante.vie.value - 1;
|
||||
}
|
||||
let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value;
|
||||
if ( data.value > data.max - (diffvie*2) ) {
|
||||
data.value = data.max - (diffvie*2);
|
||||
}
|
||||
|
||||
let blessures = this.data.data.blessures;
|
||||
let maxEnd = Math.floor( data.max / blessures.graves.nombre);
|
||||
if (data.value > maxEnd ) data.value = maxEnd;
|
||||
if ( blessures.critiques.nombre > 0 && data.value > 1) data.value = 1;
|
||||
|
||||
if (lastValue - data.value > 1) this.testSiSonne(data); // Peut-être sonné si 2 points d'endurance perdus d'un coup
|
||||
}
|
||||
|
||||
console.log(">>>> NEW VI", name, data.value);
|
||||
this.computeEtatGeneral();
|
||||
}
|
||||
|
Reference in New Issue
Block a user