Fix roll with armor 0
This commit is contained in:
@@ -18,6 +18,9 @@ import { BoLHotbar } from "./system/bol-hotbar.js"
|
||||
import { BoLCommands } from "./system/bol-commands.js"
|
||||
import { BoLRoll } from "./controllers/bol-rolls.js"
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const BOL_WELCOME_MESSAGE_URL = "https://www.uberwald.me/gitea/public/bol/raw/branch/main/welcome-message-bol.html"
|
||||
|
||||
/* -------------------------------------------- */
|
||||
Hooks.once('init', async function () {
|
||||
|
||||
@@ -86,14 +89,14 @@ Hooks.once('init', async function () {
|
||||
function welcomeMessage() {
|
||||
let content = `<div id="welcome-message-bol"><span class="rdd-roll-part">
|
||||
<strong>` + game.i18n.localize("BOL.chat.welcome1") + `</strong><p>` +
|
||||
game.i18n.localize("BOL.chat.welcome2") + "</p><p>" +
|
||||
game.i18n.localize("BOL.chat.welcome3") + "</p><p>" +
|
||||
game.i18n.localize("BOL.chat.welcome4") + "</p><p>" +
|
||||
game.i18n.localize("BOL.chat.welcome5") + "</p>" +
|
||||
game.i18n.localize("BOL.chat.welcome6")
|
||||
game.i18n.localize("BOL.chat.welcome2") + "</p><p>" +
|
||||
game.i18n.localize("BOL.chat.welcome3") + "</p><p>" +
|
||||
game.i18n.localize("BOL.chat.welcome4") + "</p><p>" +
|
||||
game.i18n.localize("BOL.chat.welcome5") + "</p>" +
|
||||
game.i18n.localize("BOL.chat.welcome6")
|
||||
|
||||
let rulebook = game.modules.find( m => m.id === "bol-rulebook")
|
||||
if ( !rulebook ) {
|
||||
let rulebook = game.modules.find(m => m.id === "bol-rulebook")
|
||||
if (!rulebook) {
|
||||
content += "<p>" + game.i18n.localize("BOL.chat.bolRulebookMessage") + "</p>"
|
||||
}
|
||||
ChatMessage.create({
|
||||
@@ -102,18 +105,38 @@ function welcomeMessage() {
|
||||
content: content
|
||||
})
|
||||
|
||||
if (game.user.isGM && game.i18n.lang == 'en' && !game.modules.find(m => m.id == "babele") ){
|
||||
if (game.user.isGM && game.i18n.lang == 'en' && !game.modules.find(m => m.id == "babele")) {
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
whisper: [game.user.id],
|
||||
content: `<div id="welcome-message-bol"><span class="rdd-roll-part">
|
||||
<strong>WARNING ! English language selected, but Babele module is not installed !<br>Please install babele from the module tab in Foundry interface.`
|
||||
} )
|
||||
})
|
||||
ui.notifications.warn("WARNING ! English language selected, but babele module is not installed !<br>Please install babele from the module tab in Foundry interface.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
function welcomeMessage() {
|
||||
if (game.user.isGM) {
|
||||
// Try to fetch the welcome message from the github repo "welcome-message-ecryme.html"
|
||||
fetch(BOL_WELCOME_MESSAGE_URL)
|
||||
.then(response => response.text())
|
||||
.then(html => {
|
||||
console.log("Fetched welcome message:", html);
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
whisper: [game.user.id],
|
||||
content: html
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error fetching welcome message:", error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
Hooks.once('ready', async function () {
|
||||
|
||||
@@ -127,6 +150,7 @@ Hooks.once('ready', async function () {
|
||||
)
|
||||
|
||||
welcomeMessage()
|
||||
welcomeMessage();
|
||||
|
||||
// User warning
|
||||
if (!game.user.isGM && game.user.character == undefined) {
|
||||
|
||||
@@ -482,17 +482,20 @@ export class BoLUtility {
|
||||
|
||||
if (defenseMode == 'damage-with-armor') {
|
||||
let armorFormula = defender.getArmorFormula()
|
||||
rollData.rollArmor = new Roll(armorFormula)
|
||||
await rollData.rollArmor.roll()
|
||||
let msg = await rollData.rollArmor.toMessage({ flavor: game.i18n.localize("BOL.chat.armorRoll") + " : " + armorFormula });
|
||||
if (game.dice3d) { // wait animation end when DsN is there
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id);
|
||||
rollData.armorProtect = 0
|
||||
armorFormula = String(armorFormula) || "0"
|
||||
if (armorFormula && armorFormula != "0" ) {
|
||||
rollData.rollArmor = new Roll(armorFormula)
|
||||
await rollData.rollArmor.roll()
|
||||
let msg = await rollData.rollArmor.toMessage({ flavor: game.i18n.localize("BOL.chat.armorRoll") + " : " + armorFormula });
|
||||
if (game.dice3d) { // wait animation end when DsN is there
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id);
|
||||
}
|
||||
rollData.armorProtect = (rollData.rollArmor.total < 0) ? 0 : rollData.rollArmor.total
|
||||
}
|
||||
rollData.armorProtect = (rollData.rollArmor.total < 0) ? 0 : rollData.rollArmor.total
|
||||
rollData.finalDamage = rollData.damageTotal - rollData.armorProtect
|
||||
rollData.finalDamage = (rollData.finalDamage < 0) ? 0 : rollData.finalDamage
|
||||
await defender.sufferDamage(rollData.finalDamage)
|
||||
console.log("Armor roll -> result ", rollData)
|
||||
}
|
||||
if (defenseMode == 'damage-without-armor') {
|
||||
rollData.finalDamage = rollData.damageTotal
|
||||
|
||||
Reference in New Issue
Block a user