Update for module support

This commit is contained in:
2024-02-22 18:29:04 +01:00
parent 20ab9a17a4
commit ae43c7c920
157 changed files with 500 additions and 402 deletions

View File

@ -421,24 +421,16 @@ export class BoLActor extends Actor {
}
isSorcerer() {
if (this.careers.find(item => item.system.properties.sorcerer == true))
return true
return false
return (this.careers.find(item => item.system.properties.sorcerer ))
}
isAlchemist() {
if (this.careers.find(item => item.system.properties.alchemist == true))
return true
return false
return (this.careers.find(item => item.system.properties.alchemist))
}
isAstrologer() {
if (this.careers.find(item => item.system.properties.astrologer == true))
return true
return false
return (this.careers.find(item => item.system.properties.astrologer))
}
isPriest() {
if (this.careers.find(item => item.system.properties.priest == true))
return true
return false
return (this.careers.find(item => item.system.properties.priest))
}
/*-------------------------------------------- */
@ -592,7 +584,7 @@ export class BoLActor extends Actor {
async spendAlchemyPoint(alchemyId, pcCost) {
let alchemy = this.items.get(alchemyId)
if (alchemy) {
pcCost = Number(pcCost) ?? 0
pcCost = Number(pcCost) || 0
if (this.system.resources.alchemypoints.value >= pcCost) {
let newPC = this.system.resources.alchemypoints.value - pcCost
newPC = (newPC < 0) ? 0 : newPC
@ -606,7 +598,7 @@ export class BoLActor extends Actor {
}
/*-------------------------------------------- */
getAstrologerBonus() {
let astrologer = this.careers.find(item => item.system.properties.astrologer == true)
let astrologer = this.careers.find(item => item.system.properties.astrologer)
if (astrologer) {
return astrologer.system.rank
}
@ -614,7 +606,7 @@ export class BoLActor extends Actor {
}
/*-------------------------------------------- */
getAlchemistBonus() {
let sorcerer = this.careers.find(item => item.system.properties.alchemist == true)
let sorcerer = this.careers.find(item => item.system.properties.alchemist)
if (sorcerer) {
return sorcerer.system.rank
}
@ -622,7 +614,7 @@ export class BoLActor extends Actor {
}
/*-------------------------------------------- */
getSorcererBonus() {
let sorcerer = this.careers.find(item => item.system.properties.sorcerer == true)
let sorcerer = this.careers.find(item => item.system.properties.sorcerer )
if (sorcerer) {
return sorcerer.system.rank
}
@ -888,10 +880,7 @@ export class BoLActor extends Actor {
checkNumeric(myObject) {
if (myObject) {
for (let key in myObject) {
if (myObject[key].value === null) {
myObject[key].value = 0
}
if (myObject[key].value === NaN) {
if (myObject[key].value === null || isNaN(myObject[key].value)) {
myObject[key].value = 0
}
}
@ -913,7 +902,7 @@ export class BoLActor extends Actor {
}
/*-------------------------------------------- */
getInitiativeRank(rollData = undefined, isCombat = false, combatData) {
getInitiativeRank(rollData = undefined, isCombat = false, combatData = undefined) {
let fvttInit = 4 // Pietaille par defaut
if (this.type == 'character') {
fvttInit = 5

View File

@ -116,7 +116,6 @@ export class BoLVehicleSheet extends ActorSheet {
/** @override */
async getData(options) {
const data = super.getData(options)
const actorData = duplicate(data)
let formData = duplicate(data)
formData.config = game.bol.config

View File

@ -19,11 +19,9 @@ export class BoLRoll {
static updateApplicableEffects(rollData) {
let appEffects = []
for (let effect of rollData.bolEffects) {
if (effect.system.properties.identifier == "always") {
appEffects.push(effect)
} else if (effect.system.properties.identifier.includes(rollData.attribute.key)) {
appEffects.push(effect)
} else if (rollData.aptitude && effect.system.properties.identifier.includes(rollData.aptitude.key)) {
if ( (effect.system.properties.identifier == "always") ||
(effect.system.properties.identifier.includes(rollData.attribute.key)) ||
(rollData.aptitude && effect.system.properties.identifier.includes(rollData.aptitude.key)) ){
appEffects.push(effect)
}
}

View File

@ -8,7 +8,7 @@ export class BoLCommands {
static init() {
if (!game.bol.commands) {
const bolCommands = new BoLCommands()
bolCommands.registerCommand({ path: ["/adventure"], func: (content, msg, params) => BoLAdventureGenerator.createAdventure(), descr: "Nouvelle idée d'aventure!" });
//bolCommands.registerCommand({ path: ["/adventure"], func: (content, msg, params) => BoLAdventureGenerator.createAdventure(), descr: "Nouvelle idée d'aventure!" });
bolCommands.registerCommand({ path: ["/pcview"], func: (content, msg, params) => BoLCharacterSummary.displayPCSummary(), descr: "Affiche la liste des PJs!" });
game.bol.commands = bolCommands
}
@ -88,7 +88,7 @@ export class BoLCommands {
console.log("===> Processing command")
let command = commandsTable[name];
path = path + name + " ";
if (command && command.subTable) {
if (command?.subTable) {
if (params[0]) {
return this._processCommand(command.subTable, params[0], params.slice(1), content, msg, path)
}
@ -97,9 +97,9 @@ export class BoLCommands {
return true;
}
}
if (command && command.func) {
if (command?.func) {
const result = command.func(content, msg, params);
if (result == false) {
if (!result) {
BoLCommands._chatAnswer(msg, command.descr);
}
return true;

View File

@ -337,7 +337,7 @@ export class BoLUtility {
// If the user is the message author or the actor owner, proceed
const actor = game.actors.get(data.message.speaker.actor)
//console.log("FOUND 1!!! ", actor)
if (actor && actor.isOwner) return
if (actor?.isOwner) return
else if (game.user.isGM || data.author.id === game.user.id) return
const divButtons = chatCard.find('.actions-section')
@ -354,7 +354,7 @@ export class BoLUtility {
/* -------------------------------------------- */
static requestInitRoll(actorId, combatData) {
let actor = game.actors.get(actorId)
if (actor && actor.isOwner) {
if (actor?.isOwner) {
ui.notifications.info(game.i18n.localize("BOL.ui.warninitiative"))
BoLRoll.aptitudeCheck(actor, "init", undefined, combatData)
}
@ -447,7 +447,7 @@ export class BoLUtility {
}
/* -------------------------------------------- */
static async processDamageHandling(attackId, defenseMode, weaponId = -1, msgId) {
static async processDamageHandling(attackId, defenseMode, weaponId, msgId) {
if (!game.user.isGM) {
return
}
@ -457,7 +457,7 @@ export class BoLUtility {
console.log("Damage Handling", attackId, defenseMode, weaponId)
// Only GM process this
if (rollData && rollData.defenderId) {
if (rollData?.defenderId) {
if (rollData.defenseDone || defenseMode == 'damage-not-applied') {
return
} // ?? Why ???
@ -668,7 +668,6 @@ export class BoLUtility {
let res = myReg.exec(damageString)
let nbDice = parseInt(res[1])
let postForm = 'kh' + nbDice
let modIndex = 3
// Upgrade damage if needed
if (upgradeDamage && (!res[3] || res[3] == "")) {
res[3] = "B" // Upgrade to bonus
@ -680,22 +679,18 @@ export class BoLUtility {
if (res[3] == 'M') {
postForm = 'kl' + nbDice
nbDice++
modIndex = 4
}
if (res[3] == 'MM') {
postForm = 'kl' + nbDice
nbDice += 2
modIndex = 4
}
if (res[3] == 'B') {
postForm = 'kh' + nbDice
nbDice++
modIndex = 4
}
if (res[3] == 'BB') {
postForm = 'kh' + nbDice
nbDice += 2
modIndex = 4
}
}
formula = "(" + nbDice + "d" + res[2] + reroll + postForm + "+" + modifier + ") *" + multiplier

View File

@ -10,7 +10,7 @@ export const registerHandlebarsHelpers = function () {
Handlebars.registerHelper('isEmpty', function (list) {
if (list) return list.length == 0;
else return 0;
else return false;
});
Handlebars.registerHelper('notEmpty', function (list) {
@ -64,8 +64,8 @@ export const registerHandlebarsHelpers = function () {
})
Handlebars.registerHelper('for', function (from, to, incr, block) {
var accum = '';
for (var i = from; i < to; i += incr)
let accum = '';
for (let i = from; i < to; i += incr)
accum += block.fn(i);
return accum;
})
@ -89,8 +89,8 @@ export const registerHandlebarsHelpers = function () {
// If you need to add Handlebars helpers, here are a few useful examples:
Handlebars.registerHelper('concat', function () {
var outStr = '';
for (var arg in arguments) {
let outStr = '';
for (let arg in arguments) {
if (typeof arguments[arg] != 'object') {
outStr += arguments[arg];
}
@ -117,7 +117,6 @@ export const registerHandlebarsHelpers = function () {
return arr[idx];
})
Handlebars.registerHelper('includesKey', function (items, type, key) {
// console.log(items);
return items.filter(i => i.type === type).map(i => i.system.key).includes(key);
})
Handlebars.registerHelper('includes', function (array, val) {
@ -128,10 +127,7 @@ export const registerHandlebarsHelpers = function () {
})
Handlebars.registerHelper('isOwnerOrGM', function (actor) {
console.log("Testing actor", actor.isOwner, game.userId)
if (actor.isOwner || game.isGM) {
return true
}
return false
return actor.isOwner || game.isGM;
})
Handlebars.registerHelper('upperFirst', function (text) {
if (typeof text !== 'string') return text

View File

@ -29,18 +29,6 @@ export default function registerHooks() {
if (data.type == "Item") {
let item = data.data;
console.log(item);
// let command = `let onlyDamage = false;\nlet customLabel = "";\nlet skillDescription = "";\nlet dmgDescription = "";\n\nif (event) {\n if (event.shiftKey) onlyDamage = true;\n}\n\ngame.cof.macros.rollItemMacro("${item._id}", "${item.name}", "${item.type}", 0, 0, 0, onlyDamage, customLabel, skillDescription, dmgDescription);`;
// let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
// if (!macro) {
// macro = await Macro.create({
// name: item.name,
// type : "script",
// img: item.img,
// command : command
// }, {displaySheet: false})
// }
// game.user.assignHotbarMacro(macro, slot);
}
// Create a macro to open the actor sheet of the actor dropped on the hotbar
else if (data.type == "Actor") {