@@ -3,7 +3,12 @@ import { PlayerCharacterSheet } from "./sheet/player.js";
3
3
import { NpcCharacterSheet } from "./sheet/npc.js" ;
4
4
import { VaesenCharacterSheet } from "./sheet/vaesen.js" ;
5
5
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" ;
7
12
import { registerSystemSettings } from "./util/settings.js" ;
8
13
import { vaesen } from "./config.js" ;
9
14
import { conditions } from "./util/conditions.js" ;
@@ -30,9 +35,9 @@ Hooks.once("init", () => {
30
35
CONFIG . push = push ;
31
36
CONFIG . Cards . presets = {
32
37
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" ,
36
41
} ,
37
42
} ;
38
43
@@ -80,7 +85,7 @@ Hooks.once("init", () => {
80
85
return TextEditor . enrichHTML ( rawText , { async : false } ) ;
81
86
} ) ;
82
87
83
- Handlebars . registerHelper ( ' ifIn' , function ( elem , list , options ) {
88
+ Handlebars . registerHelper ( " ifIn" , function ( elem , list , options ) {
84
89
if ( list && list . indexOf ( elem ) > - 1 ) {
85
90
return options . fn ( this ) ;
86
91
}
@@ -98,39 +103,50 @@ Hooks.once("init", () => {
98
103
} ) ;
99
104
100
105
Hooks . once ( "ready" , async function ( ) {
101
-
102
106
setupCards ( ) ;
103
107
conditions . onReady ( ) ;
104
108
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
+ ) ;
106
112
migrate ( ) ;
107
113
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
+ } ) ;
108
126
} ) ;
109
127
110
- Hooks . on ( ' canvasReady' , ( ) => {
128
+ Hooks . on ( " canvasReady" , ( ) => {
111
129
canvas . hud . token = new VaesenTokenHUD ( ) ;
112
130
} ) ;
113
131
114
132
Hooks . on ( "updateActor" , ( actor , changes , diff , userId ) => {
115
133
// 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 ;
117
136
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 ;
121
139
122
140
actor . update ( { "token.name" : actor . name } ) ;
123
- x . update ( { " name" : actor . name } ) ;
141
+ x . update ( { name : actor . name } ) ;
124
142
} ) ;
125
143
} ) ;
126
144
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 ;
130
147
131
148
let headquarter = await fromUuid ( data . uuid ) ;
132
- if ( headquarter . type === "headquarter" )
133
- sheet . _dropHeadquarter ( headquarter ) ;
149
+ if ( headquarter . type === "headquarter" ) sheet . _dropHeadquarter ( headquarter ) ;
134
150
} ) ;
135
151
136
152
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) {
141
157
await conditions . onActionCondition ( data ) ;
142
158
} ) ;
143
159
144
- Hooks . on ( ' updateCombat' , async function ( e ) {
160
+ Hooks . on ( " updateCombat" , async function ( e ) {
145
161
if ( ! game . user . isGM ) return ;
146
162
await conditions . onActionUpdate ( e . current . tokenId , e . combatant , e . turn ) ;
147
163
} ) ;
148
164
149
- Hooks . on ( ' deleteCombat' , async function ( e ) {
165
+ Hooks . on ( " deleteCombat" , async function ( e ) {
150
166
if ( ! game . user . isGM ) return ;
151
167
await conditions . onCombatStartEnd ( e ) ;
152
168
} ) ;
153
169
154
- Hooks . on ( ' combatStart' , async function ( e ) {
170
+ Hooks . on ( " combatStart" , async function ( e ) {
155
171
if ( ! game . user . isGM ) return ;
156
172
await conditions . onCombatStartEnd ( e ) ;
157
173
} ) ;
158
174
159
- Hooks . on ( ' combatRound' , async function ( e ) {
175
+ Hooks . on ( " combatRound" , async function ( e ) {
160
176
if ( ! game . user . isGM ) return ;
161
177
await conditions . onCombatStartEnd ( e ) ;
162
178
} ) ;
@@ -224,7 +240,7 @@ async function _onPush(event) {
224
240
event . preventDefault ( ) ;
225
241
226
242
// Get the message.
227
- let chatCard = event . currentTarget . closest ( ' .chat-message' ) ;
243
+ let chatCard = event . currentTarget . closest ( " .chat-message" ) ;
228
244
let messageId = chatCard . dataset . messageId ;
229
245
let message = game . messages . get ( messageId ) ;
230
246
@@ -240,17 +256,16 @@ async function _onPush(event) {
240
256
}
241
257
242
258
async function setupCards ( ) {
243
- const initiativeDeckId = game . settings . get ( ' vaesen' , ' initiativeDeck' ) ;
259
+ const initiativeDeckId = game . settings . get ( " vaesen" , " initiativeDeck" ) ;
244
260
const initiativeDeck = game . cards ?. get ( initiativeDeckId ) ;
245
261
//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 } ) ;
249
264
const preset = CONFIG . Cards . presets . initiative ;
250
265
const data = await foundry . utils . fetchJsonWithTimeout ( preset . src ) ;
251
- const cardsCls = getDocumentClass ( ' Cards' ) ;
266
+ const cardsCls = getDocumentClass ( " Cards" ) ;
252
267
const newDeck = await cardsCls . create ( data ) ;
253
- await game . settings . set ( ' vaesen' , ' initiativeDeck' , newDeck ?. id ) ;
268
+ await game . settings . set ( " vaesen" , " initiativeDeck" , newDeck ?. id ) ;
254
269
await newDeck ?. shuffle ( { chatNotification : false } ) ;
255
270
}
256
271
@@ -295,52 +310,47 @@ function preloadHandlebarsTemplates() {
295
310
* @returns {Promise }
296
311
*/
297
312
async function createRollMacro ( data , slot ) {
298
-
299
313
let command = "" ;
300
314
if ( data . type === "skill" ) {
301
315
command = `
302
316
if (actor == null || actor.type !== "player")
303
317
return;
304
318
305
319
actor.sheet.rollSkill("${ data . skillKey } ");` ;
306
- }
307
- else if ( data . type === "attribute" ) {
320
+ } else if ( data . type === "attribute" ) {
308
321
command = `
309
322
if (actor == null || actor.type !== "player")
310
323
return;
311
324
312
325
actor.sheet.rollAttribute("${ data . attributeKey } ");` ;
313
- }
314
- else if ( data . type === "fear" ) {
326
+ } else if ( data . type === "fear" ) {
315
327
command = `
316
328
if (actor == null || actor.type !== "player")
317
329
return;
318
330
319
331
actor.sheet.rollFear("${ data . attributeKey } ");` ;
320
- }
321
- else if ( data . type === "weapon" ) {
332
+ } else if ( data . type === "weapon" ) {
322
333
command = `
323
334
if (actor == null || actor.id != "${ data . actorId } ")
324
335
return;
325
336
326
337
actor.sheet.rollWeapon("${ data . itemId } ");` ;
327
338
}
328
339
329
- if ( command === "" )
330
- return ;
340
+ if ( command === "" ) return ;
331
341
332
- let macro = game . macros . find ( m => ( m . name === data . text ) ) ;
342
+ let macro = game . macros . find ( ( m ) => m . name === data . text ) ;
333
343
console . log ( macro ) ;
334
344
if ( ! macro ) {
335
345
macro = await Macro . create ( {
336
346
name : data . text ,
337
347
type : "script" ,
338
348
img : data . img ,
339
349
command : command ,
340
- flags : { "vaesen.skillRoll" : true }
350
+ flags : { "vaesen.skillRoll" : true } ,
341
351
} ) ;
342
352
}
343
353
344
354
game . user . assignHotbarMacro ( macro , slot ) ;
345
355
return false ;
346
- }
356
+ }
0 commit comments