Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
463b7f0fc9 | ||
|
|
266495abc8 | ||
|
|
453d4365d3 | ||
|
|
e0ce6275bf | ||
|
|
80c72a274e | ||
|
|
91f0f7954c | ||
|
|
c74abcb608 | ||
|
|
4f60766d5d | ||
|
|
e992aeebef | ||
|
|
4108346a98 |
@@ -186,7 +186,7 @@ Schemas.Character = new SimpleSchema({
|
|||||||
|
|
||||||
Characters.attachSchema(Schemas.Character);
|
Characters.attachSchema(Schemas.Character);
|
||||||
|
|
||||||
var attributeBase = function(charId, statName){
|
var attributeBase = preventLoop(function(charId, statName){
|
||||||
check(statName, String);
|
check(statName, String);
|
||||||
//if it's a damage multiplier, we treat it specially
|
//if it's a damage multiplier, we treat it specially
|
||||||
if (_.contains(DAMAGE_MULTIPLIERS, statName)){
|
if (_.contains(DAMAGE_MULTIPLIERS, statName)){
|
||||||
@@ -226,8 +226,8 @@ var attributeBase = function(charId, statName){
|
|||||||
var base = 0;
|
var base = 0;
|
||||||
var add = 0;
|
var add = 0;
|
||||||
var mul = 1;
|
var mul = 1;
|
||||||
var min = Math.NEGATIVE_INFINITY;
|
var min = Number.NEGATIVE_INFINITY;
|
||||||
var max = Math.POSITIVE_INFINITY;
|
var max = Number.POSITIVE_INFINITY;
|
||||||
|
|
||||||
Effects.find({
|
Effects.find({
|
||||||
charId: charId,
|
charId: charId,
|
||||||
@@ -253,8 +253,8 @@ var attributeBase = function(charId, statName){
|
|||||||
if (result < min) result = min;
|
if (result < min) result = min;
|
||||||
if (result > max) result = max;
|
if (result > max) result = max;
|
||||||
|
|
||||||
return result;
|
return Math.floor(result);
|
||||||
};
|
});
|
||||||
|
|
||||||
if (Meteor.isClient) {
|
if (Meteor.isClient) {
|
||||||
Template.registerHelper("characterCalculate", function(func, charId, input) {
|
Template.registerHelper("characterCalculate", function(func, charId, input) {
|
||||||
@@ -324,9 +324,9 @@ Characters.calculate = {
|
|||||||
value += attribute.adjustment;
|
value += attribute.adjustment;
|
||||||
return value;
|
return value;
|
||||||
}),
|
}),
|
||||||
attributeBase: memoize(preventLoop(function(charId, attributeName){
|
attributeBase: memoize(function(charId, attributeName){
|
||||||
return attributeBase(charId, attributeName);
|
return attributeBase(charId, attributeName);
|
||||||
})),
|
}),
|
||||||
skillMod: memoize(preventLoop(function(charId, skillName){
|
skillMod: memoize(preventLoop(function(charId, skillName){
|
||||||
var skill = Characters.calculate.getField(charId, skillName);
|
var skill = Characters.calculate.getField(charId, skillName);
|
||||||
//get the final value of the ability score
|
//get the final value of the ability score
|
||||||
@@ -369,7 +369,7 @@ Characters.calculate = {
|
|||||||
if (result < min) result = min;
|
if (result < min) result = min;
|
||||||
if (result > max) result = max;
|
if (result > max) result = max;
|
||||||
|
|
||||||
return result;
|
return Math.floor(result);
|
||||||
})),
|
})),
|
||||||
proficiency: memoize(function(charId, skillName){
|
proficiency: memoize(function(charId, skillName){
|
||||||
//return largest value in proficiency array
|
//return largest value in proficiency array
|
||||||
@@ -390,7 +390,7 @@ Characters.calculate = {
|
|||||||
});
|
});
|
||||||
var advantage = Characters.calculate.advantage(charId, skillName);
|
var advantage = Characters.calculate.advantage(charId, skillName);
|
||||||
value += 5 * advantage;
|
value += 5 * advantage;
|
||||||
return value;
|
return Math.floor(value);
|
||||||
}),
|
}),
|
||||||
advantage: memoize(function(charId, skillName){
|
advantage: memoize(function(charId, skillName){
|
||||||
var advantage = Effects.find(
|
var advantage = Effects.find(
|
||||||
|
|||||||
@@ -9,20 +9,24 @@
|
|||||||
<div class="pre-wrap">{{description}}</div>
|
<div class="pre-wrap">{{description}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div horizontal layout>
|
{{> experienceEdit}}
|
||||||
<!--Name-->
|
|
||||||
<paper-input id="experienceNameInput" label="Name" floatinglabel value={{name}} flex></paper-input>
|
|
||||||
<!--Value-->
|
|
||||||
<paper-input-decorator label="Value" floatinglabel>
|
|
||||||
<input id="valueInput" type="number" value={{value}}>
|
|
||||||
</paper-input-decorator>
|
|
||||||
</div>
|
|
||||||
<!--Description-->
|
|
||||||
<paper-input-decorator label="Description" floatinglabel layout vertical>
|
|
||||||
<paper-autogrow-textarea>
|
|
||||||
<textarea id="experienceDescriptionInput" placeholder value={{description}}></textarea>
|
|
||||||
</paper-autogrow-textarea>
|
|
||||||
</paper-input-decorator>
|
|
||||||
{{/baseDialog}}
|
{{/baseDialog}}
|
||||||
{{/with}}
|
{{/with}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template name="experienceEdit">
|
||||||
|
<div horizontal layout>
|
||||||
|
<!--Name-->
|
||||||
|
<paper-input id="experienceNameInput" label="Name" floatinglabel value={{name}} flex></paper-input>
|
||||||
|
<!--Value-->
|
||||||
|
<paper-input-decorator label="Value" floatinglabel>
|
||||||
|
<input id="valueInput" type="number" value={{value}}>
|
||||||
|
</paper-input-decorator>
|
||||||
|
</div>
|
||||||
|
<!--Description-->
|
||||||
|
<paper-input-decorator label="Description" floatinglabel layout vertical>
|
||||||
|
<paper-autogrow-textarea>
|
||||||
|
<textarea id="experienceDescriptionInput" placeholder value={{description}}></textarea>
|
||||||
|
</paper-autogrow-textarea>
|
||||||
|
</paper-input-decorator>
|
||||||
|
</template>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Template.experienceDialog.onRendered(function(){
|
Template.experienceEdit.onRendered(function(){
|
||||||
updatePolymerInputs(this);
|
updatePolymerInputs(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -22,8 +22,10 @@ Template.experienceDialog.events({
|
|||||||
);
|
);
|
||||||
GlobalUI.closeDetail();
|
GlobalUI.closeDetail();
|
||||||
},
|
},
|
||||||
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors
|
});
|
||||||
"change #experienceNameInput, input #experienceNameInput": function(event){
|
|
||||||
|
Template.experienceEdit.events({
|
||||||
|
"change #experienceNameInput": function(event){
|
||||||
var value = event.currentTarget.value;
|
var value = event.currentTarget.value;
|
||||||
Experiences.update(this._id, {$set: {name: value}});
|
Experiences.update(this._id, {$set: {name: value}});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ function CacheObject(func, address, args, cache, context){
|
|||||||
var self = this;
|
var self = this;
|
||||||
self.currentValue = null;
|
self.currentValue = null;
|
||||||
self.dep = new Tracker.Dependency();
|
self.dep = new Tracker.Dependency();
|
||||||
|
self.numRun = 0;
|
||||||
|
|
||||||
//spawn a new autorun that keeps the value up-to-date
|
//spawn a new autorun that keeps the value up-to-date
|
||||||
Tracker.nonreactive(function() {
|
Tracker.nonreactive(function() {
|
||||||
@@ -26,8 +27,22 @@ function CacheObject(func, address, args, cache, context){
|
|||||||
delete cache[address];
|
delete cache[address];
|
||||||
return;
|
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
|
//call the expensive function
|
||||||
|
//even if we don't use its value, we need to track its dependencies
|
||||||
var newValue = func.apply(context, args);
|
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 the value changed, store the new value
|
||||||
if (self.currentValue !== newValue){
|
if (self.currentValue !== newValue){
|
||||||
self.currentValue = newValue;
|
self.currentValue = newValue;
|
||||||
|
|||||||
@@ -183,7 +183,28 @@ ChangeLogs.insert({
|
|||||||
"Big performance improvements: loading characters that you've viewed recently and changing effects on characters should be much faster",
|
"Big performance improvements: loading characters that you've viewed recently and changing effects on characters should be much faster",
|
||||||
"Spell dialogs no longer show their casting time, range, etc. if those fields aren't filled in",
|
"Spell dialogs no longer show their casting time, range, etc. if those fields aren't filled in",
|
||||||
"The settings dialog now has a done button so it can be closed on small devices",
|
"The settings dialog now has a done button so it can be closed on small devices",
|
||||||
"Experience dialogs should update their edit-mode inputs properly now",
|
|
||||||
"Container dialogs now have the weight summaries rounded down properly",
|
"Container dialogs now have the weight summaries rounded down properly",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ChangeLogs.insert({
|
||||||
|
version: "0.6.1",
|
||||||
|
changes: [
|
||||||
|
"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