mirror of
https://github.com/RussellChamp/GrimoireJS.git
synced 2026-10-27 22:42:32 +00:00
Fixed some calc errors
This commit is contained in:
1 parent
b4445e77be
commit
5282411b39
1 file changed
+21
-14
+21
-14
@@ -81,7 +81,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
async: false //A project that works now is better than one that doesn't exist.
|
async: false //A project that works now is better than one that doesn't exist.
|
||||||
//I MUST come back and revisit this with promises later
|
//I MUST come back and revisit this with promises later
|
||||||
});
|
});
|
||||||
$.getJSON('sources/sources.json', function(sources) {
|
$.getJSON('./data/sources.json', function(sources) {
|
||||||
sources.sources.forEach(function(url) {
|
sources.sources.forEach(function(url) {
|
||||||
$.getJSON(url, function(source) {
|
$.getJSON(url, function(source) {
|
||||||
console.log('loaded '+ url);
|
console.log('loaded '+ url);
|
||||||
@@ -129,7 +129,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
// will not use sources that are marked as disabled
|
// will not use sources that are marked as disabled
|
||||||
//options.types manually specify what types you want to get
|
//options.types manually specify what types you want to get
|
||||||
this.getItems = function(quality, count, options) {
|
this.getItems = function(quality, count, options) {
|
||||||
options = options ? options : {};
|
options = options ? _.clone(options) : {};
|
||||||
var sources = options.sources ? options.sources : self.SOURCES;
|
var sources = options.sources ? options.sources : self.SOURCES;
|
||||||
var types = options.types ? options.types : _.values(TYPES);
|
var types = options.types ? options.types : _.values(TYPES);
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(_.sum(sourceWeights) <= 0) {
|
if(_.sum(sourceWeights) <= 0) {
|
||||||
console.error('Unable to find valid ' + quality + ' ' + type + ' within sources!', sources);
|
console.error('Unable to find valid ', quality, type, options.itemType, options.uniqueType, ' within sources!', sources);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//chance.weighted will DESTRUCTIVELY modify paramaters that have a weight of zero
|
//chance.weighted will DESTRUCTIVELY modify paramaters that have a weight of zero
|
||||||
@@ -374,7 +374,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!options.disableClue && chance.d100() <= (options.clueChance || 20)) {
|
if(!options.disableClue && chance.d100() <= (options.clueChance || 20)) {
|
||||||
item.name += ' with a clue to it\'s purpose!';
|
item.description = 'with a clue to it\'s purpose! ' + (item.description ? item.description : '');
|
||||||
}
|
}
|
||||||
item.quality = quality;
|
item.quality = quality;
|
||||||
return item;
|
return item;
|
||||||
@@ -388,6 +388,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
|
|
||||||
var maxRoll = options.maxRoll || _.sum(_.map(itemData, function(item) {
|
var maxRoll = options.maxRoll || _.sum(_.map(itemData, function(item) {
|
||||||
return item.weight[quality]; }));
|
return item.weight[quality]; }));
|
||||||
|
//console.log('itemData', itemData, 'quality', quality, 'maxRoll', maxRoll);
|
||||||
var roll = chance.integer({min: 1, max: maxRoll});
|
var roll = chance.integer({min: 1, max: maxRoll});
|
||||||
var item = {};
|
var item = {};
|
||||||
|
|
||||||
@@ -714,6 +715,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
var chance = (self.chance ? self.chance : options.seed ? new Chance(options.seed) : new Chance());
|
var chance = (self.chance ? self.chance : options.seed ? new Chance(options.seed) : new Chance());
|
||||||
var weapon = {
|
var weapon = {
|
||||||
name: '',
|
name: '',
|
||||||
|
description: '',
|
||||||
type: '',
|
type: '',
|
||||||
bonus: 0,
|
bonus: 0,
|
||||||
baseCost: 0,
|
baseCost: 0,
|
||||||
@@ -830,7 +832,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
weapon.glowing = true;
|
weapon.glowing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalBonus = weapon.bonus + _.sum(_.map(weapon.specials, function(s) { return s.bonsu; }));
|
var totalBonus = weapon.bonus + _.sum(_.map(weapon.specials, function(s) { return s.bonus; }));
|
||||||
weapon.cost = weapon.baseCost + 2000 * Math.pow(totalBonus, 2) + (weapon.intelligence.cost || 0);
|
weapon.cost = weapon.baseCost + 2000 * Math.pow(totalBonus, 2) + (weapon.intelligence.cost || 0);
|
||||||
weapon.print = function() {
|
weapon.print = function() {
|
||||||
var ret = 'Name: ';
|
var ret = 'Name: ';
|
||||||
@@ -838,9 +840,10 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
ret += this.bonus > 0 ? ('+' + this.bonus + ' ') : '';
|
ret += this.bonus > 0 ? ('+' + this.bonus + ' ') : '';
|
||||||
ret += this.specials.length > 0 ? _.map(this.specials, function(s) { return s.name;}).join(', ') + ' ' : '';
|
ret += this.specials.length > 0 ? _.map(this.specials, function(s) { return s.name;}).join(', ') + ' ' : '';
|
||||||
ret += this.name ? this.name : (this.type + ' weapon');
|
ret += this.name ? this.name : (this.type + ' weapon');
|
||||||
|
ret += this.description ? (' ' + this.description) : '';
|
||||||
ret += ';';
|
ret += ';';
|
||||||
ret += this.intelligence.print ? 'Intelligence: [' + this.intelligence.print() + '];' : '';
|
ret += this.intelligence.print ? 'Intelligence: [' + this.intelligence.print() + '];' : '';
|
||||||
ret += 'Cost: ' + this.cost + 'gp';
|
//ret += 'Cost: ' + this.cost + 'gp';
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -877,6 +880,7 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
|
|
||||||
var item = {
|
var item = {
|
||||||
name: '',
|
name: '',
|
||||||
|
description: '',
|
||||||
type: '',
|
type: '',
|
||||||
bonus: 0,
|
bonus: 0,
|
||||||
baseCost: 0,
|
baseCost: 0,
|
||||||
@@ -1033,16 +1037,18 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var totalBonus = item.bonus + _.sum(_.map(item.specials, function(s) { return s.bonsu; }));
|
var totalBonus = item.bonus + _.sum(_.map(item.specials, function(s) { return s.bonus; }));
|
||||||
item.cost = item.baseCost + 1000 * Math.pow(totalBonus, 2);
|
var specialsCost = _.sum(_.map(item.specials, function(s) { return s.cost; }));
|
||||||
|
item.cost = item.baseCost + 1000 * Math.pow(totalBonus, 2) + specialsCost;
|
||||||
|
|
||||||
item.print = function() {
|
item.print = function() {
|
||||||
var ret = 'Name: ';
|
var ret = 'Name: ';
|
||||||
ret += this.bonus > 0 ? ('+' + this.bonus + ' ') : '';
|
ret += this.bonus > 0 ? ('+' + this.bonus + ' ') : '';
|
||||||
ret += this.specials.length > 0 ? _.map(this.specials, function(s) { return s.name;}).join(', ') + ' ' : '';
|
ret += this.specials.length > 0 ? _.map(this.specials, function(s) { return s.name;}).join(', ') + ' ' : '';
|
||||||
ret += this.name ? this.name : this.type;
|
ret += this.name ? this.name : this.type;
|
||||||
ret += ';';
|
ret += this.description ? (' ' + this.description) : '';
|
||||||
ret += 'Cost: ' + this.cost + 'gp';
|
//ret += ';';
|
||||||
|
//ret += 'Cost: ' + this.cost + 'gp';
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1253,8 +1259,9 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
//extra languages are based on intelligence and ranks in Linguistics
|
//extra languages are based on intelligence and ranks in Linguistics
|
||||||
bonusLanguages += Math.floor((i.stats.intelligence-10)/2);
|
bonusLanguages += Math.floor((i.stats.intelligence-10)/2);
|
||||||
//pick is safe even if we have more bonusLanguages than exist
|
//pick is safe even if we have more bonusLanguages than exist
|
||||||
i.languages.concat(chance.pick(self.Languages.data, bonusLanguages));
|
if(bonusLanguages > 0) {
|
||||||
|
i.languages = i.languages.concat(chance.pick(self.Languages.data, bonusLanguages));
|
||||||
|
}
|
||||||
|
|
||||||
//***ITEM PURPOSE***
|
//***ITEM PURPOSE***
|
||||||
//there was NO roll chart for determining if an item has a purpose so I made this up
|
//there was NO roll chart for determining if an item has a purpose so I made this up
|
||||||
@@ -1319,14 +1326,14 @@ var Grimoire = function(config) { // jshint ignore:line
|
|||||||
ret += 'Stats: Ego ' + this.ego + ', Int ' + this.stats.intelligence + ', ' +
|
ret += 'Stats: Ego ' + this.ego + ', Int ' + this.stats.intelligence + ', ' +
|
||||||
'Wis ' + this.stats.wisdom + ', ' +
|
'Wis ' + this.stats.wisdom + ', ' +
|
||||||
'Cha ' + this.stats.charisma + ';';
|
'Cha ' + this.stats.charisma + ';';
|
||||||
ret += 'Communication: ' + this.communication + ' (' + this.languages.join(',' ) + ');';
|
ret += 'Communication: ' + this.communication + ' (' + this.languages.join(', ' ) + ');';
|
||||||
ret += 'Senses: ' + this.senses + ';';
|
ret += 'Senses: ' + this.senses + ';';
|
||||||
ret += 'Powers: ' + _.map(this.powers, function(p) { return p.description; }).join(', ') + ';';
|
ret += 'Powers: ' + _.map(this.powers, function(p) { return p.description; }).join(', ') + ';';
|
||||||
if(this.purpose) {
|
if(this.purpose) {
|
||||||
ret += 'Purpose: ' + this.purpose + ';';
|
ret += 'Purpose: ' + this.purpose + ';';
|
||||||
ret += 'Dedicated Powers: ' + _.map(this.dedicatedPowers, function(p) {return p.description; }).join(', ') + ';';
|
ret += 'Dedicated Powers: ' + _.map(this.dedicatedPowers, function(p) {return p.description; }).join(', ') + ';';
|
||||||
}
|
}
|
||||||
ret += 'Cost: ' + i.cost + 'gp';
|
//ret += 'Cost: ' + i.cost + 'gp';
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user