diff --git a/rpg-docs/.meteor/packages b/rpg-docs/.meteor/packages index 0928a7e4..89495d83 100644 --- a/rpg-docs/.meteor/packages +++ b/rpg-docs/.meteor/packages @@ -48,3 +48,4 @@ es5-shim@4.6.15 differential:vulcanize reactive-dict percolate:synced-cron +ongoworks:speakingurl diff --git a/rpg-docs/.meteor/versions b/rpg-docs/.meteor/versions index 04f53178..c2254df9 100644 --- a/rpg-docs/.meteor/versions +++ b/rpg-docs/.meteor/versions @@ -85,6 +85,7 @@ npm-mongo@2.2.16_1 oauth@1.1.12 oauth2@1.1.11 observe-sequence@1.0.14 +ongoworks:speakingurl@9.0.0 ordered-dict@1.0.9 percolate:migrations@0.9.8 percolate:synced-cron@1.3.2 diff --git a/rpg-docs/Model/Character/Actions.js b/rpg-docs/Model/Character/Actions.js index a4e2e236..31caa805 100644 --- a/rpg-docs/Model/Character/Actions.js +++ b/rpg-docs/Model/Character/Actions.js @@ -11,10 +11,12 @@ Schemas.Action = new SimpleSchema({ }, name: { type: String, + optional: true, trim: false, }, description: { type: String, + optional: true, trim: false, }, type: { diff --git a/rpg-docs/Model/Character/Attacks.js b/rpg-docs/Model/Character/Attacks.js index 2450439a..4a2dcc72 100644 --- a/rpg-docs/Model/Character/Attacks.js +++ b/rpg-docs/Model/Character/Attacks.js @@ -12,6 +12,7 @@ Schemas.Attack = new SimpleSchema({ name: { type: String, defaultValue: "New Attack", + optional: true, trim: false, }, details: { diff --git a/rpg-docs/Model/Character/Buffs.js b/rpg-docs/Model/Character/Buffs.js index 3d8c41c5..b2a367c2 100644 --- a/rpg-docs/Model/Character/Buffs.js +++ b/rpg-docs/Model/Character/Buffs.js @@ -8,6 +8,7 @@ Schemas.Buff = new SimpleSchema({ }, name: { type: String, + optional: true, trim: false, }, description: { diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 0b807d34..b16e3324 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -4,6 +4,7 @@ Characters = new Mongo.Collection("characters"); Schemas.Character = new SimpleSchema({ //strings name: {type: String, defaultValue: "", trim: false, optional: true}, + urlName: {type: String, defaultValue: "", trim: false, optional: true}, alignment: {type: String, defaultValue: "", trim: false, optional: true}, gender: {type: String, defaultValue: "", trim: false, optional: true}, race: {type: String, defaultValue: "", trim: false, optional: true}, @@ -257,7 +258,10 @@ var attributeBase = preventLoop(function(charId, statName){ var result = (base + add) * mul; if (result < min) result = min; if (result > max) result = max; - + // Don't round carry multiplier + if (statName === "carryMultiplier"){ + return result; + } return Math.floor(result); }); @@ -537,6 +541,12 @@ if (Meteor.isServer){ Items .remove({charId: character._id}); Containers .remove({charId: character._id}); }); + Characters.after.update(function(userId, doc, fieldNames, modifier, options) { + if (_.contains(fieldNames, "name")){ + var urlName = getSlug(doc.name, {maintainCase: true}); + Characters.update(doc._id, {$set: {urlName}}); + } + }); } Characters.allow({ diff --git a/rpg-docs/Model/Character/Classes.js b/rpg-docs/Model/Character/Classes.js index ac036230..52e4df9e 100644 --- a/rpg-docs/Model/Character/Classes.js +++ b/rpg-docs/Model/Character/Classes.js @@ -2,7 +2,7 @@ Classes = new Mongo.Collection("classes"); Schemas.Class = new SimpleSchema({ charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, - name: {type: String, trim: false}, + name: {type: String, optional: true, trim: false}, level: {type: Number}, createdAt: { type: Date, diff --git a/rpg-docs/Model/Character/Experience.js b/rpg-docs/Model/Character/Experience.js index ff6d5932..4dc22b2a 100644 --- a/rpg-docs/Model/Character/Experience.js +++ b/rpg-docs/Model/Character/Experience.js @@ -2,7 +2,7 @@ Experiences = new Mongo.Collection("experience"); Schemas.Experience = new SimpleSchema({ charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, - name: {type: String, defaultValue: "New Experience", trim: false}, + name: {type: String, optional: true, trim: false, defaultValue: "New Experience"}, description: {type: String, optional: true, trim: false}, value: {type: Number, defaultValue: 0}, dateAdded: { diff --git a/rpg-docs/Model/Character/Features.js b/rpg-docs/Model/Character/Features.js index 29b8c7d5..468d6fe3 100644 --- a/rpg-docs/Model/Character/Features.js +++ b/rpg-docs/Model/Character/Features.js @@ -2,7 +2,7 @@ Features = new Mongo.Collection("features"); Schemas.Feature = new SimpleSchema({ charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, - name: {type: String, trim: false}, + name: {type: String, optional: true, trim: false}, description: {type: String, optional: true, trim: false}, uses: {type: String, optional: true, trim: false}, used: {type: Number, defaultValue: 0}, diff --git a/rpg-docs/Model/Character/Notes.js b/rpg-docs/Model/Character/Notes.js index 8d1afdf5..f1ce7aa4 100644 --- a/rpg-docs/Model/Character/Notes.js +++ b/rpg-docs/Model/Character/Notes.js @@ -2,7 +2,7 @@ Notes = new Mongo.Collection("notes"); Schemas.Note = new SimpleSchema({ charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, - name: {type: String, trim: false}, + name: {type: String, optional: true, trim: false}, description: {type: String, optional: true, trim: false}, color: { type: String, diff --git a/rpg-docs/Model/Character/SpellLists.js b/rpg-docs/Model/Character/SpellLists.js index 16aa2dab..982be871 100644 --- a/rpg-docs/Model/Character/SpellLists.js +++ b/rpg-docs/Model/Character/SpellLists.js @@ -2,7 +2,7 @@ SpellLists = new Mongo.Collection("spellLists"); Schemas.SpellLists = new SimpleSchema({ charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, - name: {type: String, trim: false}, + name: {type: String, optional: true, trim: false}, description: {type: String, optional: true, trim: false}, saveDC: {type: String, optional: true, trim: false}, attackBonus: {type: String, optional: true, trim: false}, diff --git a/rpg-docs/Model/Character/Spells.js b/rpg-docs/Model/Character/Spells.js index f04e2fa7..58f21cd2 100644 --- a/rpg-docs/Model/Character/Spells.js +++ b/rpg-docs/Model/Character/Spells.js @@ -9,6 +9,7 @@ Schemas.Spell = new SimpleSchema({ }, name: { type: String, + optional: true, trim: false, defaultValue: "New Spell", }, diff --git a/rpg-docs/Model/Inventory/Containers.js b/rpg-docs/Model/Inventory/Containers.js index 94761c58..2318c930 100644 --- a/rpg-docs/Model/Inventory/Containers.js +++ b/rpg-docs/Model/Inventory/Containers.js @@ -2,7 +2,7 @@ Containers = new Mongo.Collection("containers"); Schemas.Container = new SimpleSchema({ - name: {type: String, trim: false}, + name: {type: String, optional: true, trim: false}, charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, isCarried: {type: Boolean}, weight: {type: Number, min: 0, defaultValue: 0, decimal: true}, diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index c626c16f..6c5c00e1 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -1,7 +1,7 @@ Items = new Mongo.Collection("items"); Schemas.Item = new SimpleSchema({ - name: {type: String, defaultValue: "New Item", trim: false}, + name: {type: String, optional: true, trim: false, defaultValue: "New Item"}, plural: {type: String, optional: true, trim: false}, description:{type: String, optional: true, trim: false}, charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, //id of owner diff --git a/rpg-docs/Routes/Routes.js b/rpg-docs/Routes/Routes.js index 5f2906c2..14ac42ff 100644 --- a/rpg-docs/Routes/Routes.js +++ b/rpg-docs/Routes/Routes.js @@ -24,7 +24,7 @@ Router.map(function() { this.route("characterList", { path: "/characterList", waitOn: function(){ - return subsManager.subscribe("characterList", Meteor.userId()); + return subsManager.subscribe("characterList"); }, onAfterAction: function() { document.title = appName + " - Characters"; @@ -32,11 +32,27 @@ Router.map(function() { fastRender: true, }); - this.route("characterSheet", { - path: "/character/:_id", + this.route("characterSheetNaked", { + path: "/character/:_id/", waitOn: function(){ return [ - subsManager.subscribe("singleCharacter", this.params._id, Meteor.userId()), + subsManager.subscribe("singleCharacter", this.params._id), + ]; + }, + action: function(){ + var _id = this.params._id + var character = Characters.findOne(_id); + var urlName = character && character.urlName; + var path = `\/character\/${_id}\/${urlName}`; + Router.go(path,{},{replaceState:true}); + }, + }); + + this.route("characterSheet", { + path: "/character/:_id/:urlName", + waitOn: function(){ + return [ + subsManager.subscribe("singleCharacter", this.params._id), ]; }, data: function() { diff --git a/rpg-docs/client/globalHelpers/evaluate.js b/rpg-docs/client/globalHelpers/evaluate.js index d986b1f0..65ad0240 100644 --- a/rpg-docs/client/globalHelpers/evaluate.js +++ b/rpg-docs/client/globalHelpers/evaluate.js @@ -24,6 +24,10 @@ Template.registerHelper("evaluateString", function(charId, string) { return evaluateString(charId, string); }); +Template.registerHelper("evaluateSpellString", function(charId, spellListId, string) { + return evaluateSpellString(charId, spellListId, string); +}); + Template.registerHelper("evaluateShortString", function(charId, string) { if (_.isString(string)){ return evaluateString( diff --git a/rpg-docs/client/lib/requestAnimationFramePolyfill.js b/rpg-docs/client/lib/requestAnimationFramePolyfill.js new file mode 100644 index 00000000..0fb801e6 --- /dev/null +++ b/rpg-docs/client/lib/requestAnimationFramePolyfill.js @@ -0,0 +1,28 @@ +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating + +// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel + +// MIT license +var lastTime = 0; +var vendors = ["ms", "moz", "webkit", "o"]; +for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"]; + window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || + window[vendors[x] + "CancelRequestAnimationFrame"]; +} + +if (!window.requestAnimationFrame) +window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; +}; + +if (!window.cancelAnimationFrame) +window.cancelAnimationFrame = function(id) { + clearTimeout(id); +}; diff --git a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html index 3ae51b94..078cd946 100644 --- a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html +++ b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html @@ -20,26 +20,28 @@