-
Notifications
You must be signed in to change notification settings - Fork 1
/
character.js
97 lines (88 loc) · 3.87 KB
/
character.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
var _ = require('lodash');
class Character {
constructor(characterJSON) {
this.charJSON = characterJSON;
}
get characteristics() {
var characteristicList = {};
for(var char in this.charJSON.Characteristics[0].CharCharacteristic) {
var c = this.charJSON.Characteristics[0].CharCharacteristic[char];
var rank = parseInt(c.Rank[0].SpeciesRanks[0]);
if (c.Rank[0].PurchasedRanks) {
rank += parseInt(c.Rank[0].PurchasedRanks[0]);
}
if (c.Rank[0].TalentRanks) {
rank += parseInt(c.Rank[0].TalentRanks[0]);
}
characteristicList[c.Name[0].toLowerCase()] = rank;
}
return characteristicList;
}
get skills() {
var skillList = {};
for(var skill in this.charJSON.Skills[0].CharSkill) {
var s = this.charJSON.Skills[0].CharSkill[skill];
var rank = 0;
if (s.Rank[0].SpeciesRanks) {
rank += parseInt(s.Rank[0].SpeciesRanks[0]);
}
if (s.Rank[0].PurchasedRanks) {
rank += parseInt(s.Rank[0].PurchasedRanks[0]);
}
if (s.Rank[0].CareerRanks) {
rank += parseInt(s.Rank[0].CareerRanks[0]);
}
skillList[this.skillByKey(s.Key[0]).name] = rank;
}
return skillList;
}
getDicePool(skillName) {
var skill = _.findKey(this.skillDict, function(o) {return o.name == skillName;});
var max = Math.max(this.characteristics[this.skillDict[skill].char], this.skills[skillName]);
var min = Math.min(this.characteristics[this.skillDict[skill].char], this.skills[skillName]);
return (Array(min+1).join("p") + Array(max-min+1).join("a"));
}
skillByKey(skillKey) {
return this.skillDict[skillKey];
}
get skillDict(){
return {
'ASTRO':{name:'astrogation', char:'intellect'},
'ATHL':{name:'athletics', char:'brawn'},
'BRAWL':{name:'brawl', char:'brawn'},
'CHARM':{name:'charm', char:'presence'},
'COERC':{name:'coercion', char:'willpower'},
'COMP':{name:'computers', char:'intellect'},
'COOL':{name:'cool', char:'presence'},
'COORD':{name:'coordination', char:'agility'},
'CORE':{name:'coreWorlds', char:'intellect'},
'DECEP':{name:'deception', char:'cunning'},
'DISC':{name:'discipline', char:'willpower'},
'EDU':{name:'education', char:'intellect'},
'GUNN':{name:'gunnery', char:'agility'},
'LEAD':{name:'leadership', char:'presence'},
'LTSABER':{name:'lightsaber', char:'brawn'}, //Figure out Jedi stuff
'LORE':{name:'lore', char:'intellect'},
'MECH':{name:'mechanics', char:'intellect'},
'MED':{name:'medicine', char:'intellect'},
'MELEE':{name:'melee', char:'brawn'},
'NEG':{name:'negotiation', char:'presence'},
'OUT':{name:'outerRim', char:'intellect'},
'PERC':{name:'perception', char:'cunning'},
'PILOTPL':{name:'pilotingSpace', char:'agility'},
'PILOTSP':{name:'pilotingPlanetary', char:'agility'},
'RANGHVY':{name:'rangedHeavy', char:'agility'},
'RANGLT':{name:'rangedLight', char:'agility'},
'RESIL':{name:'resilience', char:'brawn'},
'SKUL':{name:'skullduggery', char:'cunning'},
'STEAL':{name:'stealth', char:'agility'},
'SW':{name:'streetwise', char:'cunning'},
'SURV':{name:'survival', char:'cunning'},
'UND':{name:'underworld', char:'intellect'},
'VIGIL':{name:'vigilance', char:'willpower'},
'XEN':{name:'xenology', char:'intellect'},
'WARF':{name:'warfare', char:'intellect'}
};
}
}
module.exports = Character;