Update v11

This commit is contained in:
2023-06-23 08:37:50 +02:00
parent 1b8e0840b0
commit 3be7f4bf9f
5 changed files with 101 additions and 36 deletions

View File

@ -2,7 +2,7 @@ import { BoLRoll, BoLDefaultRoll } from "../controllers/bol-rolls.js";
// Spell circle to min PP cost
const __circle2minpp = { 0: 0, 1: 2, 2: 6, 3: 11 }
const __validDices = {"6": 1, "8": 1, "10": 1, "12": 1}
const __validDices = { "6": 1, "8": 1, "10": 1, "12": 1 }
export class BoLUtility {
@ -41,8 +41,8 @@ export class BoLUtility {
config: true,
default: "6",
type: String,
choices: { "6": "2d6", "8":"2d8", "10":"2d10", "12":"2d12", "20":"2d20"},
onChange: value => {
choices: { "6": "2d6", "8": "2d8", "10": "2d10", "12": "2d12", "20": "2d20" },
onChange: value => {
BoLUtility.setDiceFormula(value)
}
})
@ -58,7 +58,7 @@ export class BoLUtility {
step: 1
},
type: Number,
onChange: value => {
onChange: value => {
BoLUtility.setSuccessValue(value)
}
})
@ -74,7 +74,7 @@ export class BoLUtility {
step: 1
},
type: Number,
onChange: value => {
onChange: value => {
BoLUtility.setCriticalSuccessValue(value)
}
})
@ -90,7 +90,7 @@ export class BoLUtility {
step: 1
},
type: Number,
onChange: value => {
onChange: value => {
BoLUtility.setCriticalFailureValue(value)
}
})
@ -153,12 +153,12 @@ export class BoLUtility {
}
static getDiceData() {
let df = this.diceFormula
if ( !__validDices[String(this.diceFormula)]) {
if (!__validDices[String(this.diceFormula)]) {
df = "6"
}
return {
diceFormula: df,
successValue : this.successValue,
successValue: this.successValue,
criticalSuccessValue: this.criticalSuccessValue,
criticalFailureValue: this.criticalFailureValue
}
@ -199,6 +199,44 @@ export class BoLUtility {
CONFIG.statusEffects = duplicate(game.bol.config.statusEffects)
}
/* -------------------------------------------- */
static chatDataSetup(content, modeOverride, isRoll = false, forceWhisper) {
let chatData = {
user: game.user.id,
rollMode: modeOverride || game.settings.get("core", "rollMode"),
content: content
};
if (["gmroll", "blindroll"].includes(chatData.rollMode)) chatData["whisper"] = ChatMessage.getWhisperRecipients("GM").map(u => u.id);
if (chatData.rollMode === "blindroll") chatData["blind"] = true;
else if (chatData.rollMode === "selfroll") chatData["whisper"] = [game.user];
if (forceWhisper) { // Final force !
chatData["speaker"] = ChatMessage.getSpeaker();
chatData["whisper"] = ChatMessage.getWhisperRecipients(forceWhisper);
}
return chatData;
}
/* -------------------------------------------- */
static postItem(chatData) {
// Don't post any image for the item (which would leave a large gap) if the default image is used
if (chatData.img.includes("/blank.png")) {
chatData.img = null;
}
// JSON object for easy creation
chatData.jsondata = JSON.stringify(
{
compendium: "postedItem",
payload: chatData,
});
renderTemplate('systems/bol/templates/item/post-item.hbs', chatData).then(html => {
let chatOptions = BoLUtility.chatDataSetup(html);
ChatMessage.create(chatOptions, "selfroll")
});
}
/* -------------------------------------------- */
static createDirectOptionList(min, max) {
let options = {};
@ -314,11 +352,11 @@ export class BoLUtility {
return message.getFlag("world", "bol-roll-data")
}
/* -------------------------------------------- */
static requestInitRoll(actorId, combatData ) {
let actor = game.actors.get( actorId )
static requestInitRoll(actorId, combatData) {
let actor = game.actors.get(actorId)
if (actor && actor.isOwner) {
ui.notifications.info(game.i18n.localize("BOL.ui.warninitiative"))
BoLRoll.aptitudeCheck(actor, "init", undefined, combatData)
BoLRoll.aptitudeCheck(actor, "init", undefined, combatData)
}
}
@ -390,7 +428,7 @@ export class BoLUtility {
})
html.on("click", '.recup-vitalite', event => {
event.preventDefault()
event.preventDefault()
let actorId = event.currentTarget.attributes['data-actor-id'].value
let recupHP = event.currentTarget.attributes['data-recup-hp'].value
let actor = game.actors.get(actorId)
@ -422,7 +460,7 @@ export class BoLUtility {
rollData.defenseMode = defenseMode
let token = game.scenes.current.tokens.get(rollData.targetId)
let defender = token.actor
if (defenseMode == 'damage-with-armor') {
let armorFormula = defender.getArmorFormula()
rollData.rollArmor = new Roll(armorFormula)
@ -591,7 +629,7 @@ export class BoLUtility {
$(`#${sockmsg.data.id}`).hide() // Hide the options roll buttons
}
if (sockmsg.name == "msg_request_init_roll") {
this.requestInitRoll( sockmsg.data.actorId, sockmsg.data.combatData)
this.requestInitRoll(sockmsg.data.actorId, sockmsg.data.combatData)
}
if (sockmsg.name == "msg_damage_handling") {
BoLUtility.processDamageHandling(sockmsg.data.attackId, sockmsg.data.defenseMode, sockmsg.data.weaponId, sockmsg.data.msgId)