Skip to content

Commit e9f1a37

Browse files
committed
verify vaesen token images are correct
1 parent 774a078 commit e9f1a37

File tree

1 file changed

+51
-41
lines changed

1 file changed

+51
-41
lines changed

Diff for: script/hooks.js

+51-41
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { PlayerCharacterSheet } from "./sheet/player.js";
33
import { NpcCharacterSheet } from "./sheet/npc.js";
44
import { VaesenCharacterSheet } from "./sheet/vaesen.js";
55
import { HeadquarterCharacterSheet } from "./sheet/headquarter.js";
6-
import { prepareRollNewDialog, push, registerGearSelectTooltip, totalRoll as totalRoll } from "./util/roll.js";
6+
import {
7+
prepareRollNewDialog,
8+
push,
9+
registerGearSelectTooltip,
10+
totalRoll as totalRoll,
11+
} from "./util/roll.js";
712
import { registerSystemSettings } from "./util/settings.js";
813
import { vaesen } from "./config.js";
914
import { conditions } from "./util/conditions.js";
@@ -30,9 +35,9 @@ Hooks.once("init", () => {
3035
CONFIG.push = push;
3136
CONFIG.Cards.presets = {
3237
initiative: {
33-
label: 'Initiative Deck',
34-
src: 'systems/vaesen/asset/cards/initiative-deck.json',
35-
type: 'deck',
38+
label: "Initiative Deck",
39+
src: "systems/vaesen/asset/cards/initiative-deck.json",
40+
type: "deck",
3641
},
3742
};
3843

@@ -80,7 +85,7 @@ Hooks.once("init", () => {
8085
return TextEditor.enrichHTML(rawText, { async: false });
8186
});
8287

83-
Handlebars.registerHelper('ifIn', function (elem, list, options) {
88+
Handlebars.registerHelper("ifIn", function (elem, list, options) {
8489
if (list && list.indexOf(elem) > -1) {
8590
return options.fn(this);
8691
}
@@ -98,39 +103,50 @@ Hooks.once("init", () => {
98103
});
99104

100105
Hooks.once("ready", async function () {
101-
102106
setupCards();
103107
conditions.onReady();
104108
Hooks.on("hotbarDrop", (bar, data, slot) => createRollMacro(data, slot));
105-
Hooks.on("chatMessage", (_, messageText, chatData) => totalRoll(messageText, chatData));
109+
Hooks.on("chatMessage", (_, messageText, chatData) =>
110+
totalRoll(messageText, chatData)
111+
);
106112
migrate();
107113
registerGearSelectTooltip();
114+
115+
let allVaesen = game.actors.filter((it) => it.type == "vaesen");
116+
117+
allVaesen.forEach((vaesen) => {
118+
let conditions = vaesen.items.filter((c) => c.type == "condition");
119+
let count = 0;
120+
conditions.forEach((condition) => {
121+
count++;
122+
const img = "systems/vaesen/asset/counter_tokens/" + count + ".png";
123+
condition.update({ img: img });
124+
});
125+
});
108126
});
109127

110-
Hooks.on('canvasReady', () => {
128+
Hooks.on("canvasReady", () => {
111129
canvas.hud.token = new VaesenTokenHUD();
112130
});
113131

114132
Hooks.on("updateActor", (actor, changes, diff, userId) => {
115133
// if we don't have an active scene, don't do anything
116-
if (!game.scenes.current || !actor.isOwner || changes.name == undefined) return;
134+
if (!game.scenes.current || !actor.isOwner || changes.name == undefined)
135+
return;
117136
console.log("updateActor", actor, changes, diff, userId);
118-
game.scenes.current.tokens.forEach(x => {
119-
if (x.actorId !== actor._id)
120-
return;
137+
game.scenes.current.tokens.forEach((x) => {
138+
if (x.actorId !== actor._id) return;
121139

122140
actor.update({ "token.name": actor.name });
123-
x.update({ "name": actor.name });
141+
x.update({ name: actor.name });
124142
});
125143
});
126144

127-
Hooks.on('dropActorSheetData', async (actor, sheet, data) => {
128-
if (actor.type !== 'player' || data.type !== "Actor")
129-
return;
145+
Hooks.on("dropActorSheetData", async (actor, sheet, data) => {
146+
if (actor.type !== "player" || data.type !== "Actor") return;
130147

131148
let headquarter = await fromUuid(data.uuid);
132-
if (headquarter.type === "headquarter")
133-
sheet._dropHeadquarter(headquarter);
149+
if (headquarter.type === "headquarter") sheet._dropHeadquarter(headquarter);
134150
});
135151

136152
Hooks.on("yze-combat.fast-action-button-clicked", async function (data) {
@@ -141,22 +157,22 @@ Hooks.on("yze-combat.slow-action-button-clicked", async function (data) {
141157
await conditions.onActionCondition(data);
142158
});
143159

144-
Hooks.on('updateCombat', async function (e) {
160+
Hooks.on("updateCombat", async function (e) {
145161
if (!game.user.isGM) return;
146162
await conditions.onActionUpdate(e.current.tokenId, e.combatant, e.turn);
147163
});
148164

149-
Hooks.on('deleteCombat', async function (e) {
165+
Hooks.on("deleteCombat", async function (e) {
150166
if (!game.user.isGM) return;
151167
await conditions.onCombatStartEnd(e);
152168
});
153169

154-
Hooks.on('combatStart', async function (e) {
170+
Hooks.on("combatStart", async function (e) {
155171
if (!game.user.isGM) return;
156172
await conditions.onCombatStartEnd(e);
157173
});
158174

159-
Hooks.on('combatRound', async function (e) {
175+
Hooks.on("combatRound", async function (e) {
160176
if (!game.user.isGM) return;
161177
await conditions.onCombatStartEnd(e);
162178
});
@@ -224,7 +240,7 @@ async function _onPush(event) {
224240
event.preventDefault();
225241

226242
// Get the message.
227-
let chatCard = event.currentTarget.closest('.chat-message');
243+
let chatCard = event.currentTarget.closest(".chat-message");
228244
let messageId = chatCard.dataset.messageId;
229245
let message = game.messages.get(messageId);
230246

@@ -240,17 +256,16 @@ async function _onPush(event) {
240256
}
241257

242258
async function setupCards() {
243-
const initiativeDeckId = game.settings.get('vaesen', 'initiativeDeck');
259+
const initiativeDeckId = game.settings.get("vaesen", "initiativeDeck");
244260
const initiativeDeck = game.cards?.get(initiativeDeckId);
245261
//return early if both the deck and the ID exist in the world
246-
if (initiativeDeckId && initiativeDeck)
247-
return;
248-
ui.notifications.info('UI.NoInitiativeDeckFound', { localize: true });
262+
if (initiativeDeckId && initiativeDeck) return;
263+
ui.notifications.info("UI.NoInitiativeDeckFound", { localize: true });
249264
const preset = CONFIG.Cards.presets.initiative;
250265
const data = await foundry.utils.fetchJsonWithTimeout(preset.src);
251-
const cardsCls = getDocumentClass('Cards');
266+
const cardsCls = getDocumentClass("Cards");
252267
const newDeck = await cardsCls.create(data);
253-
await game.settings.set('vaesen', 'initiativeDeck', newDeck?.id);
268+
await game.settings.set("vaesen", "initiativeDeck", newDeck?.id);
254269
await newDeck?.shuffle({ chatNotification: false });
255270
}
256271

@@ -295,52 +310,47 @@ function preloadHandlebarsTemplates() {
295310
* @returns {Promise}
296311
*/
297312
async function createRollMacro(data, slot) {
298-
299313
let command = "";
300314
if (data.type === "skill") {
301315
command = `
302316
if (actor == null || actor.type !== "player")
303317
return;
304318
305319
actor.sheet.rollSkill("${data.skillKey}");`;
306-
}
307-
else if (data.type === "attribute") {
320+
} else if (data.type === "attribute") {
308321
command = `
309322
if (actor == null || actor.type !== "player")
310323
return;
311324
312325
actor.sheet.rollAttribute("${data.attributeKey}");`;
313-
}
314-
else if (data.type === "fear") {
326+
} else if (data.type === "fear") {
315327
command = `
316328
if (actor == null || actor.type !== "player")
317329
return;
318330
319331
actor.sheet.rollFear("${data.attributeKey}");`;
320-
}
321-
else if (data.type === "weapon") {
332+
} else if (data.type === "weapon") {
322333
command = `
323334
if (actor == null || actor.id != "${data.actorId}")
324335
return;
325336
326337
actor.sheet.rollWeapon("${data.itemId}");`;
327338
}
328339

329-
if (command === "")
330-
return;
340+
if (command === "") return;
331341

332-
let macro = game.macros.find(m => (m.name === data.text));
342+
let macro = game.macros.find((m) => m.name === data.text);
333343
console.log(macro);
334344
if (!macro) {
335345
macro = await Macro.create({
336346
name: data.text,
337347
type: "script",
338348
img: data.img,
339349
command: command,
340-
flags: { "vaesen.skillRoll": true }
350+
flags: { "vaesen.skillRoll": true },
341351
});
342352
}
343353

344354
game.user.assignHotbarMacro(macro, slot);
345355
return false;
346-
}
356+
}

0 commit comments

Comments
 (0)