Implémentation modif remarques v7

This commit is contained in:
2021-04-22 16:03:51 +02:00
parent 4c1640bb31
commit 2bfc6ed124
12 changed files with 58 additions and 14 deletions

View File

@ -205,8 +205,12 @@ export class VadentisActor extends Actor {
alias: this.name,
img: "systems/foundryvtt-vadentis/images/icons/tchat_dégâts_infligés.webp",
title: `${this.name} encaisse des dégâts !`,
msg: `${this.name} vient de perdre ${damageValue} Points de Vie. Ses Points de Vie actuels sont désormais de ${newValue}.`
msg: `${this.name} encaisse ${damageValue} dégâts !`
}
if ( game.user.isGM) {
msgData.msg += `<br>Ses Points de Vie actuels sont désormais de ${newValue}.`;
}
ChatMessage.create({
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
@ -298,12 +302,13 @@ export class VadentisActor extends Actor {
let msgData = {
alias: this.name,
img: competence.img,
rollMode: game.settings.get("core", "rollMode"),
title: `Compétence ${competence.name}`
}
let statValue = competence.data.base + competence.data.malus + competence.data.bonus;
let formulaFull = this.buildTexteFormula( competence.data );
let myRoll = await VadentisUtility.processRoll("1d20+"+statValue );
let myRoll = await VadentisUtility.processRoll("1d20+"+statValue, msgData.rollMode );
msgData.msg = `${formulaFull} => <strong>${myRoll.total}</strong>`;
if (myRoll.results[0] == 1 ) { // Critique ?
@ -315,8 +320,12 @@ export class VadentisActor extends Actor {
msgData.msg += `<br>C'est une <strong>réussite critique</strong> !`;
}
if (["gmroll", "blindroll"].includes(msgData.rollMode)) msgData["whisper"] = ChatMessage.getWhisperRecipients("GM").map(u => u.id);
if (msgData.rollMode === "blindroll") msgData["blind"] = true;
else if (msgData.rollMode === "selfroll") msgData["whisper"] = [game.user];
ChatMessage.create({
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
whisper: msgData["whisper"],
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
});
} else {
@ -365,6 +374,15 @@ export class VadentisActor extends Actor {
this.genericRoll( stat, magieName );
}
/* -------------------------------------------- */
async decrementeMunition( arme ) {
let armeTir = this.data.items.find( item => item.type == 'tir' && item.name == arme.name);
if (armeTir) {
let newMunition = armeTir.data.munition - 1;
await this.updateOwnedItem( { _id: armeTir._id, 'data.munition': newMunition } );
}
}
/* -------------------------------------------- */
rollArme(armeId) {
let target = VadentisUtility.getTarget();
@ -372,6 +390,10 @@ export class VadentisActor extends Actor {
if ( target ) {
let arme = this.data.items.find( item => (item.type == 'armecc' || item.type == 'tir') && item._id == armeId);
if (arme) {
if ( arme == 'tir' && arme.data.munition <= 0 ) {
ui.notifications.warn("Vous n'avez plus de munitions avec cette arme.");
return;
}
let combatData = {
attackerActorId: this._id,
targetActorId: target.actor._id,

View File

@ -72,7 +72,7 @@ export class VadentisUtility extends Entity {
}
/* -------------------------------------------- */
static async processRoll( formula ) {
static async processRoll( formula, rollMode ) {
let myRoll = new Roll(formula);
myRoll.evaluate();
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
@ -102,6 +102,11 @@ export class VadentisUtility extends Entity {
let degats = `normaux : ${combatData.arme.data.damage}`;
let formula = combatData.arme.data.damage.toLowerCase();
msgData.msg = `${attacker.name} a réussi son attaque sur ${defender.name} (${formulaFull} => ${myRoll.total} / ${defense}) !<br> Les dégâts sont ${degats}.`;
if ( combatData.arme.type == 'tir') {
attacker.decrementeMunition(combatData.arme);
msgData.msg += `<br>C'est un tir, les munitions de l'attaquant ont été décrémentées`;
}
if ( myRoll.results[0] >= combatData.arme.data.valuecritical ) {
degats = `critiques : ${combatData.arme.data.criticaldamage}`;