Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
463b7f0fc9 | ||
|
|
266495abc8 | ||
|
|
453d4365d3 | ||
|
|
e0ce6275bf | ||
|
|
80c72a274e | ||
|
|
91f0f7954c | ||
|
|
c74abcb608 |
@@ -186,7 +186,7 @@ Schemas.Character = new SimpleSchema({
|
||||
|
||||
Characters.attachSchema(Schemas.Character);
|
||||
|
||||
var attributeBase = function(charId, statName){
|
||||
var attributeBase = preventLoop(function(charId, statName){
|
||||
check(statName, String);
|
||||
//if it's a damage multiplier, we treat it specially
|
||||
if (_.contains(DAMAGE_MULTIPLIERS, statName)){
|
||||
@@ -226,8 +226,8 @@ var attributeBase = function(charId, statName){
|
||||
var base = 0;
|
||||
var add = 0;
|
||||
var mul = 1;
|
||||
var min = Math.NEGATIVE_INFINITY;
|
||||
var max = Math.POSITIVE_INFINITY;
|
||||
var min = Number.NEGATIVE_INFINITY;
|
||||
var max = Number.POSITIVE_INFINITY;
|
||||
|
||||
Effects.find({
|
||||
charId: charId,
|
||||
@@ -253,8 +253,8 @@ var attributeBase = function(charId, statName){
|
||||
if (result < min) result = min;
|
||||
if (result > max) result = max;
|
||||
|
||||
return result;
|
||||
};
|
||||
return Math.floor(result);
|
||||
});
|
||||
|
||||
if (Meteor.isClient) {
|
||||
Template.registerHelper("characterCalculate", function(func, charId, input) {
|
||||
@@ -324,9 +324,9 @@ Characters.calculate = {
|
||||
value += attribute.adjustment;
|
||||
return value;
|
||||
}),
|
||||
attributeBase: memoize(preventLoop(function(charId, attributeName){
|
||||
attributeBase: memoize(function(charId, attributeName){
|
||||
return attributeBase(charId, attributeName);
|
||||
})),
|
||||
}),
|
||||
skillMod: memoize(preventLoop(function(charId, skillName){
|
||||
var skill = Characters.calculate.getField(charId, skillName);
|
||||
//get the final value of the ability score
|
||||
@@ -369,7 +369,7 @@ Characters.calculate = {
|
||||
if (result < min) result = min;
|
||||
if (result > max) result = max;
|
||||
|
||||
return result;
|
||||
return Math.floor(result);
|
||||
})),
|
||||
proficiency: memoize(function(charId, skillName){
|
||||
//return largest value in proficiency array
|
||||
@@ -390,7 +390,7 @@ Characters.calculate = {
|
||||
});
|
||||
var advantage = Characters.calculate.advantage(charId, skillName);
|
||||
value += 5 * advantage;
|
||||
return value;
|
||||
return Math.floor(value);
|
||||
}),
|
||||
advantage: memoize(function(charId, skillName){
|
||||
var advantage = Effects.find(
|
||||
|
||||
@@ -15,6 +15,7 @@ function CacheObject(func, address, args, cache, context){
|
||||
var self = this;
|
||||
self.currentValue = null;
|
||||
self.dep = new Tracker.Dependency();
|
||||
self.numRun = 0;
|
||||
|
||||
//spawn a new autorun that keeps the value up-to-date
|
||||
Tracker.nonreactive(function() {
|
||||
@@ -26,8 +27,22 @@ function CacheObject(func, address, args, cache, context){
|
||||
delete cache[address];
|
||||
return;
|
||||
}
|
||||
//if we haven't run this before this flush, reset the counter after the flush
|
||||
if(self.numRun === 0){
|
||||
Tracker.afterFlush(function(){
|
||||
self.numRun = 0;
|
||||
});
|
||||
}
|
||||
self.numRun++;
|
||||
//call the expensive function
|
||||
//even if we don't use its value, we need to track its dependencies
|
||||
var newValue = func.apply(context, args);
|
||||
//prevent dependency loops, the memoized function shouldn't re-run
|
||||
//more than once per flush
|
||||
if (self.numRun > 1){
|
||||
newValue = NaN;
|
||||
if(_.isNaN(self.currentValue)) return;
|
||||
}
|
||||
//if the value changed, store the new value
|
||||
if (self.currentValue !== newValue){
|
||||
self.currentValue = newValue;
|
||||
|
||||
@@ -193,3 +193,18 @@ ChangeLogs.insert({
|
||||
"Experience dialogs should update their edit-mode inputs properly now",
|
||||
],
|
||||
});
|
||||
|
||||
ChangeLogs.insert({
|
||||
version: "0.6.2",
|
||||
changes: [
|
||||
"Fixed a regression which broke min and max effects",
|
||||
],
|
||||
});
|
||||
|
||||
ChangeLogs.insert({
|
||||
version: "0.6.3",
|
||||
changes: [
|
||||
"Fixed a regression that stopped skills and attributes from rounding down correctly",
|
||||
"Made dependency loops return NaN immediately, rather than looping indefinitely until a page refresh. Adding an effect that adds \"strength\" to Strength, won't cause Strength to constantly increase or freeze the browser, Strength just becomes NaN",
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user