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

Commit

Permalink
adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth committed May 31, 2018
1 parent fd74cc5 commit 22e3b76
Showing 1 changed file with 123 additions and 50 deletions.
173 changes: 123 additions & 50 deletions src/workers/stats.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,140 @@
/**
* @param {Object} data
* @return {Object}
*/
function work ( data ) {
return idrinth.calculate (
new idrinth.StatSet(data.attack, data.defense, data.perception, data.level, data.stats),
new idrinth.PremiumSet(data.utym, data.mirele, data.kraken),
new idrinth.MultiplierSet(data.legion, data.mount, data.critchance)
new idrinth.StatSet ( data.attack, data.defense, data.perception, data.level, data.stats ),
new idrinth.PremiumSet ( data.utym, data.mirele, data.kraken ),
new idrinth.MultiplierSet ( data.legion, data.mount, data.critchance )
);
};
}
/**
* @type {Object}
*/
var idrinth = {
PremiumSet: function (utym, mirele, kraken) {
this.utym = utym;
this.mirele = mirele;
this.kraken = kraken;
this.modifyBase = function(base, stat, stats) {};
this.modifyTotal = function(base, stat, stats) {};
/**
* @class Container for premium
* @constructs {idrinth.PremiumSet}
*/
PremiumSet: class PremiumSet {
/**
* @constructor
* @param {Boolean} utym
* @param {Boolean} mirele
* @param {Boolean} kraken
* @return {idrinth.PremiumSet}
*/
constructor ( utym, mirele, kraken ) {
this.utym = utym;
this.mirele = mirele;
this.kraken = kraken;
}
/**
* @param {Number} damage
* @param {String} stat
* @param {idrinth.StatSet} stats
* @return {Number}
*/
modifyBase ( damage, stat, stats ) {}
/**
* @param {Number} damage
* @param {String} stat
* @param {idrinth.StatSet} stats
* @return {Number}
*/
modifyTotal ( damage, stat, stats ) {}
},
MultiplierSet: function (legion, mount, critchance) {
this.legion = legion;
this.mount = mount;
this.critchance = critchance;
this.modifyTotal = function(base, stat, stats, premiums) {};
/**
* @class Container for damage multipliers
* @constructs {idrinth.StatSet}
*/
MultiplierSet: class MultiplierSet {
/**
* @constructor
* @param {Number} legion
* @param {Number} mount
* @param {Number} critchance
* @return {idrinth.MultiplierSet}
*/
constructor ( legion, mount, critchance ) {
this.legion = legion;
this.mount = mount;
this.critchance = critchance;
}
/**
* @param {Number} base
* @param {String} stat
* @param {idrinth.StatSet} stats
* @param {idrinth.PremiumSet} premiums
* @return {idrinth.StatSet}
*/
modifyTotal ( base, stat, stats, premiums ) {}
},
StatSet: function(attack, defense, perception, level, stats) {
this.attack = attack;
this.defense = defense;
this.perception = perception;
this.stats = stats;
this.level = level;
this.getCost = function ( value ) {
let toPositive = function(number) {
return Math.max(number, 0);
};
return 1+ Math.ceil (
toPositive (
value -
10000 -
Math.floor (toPositive ( this.level / 500 - 2 )) * 1500
) / 1500
);
};
this.getIncreaseableStats = function() {
let stats = [];
if (this.getCost(this.attack) <= this.stats) {
stats.push ('attack');
/**
* @class Container for attributes
* @constructs {idrinth.StatSet}
*/
StatSet: class StatSet {
/**
* @constructor
* @param {Number} attack
* @param {Number} defense
* @param {Number} perception
* @param {Number} level
* @param {Number} stats
* @return {idrinth.StatSet}
*/
constructor ( attack, defense, perception, level, stats ) {
this.attack = attack;
this.defense = defense;
this.perception = perception;
this.stats = stats;
this.level = level;
}
/**
* @param {Number} value
* @return {Number}
*/
getCost ( value ) {
/**
* @param {Number} number
* @return {Number}
*/
let toPositive = function ( number ) {
return Math.max ( number, 0 );
};
let modifier = 10000 + Math.floor ( toPositive ( this.level / 500 - 2 ) ) * 1500;
return 1 + Math.ceil (toPositive (value - modifier) / 1500);
}
/**
* @return {Array}
*/
getIncreaseableStats () {
let stats = [ ];
if ( this.getCost ( this.attack ) <= this.stats ) {
stats.push ( 'attack' );
}
if (this.getCost(this.defense) <= this.stats) {
stats.push ('defense');
if ( this.getCost ( this.defense ) <= this.stats ) {
stats.push ( 'defense' );
}
if (this.getCost(this.perception) <= this.stats) {
stats.push ('perception');
if ( this.getCost ( this.perception ) <= this.stats ) {
stats.push ( 'perception' );
}
return stats;
};
}
},
/**
* @param {idrinth.StatSet} stat
* @param {idrinth.PremiumSet} premium
* @param {idrinth.MultiplierSet} multiplier
* @return {idrinth.StatSet}
* @param {StatSet} stat
* @param {PremiumSet} premium
* @param {MultiplierSet} multiplier
* @return {StatSet}
*/
calculate(stat, premium, multiplier) {
let modified = false
calculate ( stat, premium, multiplier ) {
let modified = false;
do {
stat.getIncreaseableStats().forEach();
} while (modified)
stat.getIncreaseableStats ().forEach ();
} while ( modified )
return stat;
}
};

0 comments on commit 22e3b76

Please sign in to comment.