Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit 22e3b76

Browse files
committed
adding docs
1 parent fd74cc5 commit 22e3b76

1 file changed

Lines changed: 123 additions & 50 deletions

File tree

src/workers/stats.js

Lines changed: 123 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,140 @@
1+
/**
2+
* @param {Object} data
3+
* @return {Object}
4+
*/
15
function work ( data ) {
26
return idrinth.calculate (
3-
new idrinth.StatSet(data.attack, data.defense, data.perception, data.level, data.stats),
4-
new idrinth.PremiumSet(data.utym, data.mirele, data.kraken),
5-
new idrinth.MultiplierSet(data.legion, data.mount, data.critchance)
7+
new idrinth.StatSet ( data.attack, data.defense, data.perception, data.level, data.stats ),
8+
new idrinth.PremiumSet ( data.utym, data.mirele, data.kraken ),
9+
new idrinth.MultiplierSet ( data.legion, data.mount, data.critchance )
610
);
7-
};
11+
}
12+
/**
13+
* @type {Object}
14+
*/
815
var idrinth = {
9-
PremiumSet: function (utym, mirele, kraken) {
10-
this.utym = utym;
11-
this.mirele = mirele;
12-
this.kraken = kraken;
13-
this.modifyBase = function(base, stat, stats) {};
14-
this.modifyTotal = function(base, stat, stats) {};
16+
/**
17+
* @class Container for premium
18+
* @constructs {idrinth.PremiumSet}
19+
*/
20+
PremiumSet: class PremiumSet {
21+
/**
22+
* @constructor
23+
* @param {Boolean} utym
24+
* @param {Boolean} mirele
25+
* @param {Boolean} kraken
26+
* @return {idrinth.PremiumSet}
27+
*/
28+
constructor ( utym, mirele, kraken ) {
29+
this.utym = utym;
30+
this.mirele = mirele;
31+
this.kraken = kraken;
32+
}
33+
/**
34+
* @param {Number} damage
35+
* @param {String} stat
36+
* @param {idrinth.StatSet} stats
37+
* @return {Number}
38+
*/
39+
modifyBase ( damage, stat, stats ) {}
40+
/**
41+
* @param {Number} damage
42+
* @param {String} stat
43+
* @param {idrinth.StatSet} stats
44+
* @return {Number}
45+
*/
46+
modifyTotal ( damage, stat, stats ) {}
1547
},
16-
MultiplierSet: function (legion, mount, critchance) {
17-
this.legion = legion;
18-
this.mount = mount;
19-
this.critchance = critchance;
20-
this.modifyTotal = function(base, stat, stats, premiums) {};
48+
/**
49+
* @class Container for damage multipliers
50+
* @constructs {idrinth.StatSet}
51+
*/
52+
MultiplierSet: class MultiplierSet {
53+
/**
54+
* @constructor
55+
* @param {Number} legion
56+
* @param {Number} mount
57+
* @param {Number} critchance
58+
* @return {idrinth.MultiplierSet}
59+
*/
60+
constructor ( legion, mount, critchance ) {
61+
this.legion = legion;
62+
this.mount = mount;
63+
this.critchance = critchance;
64+
}
65+
/**
66+
* @param {Number} base
67+
* @param {String} stat
68+
* @param {idrinth.StatSet} stats
69+
* @param {idrinth.PremiumSet} premiums
70+
* @return {idrinth.StatSet}
71+
*/
72+
modifyTotal ( base, stat, stats, premiums ) {}
2173
},
22-
StatSet: function(attack, defense, perception, level, stats) {
23-
this.attack = attack;
24-
this.defense = defense;
25-
this.perception = perception;
26-
this.stats = stats;
27-
this.level = level;
28-
this.getCost = function ( value ) {
29-
let toPositive = function(number) {
30-
return Math.max(number, 0);
31-
};
32-
return 1+ Math.ceil (
33-
toPositive (
34-
value -
35-
10000 -
36-
Math.floor (toPositive ( this.level / 500 - 2 )) * 1500
37-
) / 1500
38-
);
39-
};
40-
this.getIncreaseableStats = function() {
41-
let stats = [];
42-
if (this.getCost(this.attack) <= this.stats) {
43-
stats.push ('attack');
74+
/**
75+
* @class Container for attributes
76+
* @constructs {idrinth.StatSet}
77+
*/
78+
StatSet: class StatSet {
79+
/**
80+
* @constructor
81+
* @param {Number} attack
82+
* @param {Number} defense
83+
* @param {Number} perception
84+
* @param {Number} level
85+
* @param {Number} stats
86+
* @return {idrinth.StatSet}
87+
*/
88+
constructor ( attack, defense, perception, level, stats ) {
89+
this.attack = attack;
90+
this.defense = defense;
91+
this.perception = perception;
92+
this.stats = stats;
93+
this.level = level;
94+
}
95+
/**
96+
* @param {Number} value
97+
* @return {Number}
98+
*/
99+
getCost ( value ) {
100+
/**
101+
* @param {Number} number
102+
* @return {Number}
103+
*/
104+
let toPositive = function ( number ) {
105+
return Math.max ( number, 0 );
106+
};
107+
let modifier = 10000 + Math.floor ( toPositive ( this.level / 500 - 2 ) ) * 1500;
108+
return 1 + Math.ceil (toPositive (value - modifier) / 1500);
109+
}
110+
/**
111+
* @return {Array}
112+
*/
113+
getIncreaseableStats () {
114+
let stats = [ ];
115+
if ( this.getCost ( this.attack ) <= this.stats ) {
116+
stats.push ( 'attack' );
44117
}
45-
if (this.getCost(this.defense) <= this.stats) {
46-
stats.push ('defense');
118+
if ( this.getCost ( this.defense ) <= this.stats ) {
119+
stats.push ( 'defense' );
47120
}
48-
if (this.getCost(this.perception) <= this.stats) {
49-
stats.push ('perception');
121+
if ( this.getCost ( this.perception ) <= this.stats ) {
122+
stats.push ( 'perception' );
50123
}
51124
return stats;
52-
};
125+
}
53126
},
54127
/**
55-
* @param {idrinth.StatSet} stat
56-
* @param {idrinth.PremiumSet} premium
57-
* @param {idrinth.MultiplierSet} multiplier
58-
* @return {idrinth.StatSet}
128+
* @param {StatSet} stat
129+
* @param {PremiumSet} premium
130+
* @param {MultiplierSet} multiplier
131+
* @return {StatSet}
59132
*/
60-
calculate(stat, premium, multiplier) {
61-
let modified = false
133+
calculate ( stat, premium, multiplier ) {
134+
let modified = false;
62135
do {
63-
stat.getIncreaseableStats().forEach();
64-
} while (modified)
136+
stat.getIncreaseableStats ().forEach ();
137+
} while ( modified )
65138
return stat;
66139
}
67140
};

0 commit comments

Comments
 (0)