forked from MaterialFoundry/materialdeck-systemtemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaterialdeck-template.js
More file actions
381 lines (340 loc) · 12.6 KB
/
Copy pathmaterialdeck-template.js
File metadata and controls
381 lines (340 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
const data = {
moduleId: '', //id from module.json
systemId: '', //id of the system, you can get it using `game.system.id` in the console
systemName: '' //name of the system, for example: 'Dungeons & Dragons 5e'
}
/**
* Proficiency colors to show if a token is proficient in for example a skill
*/
const proficiencyColors = {
0: "#000000",
0.5: "#804A00",
1: "#C0C0C0",
2: "#FFD700"
}
/**
* Main class that describes the system
*/
class system {
conf; //this variable stores the configuration data for the system, set in the constructor
constructor(){
console.log("Material Deck: Using system 'SystemName'");
this.conf = CONFIG.DND5E; //You can use this to get various things like the list of ability scores, conditions, etc. Make sure you set it to the correct value for your system
}
getActorData(token) {
return token.actor.system;
}
getItemData(item) {
return item.system;
}
/**
* This generates a list of stats to be displayed on the SD: Token Action => Stats.
* Choose the ones you want to use and change the 'name' value if desired. If you add new ones, you will need to add a function to handle them in src/token.js.
* After each option you'll find what function it will call after the button is pressed on the SD
*/
getStatsList() {
return [
{value:'HP', name:'HP'}, //will call getHP()
{value:'HPbox', name:'HP (box)'}, //will call getHP()
{value:'TempHP', name:'Temp HP'}, //will call getTempHP()
{value:'AC', name:'AC'}, //will call getAC()
{value:'ShieldHP', name:'Shield HP'}, //will call getShieldHP()
{value:'Speed', name:'Speed'}, //will call getSpeed()
{value:'Init', name:'Initiative'}, //will call getInitiative()
{value:'Ability', name:'Ability Score'}, //will call getAbility()
{value:'AbilityMod', name:'Ability Score Modifier'}, //will call getAbilityModifier()
{value:'Save', name:'Saving Throw Modifier'}, //will call getAbilitySave()
{value:'Skill', name:'Skill Modifier'}, //will call getSkill()
{value:'PassivePerception', name:'Passive Perception'}, //will call getPassivePerception()
{value:'PassiveInvestigation', name:'Passive Investigation'}, //will call getPassiveInvestigation()
{value:'Prof', name:'Proficiency'}, //will call getProficiency()
{value:'Condition', name: 'Condition'}, //will call getConditionValue()
]
}
/**
* Adds an on click option to the SD: Token Action => On Click
* Currently only supports toggling initiative (for Shadow of the Demonlord)
*/
getOnClickList() {
return [
//{value:'initiative',name:'Toggle Initiative'}
]
}
/**
* Returns the HP of the token
* @param {Token} token Token instance to get the HP from
* @returns {object} Token hp value and max: {value: ##, max: ##}
*/
getHP(token) {
return;
}
/**
* Returns the temporary HP of the token
* @param {Token} token Token instance to get the temp HP from
* @returns {object} Token temp hp value and max: {value: ##, max: ##}
*/
getTempHP(token) {
return;
}
/**
* Returns the armor class of the token
* @param {Token} token Token instance to get the AC from
* @returns {number} AC value
*/
getAC(token) {
return;
}
/**
* Returns the shield HP of the token
* @param {Token} token Token instance to get the shield HP from
* @returns {number} Shield HP
*/
getShieldHP(token) {
return;
}
/**
* Returns a string with movement speeds of the token
* @param {Token} token Token instance to get the speed from
* @returns {string} Movement speed string
*/
getSpeed(token) {
return;
}
/**
* Returns the initiative of the token
* @param {Token} token Token instance to get the initiative from
* @returns {number} Initiative value
*/
getInitiative(token) {
return;
}
/**
* Toggles the initiative of the token
* @param {Token} token Token instance to toggle the initiative for
*/
toggleInitiative(token) {
}
/**
* Returns the passive perception of the token
* @param {Token} token Token instance to get the passive perception from
* @returns {number} Passive perception value
*/
getPassivePerception(token) {
return;
}
/**
* Returns the passive investigation of the token
* @param {Token} token Token instance to get the passive investigation from
* @returns {number} Passive investigation value
*/
getPassiveInvestigation(token) {
return;
}
/**
* Returns the ability value of the token
* @param {Token} token Token instance to get the ability value from
* @param {string} ability Ability to get the value from
* @returns {number} Ability value
*/
getAbility(token, ability) {
if (ability == undefined) ability = ''; //default ability
return;
}
/**
* Returns the ability modifier of the token
* @param {Token} token Token instance to get the ability modifier from
* @param {string} ability Ability to get the value from
* @returns {number} Ability modifier
*/
getAbilityModifier(token, ability) {
if (ability == undefined) ability = ''; //default ability
return;
}
/**
* Returns the ability save of the token
* @param {Token} token Token instance to get the ability save from
* @param {string} ability Ability to get the value from
* @returns {number} Ability save
*/
getAbilitySave(token, ability) {
if (ability == undefined) ability = ''; //default ability
return;
}
/**
* Returns a list of abilities available to the system
* Each array item must be {value:'abilityId', name:'abilityName'}
* 'abilityId' is defined by the system, the name can be anything you want
* @returns
*/
getAbilityList() {
let abilities = [];
return abilities;
}
/**
* Returns the skill value of the token
* @param {Token} token Token instance to get the skill value from
* @param {string} skill Skill to get the value from
* @returns {number} Skill value
*/
getSkill(token, skill) {
if (skill == undefined) skill = '';
return;
}
/**
* Returns the proficiency value of the token
* @param {Token} token Token instance to get the proficiency from
* @returns {number} Proficiency value
*/
getProficiency(token) {
return;
}
/**
* Returns the icon location of a condition
* @param {string} condition Name of the condition
* @returns {string} Icon location
*/
getConditionIcon(condition) {
if (condition == undefined) condition = 'removeAll';
if (condition == 'removeAll') return;
else return;
}
/**
* Returns whether a condition is active on the token
* @param {Token} token Token instance to get the value from
* @param {string} condition Name of the condition
* @returns {boolean} Condition is active or not
*/
getConditionActive(token,condition) {
if (condition == undefined) condition = 'removeAll';
return;
}
/**
* Toggles a condition on a token
* @param {Token} token Token instance to get the value from
* @param {string} condition Name of the condition
*/
async toggleCondition(token,condition) {
if (condition == undefined) condition = 'removeAll';
}
/**
* Roll for a token
* @param {Token} token Token instance to roll for
* @param {string} roll Roll type (ability/save/skill/initiative/deathSave)
* @param {bbject} options Roll options
* @param {string} ability Name of the ability to roll
* @param {string} skill Name of the skill to roll
* @param {string} save Name of the save to roll
*/
roll(token,roll,options,ability,skill,save) {
if (roll == undefined) roll = 'ability';
if (ability == undefined) ability = ''; //default ability
if (skill == undefined) skill = ''; //default skill
if (save == undefined) save = ''; //default save
if (roll == 'ability')
else if (roll == 'save')
else if (roll == 'skill')
else if (roll == 'initiative')
else if (roll == 'deathSave')
}
/**
* Get array of items
* @param {Token} token Token instance to get the items from
* @param {string} itemType Item type
* @returns {array} Array of items
*/
getItems(token,itemType) {
if (itemType == undefined) itemType = 'any';
if (itemType == 'any') return ;
else return ;
}
/**
* Returns uses/quantity of an item
* @param {Item} item Item instance to get the uses/quantity from
* @returns {object} Uses/quantity available {available: ###, maximum: ###}
*/
getItemUses(item) {
return;
}
/**
* Returns the features of a token
* @param {Token} token Token instance to get the features from
* @param {string} featureType Feature types to return
* @returns {array} Array of features
*/
getFeatures(token,featureType) {
if (featureType == undefined) featureType = 'any';
if (featureType == 'any') return;
else return;
}
/**
* Returns uses/quantity of a feature
* @param {Item} item Item/feature instance to get the uses/quantity from
* @returns {object} Uses/quantity available {available: ###, maximum: ###}
*/
getFeatureUses(item) {
return {};
}
/**
* Returns the spells of a token
* @param {Token} token Token instance to get the spells from
* @param {string} level Spell level
* @returns {array} Array of spells
*/
getSpells(token,level) {
if (level == undefined) level = 'any';
if (level == 'any') return;
else return;
}
/**
* Returns the spell uses of a specific spell for a token
* @param {Token} token Token instance to get the spell uses from
* @param {string} level Spell level
* @param {Item} item Spell instance to get the uses from
* @returns {object} Spell uses left: {available: ###, maximum: ###}
*/
getSpellUses(token,level,item) {
return {
}
}
/**
* Roll an item
* @param {Token} item Item instance to roll
* @param {object} settings Settings of the action
* @param {object} rollOption Roll options
*/
rollItem(item, settings, rollOption) {
}
/**
* Returns a color to display proficiency for skills
* @param {Token} token Token instance to get the proficiency from
* @param {string} skill Skill name
* @returns {string} Hex color string from proficiencyColors array
*/
getSkillRingColor(token, skill) {
const profLevel = ;
if (profLevel == undefined) return;
return proficiencyColors?.[profLevel];
}
/**
* Returns a color to display proficiency for saves
* @param {Token} token Token instance to get the proficiency from
* @param {string} save Save name
* @returns {string} Hex color string from proficiencyColors array
*/
getSaveRingColor(token, save) {
const profLevel = ;
if (profLevel == undefined) return;
return proficiencyColors?.[profLevel];
}
}
Hooks.once('MaterialDeck_Ready', () => {
const moduleData = game.modules.get(data.moduleId);
game.materialDeck.registerSystem({
systemId: data.systemId,
moduleId: data.moduleId,
systemName: data.systemName,
version: moduleData.version,
manifest: moduleData.manifest,
system
});
});