Foundry v13 migration

This commit is contained in:
2025-05-01 08:48:02 +02:00
parent 342f9c2342
commit d647fcc35e
40 changed files with 249 additions and 212 deletions

View File

@@ -6,7 +6,7 @@
import { MaleficesUtility } from "./malefices-utility.js";
/* -------------------------------------------- */
export class MaleficesActorSheet extends ActorSheet {
export class MaleficesActorSheet extends foundry.appv1.sheets.ActorSheet {
/** @override */
static get defaultOptions() {
@@ -44,9 +44,9 @@ export class MaleficesActorSheet extends ActorSheet {
phyMalus: this.actor.getPhysiqueMalus(),
elementsbio: this.actor.getElementsBio(),
sorts: this.actor.getSorts(),
description: await TextEditor.enrichHTML(this.object.system.biodata.description, { async: true }),
notes: await TextEditor.enrichHTML(this.object.system.biodata.notes, { async: true }),
equipementlibre: await TextEditor.enrichHTML(this.object.system.equipementlibre, { async: true }),
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.biodata.description, { async: true }),
notes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.biodata.notes, { async: true }),
equipementlibre: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.equipementlibre, { async: true }),
options: this.options,
owner: this.document.isOwner,
editScore: this.options.editScore,
@@ -66,10 +66,10 @@ export class MaleficesActorSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
html.bind("keydown", function(e) { // Ignore Enter in actores sheet
if (e.keyCode === 13) return false;
});
});
// Update Inventory Item
html.find('.item-edit').click(ev => {
@@ -87,14 +87,14 @@ export class MaleficesActorSheet extends ActorSheet {
let dataType = $(ev.currentTarget).data("type")
this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true })
})
html.find('.subactor-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let actorId = li.data("actor-id");
let actor = game.actors.get( actorId );
actor.sheet.render(true);
});
html.find('.subactor-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let actorId = li.data("actor-id");
@@ -117,38 +117,38 @@ export class MaleficesActorSheet extends ActorSheet {
const li = $(event.currentTarget).parents(".item")
this.actor.incDecAmmo( li.data("item-id"), +1 )
} );
html.find('.roll-attribut').click((event) => {
let attrKey = $(event.currentTarget).data("attr-key")
this.actor.rollAttribut(attrKey)
});
});
html.find('.roll-arme').click((event) => {
const armeId = $(event.currentTarget).data("arme-id")
this.actor.rollArme(armeId)
});
html.find('.lock-unlock-sheet').click((event) => {
this.options.editScore = !this.options.editScore;
this.render(true);
});
});
html.find('.item-link a').click((event) => {
const itemId = $(event.currentTarget).data("item-id");
const item = this.actor.getOwnedItem(itemId);
item.sheet.render(true);
});
});
html.find('.item-equip').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.equipItem( li.data("item-id") );
this.render(true);
this.render(true);
});
html.find('.update-field').change(ev => {
const fieldName = $(ev.currentTarget).data("field-name");
let value = Number(ev.currentTarget.value);
this.actor.update( { [`${fieldName}`]: value } );
});
});
}
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {

View File

@@ -80,7 +80,7 @@ export class MaleficesCommands {
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)
}
@@ -89,7 +89,7 @@ export class MaleficesCommands {
return true;
}
}
if (command && command.func) {
if (command?.func) {
const result = command.func(content, msg, params);
if (result == false) {
CrucibleCommands._chatAnswer(msg, command.descr);
@@ -140,7 +140,7 @@ export class MaleficesCommands {
selectedCard.system.isgm = false
selectedCard.value = (selectedCard.system.ispositif)? selectedCard.system.numericvalueup : selectedCard.system.numericvaluedown
MaleficesUtility.createChatMessage(game.user.name, "", {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
content: await foundry.applications.handlebars.renderTemplates(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
})
}

View File

@@ -4,7 +4,7 @@ import { MaleficesUtility } from "./malefices-utility.js";
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class MaleficesItemSheet extends ItemSheet {
export class MaleficesItemSheet extends foundry.appv1.sheets.ItemSheet {
/** @override */
static get defaultOptions() {
@@ -48,15 +48,15 @@ export class MaleficesItemSheet extends ItemSheet {
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner,
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }),
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.description, { async: true }),
notes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.notes, { async: true }),
isGM: game.user.isGM
}
if ( this.object.type == "archetype") {
formData.tarots = MaleficesUtility.getTarots()
}
this.options.editable = !(this.object.origin == "embeddedItem");
console.log("ITEM DATA", formData, this);
return formData;
@@ -102,7 +102,7 @@ export class MaleficesItemSheet extends ItemSheet {
let levelIndex = Number($(ev.currentTarget).parents(".item").data("level-index"))
let choiceIndex = Number($(ev.currentTarget).parents(".item").data("choice-index"))
let featureId = $(ev.currentTarget).parents(".item").data("feature-id")
let itemData = this.object.system.levels[levelIndex].choices[choiceIndex].features[featureId]
if (itemData.name != 'None') {

View File

@@ -39,7 +39,7 @@ Hooks.once("init", async function () {
MaleficesUtility.preloadHandlebarsTemplates();
/* -------------------------------------------- */
// Set an initiative formula for the system
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
@@ -58,12 +58,12 @@ Hooks.once("init", async function () {
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("fvtt-malefices", MaleficesActorSheet, { types: ["personnage"], makeDefault: true });
Actors.registerSheet("fvtt-malefices", MaleficesNPCSheet, { types: ["pnj"], makeDefault: false });
foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet);
foundry.documents.collections.Actors.registerSheet("fvtt-malefices", MaleficesActorSheet, { types: ["personnage"], makeDefault: true });
foundry.documents.collections.Actors.registerSheet("fvtt-malefices", MaleficesNPCSheet, { types: ["pnj"], makeDefault: false });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-malefices", MaleficesItemSheet, { makeDefault: true });
foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ItemSheet);
foundry.documents.collections.Items.registerSheet("fvtt-malefices", MaleficesItemSheet, { makeDefault: true });
MaleficesUtility.init()
@@ -119,4 +119,3 @@ Hooks.on("chatMessage", (html, content, msg) => {
}
return true;
});

View File

@@ -6,7 +6,7 @@
import { MaleficesUtility } from "./malefices-utility.js";
/* -------------------------------------------- */
export class MaleficesNPCSheet extends ActorSheet {
export class MaleficesNPCSheet extends foundry.appv1.sheets.ActorSheet {
/** @override */
static get defaultOptions() {
@@ -71,10 +71,10 @@ export class MaleficesNPCSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
html.bind("keydown", function(e) { // Ignore Enter in actores sheet
if (e.keyCode === 13) return false;
});
});
// Update Inventory Item
html.find('.item-edit').click(ev => {
@@ -92,17 +92,17 @@ export class MaleficesNPCSheet extends ActorSheet {
let dataType = $(ev.currentTarget).data("type")
this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true })
})
html.find('.equip-activate').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let itemId = li.data("item-id")
this.actor.equipActivate( itemId)
});
});
html.find('.equip-deactivate').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let itemId = li.data("item-id")
this.actor.equipDeactivate( itemId)
});
});
html.find('.subactor-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
@@ -110,7 +110,7 @@ export class MaleficesNPCSheet extends ActorSheet {
let actor = game.actors.get( actorId );
actor.sheet.render(true);
});
html.find('.subactor-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let actorId = li.data("actor-id");
@@ -133,7 +133,7 @@ export class MaleficesNPCSheet extends ActorSheet {
const li = $(event.currentTarget).parents(".item")
this.actor.incDecAmmo( li.data("item-id"), +1 )
} );
html.find('.roll-ability').click((event) => {
const abilityKey = $(event.currentTarget).data("ability-key");
this.actor.rollAbility(abilityKey);
@@ -142,7 +142,7 @@ export class MaleficesNPCSheet extends ActorSheet {
const li = $(event.currentTarget).parents(".item")
const skillId = li.data("item-id")
this.actor.rollSkill(skillId)
});
});
html.find('.roll-weapon').click((event) => {
const li = $(event.currentTarget).parents(".item");
@@ -163,28 +163,28 @@ export class MaleficesNPCSheet extends ActorSheet {
const saveKey = $(event.currentTarget).data("save-key")
this.actor.rollSave(saveKey)
});
html.find('.lock-unlock-sheet').click((event) => {
this.options.editScore = !this.options.editScore;
this.render(true);
});
});
html.find('.item-link a').click((event) => {
const itemId = $(event.currentTarget).data("item-id");
const item = this.actor.getOwnedItem(itemId);
item.sheet.render(true);
});
});
html.find('.item-equip').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.equipItem( li.data("item-id") );
this.render(true);
this.render(true);
});
html.find('.update-field').change(ev => {
const fieldName = $(ev.currentTarget).data("field-name");
let value = Number(ev.currentTarget.value);
this.actor.update( { [`${fieldName}`]: value } );
});
});
}

