Fouindry v13 support
This commit is contained in:
@@ -7,7 +7,7 @@ import { WastelandUtility } from "./wasteland-utility.js";
|
||||
import { WastelandRollDialog } from "./wasteland-roll-dialog.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class WastelandActorSheet extends ActorSheet {
|
||||
export class WastelandActorSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
@@ -25,8 +25,8 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = foundry.utils.duplicate(this.object)
|
||||
let actorData = objectData
|
||||
const objectData = foundry.utils.duplicate(this.object)
|
||||
let actorData = objectData
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@@ -52,15 +52,15 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
origine: foundry.utils.duplicate(this.actor.getOrigine() || {}),
|
||||
heritage: foundry.utils.duplicate(this.actor.getHeritage() || {}),
|
||||
metier: foundry.utils.duplicate(this.actor.getMetier() || {}),
|
||||
combat: this.actor.getCombatValues(),
|
||||
combat: this.actor.getCombatValues(),
|
||||
config: foundry.utils.duplicate(game.system.wasteland.config),
|
||||
capacites: foundry.utils.duplicate(this.actor.getCapacites()),
|
||||
equipements: foundry.utils.duplicate(this.actor.getEquipments()),
|
||||
monnaies: foundry.utils.duplicate(this.actor.getMonnaies()),
|
||||
mutations: foundry.utils.duplicate(this.actor.getMutations()),
|
||||
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
comportement: await TextEditor.enrichHTML(this.object.system.biodata.comportement, {async: true}),
|
||||
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}),
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
comportement: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.biodata.comportement, {async: true}),
|
||||
habitat: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.biodata.habitat, {async: true}),
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
@@ -73,7 +73,7 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
@@ -81,14 +81,14 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
const item = this.actor.items.get( itemId )
|
||||
item.sheet.render(true)
|
||||
})
|
||||
})
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
@@ -103,7 +103,7 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
let value = ev.currentTarget.value
|
||||
this.actor.editItemField(itemId, itemType, itemField, dataType, value)
|
||||
})
|
||||
|
||||
|
||||
html.find('.quantity-minus').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
this.actor.incDecQuantity( li.data("item-id"), -1 );
|
||||
@@ -129,7 +129,7 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
let charmeId = li.data("item-id")
|
||||
this.actor.rollCharme(charmeId)
|
||||
})
|
||||
|
||||
|
||||
html.find('.roll-pouvoir').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
let pouvoirId = li.data("item-id")
|
||||
@@ -155,19 +155,19 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
this.actor.createEmbeddedDocuments('Item', [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true })
|
||||
})
|
||||
|
||||
|
||||
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
setPosition(options = {}) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { WastelandUtility } from "./wasteland-utility.js";
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class WastelandItemSheet extends ItemSheet {
|
||||
export class WastelandItemSheet extends foundry.appv1.sheets.ItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
@@ -49,7 +49,7 @@ export class WastelandItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = foundry.utils.duplicate(this.object)
|
||||
let itemData = objectData
|
||||
let itemData = objectData
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: this.id,
|
||||
@@ -147,10 +147,10 @@ export class WastelandItemSheet extends ItemSheet {
|
||||
let pred = foundry.utils.duplicate(this.object.system.predilections)
|
||||
pred[index].used = ev.currentTarget.checked
|
||||
this.object.update( { 'data.predilections': pred })
|
||||
})
|
||||
})
|
||||
html.find('#add-predilection').click(ev => {
|
||||
let pred = foundry.utils.duplicate(this.object.system.predilections)
|
||||
pred.push( { name: "Nouvelle prédilection", used: false })
|
||||
pred.push( { name: "Nouvelle prédilection", used: false })
|
||||
this.object.update( { 'data.predilections': pred })
|
||||
})
|
||||
// Update Inventory Item
|
||||
|
||||
@@ -30,7 +30,7 @@ Hooks.once("init", async function () {
|
||||
WastelandUtility.preloadHandlebarsTemplates();
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Set an initiative formula for the system
|
||||
// Set an initiative formula for the system
|
||||
CONFIG.Combat.initiative = {
|
||||
formula: "1d6",
|
||||
decimals: 1
|
||||
@@ -52,12 +52,12 @@ Hooks.once("init", async function () {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("fvtt-wasteland", WastelandActorSheet, { types: ["personnage"], makeDefault: true })
|
||||
Actors.registerSheet("fvtt-wasteland", WastelandCreatureSheet, { types: ["creature"], makeDefault: false });
|
||||
foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet);
|
||||
foundry.documents.collections.Actors.registerSheet("fvtt-wasteland", WastelandActorSheet, { types: ["personnage"], makeDefault: true })
|
||||
foundry.documents.collections.Actors.registerSheet("fvtt-wasteland", WastelandCreatureSheet, { types: ["creature"], makeDefault: false });
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-wasteland", WastelandItemSheet, { makeDefault: true })
|
||||
foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ItemSheet);
|
||||
foundry.documents.collections.Items.registerSheet("fvtt-wasteland", WastelandItemSheet, { makeDefault: true })
|
||||
|
||||
WastelandUtility.init();
|
||||
|
||||
@@ -136,4 +136,3 @@ Hooks.on("chatMessage", (html, content, msg) => {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export class WastelandRollDialog extends Dialog {
|
||||
static async create(actor, rollData) {
|
||||
|
||||
let options = { classes: ["WastelandDialog"], width: 340, height: 'fit-content', 'z-index': 99999 };
|
||||
let html = await renderTemplate('systems/fvtt-wasteland/templates/roll-dialog-generic.html', rollData);
|
||||
let html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-wasteland/templates/roll-dialog-generic.html', rollData);
|
||||
|
||||
return new WastelandRollDialog(actor, rollData, html, options);
|
||||
}
|
||||
@@ -68,7 +68,6 @@ export class WastelandRollDialog extends Dialog {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
var dialog = this;
|
||||
function onLoad() {
|
||||
}
|
||||
$(function () { onLoad(); });
|
||||
|
||||
@@ -4,7 +4,7 @@ import { WastelandCommands } from "./wasteland-commands.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const __contrecouptCharme = {
|
||||
1 : {name: "Effet chromatique", description: "le corps du kobold prend des teintes aussi étranges que voyantes. L'effet s’estompe progressivement et 24 heures plus tard, le kobold retrouve ses couleurs d’origine." },
|
||||
1 : {name: "Effet chromatique", description: "le corps du kobold prend des teintes aussi étranges que voyantes. L'effet s’estompe progressivement et 24 heures plus tard, le kobold retrouve ses couleurs d’origine." },
|
||||
3 : {name: "Enivrement Kobold", description: "très excité par son premier tour, le kobold doit immédiatement faire un autre tour, pour lequel il emploiera un dé plus gros." },
|
||||
5 : {name: "Mutisme superstitieux", description: "le kobold ne doit plus parler» pendant les prochaines 24 heures. S'il le fait malgré tout, les effets de son tour s’arrêtent." },
|
||||
7 : {name: "Agité!", description: "le kobold ne tient plus en place. Il ne peut se reposer pendant les prochaines 12 heures. Dès. que 12 heures se sont écoulées, il s'effondre comme une masse et dort 12 heures d'affilée d’un sommeil enchanté dont rien ne pourra le réveiller." },
|
||||
@@ -14,7 +14,7 @@ const __contrecouptCharme = {
|
||||
15 : {name: "La petite Mort", description: "le kobold s'endort pour 1420 heures. Rien ni personne ne pourra le tirer de ce sommeil enchanté avant que ce contrecoup ne prenne fin." },
|
||||
17 : {name: "Angoisse cauchemardesque", description: "le kobold a une brève vision de pure horreur. Il perd 1420 points de Psyché {s'il doit en perdre plus qu'il n’en a, il tombe à 0)." },
|
||||
19 : {name: "Anémie Kobold", description: "le kobold se met à saigner du nez, des oreilles et même d’autres endroits. Il perd 1420 point(s) de Santé." }
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class WastelandUtility {
|
||||
@@ -23,7 +23,7 @@ export class WastelandUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async init() {
|
||||
Hooks.on('renderChatLog', (log, html, data) => WastelandUtility.chatListeners(html))
|
||||
Hooks.on("getChatLogEntryContext", (html, options) => WastelandUtility.chatRollMenu(html, options))
|
||||
Hooks.on("getChatMessageContextOptions", (html, options) => WastelandUtility.chatRollMenu(html, options))
|
||||
|
||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||
WastelandUtility.pushInitiativeOptions(html, options);
|
||||
@@ -118,7 +118,7 @@ export class WastelandUtility {
|
||||
game.system.wasteland.config.pointsAmeOptions = WastelandUtility.createDirectOptionList(0, 20)
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static createDirectOptionList(min, max) {
|
||||
let options = {};
|
||||
@@ -154,7 +154,7 @@ export class WastelandUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
html.on("click", '.predilection-reroll', async event => {
|
||||
$(html).on("click", '.predilection-reroll', async event => {
|
||||
let predIdx = $(event.currentTarget).data("predilection-index")
|
||||
let messageId = WastelandUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
@@ -173,7 +173,7 @@ export class WastelandUtility {
|
||||
'systems/fvtt-wasteland/templates/editor-notes-gm.html',
|
||||
'systems/fvtt-wasteland/templates/partial-item-description.html'
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
return foundry.applications.handlebars.loadTemplates(templatePaths);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -236,7 +236,7 @@ export class WastelandUtility {
|
||||
static saveRollData(rollData) {
|
||||
game.socket.emit("system.fvtt-wasteland", {
|
||||
name: "msg_update_roll", data: rollData
|
||||
}); // Notify all other clients of the roll
|
||||
}); // Notify all other clients of the roll
|
||||
this.updateRollData(rollData);
|
||||
}
|
||||
|
||||
@@ -322,8 +322,8 @@ export class WastelandUtility {
|
||||
}
|
||||
}
|
||||
if (rollData.charme.system.charmetype == "charme") {
|
||||
rollData.charmeSante = effectRoll.total
|
||||
actor.incDecSante(rollData.charmeSante)
|
||||
rollData.charmeSante = effectRoll.total
|
||||
actor.incDecSante(rollData.charmeSante)
|
||||
}
|
||||
} else {
|
||||
if (rollData.mainDice == "1d20") {
|
||||
@@ -339,13 +339,13 @@ export class WastelandUtility {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//console.log("Result : ", rollData)
|
||||
if (rollData.difficulte > 0 && !rollData.isDramatique) {
|
||||
rollData.isSuccess = (rollData.finalResult >= rollData.difficulte)
|
||||
rollData.isHeroique = ((rollData.finalResult - rollData.difficulte) >= 10)
|
||||
rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ export class WastelandUtility {
|
||||
if (!rollData.isReroll) {
|
||||
actor.changeEclat(-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//console.log("BEFORE COMP", rollData)
|
||||
@@ -395,7 +395,7 @@ export class WastelandUtility {
|
||||
await this.computeResult(rollData, actor)
|
||||
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-wasteland/templates/chat-generic-result.html`, rollData)
|
||||
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-wasteland/templates/chat-generic-result.html`, rollData)
|
||||
}, rollData)
|
||||
|
||||
}
|
||||
@@ -535,7 +535,7 @@ export class WastelandUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static applyBonneAventureRoll(li, changed, addedBonus) {
|
||||
let msgId = li.data("message-id")
|
||||
let msgId = $(li).data("message-id")
|
||||
let msg = game.messages.get(msgId)
|
||||
if (msg) {
|
||||
let rollData = msg.getFlag("world", "wasteland-roll")
|
||||
@@ -554,7 +554,7 @@ export class WastelandUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static applyEclatRoll(li, changed, addedBonus) {
|
||||
let msgId = li.data("message-id")
|
||||
let msgId = $(li).data("message-id")
|
||||
let msg = game.messages.get(msgId)
|
||||
if (msg) {
|
||||
let rollData = msg.getFlag("world", "wasteland-roll")
|
||||
@@ -571,7 +571,7 @@ export class WastelandUtility {
|
||||
static chatRollMenu(html, options) {
|
||||
let canApply = li => canvas.tokens.controlled.length && li.find(".wasteland-roll").length
|
||||
let hasBA = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let message = game.messages.get($(li).attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
@@ -581,7 +581,7 @@ export class WastelandUtility {
|
||||
return false
|
||||
}
|
||||
let hasBA2 = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let message = game.messages.get($(li).attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
@@ -591,7 +591,7 @@ export class WastelandUtility {
|
||||
return false
|
||||
}
|
||||
let hasBA3 = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let message = game.messages.get($(li).attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
@@ -601,7 +601,7 @@ export class WastelandUtility {
|
||||
return false
|
||||
}
|
||||
let hasPE = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let message = game.messages.get($(li).attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
@@ -611,7 +611,7 @@ export class WastelandUtility {
|
||||
return false
|
||||
}
|
||||
let hasPredilection = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let message = game.messages.get($(li).attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
if (rollData.competence) {
|
||||
let nbPred = rollData.competence.data.predilections.filter(pred => !pred.used).length
|
||||
@@ -620,7 +620,7 @@ export class WastelandUtility {
|
||||
return false
|
||||
}
|
||||
let canCompetenceDouble = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let message = game.messages.get($(li).attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
if (rollData.competence) {
|
||||
return rollData.competence.data.doublebonus
|
||||
|
||||
Reference in New Issue
Block a user