forked from public/foundryvtt-reve-de-dragon
Ongoing progress for weapons
This commit is contained in:
@ -94,7 +94,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,25 @@ export class RdDUtility {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getArmeCategory( arme )
|
||||
{
|
||||
let compname = arme.data.competence.toLowerCase();
|
||||
if ( compname.match("hache") ) return "hache";
|
||||
if ( compname.match("hast") ) return "hast";
|
||||
if ( compname.match("lance") ) return "lance";
|
||||
if ( compname.match("bouclier") ) return "bouclier";
|
||||
if ( compname.match("masse") ) return "masse";
|
||||
if ( compname.match("fléau") ) return "fleau";
|
||||
if ( compname.match("epée") ) {
|
||||
let armename = arme.name.toLowerCase();
|
||||
if (armename == "dague" || armename.match("gnome") )
|
||||
return "epee_courte";
|
||||
}
|
||||
return "epee_longue";
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isArmeMelee( compName)
|
||||
{
|
||||
|
Reference in New Issue
Block a user