Ongoing progress for weapons

This commit is contained in:
2020-06-12 11:47:41 +02:00
parent b16e977b19
commit 711ff19b10
5 changed files with 82 additions and 44 deletions

View File

@ -94,12 +94,39 @@ export class RdDActor extends Actor {
rollData.qualite = -6;
}
// Manage weapon categories when parrying (cf. page 115 )
let need_significative = false; // Do we need to have a sgnificative ?
let need_resist = false; // Do we need to have a sgnificative ?
if ( rollData.arme && rollData.attackerRoll ) { // Manage parade depeding on weapon type, and change roll results
let attCategory = RdDUtility.getArmeCategory( rollData.attackerRoll.arme );
let defCategory = RdDUtility.getArmeCategory( rollData.arme );
if ( defCategory == "bouclier" )
need_significative = true;
else if ( attCategory != defCategory )
need_significative = true;
if ( attCategory.match("epee") && ( defCategory == "hache" || defCategory == "lance") )
need_resist = true;
}
// Sonne management or if need_significative is set
if ( this.data.data.sante.sonne.value || need_significative) {
if (rollData.pointsDeTache >= 2 ) { // Reussite normale dès que significative
quality = "Réussite Normale";
rollData.pointsDeTache = 1;
rollData.qualite = 0;
} else if (rollData.pointsDeTache < 2 ) { // Not a "significative"
quality = "Echec Normal";
rollData.pointsDeTache = 0;
rollData.qualite = -2;
}
}
// Fight management !
let defenseMsg;
let encaisser = false;
let specialStr = "<br>Points de taches : " + rollData.pointsDeTache; // Per default
if ( rollData.arme ) { // In case of fight, replace the "tache" per dommages + localization. "tache" indicates if result is OK or not
if ( rollData.attackerRoll) {
if ( rollData.arme ) { // In case of fight, replace the "tache" message per dommages + localization. "tache" indicates if result is OK or not
if ( rollData.attackerRoll) { // Defense case !
if ( rollData.pointsDeTache > 0 ) { // Réussite !
specialStr = "<br><strong>Attaque parée/esquivée !</strong>";
} else {
@ -212,13 +239,14 @@ export class RdDActor extends Actor {
sante.fatigue.value = sante.fatigue.value - inc
// If endurance is 0 -> -1 vie
if ( data.value == 0 ) {
if ( data.value == 0 && sante.vie.value > 0) {
sante.vie.value = sante.vie.value - 1;
}
let diffVie = sante.vie.max - sante.vie.value;
if ( data.value > data.max - (diffVie*2) ) {
data.value = data.max - (diffVie*2);
}
if ( data.value < 0 ) data.value = 0; // Security
let blessures = this.data.data.blessures;
let maxEnd = Math.floor( data.max / blessures.graves.nombre);
@ -227,10 +255,12 @@ export class RdDActor extends Actor {
if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup
}
console.log(name, inc, data.value);
let diffEndurance = sante.endurance.max - this.data.data.sante.endurance.value;
if ( sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered
sante.fatigue.value = diffEndurance;
console.log("SANTE::::", sante);
await this.update( {"data.sante": sante } );
}
@ -290,7 +320,7 @@ export class RdDActor extends Actor {
"carac": this.data.data.carac,
"bonusmalusTable": CONFIG.RDD.bonusmalus,
"etat": this.data.data.compteurs.etat.value,
"bmValue": 0,
"bmValue": (attackerRoll) ? attackerRoll.bmValue : 0,
"attackerRoll": attackerRoll,
"finalLevel": 0
}
@ -344,29 +374,7 @@ export class RdDActor extends Actor {
/** @override */
getRollData() {
const data = super.getRollData();
const shorthand = game.settings.get("foundryvtt-reve-de-dragon", "macroShorthand");
// Re-map all attributes onto the base roll data
if ( !!shorthand ) {
for ( let [k, v] of Object.entries(data.attributes) ) {
if ( !(k in data) ) data[k] = v.value;
}
delete data.attributes;
}
// Map all items data using their slugified names
data.items = this.data.items.reduce((obj, i) => {
let key = i.name.slugify({strict: true});
let itemData = duplicate(i.data);
if ( !!shorthand ) {
for ( let [k, v] of Object.entries(itemData.attributes) ) {
if ( !(k in itemData) ) itemData[k] = v.value;
}
delete itemData["attributes"];
}
obj[key] = itemData;
return obj;
}, {});
return data;
}
}