Update v11

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

View File

@ -1,6 +1,5 @@
import { BoLDefaultRoll } from "../controllers/bol-rolls.js"; import { BoLDefaultRoll, BoLRoll } from "../controllers/bol-rolls.js";
import { BoLUtility } from "../system/bol-utility.js"; import { BoLUtility } from "../system/bol-utility.js";
import { BoLRoll } from "../controllers/bol-rolls.js";
/** /**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
@ -753,7 +752,7 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */ /*-------------------------------------------- */
buildListeActions() { buildListeActions() {
return this.melee.concat(this.ranged).concat(this.natural) return this.melee.concat(this.ranged).concat(this.natural).concat(this.fightoptions)
} }
/*-------------------------------------------- */ /*-------------------------------------------- */

View File

@ -27,23 +27,23 @@ export class BoLItemSheet extends ItemSheet {
data.category = itemData.system.category data.category = itemData.system.category
data.isGM = game.user.isGM; data.isGM = game.user.isGM;
data.itemProperties = this.item.itemProperties; data.itemProperties = this.item.itemProperties;
data.description = await TextEditor.enrichHTML(this.object.system.description, {async: true}) data.description = await TextEditor.enrichHTML(this.object.system.description, { async: true })
// Dynamic default data fix/adapt // Dynamic default data fix/adapt
if (itemData.type == "item") { if (itemData.type == "item") {
if (!itemData.system.category) { if (!itemData.system.category) {
itemData.system.category = "equipment" itemData.system.category = "equipment"
} }
if ( itemData.system.category == "equipment" && itemData.system.properties.equipable) { if (itemData.system.category == "equipment" && itemData.system.properties.equipable) {
if (!itemData.system.properties.slot) { if (!itemData.system.properties.slot) {
itemData.system.properties.slot = "-" itemData.system.properties.slot = "-"
} }
} }
if (itemData.system.category == 'spell') { if (itemData.system.category == 'spell') {
if(!itemData.system.properties.mandatoryconditions) { if (!itemData.system.properties.mandatoryconditions) {
itemData.system.properties.mandatoryconditions = [] itemData.system.properties.mandatoryconditions = []
} }
if(!itemData.system.properties.optionnalconditions) { if (!itemData.system.properties.optionnalconditions) {
itemData.system.properties.optionnalconditions = [] itemData.system.properties.optionnalconditions = []
} }
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
@ -64,7 +64,27 @@ export class BoLItemSheet extends ItemSheet {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
buttons.unshift({
class: "post",
icon: "fas fa-comment",
onclick: ev => this.postItem()
});
return buttons
}
/* -------------------------------------------- */
postItem() {
let chatData = duplicate(this.item)
if (this.actor) {
chatData.actor = { id: this.actor.id };
}
BoLUtility.postItem(chatData);
}
/* -------------------------------------------- */
/** @override */ /** @override */
setPosition(options = {}) { setPosition(options = {}) {
const position = super.setPosition(options); const position = super.setPosition(options);

View File

@ -1,5 +1,6 @@
/* -------------------------------------------- */ /* -------------------------------------------- */
import { BoLRoll } from "../controllers/bol-rolls.js"; import { BoLRoll } from "../controllers/bol-rolls.js";
import { BoLUtility } from "../system/bol-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class BoLTokenHud { export class BoLTokenHud {
@ -30,10 +31,17 @@ export class BoLTokenHud {
(event) => { (event) => {
let actionIndex = Number(event.currentTarget.attributes['data-action-index'].value) let actionIndex = Number(event.currentTarget.attributes['data-action-index'].value)
let action = hudData.actionsList[actionIndex] let action = hudData.actionsList[actionIndex]
const weapon = actor.items.get( action._id ) const actionItem = actor.items.get(action._id)
BoLRoll.weaponCheckWithWeapon(hudData.actor, duplicate(weapon)) if (actionItem.system.subtype == "weapon") {
//console.log("Clicked", action) BoLRoll.weaponCheckWithWeapon(hudData.actor, duplicate(actionItem))
} ) } else if (actionItem.system.subtype == "fightoption") {
let chatData = duplicate(actionItem)
if (actionItem.actor) {
chatData.actor = { id: actionItem.actor._id };
}
BoLUtility.postItem(chatData);
}
})
const controlIconTarget = html.find('.control-icon[data-action=target]'); const controlIconTarget = html.find('.control-icon[data-action=target]');
// att+apt+career // att+apt+career
@ -41,18 +49,18 @@ export class BoLTokenHud {
(event) => { (event) => {
let rollIndex = Number(event.currentTarget.attributes['data-roll-index'].value) let rollIndex = Number(event.currentTarget.attributes['data-roll-index'].value)
let roll = hudData.rollsList[rollIndex] let roll = hudData.rollsList[rollIndex]
if ( roll.type == "aptitude") { if (roll.type == "aptitude") {
BoLRoll.aptitudeCheck(actor, roll.key ) BoLRoll.aptitudeCheck(actor, roll.key)
} else if ( roll.type == "attribute") { } else if (roll.type == "attribute") {
BoLRoll.attributeCheck(actor, roll.key ) BoLRoll.attributeCheck(actor, roll.key)
} }
}) })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async addTokenHudExtensions(app, html, tokenId) { static async addTokenHudExtensions(app, html, tokenId) {
const controlIconCombat = html.find('.control-icon[data-action=combat]') const controlIconCombat = html.find('.control-icon[data-action=combat]')
if (controlIconCombat.length>0 ) { if (controlIconCombat.length > 0) {
BoLTokenHud.addExtensionHud(app, html, tokenId); BoLTokenHud.addExtensionHud(app, html, tokenId);
} }
} }
@ -61,9 +69,9 @@ export class BoLTokenHud {
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) { static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
const hud = $(await renderTemplate(template, hudData)) const hud = $(await renderTemplate(template, hudData))
const list = hud.find('div.bol-hud-list') const list = hud.find('div.bol-hud-list')
BoLTokenHud._toggleHudListActive(hud, list); BoLTokenHud._toggleHudListActive(hud, list);
hud.find('img.bol-hud-togglebutton').click(event => BoLTokenHud._toggleHudListActive(hud, list)); hud.find('img.bol-hud-togglebutton').click(event => BoLTokenHud._toggleHudListActive(hud, list));
list.find('.bol-hud-menu').click(onMenuItem); list.find('.bol-hud-menu').click(onMenuItem);

View File

@ -2,7 +2,7 @@ import { BoLRoll, BoLDefaultRoll } from "../controllers/bol-rolls.js";
// Spell circle to min PP cost // Spell circle to min PP cost
const __circle2minpp = { 0: 0, 1: 2, 2: 6, 3: 11 } 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 { export class BoLUtility {
@ -41,8 +41,8 @@ export class BoLUtility {
config: true, config: true,
default: "6", default: "6",
type: String, type: String,
choices: { "6": "2d6", "8":"2d8", "10":"2d10", "12":"2d12", "20":"2d20"}, choices: { "6": "2d6", "8": "2d8", "10": "2d10", "12": "2d12", "20": "2d20" },
onChange: value => { onChange: value => {
BoLUtility.setDiceFormula(value) BoLUtility.setDiceFormula(value)
} }
}) })
@ -58,7 +58,7 @@ export class BoLUtility {
step: 1 step: 1
}, },
type: Number, type: Number,
onChange: value => { onChange: value => {
BoLUtility.setSuccessValue(value) BoLUtility.setSuccessValue(value)
} }
}) })
@ -74,7 +74,7 @@ export class BoLUtility {
step: 1 step: 1
}, },
type: Number, type: Number,
onChange: value => { onChange: value => {
BoLUtility.setCriticalSuccessValue(value) BoLUtility.setCriticalSuccessValue(value)
} }
}) })
@ -90,7 +90,7 @@ export class BoLUtility {
step: 1 step: 1
}, },
type: Number, type: Number,
onChange: value => { onChange: value => {
BoLUtility.setCriticalFailureValue(value) BoLUtility.setCriticalFailureValue(value)
} }
}) })
@ -153,12 +153,12 @@ export class BoLUtility {
} }
static getDiceData() { static getDiceData() {
let df = this.diceFormula let df = this.diceFormula
if ( !__validDices[String(this.diceFormula)]) { if (!__validDices[String(this.diceFormula)]) {
df = "6" df = "6"
} }
return { return {
diceFormula: df, diceFormula: df,
successValue : this.successValue, successValue: this.successValue,
criticalSuccessValue: this.criticalSuccessValue, criticalSuccessValue: this.criticalSuccessValue,
criticalFailureValue: this.criticalFailureValue criticalFailureValue: this.criticalFailureValue
} }
@ -199,6 +199,44 @@ export class BoLUtility {
CONFIG.statusEffects = duplicate(game.bol.config.statusEffects) 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) { static createDirectOptionList(min, max) {
let options = {}; let options = {};
@ -314,11 +352,11 @@ export class BoLUtility {
return message.getFlag("world", "bol-roll-data") return message.getFlag("world", "bol-roll-data")
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static requestInitRoll(actorId, combatData ) { static requestInitRoll(actorId, combatData) {
let actor = game.actors.get( actorId ) let actor = game.actors.get(actorId)
if (actor && actor.isOwner) { if (actor && actor.isOwner) {
ui.notifications.info(game.i18n.localize("BOL.ui.warninitiative")) 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 => { html.on("click", '.recup-vitalite', event => {
event.preventDefault() event.preventDefault()
let actorId = event.currentTarget.attributes['data-actor-id'].value let actorId = event.currentTarget.attributes['data-actor-id'].value
let recupHP = event.currentTarget.attributes['data-recup-hp'].value let recupHP = event.currentTarget.attributes['data-recup-hp'].value
let actor = game.actors.get(actorId) let actor = game.actors.get(actorId)
@ -422,7 +460,7 @@ export class BoLUtility {
rollData.defenseMode = defenseMode rollData.defenseMode = defenseMode
let token = game.scenes.current.tokens.get(rollData.targetId) let token = game.scenes.current.tokens.get(rollData.targetId)
let defender = token.actor let defender = token.actor
if (defenseMode == 'damage-with-armor') { if (defenseMode == 'damage-with-armor') {
let armorFormula = defender.getArmorFormula() let armorFormula = defender.getArmorFormula()
rollData.rollArmor = new Roll(armorFormula) rollData.rollArmor = new Roll(armorFormula)
@ -591,7 +629,7 @@ export class BoLUtility {
$(`#${sockmsg.data.id}`).hide() // Hide the options roll buttons $(`#${sockmsg.data.id}`).hide() // Hide the options roll buttons
} }
if (sockmsg.name == "msg_request_init_roll") { 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") { if (sockmsg.name == "msg_damage_handling") {
BoLUtility.processDamageHandling(sockmsg.data.attackId, sockmsg.data.defenseMode, sockmsg.data.weaponId, sockmsg.data.msgId) BoLUtility.processDamageHandling(sockmsg.data.attackId, sockmsg.data.defenseMode, sockmsg.data.weaponId, sockmsg.data.msgId)

View File

@ -1,7 +1,7 @@
{ {
"id": "bol", "id": "bol",
"title": "Barbarians of Lemuria", "title": "Barbarians of Lemuria",
"description": "The Barbarians of Lemuria system for FoundryVTT!", "description": "The Barbarians of Lemuria system for FoundryVTT !",
"authors": [ "authors": [
{ {
"name": "LeRatierBretonnien", "name": "LeRatierBretonnien",
@ -14,7 +14,7 @@
], ],
"url": "https://www.uberwald.me/gitea/public/bol", "url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"version": "11.0.5", "version": "11.0.6",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"maximum": "11", "maximum": "11",
@ -203,7 +203,7 @@
], ],
"socket": true, "socket": true,
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v11.0.5.zip", "download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v11.0.6.zip",
"background": "systems/bol/ui/page_accueil.webp", "background": "systems/bol/ui/page_accueil.webp",
"gridDistance": 1.5, "gridDistance": 1.5,
"gridUnits": "m", "gridUnits": "m",