Ehance UI and weapon damages
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
/* -------------------------------------------- */
|
||||
import { VadentisUtility } from "./vadentis-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const MIN_PV = -50;
|
||||
const MIN_PE = -50;
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
@@ -114,36 +118,84 @@ export class VadentisActor extends Actor {
|
||||
myRoll.evaluate();
|
||||
myRoll.toMessage( { flavor: `Lancer de ${name} : ${devotionSort.name} (${formulaFull})` } );
|
||||
|
||||
if (myRoll.total >= devotionSort.data.difficulty) {
|
||||
if (myRoll.results[0] > 1 && myRoll.total >= devotionSort.data.difficulty) {
|
||||
let content = `${this.name} a réussi son ${name} et perd ${devotionSort.data.pe} Points d'Energie. L'effet suivant se produit: <br>${devotionSort.data.effect}`;
|
||||
let newEnergie = this.data.data.stats.pointsenergie.value - devotionSort.data.pe;
|
||||
await this.update( {'data.stats.pointsenergie.value': newEnergie });
|
||||
|
||||
if ( devotionSort.data.damage != "") {
|
||||
let degatsText = `<br>Et provoque les dégats suivants : `;
|
||||
let formula = devotionSort.data.damage;
|
||||
if (myRoll.results[0] == 20 ) { // Critique ?
|
||||
content += `<br>Et provoque les dégats critiques suivants : ${devotionSort.data.damagecritical}`;
|
||||
} else {
|
||||
content += `<br>Et provoque les dégats suivants : ${devotionSort.data.damage}`;
|
||||
degatsText += `<br>Et provoque les dégats critiques suivants : `;
|
||||
formula = devotionSort.data.damagecritical;
|
||||
}
|
||||
content += degatsText;
|
||||
/*let myRoll = new Roll(formula);
|
||||
myRoll.evaluate();
|
||||
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||
await game.dice3d.showForRoll(degatsRoll, game.user, true);
|
||||
}
|
||||
content += myRoll.total + `(${devotionSort.data.damagecritical})`; */
|
||||
content += `${devotionSort.data.damagecritical}`;
|
||||
}
|
||||
if ( newEnergie < 0) {
|
||||
content += `<br>Les Points d'Energie de ${this.name} sont négatifs ! Il convient d'éditer ses Points de Vie en conséquence.`;
|
||||
content += `<br><strong>Attention</strong> : Les Points d'Energie de ${this.name} sont négatifs ! Il convient d'éditer ses Points de Vie en conséquence.`;
|
||||
}
|
||||
ChatMessage.create( { content: content} );
|
||||
} else {
|
||||
ChatMessage.create( { content: `${this.name} a échoué son lancer de ${name}` } );
|
||||
if (myRoll.results[0] == 1 ) { // Critique ?
|
||||
ChatMessage.create( { content: `${this.name} a fait un <strong>échec critique</strong> à son lancer de ${name}` } );
|
||||
} else {
|
||||
ChatMessage.create( { content: `${this.name} a échoué son lancer de ${name}` } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollDamage( weapon, damageType ) {
|
||||
let formula = VadentisUtility.processDamageString( weapon.data.data[damageType], this );
|
||||
let degatsRoll = await VadentisUtility.processRoll( formula );
|
||||
|
||||
ChatMessage.create( { content: `${this.name} frappe avec ${weapon.name} et produit ${degatsRoll.total} Points de Dégâts (${formula}).` } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyDamage( damageValue ) {
|
||||
let pvData = this.data.data.stats.pointsvie;
|
||||
let newValue = Math.max( pvData.value - damageValue, MIN_PV);
|
||||
await this.update( {'data.stats.pointsvie.value': newValue });
|
||||
ChatMessage.create( { content: `${this.name} vient de perdre ${damageValue} Points de Vie. Ses Points de Vie actuels sont désormais de ${newValue}.` } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getCombatValue(mydata) {
|
||||
if ( Number(mydata.base)) {
|
||||
return mydata.base + mydata.malus + mydata.bonus;
|
||||
}else {
|
||||
return Number(mydata.base[0]) + Number(mydata.malus[0]) + Number(mydata.bonus[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore( ) {
|
||||
let initData = this.data.data.combat.initiative;
|
||||
return this._getCombatValue( initData);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getDefenseScore( ) {
|
||||
let defenseData = this.data.data.combat.defense;
|
||||
return defenseData.base + defenseData.malus + defenseData.bonus;
|
||||
return this._getCombatValue( defenseData);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getForceScore( ) {
|
||||
let forceData = this.data.data.combat.force;
|
||||
return this._getCombatValue( forceData);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getAttaqueScore( ) {
|
||||
let attaqueData = this.data.data.combat.attaque;
|
||||
return attaqueData.base + attaqueData.malus + attaqueData.bonus;
|
||||
return this._getCombatValue( attaqueData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -193,7 +245,7 @@ export class VadentisActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
rollCombat( combatName ) {
|
||||
let stat = this.data.data.combat[combatName];
|
||||
let statValue = stat.base + stat.malus + stat.bonus;
|
||||
let statValue = this._getCombatValue( stat );
|
||||
let formulaFull = `1d20+${stat.base}+${stat.malus}+${stat.bonus}`;
|
||||
let myRoll = new Roll("1d20+"+statValue);
|
||||
myRoll.evaluate();
|
||||
|
||||
Reference in New Issue
Block a user