-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsjgurps4e.js
116 lines (96 loc) · 3.66 KB
/
sjgurps4e.js
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
import {sjgurps4e} from "./module/config.js";
import * as Chat from "./module/chat.js";
import sjgurps4eItemSheet from "./module/item/sheet.js";
import sjgurps4eActorSheet from "./module/actor/sheet.js";
import { preloadHandlebarsTemplates } from "./module/templates.js";
import sjgurps4eActor from "./module/actor/entity.js";
import sjgurps4eItem from "./module/item/entity.js";
import { registerSystemSettings } from "./module/settings.js";
import { _getInitiativeFormula } from "./module/combat.js";
Hooks.once("init", function (){
console.log("sjgurps4e | Initializing GURPS 4e");
console.log(sjgurps4e.ASCII);
game.sjgurps4e ={
applications: {
sjgurps4eActor,
sjgurps4eActorSheet
},
config: sjgurps4e,
entities: {
sjgurps4eActor,
sjgurps4eItem,
}
}
CONFIG.sjgurps4e = sjgurps4e;
CONFIG.Actor.entityClass = sjgurps4eActor;
CONFIG.Item.entityClass = sjgurps4eItem;
// Register System Settings
registerSystemSettings();
// set up the baseline inititive formula
CONFIG.Combat.initiative.formula = String("@baseSpeed + (1d6/1000)");
Combat.prototype._getInitiativeFormula = _getInitiativeFormula;
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("sjgurps4e", sjgurps4eItemSheet, {makeDefault: true});
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("sjgurps4e", sjgurps4eActorSheet, {makeDefault: true});
// Preload Handlebars Templates
preloadHandlebarsTemplates();
//calculate point costs for attribute values
Handlebars.registerHelper("statValue", function(n, string, attribute = 10){
let result = '';
// yeah yeah I know it's a multiplier... it used to be a division thing but I changed it and
// was too lazy to change the code :P
let divisor = '';
let baseValue = 10;
if(string === "ST" || string === "HT"){
divisor = 10;
} else if (string === "DX" || string === "IQ"){
divisor = 20;
} else if (string === "Will" || string === "Per") {
divisor = 5;
baseValue = attribute;
} else if (string === "HP") {
divisor = 2;
//console.log("*-* ST is currently: " + ST);
baseValue = attribute;
} else if (string === "FP"){
//console.log("*-* HT is currently: " + ST);
baseValue = attribute;
divisor = 3;
}
result = (n-baseValue)*divisor;
//console.log("*-* value of n in handlebarhelper " + n);
//console.log("*-* value of divisor in helper " + divisor);
return result;
});
Handlebars.registerHelper('getProperty', function (data, property) {
return getProperty(data, property);
});
Handlebars.registerHelper('getRollTarget', function(data, item, skill, mod){
return;
})
Handlebars.registerHelper('localizeData', function (locationString, datastring){
let localizationLocation = "";
//console.log(datastring);
if(datastring == ""){
localizationLocation = "sjgurps4e."+locationString+"."+"none";
} else {
localizationLocation = "sjgurps4e."+locationString+"."+datastring;
}
//console.log(localizationLocation);
return game.i18n.localize(localizationLocation);
});
})
Hooks.on("preCreateItem", (createData) =>{
if(!createData.img)
createData.img = "systems/sjgurps4e/icons/new_item.svg"
})
/**
* Set default values for new actors' tokens
*/
Hooks.on("preCreateActor", (createData) =>{
// Set custom default token
if (!createData.img)
createData.img = "systems/sjgurps4e/icons/new_actor.png"
})
Hooks.on("renderChatLog", (app, html, data) => Chat.addChatListeners(html));