View File

@@ -7,10 +7,10 @@ export class MaleficesRollDialog extends Dialog {
let options = { classes: ["MaleficesDialog"], width: 540, height: 'fit-content', 'z-index': 99999 }
let html
if (rollData.attr && rollData.attr.iscard) {
html = await renderTemplate('systems/fvtt-malefices/templates/dialogs/confrontation-dialog.hbs', rollData);
if (rollData?.attr?.iscard) {
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-malefices/templates/dialogs/confrontation-dialog.hbs', rollData);
} else {
html = await renderTemplate('systems/fvtt-malefices/templates/dialogs/roll-dialog-generic.hbs', rollData);
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-malefices/templates/dialogs/roll-dialog-generic.hbs', rollData);
}
return new MaleficesRollDialog(actor, rollData, html, options);
@@ -18,7 +18,7 @@ export class MaleficesRollDialog extends Dialog {
/* -------------------------------------------- */
constructor(actor, rollData, html, options, close = undefined) {
let isCard = rollData.attr && rollData.attr.iscard
let isCard = rollData?.attr?.iscard
let conf = {
title: (isCard) ? "Jet" : "Tirage",
content: html,
@@ -45,7 +45,7 @@ export class MaleficesRollDialog extends Dialog {
/* -------------------------------------------- */
roll() {
let isCard = this.rollData.attr && this.rollData.attr.iscard
let isCard = this.rollData?.attr?.iscard
if (isCard) {
MaleficesUtility.tirageConfrontationMalefices(this.rollData)
} else {
@@ -64,7 +64,6 @@ export class MaleficesRollDialog extends Dialog {
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
@@ -87,6 +86,6 @@ export class MaleficesRollDialog extends Dialog {
html.find('#confrontationModif').change((event) => {
this.rollData.confrontationModif = Number(event.currentTarget.value)
})
}
}

View File

@@ -6,7 +6,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
static async create(actor, tirageData) {
let options = { classes: ["MaleficesDialog"], width: 720, height: 740, 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-malefices/templates/dialogs/tirage-tarot-dialog.hbs', tirageData);
let html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-malefices/templates/dialogs/tirage-tarot-dialog.hbs', tirageData);
return new MaleficesTirageTarotDialog(actor, tirageData, html, options);
}
@@ -36,7 +36,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
async sendCardRequest() {
this.tirageData.state = 'waiting-user-card'
let msg = await MaleficesUtility.createChatMessage(this.tirageData.user.name, "useronly", {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/request-tarot-card.hbs`, this.tirageData)
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/request-tarot-card.hbs`, this.tirageData)
})
//msg.setFlag("world", "tirage-data", this.tirageData)
console.log("MSG IS", msg)
@@ -50,7 +50,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
if ( selectedCard.system.isdualside) { // Cas des cartes pouvant avoir 2 sens
selectedCard.system.ispositif = (Math.random() > 0.5)
}
console.log("CARD SELECTED:", selectedCard)
console.log("CARD SELECTED:", selectedCard)
// Cas spécial de la Roue de la Fortune
if ( selectedCard.name.toLowerCase().includes("fortune")) {
this.tirageData.maxPlayerCard += 1
@@ -63,7 +63,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
}
}
this.tirageData.deck = newList
return selectedCard
}
@@ -74,9 +74,9 @@ export class MaleficesTirageTarotDialog extends Dialog {
let selectedCard = this.drawCard()
selectedCard.system.isgm = false
await MaleficesUtility.createChatMessage(this.tirageData.user.name, "gmroll", {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
})
if (this.tirageData.cards[0].name == "???") {
if (this.tirageData.cards[0].name == "???") {
this.tirageData.cards.shift()
}
this.tirageData.cards.push(selectedCard)
@@ -87,9 +87,9 @@ export class MaleficesTirageTarotDialog extends Dialog {
let selectedCard = this.drawCard()
selectedCard.system.isgm = true
await MaleficesUtility.createChatMessage(this.tirageData.user.name, "blindroll", {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
})
if (this.tirageData.secretCards[0].name == "???") {
if (this.tirageData.secretCards[0].name == "???") {
this.tirageData.secretCards.shift()
}
this.tirageData.secretCards.push(selectedCard)
@@ -124,7 +124,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
}
/* -------------------------------------------- */
async refreshDialog() {
const content = await renderTemplate("systems/fvtt-malefices/templates/dialogs/tirage-tarot-dialog.hbs", this.tirageData)
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-malefices/templates/dialogs/tirage-tarot-dialog.hbs", this.tirageData)
this.data.content = content
this.render(true)
}
@@ -133,7 +133,7 @@ export class MaleficesTirageTarotDialog extends Dialog {
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
let dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
@@ -150,6 +150,6 @@ export class MaleficesTirageTarotDialog extends Dialog {
dialog.attributeToActor(actorId)
}
})
}
}

View File

@@ -43,6 +43,14 @@ export class MaleficesUtility {
Handlebars.registerHelper('add', function (a, b) {
return parseInt(a) + parseInt(b);
})
// Handle v12 removal of this helper
Handlebars.registerHelper('select', function (selected, options) {
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
const html = options.fn(this);
return html.replace(rgx, "$& selected");
});
game.settings.register("world", "character-summary-data", {
name: "character-summary-data",
@@ -68,7 +76,7 @@ export class MaleficesUtility {
return foundry.utils.duplicate(this.tarots)
}
static getTarot(tId) {
return this.tarots.find(t => t._id == tId)
return this.tarots.find(t => t._id == tId)
}
/* -------------------------------------------- */
@@ -99,14 +107,14 @@ export class MaleficesUtility {
if (game.user.isGM) {
game.system.malefices.currentTirage.addCard(msgId)
} else {
game.socket.emit( "system.fvtt-malefices", {name: "msg-draw-card", data: {msgId: msgId}})
game.socket.emit("system.fvtt-malefices", { name: "msg-draw-card", data: { msgId: msgId } })
}
}
/* -------------------------------------------- */
static async chatListeners(html) {
html.on("click", '.roll-destin', event => {
$(html).on("click", '.roll-destin', event => {
let messageId = MaleficesUtility.findChatMessageId(event.currentTarget)
let message = game.messages.get(messageId)
let rollData = message.getFlag("world", "rolldata")
@@ -115,11 +123,11 @@ export class MaleficesUtility {
rollData.isReroll = true
this.rollMalefices(rollData)
})
html.on("click", '.draw-tarot-card', event => {
$(html).on("click", '.draw-tarot-card', event => {
let messageId = MaleficesUtility.findChatMessageId(event.currentTarget)
this.drawDeckCard(messageId)
})
}
/* -------------------------------------------- */
@@ -130,7 +138,7 @@ export class MaleficesUtility {
'systems/fvtt-malefices/templates/items/partial-item-nav.hbs',
'systems/fvtt-malefices/templates/items/partial-item-description.hbs'
]
return loadTemplates(templatePaths);
return foundry.applications.handlebars.loadTemplates(templatePaths);
}
/* -------------------------------------------- */
@@ -204,7 +212,7 @@ export class MaleficesUtility {
static async onSocketMesssage(msg) {
console.log("SOCKET MESSAGE", msg.name)
if (msg.name == "msg-draw-card") {
if ( game.user.isGM && game.system.malefices.currentTirage) {
if (game.user.isGM && game.system.malefices.currentTirage) {
game.system.malefices.currentTirage.addCard(msg.data.msgId)
}
}
@@ -271,71 +279,79 @@ export class MaleficesUtility {
/* -------------------------------------------- */
static processSpecialCard(actor, rollData) {
if (rollData.selectedCard.name.toLowerCase().includes("archange")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("archange"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("archange"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "gmroll", {
content: `Conséquence supplémentaire ! <br>L'Archange : ${actor.name} gagne 1 point de Spiritualité.` })
content: `Conséquence supplémentaire ! <br>L'Archange : ${actor.name} gagne 1 point de Spiritualité.`
})
actor.incDecAttr("spiritualite", 1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("vicaire")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("vicaire"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("vicaire"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "blindroll", {
content: `Conséquence supplémentaire ! <br>Le Vicaire : ${actor.name} vient de gagner 1 point en Pratique de la Magie Blanche (MPMB, secret).` })
content: `Conséquence supplémentaire ! <br>Le Vicaire : ${actor.name} vient de gagner 1 point en Pratique de la Magie Blanche (MPMB, secret).`
})
actor.incDecMPMB(1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("chance")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("chance"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("chance"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "gmroll", {
content: `Conséquence supplémentaire ! <br>La Chance : ${actor.name} a gagné 1 point de Destin.` })
content: `Conséquence supplémentaire ! <br>La Chance : ${actor.name} a gagné 1 point de Destin.`
})
actor.incDecDestin(1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("mort")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("mort"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("mort"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "gmroll", {
content: `Conséquence supplémentaire ! <br>La Mort : ${actor.name} est pétrifié par la peur.` })
content: `Conséquence supplémentaire ! <br>La Mort : ${actor.name} est pétrifié par la peur.`
})
actor.incDecDestin(1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("diable")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("diable"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("diable"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "gmroll", {
content: `Conséquence supplémentaire ! <br>Le Diable : ${actor.name} gagne 1 point de Rationnalité.` })
content: `Conséquence supplémentaire ! <br>Le Diable : ${actor.name} gagne 1 point de Rationnalité.`
})
actor.incDecAttr("rationnalite", 1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("lune noire")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("lune noire"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("lune noire"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "blindroll", {
content: `Conséquence supplémentaire ! <br>La Lune Noire : ${actor.name} vient de gagner 1 point de Fluide (secret).` })
content: `Conséquence supplémentaire ! <br>La Lune Noire : ${actor.name} vient de gagner 1 point de Fluide (secret).`
})
actor.incDecFluide(1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("grand livre")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("grand livre"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("grand livre"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "blindroll", {
content: `Conséquence supplémentaire ! <br>La Lune Noire : ${actor.name} vient de gagner 1 point de Fluide (secret).` })
content: `Conséquence supplémentaire ! <br>La Lune Noire : ${actor.name} vient de gagner 1 point de Fluide (secret).`
})
actor.incDecFluide(1)
}
}
if (rollData.selectedCard.name.toLowerCase().includes("sorcier")) {
let actorCard = actor.items.find( c => c.type =="tarot" && c.name.toLowerCase().includes("sorcier"))
let actorCard = actor.items.find(c => c.type == "tarot" && c.name.toLowerCase().includes("sorcier"))
if (actorCard) {
MaleficesUtility.createChatMessage(actor.name, "blindroll", {
content: `Conséquence supplémentaire ! <br>Le Vicaire : ${actor.name} vient de gagner 1 point en Pratique de la Magie Noire (MPMN, secret).` })
content: `Conséquence supplémentaire ! <br>Le Vicaire : ${actor.name} vient de gagner 1 point en Pratique de la Magie Noire (MPMN, secret).`
})
actor.incDecMPMN(1)
}
}
}
}
/* -------------------------------------------- */
static computeResults(rollData) {
@@ -362,30 +378,30 @@ export class MaleficesUtility {
rollData.target = rollData.attr.value - rollData.confrontationDegre + rollData.confrontationModif
let deck = this.getTarots()
let index = Math.round(Math.random() * (deck.length-1))
let index = Math.round(Math.random() * (deck.length - 1))
let selectedCard = deck[index]
selectedCard.system.ispositif = (Math.random() > 0.5)
selectedCard.value = (selectedCard.system.ispositif)? selectedCard.system.numericvalueup : selectedCard.system.numericvaluedown
selectedCard.value = (selectedCard.system.ispositif) ? selectedCard.system.numericvalueup : selectedCard.system.numericvaluedown
rollData.total = selectedCard.value
rollData.selectedCard = selectedCard
await MaleficesUtility.createChatMessage(actor.name, "gmroll", {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/display-tarot-card.hbs`, selectedCard)
})
this.computeResults(rollData)
if (rollData.isSuccess) {
rollData.gainAttr = Math.ceil(rollData.confrontationDegre/2) + ((rollData.isCritical ) ? 1 : 0)
actor.incDecAttr(rollData.attr.abbrev, rollData.gainAttr )
rollData.gainAttr = Math.ceil(rollData.confrontationDegre / 2) + ((rollData.isCritical) ? 1 : 0)
actor.incDecAttr(rollData.attr.abbrev, rollData.gainAttr)
} else {
rollData.gainAttr = rollData.confrontationDegre
actor.incDecAttr(rollData.attr.abbrev, -rollData.gainAttr )
actor.incDecAttr(rollData.attr.abbrev, -rollData.gainAttr)
}
await MaleficesUtility.createChatMessage(actor.name, "gmroll", {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/chat-confrontation-result.hbs`, rollData)
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/chat-confrontation-result.hbs`, rollData)
})
this.processSpecialCard(actor, rollData)
this.processSpecialCard(actor, rollData)
}
/* -------------------------------------------- */
static async rollMalefices(rollData) {
@@ -410,7 +426,7 @@ export class MaleficesUtility {
this.computeResults(rollData)
let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/chat-generic-result.hbs`, rollData)
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-malefices/templates/chat/chat-generic-result.hbs`, rollData)
})
msg.setFlag("world", "rolldata", rollData)
if (rollData.mode == "initiative") {