From be92ef224c2170c8b0249a5d29672268f1d89841 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 15 Jul 2017 19:54:23 +0100 Subject: [PATCH 01/24] Preliminary additions --- .../client/views/character/stats/buff/buff.html | 9 +++++++++ rpg-docs/client/views/character/stats/buff/buff.js | 5 +++++ .../character/stats/buffViewList/buffViewList.html | 14 ++++++++++++++ .../character/stats/buffViewList/buffViewList.js | 12 ++++++++++++ rpg-docs/client/views/character/stats/stats.html | 2 ++ rpg-docs/client/views/character/stats/stats.js | 6 ++++++ 6 files changed, 48 insertions(+) create mode 100644 rpg-docs/client/views/character/stats/buff/buff.html create mode 100644 rpg-docs/client/views/character/stats/buff/buff.js create mode 100644 rpg-docs/client/views/character/stats/buffViewList/buffViewList.html create mode 100644 rpg-docs/client/views/character/stats/buffViewList/buffViewList.js diff --git a/rpg-docs/client/views/character/stats/buff/buff.html b/rpg-docs/client/views/character/stats/buff/buff.html new file mode 100644 index 00000000..79fd2458 --- /dev/null +++ b/rpg-docs/client/views/character/stats/buff/buff.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/stats/buff/buff.js b/rpg-docs/client/views/character/stats/buff/buff.js new file mode 100644 index 00000000..64b5d944 --- /dev/null +++ b/rpg-docs/client/views/character/stats/buff/buff.js @@ -0,0 +1,5 @@ +Template.buff.helpers({ + name: function() { + return this.name + } +}) \ No newline at end of file diff --git a/rpg-docs/client/views/character/stats/buffViewList/buffViewList.html b/rpg-docs/client/views/character/stats/buffViewList/buffViewList.html new file mode 100644 index 00000000..9d58304a --- /dev/null +++ b/rpg-docs/client/views/character/stats/buffViewList/buffViewList.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/stats/buffViewList/buffViewList.js b/rpg-docs/client/views/character/stats/buffViewList/buffViewList.js new file mode 100644 index 00000000..a758b138 --- /dev/null +++ b/rpg-docs/client/views/character/stats/buffViewList/buffViewList.js @@ -0,0 +1,12 @@ +Template.buffViewList.helpers({ + buffs: function(){ + var selector = { + "parent.id": this.parentId, + "charId": this.charId, + }; + if (this.parentGroup){ + selector["parent.group"] = this.parentGroup; + } + return Buffs.find(selector); + } +}); diff --git a/rpg-docs/client/views/character/stats/stats.html b/rpg-docs/client/views/character/stats/stats.html index 3a5ce782..642ebafd 100644 --- a/rpg-docs/client/views/character/stats/stats.html +++ b/rpg-docs/client/views/character/stats/stats.html @@ -42,6 +42,8 @@ + +
diff --git a/rpg-docs/client/views/character/stats/stats.js b/rpg-docs/client/views/character/stats/stats.js index f38934b8..d95e1213 100644 --- a/rpg-docs/client/views/character/stats/stats.js +++ b/rpg-docs/client/views/character/stats/stats.js @@ -1,3 +1,9 @@ +Template.stats.helpers({ + buffs: function() { + return Buffs.find({charId: this._id}, {sort: {name: 1}}); + } +}) + Template.stats.events({ "click .stat-card": function(event, instance){ var charId = instance.data._id; From b3ef43eb70539b807362f01648287efb75952dee Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 16 Jul 2017 04:27:32 +0100 Subject: [PATCH 02/24] Added ability to add/remove basic conditions Conditions are those listed in ./lib/methods/conditions.js --- .../buffs/buffDialog/buffDialog.html | 8 +- .../character/buffs/buffDialog/buffDialog.js | 7 + .../character/buffs/buffView/buffView.html | 7 + .../character/buffs/buffView/buffView.js | 17 ++ .../buffs/buffViewList/buffViewList.html | 17 ++ .../buffs/buffViewList/buffViewList.js | 28 +++ .../conditionLibraryDialog.css | 11 ++ .../conditionLibraryDialog.html | 34 ++++ .../conditionLibraryDialog.js | 166 ++++++++++++++++++ .../inventory/itemDialog/itemDialog.html | 5 +- .../views/character/stats/buff/buff.html | 9 - .../client/views/character/stats/buff/buff.js | 5 - .../stats/buffViewList/buffViewList.html | 14 -- .../stats/buffViewList/buffViewList.js | 12 -- .../client/views/character/stats/stats.html | 2 +- rpg-docs/lib/methods/conditions.js | 28 ++- 16 files changed, 316 insertions(+), 54 deletions(-) create mode 100644 rpg-docs/client/views/character/buffs/buffView/buffView.html create mode 100644 rpg-docs/client/views/character/buffs/buffView/buffView.js create mode 100644 rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html create mode 100644 rpg-docs/client/views/character/buffs/buffViewList/buffViewList.js create mode 100644 rpg-docs/client/views/character/buffs/conditionLibraryDialog/conditionLibraryDialog.css create mode 100644 rpg-docs/client/views/character/buffs/conditionLibraryDialog/conditionLibraryDialog.html create mode 100644 rpg-docs/client/views/character/buffs/conditionLibraryDialog/conditionLibraryDialog.js delete mode 100644 rpg-docs/client/views/character/stats/buff/buff.html delete mode 100644 rpg-docs/client/views/character/stats/buff/buff.js delete mode 100644 rpg-docs/client/views/character/stats/buffViewList/buffViewList.html delete mode 100644 rpg-docs/client/views/character/stats/buffViewList/buffViewList.js diff --git a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html index 165dd377..5bb63d08 100644 --- a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html +++ b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html @@ -1,6 +1,8 @@ From cb648b4a28b1400e4b8e43fe972b4ee4905b9f68 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 11:13:24 +0100 Subject: [PATCH 07/24] Buffs now display who and what they were applied by. --- .../buffs/buffDialog/buffDialog.html | 3 ++ .../character/buffs/buffDialog/buffDialog.js | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html index 1c5b7878..a7268141 100644 --- a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html +++ b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html @@ -9,6 +9,9 @@ diff --git a/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.html b/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.html new file mode 100644 index 00000000..dbef48eb --- /dev/null +++ b/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.html @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js b/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js new file mode 100644 index 00000000..e695af62 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js @@ -0,0 +1,17 @@ +Template.buffListItem.helpers({ + name: function() { + return this.buff.name + } +}); + +Template.buffListItem.events({ + "click .buffListItem": function(event){ + var buffId = this.buff._id; + var charId = this.buff.charId; + pushDialogStack({ + template: "buffDialog", + data: {buffId: buffId, charId: charId}, + element: event.currentTarget, + }); + }, +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/buffView/buffView.html b/rpg-docs/client/views/character/buffs/buffView/buffView.html deleted file mode 100644 index 27d3cdd4..00000000 --- a/rpg-docs/client/views/character/buffs/buffView/buffView.html +++ /dev/null @@ -1,7 +0,0 @@ - \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/buffView/buffView.js b/rpg-docs/client/views/character/buffs/buffView/buffView.js deleted file mode 100644 index 359fde75..00000000 --- a/rpg-docs/client/views/character/buffs/buffView/buffView.js +++ /dev/null @@ -1,17 +0,0 @@ -Template.buffView.helpers({ - name: function() { - return this.name - } -}); - -Template.buffView.events({ - "click .buffView": function(event){ - var buffId = this._id; - var charId = Template.parentData()._id; - pushDialogStack({ - template: "buffDialog", - data: {buffId: buffId, charId: charId}, - element: event.currentTarget, - }); - }, -}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html b/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html index 9998abf1..720f7814 100644 --- a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html +++ b/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html @@ -8,20 +8,22 @@ {{/if}}
- {{#each conditions}} - {{>buffView}} - {{/each}} - - {{#if buffs.count}} -
-
- Buffs -
- {{#each buffs}} - {{> buffView}} - {{/each}} +
+ {{#each conditions}} + {{>buffListItem}} + {{/each}} +
+ {{#if totalBuffs.count}} +
+
Buffs
+ View All
- {/if}} + {{/if}} +
+ {{#each buff in buffs}} + {{>buffListItem buff=buff}} + {{/each}} +
From 0d023e2ba317b9a0e77a3cb9800aa450c5d516cf Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 11:36:45 +0100 Subject: [PATCH 09/24] Adding conditions now works again --- rpg-docs/Model/Character/Buffs.js | 3 ++- .../views/character/buffs/buffViewList/buffViewList.html | 4 ++-- rpg-docs/lib/methods/conditions.js | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rpg-docs/Model/Character/Buffs.js b/rpg-docs/Model/Character/Buffs.js index dd065e2f..e6e00710 100644 --- a/rpg-docs/Model/Character/Buffs.js +++ b/rpg-docs/Model/Character/Buffs.js @@ -46,8 +46,9 @@ Schemas.Buff = new SimpleSchema({ type: String, regEx: SimpleSchema.RegEx.Id, }, - appliedByDetails: {//the name and collection of the thing that applied the buff, and the character's name + appliedByDetails: {//the name and collection of the thing that applied the buff type: Object, + optional: true, }, "appliedByDetails.name": { type: String, diff --git a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html b/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html index 720f7814..d8273057 100644 --- a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html +++ b/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html @@ -9,8 +9,8 @@
- {{#each conditions}} - {{>buffListItem}} + {{#each condition in conditions}} + {{>buffListItem buff=condition}} {{/each}}
{{#if totalBuffs.count}} diff --git a/rpg-docs/lib/methods/conditions.js b/rpg-docs/lib/methods/conditions.js index 0916941d..2202c5f8 100644 --- a/rpg-docs/lib/methods/conditions.js +++ b/rpg-docs/lib/methods/conditions.js @@ -26,7 +26,12 @@ Meteor.methods({ var condition = getCondition(conditionName); //create the buff var buff = _.extend( - {charId: charId, type: "inate"}, condition.buff + { + charId: charId, + type: "inate", + appliedBy: charId, + }, + condition.buff ); //make sure the character doesn't already have the buff From bce1b856004d59da96a2ce55963f37d28679a0b4 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 11:38:30 +0100 Subject: [PATCH 10/24] Relocated the buff list to be inline in stats.html --- .../buffs/buffViewList/buffViewList.html | 30 ----------------- .../buffs/buffViewList/buffViewList.js | 32 ------------------- .../client/views/character/stats/stats.html | 29 ++++++++++++++++- .../client/views/character/stats/stats.js | 30 +++++++++++++++-- 4 files changed, 55 insertions(+), 66 deletions(-) delete mode 100644 rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html delete mode 100644 rpg-docs/client/views/character/buffs/buffViewList/buffViewList.js diff --git a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html b/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html deleted file mode 100644 index d8273057..00000000 --- a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.html +++ /dev/null @@ -1,30 +0,0 @@ - \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.js b/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.js deleted file mode 100644 index af07ae6c..00000000 --- a/rpg-docs/client/views/character/buffs/buffViewList/buffViewList.js +++ /dev/null @@ -1,32 +0,0 @@ -Template.buffViewList.helpers({ - conditions: function(){ - var selector = { - "charId": this._id, - "type": "inate", - }; - return Buffs.find(selector); - }, - buffs: function(){ - var selector = { - "charId": this._id, - "type": "custom", - }; - return Buffs.find(selector); - } -}); - -Template.buffViewList.events({ - "click #addCondition": function(event, template){ - pushDialogStack({ - template: "conditionLibraryDialog", - element: event.currentTarget, - callback: (result) => { - if (!result) { - return; - } - else Meteor.call("giveCondition", this._id, result) - }, - //returnElement: () => $(`[data-id='${itemId}']`).get(0), - }) - }, -}); diff --git a/rpg-docs/client/views/character/stats/stats.html b/rpg-docs/client/views/character/stats/stats.html index 74d0c8d6..4da78330 100644 --- a/rpg-docs/client/views/character/stats/stats.html +++ b/rpg-docs/client/views/character/stats/stats.html @@ -43,7 +43,34 @@
- {{> buffViewList}} +
+ +
+
Conditions
+ {{#if canEditCharacter _id}} + + {{/if}} +
+
+
+ {{#each condition in conditions}} + {{>buffListItem buff=condition}} + {{/each}} +
+ {{#if totalBuffs.count}} +
+
Buffs
+ View All +
+ {{/if}} +
+ {{#each buff in buffs}} + {{>buffListItem buff=buff}} + {{/each}} +
+
+
+
diff --git a/rpg-docs/client/views/character/stats/stats.js b/rpg-docs/client/views/character/stats/stats.js index d95e1213..8c02073c 100644 --- a/rpg-docs/client/views/character/stats/stats.js +++ b/rpg-docs/client/views/character/stats/stats.js @@ -1,7 +1,18 @@ Template.stats.helpers({ - buffs: function() { - return Buffs.find({charId: this._id}, {sort: {name: 1}}); - } + conditions: function(){ + var selector = { + "charId": this._id, + "type": "inate", + }; + return Buffs.find(selector); + }, + buffs: function(){ + var selector = { + "charId": this._id, + "type": "custom", + }; + return Buffs.find(selector); + }, }) Template.stats.events({ @@ -71,4 +82,17 @@ Template.stats.events({ element: event.currentTarget.parentElement.parentElement, }); }, + "click #addCondition": function(event, template){ + pushDialogStack({ + template: "conditionLibraryDialog", + element: event.currentTarget, + callback: (result) => { + if (!result) { + return; + } + else Meteor.call("giveCondition", this._id, result) + }, + //returnElement: () => $(`[data-id='${itemId}']`).get(0), + }) + }, }); From 08735ea4f7042bfc51134aa7873ee503e1ee015a Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 15:01:20 +0100 Subject: [PATCH 11/24] Added ability to add/edit buffs --- rpg-docs/Model/Character/CustomBuffs.js | 24 +++--- .../client/globalHelpers/openParentDialog.js | 3 + .../applyBuffDialog/applyBuffDialog.html | 40 +++++++++ .../buffs/applyBuffDialog/applyBuffDialog.js | 83 +++++++++++++++++++ .../buffs/buffDialog/buffDialog.html | 2 +- .../character/buffs/buffDialog/buffDialog.js | 15 ++-- .../buffs/customBuffEdit/customBuffEdit.html | 15 ++++ .../buffs/customBuffEdit/customBuffEdit.js | 35 ++++++++ .../customBuffEditList.html | 30 +++++++ .../customBuffEditList/customBuffEditList.js | 41 +++++++++ .../buffs/customBuffView/customBuffView.html | 6 ++ .../buffs/customBuffView/customBuffView.js | 9 ++ .../customBuffViewList.html | 12 +++ .../customBuffViewList/customBuffViewList.js | 9 ++ .../features/featureDialog/featureDialog.html | 2 + .../inventory/itemDialog/itemDialog.html | 3 + .../spells/spellDialog/spellDialog.html | 2 + .../client/views/character/stats/stats.html | 3 +- 18 files changed, 308 insertions(+), 26 deletions(-) create mode 100644 rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html create mode 100644 rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js create mode 100644 rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html create mode 100644 rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js create mode 100644 rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.html create mode 100644 rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js create mode 100644 rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html create mode 100644 rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js create mode 100644 rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html create mode 100644 rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.js diff --git a/rpg-docs/Model/Character/CustomBuffs.js b/rpg-docs/Model/Character/CustomBuffs.js index 2920a547..7a766b01 100644 --- a/rpg-docs/Model/Character/CustomBuffs.js +++ b/rpg-docs/Model/Character/CustomBuffs.js @@ -16,6 +16,15 @@ Schemas.CustomBuff = new SimpleSchema({ optional: true, trim: false, }, + target: { + type: String, + allowedValues: [ + "self", + "others", + "both" + ], + defaultValue: "self", + }, enabled: { type: Boolean, autoValue: function(){ @@ -23,27 +32,14 @@ Schemas.CustomBuff = new SimpleSchema({ //enabled is ALWAYS false on these, so that its children are also not enabled, so that the buff templates have no effects. }, }, - type: { - type: String, - allowedValues: [ - "inate", //this should be "innate", but changing it could be problematic - "custom", - ], - }, "lifeTime.total": { type: Number, defaultValue: 0, //0 is infinite min: 0, }, - color: { - type: String, - allowedValues: _.pluck(colorOptions, "key"), - defaultValue: "q", - }, //the id of the feature, buff or item that creates this buff parent: { type: Schemas.Parent, - optional: true, }, }); @@ -51,7 +47,7 @@ CustomBuffs.attachSchema(Schemas.CustomBuff); CustomBuffs.attachBehaviour("softRemovable"); makeParent(CustomBuffs, ["name", "enabled"]); //parents of effects, attacks, proficiencies. Since this represents a template, "enabled" is always false. -makeChild(CustomBuffs, ["enabled"]); //children of lots of things +makeChild(CustomBuffs); //children of lots of things CustomBuffs.allow(CHARACTER_SUBSCHEMA_ALLOW); CustomBuffs.deny(CHARACTER_SUBSCHEMA_DENY); diff --git a/rpg-docs/client/globalHelpers/openParentDialog.js b/rpg-docs/client/globalHelpers/openParentDialog.js index 139428fe..b220a652 100644 --- a/rpg-docs/client/globalHelpers/openParentDialog.js +++ b/rpg-docs/client/globalHelpers/openParentDialog.js @@ -18,6 +18,9 @@ openParentDialog = function({ } else if (parent.collection === "Spells") { template = "spellDialog"; data = {spellId: parent.id}; + } else if (parent.collection === "Buffs") { + template = "buffDialog"; + data = {buffId: parent.id}; } pushDialogStack({template, data, element, returnElement, callback}); }; diff --git a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html new file mode 100644 index 00000000..5618141e --- /dev/null +++ b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html @@ -0,0 +1,40 @@ + + diff --git a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js new file mode 100644 index 00000000..0100145a --- /dev/null +++ b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js @@ -0,0 +1,83 @@ +Template.applyBuffDialog.onCreated(function(){ + this.selectedTarget = new ReactiveVar("default"); +}); + +Template.applyBuffDialog.helpers({ + cantApply: function() { + return this.buff.target === "others" && Template.instance().selectedTarget.get() === "default"; //this is the only case where we can't apply a buff + }, + canApplyToSelf: function() { + return this.buff.target !== "others"; //i.e. it is "self" or "both" + }, + writableCharacters: function() { + var returnArray = []; + Characters.find({}).forEach(function(char){ //we look through all characters we have access to + if (canEditCharacter(char._id)) { + returnArray.push(char) + } + }); + return returnArray; + }, +}); + +Template.applyBuffDialog.events({ + "iron-select .target-dropdown": function(event){ + var detail = event.originalEvent.detail; + var value = detail.item.getAttribute("name"); + Template.instance().selectedTarget.set(value); + }, + "click #applyButton": function(event, instance){ + var targetId = Template.instance().selectedTarget.get(); + var parent = global[this.buff.parent.collection].findOne(this.buff.parent.id); + console.log(parent, this.buff.parent); + if (targetId === "default") { + if (this.buff.target === "others") return; //we have "Select a character" selected + targetId = this.buff.charId; //i.e. target self + } + + //insert new buff + newBuffId = Buffs.insert({ + charId: targetId, + name: this.buff.name, + description: this.buff.description, + lifeTime: {total: this.buff.lifeTime.total}, + type: "custom", + + appliedBy: this.buff.charId, + appliedByDetails: { + name: parent.name, + collection: this.buff.parent.collection, + }, + }); + + //insert children + Attacks.find({"parent.id": this.buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Attacks.insert(temp); + }); + Effects.find({"parent.id": this.buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Effects.insert(temp); + }); + Proficiencies.find({"parent.id": this.buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Proficiencies.insert(temp); + }); + popDialogStack(); + }, + "click #cancelButton": function(event, instance){ + popDialogStack(); + }, +}); diff --git a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html index d194ff85..78fef7c5 100644 --- a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html +++ b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html @@ -17,6 +17,6 @@
{{#markdown}}{{evaluateString charId description}}{{/markdown}}
{{/if}} {{> effectsViewList charId=charId parentId=_id}} - {{> attacksViewList charId=charId parentId=_id}} {{> proficiencyViewList charId=charId parentId=_id}} + {{> attacksViewList charId=charId parentId=_id}} diff --git a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js index 90bb0c10..a2b5cff6 100644 --- a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js +++ b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js @@ -6,7 +6,7 @@ Template.buffDialog.helpers({ Template.buffDialog.events({ "click #deleteButton": function(event, instance){ - Buffs.remove(instance.data.buffId); + Buffs.softRemoveNode(instance.data.buffId); popDialogStack(); }, }); @@ -29,18 +29,15 @@ Template.buffDetails.helpers({ if (applierCharacter.name === myName) { var charName = "your " } else { - if (applierCharacter.charName[applierCharacter.charName.length -1] === 's') { - var charName = applierCharacter.charName + "' "; + if (applierCharacter.name[applierCharacter.name.length - 1] === 's') { + var charName = applierCharacter.name + "' "; } else { - var charName = applierCharacter.charName + "'s "; + var charName = applierCharacter.name + "'s "; } } - var type = typeDict[this.appliedByDetails.collection] || ""; - var applierThing = global[this.appliedByDetails.collection] - && global[this.appliedByDetails.collection].findOne(this.appliedByDetails.id) - && global[this.appliedByDetails.collection].findOne(this.appliedByDetails.id).name - || "unknown ability"; + var type = typeDict[this.appliedByDetails.collection] + " "; + var applierThing = this.appliedByDetails.name; return "Applied by " + charName + type + applierThing + "."; } diff --git a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html new file mode 100644 index 00000000..5a12d152 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js new file mode 100644 index 00000000..aed7d9b9 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js @@ -0,0 +1,35 @@ +Template.customBuffEdit.helpers({ + buff: function(){ + return CustomBuffs.findOne(this.buffId); + }, +}); + +const debounce = (f) => _.debounce(f, 300); + +Template.customBuffEdit.events({ + "input #buffNameInput": debounce(function(event){ + const input = event.currentTarget; + var name = input.value; + if (!name){ + input.invalid = true; + input.errorMessage = "Name is required"; + } else { + input.invalid = false; + CustomBuffs.update(this._id, { + $set: {name: name} + }, { + removeEmptyStrings: false, + trimStrings: false, + }); + } + }), + "input #buffDescriptionInput": debounce(function(event){ + var description = event.currentTarget.value; + CustomBuffs.update(this._id, { + $set: {description: description} + }, { + removeEmptyStrings: false, + trimStrings: false, + }); + }), +}); diff --git a/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.html b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.html new file mode 100644 index 00000000..a3f8cf78 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.html @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js new file mode 100644 index 00000000..a7d955f4 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js @@ -0,0 +1,41 @@ +Template.customBuffEditList.helpers({ + buffs: function(){ + var selector = { + "parent.id": this.parentId, + "charId": this.charId, + }; + return CustomBuffs.find(selector); + } +}); + +Template.customBuffEditList.events({ + "tap #addBuffButton": function(event, instance){ + if (!_.isBoolean(this.enabled)) { + this.enabled = true; + } + const customBuffId = CustomBuffs.insert({ + name: "New Buff", + charId: this.charId, + parent: { + id: this.parentId, + collection: this.parentCollection, + }, + }); + pushDialogStack({ + template: "customBuffEdit", + data: {id: customBuffId}, + element: event.currentTarget, + returnElement: () => instance.find(`tr.buff[data-id='${customBuffId}']`), + }); + }, +}); + +Template.customBuffEditListItem.events({ + "tap .edit-buff": function(event, template){ + pushDialogStack({ + template: "customBuffEdit", + data: {id: this.buff._id}, + element: event.currentTarget.parentElement.parentElement, + }); + }, +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html new file mode 100644 index 00000000..63c6a5b6 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html @@ -0,0 +1,6 @@ + diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js new file mode 100644 index 00000000..eab7ec97 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js @@ -0,0 +1,9 @@ +Template.customBuffView.events({ + "click .apply-buff-button": function(){ + pushDialogStack({ + template: "applyBuffDialog", + data: {buff: this.buff}, + element: event.currentTarget, + }); + }, +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html b/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html new file mode 100644 index 00000000..ea002b05 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html @@ -0,0 +1,12 @@ + diff --git a/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.js b/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.js new file mode 100644 index 00000000..2efa4dd4 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.js @@ -0,0 +1,9 @@ +Template.customBuffViewList.helpers({ + buffs: function(){ + var selector = { + "parent.id": this.parentId, + "charId": this.charId, + }; + return CustomBuffs.find(selector); + } +}); diff --git a/rpg-docs/client/views/character/features/featureDialog/featureDialog.html b/rpg-docs/client/views/character/features/featureDialog/featureDialog.html index 02ea0ccf..b9d0a437 100644 --- a/rpg-docs/client/views/character/features/featureDialog/featureDialog.html +++ b/rpg-docs/client/views/character/features/featureDialog/featureDialog.html @@ -36,6 +36,7 @@ {{> effectsViewList charId=charId parentId=_id}} {{> proficiencyViewList charId=charId parentId=_id}} + {{> customBuffViewList charId=charId parentId=_id}} diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html index 9692c27f..874c5d82 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html @@ -23,6 +23,7 @@ {{/if}} {{> effectsViewList charId=charId parentId=_id}} {{> attacksViewList charId=charId parentId=_id}} + {{> customBuffViewList charId=charId parentId=_id}} diff --git a/rpg-docs/client/views/character/stats/stats.html b/rpg-docs/client/views/character/stats/stats.html index 4da78330..5ecdb947 100644 --- a/rpg-docs/client/views/character/stats/stats.html +++ b/rpg-docs/client/views/character/stats/stats.html @@ -57,10 +57,9 @@ {{>buffListItem buff=condition}} {{/each}}
- {{#if totalBuffs.count}} + {{#if buffs.count}}
Buffs
- View All
{{/if}}
From 64ef426035c1537cd32fae25be9762a1b2f4dab5 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 15:14:28 +0100 Subject: [PATCH 12/24] Applying character no longer duplicated in buff apply list --- .../views/character/buffs/applyBuffDialog/applyBuffDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js index 0100145a..f5fcbe44 100644 --- a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js +++ b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js @@ -11,9 +11,9 @@ Template.applyBuffDialog.helpers({ }, writableCharacters: function() { var returnArray = []; - Characters.find({}).forEach(function(char){ //we look through all characters we have access to + Characters.find({_id: {$ne: this.buff.charId}}).forEach(function(char){ //we look through all characters we have access to if (canEditCharacter(char._id)) { - returnArray.push(char) + returnArray.push(char); } }); return returnArray; From 818cb3905fad8ec56672a686eaca2d497c12b3d2 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 15:30:33 +0100 Subject: [PATCH 13/24] Can now access the name of public characters for buffs the buffDialog can now access the name of a publicly-available character so it can display their name as the caster --- .../character/buffs/buffDialog/buffDialog.js | 5 +++++ rpg-docs/server/publications/singleCharacter.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js index a2b5cff6..66652ee8 100644 --- a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js +++ b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.js @@ -1,3 +1,8 @@ +Template.buffDialog.onCreated(function(){ + var buff = Buffs.findOne(this.buffId); + Meteor.subscribe("singleCharacterName", buff.charId); //so we can access the names of public characters +}); + Template.buffDialog.helpers({ buff: function(){ return Buffs.findOne(this.buffId); diff --git a/rpg-docs/server/publications/singleCharacter.js b/rpg-docs/server/publications/singleCharacter.js index 3a039c38..f6a82658 100644 --- a/rpg-docs/server/publications/singleCharacter.js +++ b/rpg-docs/server/publications/singleCharacter.js @@ -33,3 +33,19 @@ Meteor.publish("singleCharacter", function(characterId){ return []; } }); + +Meteor.publish("singleCharacterName", function(characterId){ + userId = this.userId; + var char = Characters.findOne({ + _id: characterId, + $or: [ + {readers: userId}, + {writers: userId}, + {owner: userId}, + {"settings.viewPermission": "public"}, + ], + }); + if (char) { + return Characters.find(characterId, {fields:"name"}); + } +}); \ No newline at end of file From c9fe2f17a0cdb6c58c5351f15a393622c61f390d Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 15:48:12 +0100 Subject: [PATCH 14/24] If buff's target is "self", dialog is no longer shown --- .../buffs/customBuffView/customBuffView.html | 4 +- .../buffs/customBuffView/customBuffView.js | 73 +++++++++++++++++-- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html index 63c6a5b6..de9e8798 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html @@ -1,6 +1,8 @@ diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js index eab7ec97..c7421820 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js @@ -1,9 +1,72 @@ +Template.customBuffView.helpers({ + toSelf: function() { + if (this.buff.target === "self") { + return " to self"; + } else { + return ""; + } + } +}); + Template.customBuffView.events({ "click .apply-buff-button": function(){ - pushDialogStack({ - template: "applyBuffDialog", - data: {buff: this.buff}, - element: event.currentTarget, - }); + if (this.buff.target !== "self") { + pushDialogStack({ + template: "applyBuffDialog", + data: {buff: this.buff}, + element: event.currentTarget, + }); + } + else { + var targetId = this.buff.charId; + var parent = global[this.buff.parent.collection].findOne(this.buff.parent.id); + console.log(parent, this.buff.parent); + if (targetId === "default") { + if (this.buff.target === "others") return; //we have "Select a character" selected + targetId = this.buff.charId; //i.e. target self + } + + //insert new buff + newBuffId = Buffs.insert({ + charId: targetId, + name: this.buff.name, + description: this.buff.description, + lifeTime: {total: this.buff.lifeTime.total}, + type: "custom", + + appliedBy: this.buff.charId, + appliedByDetails: { + name: parent.name, + collection: this.buff.parent.collection, + }, + }); + + //insert children + Attacks.find({"parent.id": this.buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Attacks.insert(temp); + }); + Effects.find({"parent.id": this.buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Effects.insert(temp); + }); + Proficiencies.find({"parent.id": this.buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Proficiencies.insert(temp); + }); + popDialogStack(); + } }, }); \ No newline at end of file From 18e5ab3f212ffcefd28158f84f80d45fd89ad347 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 16:08:19 +0100 Subject: [PATCH 15/24] Can now set target of buffs ...to "Self only", "Others only", or "Both". --- .../buffs/customBuffEdit/customBuffEdit.html | 16 ++++++++++++++++ .../buffs/customBuffEdit/customBuffEdit.js | 6 ++++++ .../buffs/customBuffView/customBuffView.js | 1 - 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html index 5a12d152..92cd8050 100644 --- a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html +++ b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html @@ -4,6 +4,22 @@ +
+ + + + Self only + + + Others only + + + Both + + + +
+ diff --git a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js index aed7d9b9..4941e58d 100644 --- a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js +++ b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js @@ -32,4 +32,10 @@ Template.customBuffEdit.events({ trimStrings: false, }); }), + "iron-select .target-dropdown": function(event){ + var detail = event.originalEvent.detail; + var value = detail.item.getAttribute("name"); + if (value === this.target) return; + CustomBuffs.update(this._id, {$set: {target: value}}); + }, }); diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js index c7421820..d1d7fac2 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js @@ -66,7 +66,6 @@ Template.customBuffView.events({ Proficiencies.insert(temp); }); - popDialogStack(); } }, }); \ No newline at end of file From d4031dc4a78675e885ec93a489c5e12800a553f5 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 16:11:09 +0100 Subject: [PATCH 16/24] Removed an unnecessary console log --- .../views/character/buffs/customBuffView/customBuffView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js index d1d7fac2..c8573872 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js @@ -20,7 +20,6 @@ Template.customBuffView.events({ else { var targetId = this.buff.charId; var parent = global[this.buff.parent.collection].findOne(this.buff.parent.id); - console.log(parent, this.buff.parent); if (targetId === "default") { if (this.buff.target === "others") return; //we have "Select a character" selected targetId = this.buff.charId; //i.e. target self From 471a3e274e7d7192439f2b8bd4b5ea32226842e0 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 9 Aug 2017 16:48:38 +0100 Subject: [PATCH 17/24] Refactored code which applies buffs --- .../buffs/applyBuffDialog/applyBuffDialog.js | 48 +--------- .../buffs/customBuffView/customBuffView.js | 96 ++++++++++--------- .../server/publications/singleCharacter.js | 2 +- 3 files changed, 54 insertions(+), 92 deletions(-) diff --git a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js index f5fcbe44..c5f9bb8c 100644 --- a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js +++ b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.js @@ -28,54 +28,12 @@ Template.applyBuffDialog.events({ }, "click #applyButton": function(event, instance){ var targetId = Template.instance().selectedTarget.get(); - var parent = global[this.buff.parent.collection].findOne(this.buff.parent.id); - console.log(parent, this.buff.parent); if (targetId === "default") { - if (this.buff.target === "others") return; //we have "Select a character" selected - targetId = this.buff.charId; //i.e. target self + if (this.buff.target === "others") return; //since we have "Select a character" selected + targetId = this.buff.charId; //otherwise, the default is to target self } - //insert new buff - newBuffId = Buffs.insert({ - charId: targetId, - name: this.buff.name, - description: this.buff.description, - lifeTime: {total: this.buff.lifeTime.total}, - type: "custom", - - appliedBy: this.buff.charId, - appliedByDetails: { - name: parent.name, - collection: this.buff.parent.collection, - }, - }); - - //insert children - Attacks.find({"parent.id": this.buff._id}).forEach(function(doc){ - temp = _.clone(doc); - temp.parent.id = newBuffId; - temp.parent.collection = "Buffs"; - delete temp._id; - - Attacks.insert(temp); - }); - Effects.find({"parent.id": this.buff._id}).forEach(function(doc){ - temp = _.clone(doc); - temp.parent.id = newBuffId; - temp.parent.collection = "Buffs"; - delete temp._id; - - Effects.insert(temp); - }); - Proficiencies.find({"parent.id": this.buff._id}).forEach(function(doc){ - temp = _.clone(doc); - temp.parent.id = newBuffId; - temp.parent.collection = "Buffs"; - delete temp._id; - - Proficiencies.insert(temp); - }); - popDialogStack(); + popDialogStack(targetId); }, "click #cancelButton": function(event, instance){ popDialogStack(); diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js index c8573872..70c8d4da 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js @@ -1,3 +1,48 @@ +const applyBuff = function(targetId, buff) { + var parent = global[buff.parent.collection].findOne(buff.parent.id); + + //insert new buff + newBuffId = Buffs.insert({ + charId: targetId, + name: buff.name, + description: buff.description, + lifeTime: {total: buff.lifeTime.total}, + type: "custom", + + appliedBy: buff.charId, + appliedByDetails: { + name: parent.name, + collection: buff.parent.collection, + }, + }); + + //insert children + Attacks.find({"parent.id": buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Attacks.insert(temp); + }); + Effects.find({"parent.id": buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Effects.insert(temp); + }); + Proficiencies.find({"parent.id": buff._id}).forEach(function(doc){ + temp = _.clone(doc); + temp.parent.id = newBuffId; + temp.parent.collection = "Buffs"; + delete temp._id; + + Proficiencies.insert(temp); + }); +} + Template.customBuffView.helpers({ toSelf: function() { if (this.buff.target === "self") { @@ -15,56 +60,15 @@ Template.customBuffView.events({ template: "applyBuffDialog", data: {buff: this.buff}, element: event.currentTarget, + callback: (targetId) => { + if (!targetId) return; + applyBuff(targetId, this.buff); + }, }); } else { var targetId = this.buff.charId; - var parent = global[this.buff.parent.collection].findOne(this.buff.parent.id); - if (targetId === "default") { - if (this.buff.target === "others") return; //we have "Select a character" selected - targetId = this.buff.charId; //i.e. target self - } - - //insert new buff - newBuffId = Buffs.insert({ - charId: targetId, - name: this.buff.name, - description: this.buff.description, - lifeTime: {total: this.buff.lifeTime.total}, - type: "custom", - - appliedBy: this.buff.charId, - appliedByDetails: { - name: parent.name, - collection: this.buff.parent.collection, - }, - }); - - //insert children - Attacks.find({"parent.id": this.buff._id}).forEach(function(doc){ - temp = _.clone(doc); - temp.parent.id = newBuffId; - temp.parent.collection = "Buffs"; - delete temp._id; - - Attacks.insert(temp); - }); - Effects.find({"parent.id": this.buff._id}).forEach(function(doc){ - temp = _.clone(doc); - temp.parent.id = newBuffId; - temp.parent.collection = "Buffs"; - delete temp._id; - - Effects.insert(temp); - }); - Proficiencies.find({"parent.id": this.buff._id}).forEach(function(doc){ - temp = _.clone(doc); - temp.parent.id = newBuffId; - temp.parent.collection = "Buffs"; - delete temp._id; - - Proficiencies.insert(temp); - }); + applyBuff(targetId, this.buff); } }, }); \ No newline at end of file diff --git a/rpg-docs/server/publications/singleCharacter.js b/rpg-docs/server/publications/singleCharacter.js index f6a82658..42f8c073 100644 --- a/rpg-docs/server/publications/singleCharacter.js +++ b/rpg-docs/server/publications/singleCharacter.js @@ -46,6 +46,6 @@ Meteor.publish("singleCharacterName", function(characterId){ ], }); if (char) { - return Characters.find(characterId, {fields:"name"}); + return Characters.find(characterId, {fields:{"name": 1}}); } }); \ No newline at end of file From 6dd92586a4e0e4812a746e8436260ef1ac0d46e2 Mon Sep 17 00:00:00 2001 From: Jacob Date: Mon, 4 Sep 2017 19:25:05 +0100 Subject: [PATCH 18/24] Conditions are now separate from buffs, like in #109 --- rpg-docs/Model/Character/Conditions.js | 42 ++++++++++++++++ .../buffs/conditionView/conditionView.html | 7 +++ .../buffs/conditionView/conditionView.js | 11 ++++ .../conditionViewDialog.html | 14 ++++++ .../conditionViewDialog.js | 6 +++ .../buffs/customBuffEdit/customBuffEdit.html | 50 +++++++++---------- .../buffs/customBuffEdit/customBuffEdit.js | 14 ++---- .../customBuffEditList/customBuffEditList.js | 2 +- .../client/views/character/stats/stats.html | 2 +- .../client/views/character/stats/stats.js | 11 ++-- rpg-docs/lib/methods/conditions.js | 10 ++-- .../server/publications/singleCharacter.js | 1 + 12 files changed, 118 insertions(+), 52 deletions(-) create mode 100644 rpg-docs/Model/Character/Conditions.js create mode 100644 rpg-docs/client/views/character/buffs/conditionView/conditionView.html create mode 100644 rpg-docs/client/views/character/buffs/conditionView/conditionView.js create mode 100644 rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.html create mode 100644 rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.js diff --git a/rpg-docs/Model/Character/Conditions.js b/rpg-docs/Model/Character/Conditions.js new file mode 100644 index 00000000..ce894fe1 --- /dev/null +++ b/rpg-docs/Model/Character/Conditions.js @@ -0,0 +1,42 @@ +Conditions = new Mongo.Collection("conditions"); + +Schemas.Conditions = new SimpleSchema({ + charId: { + type: String, + regEx: SimpleSchema.RegEx.Id, + index: 1, + }, + name: { + type: String, + optional: true, + trim: false, + }, + description: { + type: String, + optional: true, + trim: false, + }, + "lifeTime.total": { + type: Number, + defaultValue: 0, //0 is infinite + min: 0, + }, + "lifeTime.spent": { + type: Number, + defaultValue: 0, + min: 0, + }, + color: { + type: String, + allowedValues: _.pluck(colorOptions, "key"), + defaultValue: "q", + }, +}); + +Conditions.attachSchema(Schemas.Conditions); + +Conditions.attachBehaviour("softRemovable"); +makeParent(Conditions, ["name"]); //parents of effects, attacks, proficiencies + +Conditions.allow(CHARACTER_SUBSCHEMA_ALLOW); +Conditions.deny(CHARACTER_SUBSCHEMA_DENY); diff --git a/rpg-docs/client/views/character/buffs/conditionView/conditionView.html b/rpg-docs/client/views/character/buffs/conditionView/conditionView.html new file mode 100644 index 00000000..38659a6d --- /dev/null +++ b/rpg-docs/client/views/character/buffs/conditionView/conditionView.html @@ -0,0 +1,7 @@ + diff --git a/rpg-docs/client/views/character/buffs/conditionView/conditionView.js b/rpg-docs/client/views/character/buffs/conditionView/conditionView.js new file mode 100644 index 00000000..752a9ba6 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/conditionView/conditionView.js @@ -0,0 +1,11 @@ +Template.conditionView.events({ + "click .conditionView": function(event){ + var condition = this.condition; + var charId = Template.parentData()._id; + pushDialogStack({ + template: "conditionViewDialog", + data: {condition: condition}, + element: event.currentTarget, + }); + }, +}); diff --git a/rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.html b/rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.html new file mode 100644 index 00000000..9800cc25 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.html @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.js b/rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.js new file mode 100644 index 00000000..da029186 --- /dev/null +++ b/rpg-docs/client/views/character/buffs/conditionViewDialog/conditionViewDialog.js @@ -0,0 +1,6 @@ +Template.conditionViewDialog.events({ + "click #deleteButton": function(event, instance){ + Conditions.remove(instance.data.condition._id); + popDialogStack(); + }, +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html index 92cd8050..59ada714 100644 --- a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html +++ b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.html @@ -1,31 +1,29 @@ \ No newline at end of file diff --git a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js index 4941e58d..66330ba4 100644 --- a/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js +++ b/rpg-docs/client/views/character/buffs/customBuffEdit/customBuffEdit.js @@ -1,9 +1,3 @@ -Template.customBuffEdit.helpers({ - buff: function(){ - return CustomBuffs.findOne(this.buffId); - }, -}); - const debounce = (f) => _.debounce(f, 300); Template.customBuffEdit.events({ @@ -15,7 +9,7 @@ Template.customBuffEdit.events({ input.errorMessage = "Name is required"; } else { input.invalid = false; - CustomBuffs.update(this._id, { + CustomBuffs.update(this.buff._id, { $set: {name: name} }, { removeEmptyStrings: false, @@ -25,7 +19,7 @@ Template.customBuffEdit.events({ }), "input #buffDescriptionInput": debounce(function(event){ var description = event.currentTarget.value; - CustomBuffs.update(this._id, { + CustomBuffs.update(this.buff._id, { $set: {description: description} }, { removeEmptyStrings: false, @@ -35,7 +29,7 @@ Template.customBuffEdit.events({ "iron-select .target-dropdown": function(event){ var detail = event.originalEvent.detail; var value = detail.item.getAttribute("name"); - if (value === this.target) return; - CustomBuffs.update(this._id, {$set: {target: value}}); + if (value === this.buff.target) return; + CustomBuffs.update(this.buff._id, {$set: {target: value}}); }, }); diff --git a/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js index a7d955f4..54f7fc29 100644 --- a/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js +++ b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js @@ -34,7 +34,7 @@ Template.customBuffEditListItem.events({ "tap .edit-buff": function(event, template){ pushDialogStack({ template: "customBuffEdit", - data: {id: this.buff._id}, + data: {buff: this.buff}, element: event.currentTarget.parentElement.parentElement, }); }, diff --git a/rpg-docs/client/views/character/stats/stats.html b/rpg-docs/client/views/character/stats/stats.html index 5ecdb947..e9c8736e 100644 --- a/rpg-docs/client/views/character/stats/stats.html +++ b/rpg-docs/client/views/character/stats/stats.html @@ -54,7 +54,7 @@
{{#each condition in conditions}} - {{>buffListItem buff=condition}} + {{>conditionView condition=condition}} {{/each}}
{{#if buffs.count}} diff --git a/rpg-docs/client/views/character/stats/stats.js b/rpg-docs/client/views/character/stats/stats.js index 8c02073c..365136b8 100644 --- a/rpg-docs/client/views/character/stats/stats.js +++ b/rpg-docs/client/views/character/stats/stats.js @@ -1,15 +1,10 @@ Template.stats.helpers({ - conditions: function(){ - var selector = { - "charId": this._id, - "type": "inate", - }; - return Buffs.find(selector); + conditions: function() { + return Conditions.find({charId: this._id}); }, - buffs: function(){ + buffs: function() { var selector = { "charId": this._id, - "type": "custom", }; return Buffs.find(selector); }, diff --git a/rpg-docs/lib/methods/conditions.js b/rpg-docs/lib/methods/conditions.js index 2202c5f8..d0f949c8 100644 --- a/rpg-docs/lib/methods/conditions.js +++ b/rpg-docs/lib/methods/conditions.js @@ -28,21 +28,19 @@ Meteor.methods({ var buff = _.extend( { charId: charId, - type: "inate", - appliedBy: charId, }, condition.buff ); //make sure the character doesn't already have the buff - var existingBuffs = Buffs.find(_.clone(buff)).count(); + var existingBuffs = Conditions.find(_.clone(buff)).count(); if (existingBuffs) return; //remove exclusive conditions _.each(condition.exclusiveConditions, function(exCond) { Meteor.call("removeCondition", charId, exCond); }); //insert the buff - var buffId = Buffs.insert(buff); + var buffId = Conditions.insert(buff); //extend and insert each effect _.each(condition.effects, function(effect) { var newEffect = { @@ -53,7 +51,7 @@ Meteor.methods({ charId: charId, parent: { id: buffId, - collection: "Buffs", + collection: "Conditions", }, enabled: true, }; @@ -81,7 +79,7 @@ Meteor.methods({ var buff = _.extend( {charId: charId, type: "inate"}, condition.buff ); - Buffs.remove(buff); + Conditions.remove(buff); //dont remove the effects, they get removed automatically through parenting }, getConditions: function() { diff --git a/rpg-docs/server/publications/singleCharacter.js b/rpg-docs/server/publications/singleCharacter.js index 42f8c073..771375b6 100644 --- a/rpg-docs/server/publications/singleCharacter.js +++ b/rpg-docs/server/publications/singleCharacter.js @@ -17,6 +17,7 @@ Meteor.publish("singleCharacter", function(characterId){ Attacks.find ({charId: characterId}, {removed: true}), Buffs.find ({charId: characterId}, {removed: true}), Classes.find ({charId: characterId}, {removed: true}), + Conditions.find ({charId: characterId}, {removed: true}), Containers.find ({charId: characterId}, {removed: true}), CustomBuffs.find ({charId: characterId}, {removed: true}), Effects.find ({charId: characterId}, {removed: true}), From 7b62c82e323e5587aadde3c6e5a6fb0236ff8956 Mon Sep 17 00:00:00 2001 From: Jacob Date: Mon, 4 Sep 2017 20:16:56 +0100 Subject: [PATCH 19/24] Buff and condition view dialogs now only have the delete button --- .../views/character/buffs/buffDialog/buffDialog.html | 5 +++-- .../views/paperTemplates/baseDialog/baseDialog.html | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html index 78fef7c5..6bd27c7e 100644 --- a/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html +++ b/rpg-docs/client/views/character/buffs/buffDialog/buffDialog.html @@ -1,6 +1,6 @@ \ No newline at end of file + diff --git a/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js b/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js index e695af62..23f1d9ed 100644 --- a/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js +++ b/rpg-docs/client/views/character/buffs/buffListItem/buffListItem.js @@ -14,4 +14,8 @@ Template.buffListItem.events({ element: event.currentTarget, }); }, -}); \ No newline at end of file + "tap .deleteButton": function(event){ + event.stopPropagation(); + Buffs.remove(this.buff._id); + }, +}); diff --git a/rpg-docs/client/views/character/buffs/conditionView/conditionView.html b/rpg-docs/client/views/character/buffs/conditionView/conditionView.html index 38659a6d..4dff87ab 100644 --- a/rpg-docs/client/views/character/buffs/conditionView/conditionView.html +++ b/rpg-docs/client/views/character/buffs/conditionView/conditionView.html @@ -3,5 +3,13 @@
{{condition.name}}
+ + {{#if canEditCharacter condition.charId}} + + + {{/if}}
diff --git a/rpg-docs/client/views/character/buffs/conditionView/conditionView.js b/rpg-docs/client/views/character/buffs/conditionView/conditionView.js index 752a9ba6..8d22a0ea 100644 --- a/rpg-docs/client/views/character/buffs/conditionView/conditionView.js +++ b/rpg-docs/client/views/character/buffs/conditionView/conditionView.js @@ -8,4 +8,8 @@ Template.conditionView.events({ element: event.currentTarget, }); }, + "tap .deleteButton": function(event){ + event.stopPropagation(); + Conditions.remove(this.condition._id); + }, }); From 87583fdac6719b1869f64c31a2131c8e9fa1a9d0 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 5 Sep 2017 13:48:26 +0100 Subject: [PATCH 21/24] Added buff details to apply buff dialog --- .../buffs/applyBuffDialog/applyBuffDialog.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html index 5618141e..1cfc4320 100644 --- a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html +++ b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html @@ -1,7 +1,7 @@ \ No newline at end of file +
+ + diff --git a/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js index 54f7fc29..c9f1e752 100644 --- a/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js +++ b/rpg-docs/client/views/character/buffs/customBuffEditList/customBuffEditList.js @@ -14,7 +14,7 @@ Template.customBuffEditList.events({ this.enabled = true; } const customBuffId = CustomBuffs.insert({ - name: "New Buff", + name: this.name || "New Buff", charId: this.charId, parent: { id: this.parentId, @@ -23,7 +23,7 @@ Template.customBuffEditList.events({ }); pushDialogStack({ template: "customBuffEdit", - data: {id: customBuffId}, + data: {customBuffId}, element: event.currentTarget, returnElement: () => instance.find(`tr.buff[data-id='${customBuffId}']`), }); @@ -34,8 +34,8 @@ Template.customBuffEditListItem.events({ "tap .edit-buff": function(event, template){ pushDialogStack({ template: "customBuffEdit", - data: {buff: this.buff}, + data: {customBuffId: this.buff._id}, element: event.currentTarget.parentElement.parentElement, }); }, -}); \ No newline at end of file +}); diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html index de9e8798..09971a01 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.html @@ -1,8 +1,8 @@ diff --git a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js index 70c8d4da..fdc30712 100644 --- a/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js +++ b/rpg-docs/client/views/character/buffs/customBuffView/customBuffView.js @@ -41,7 +41,16 @@ const applyBuff = function(targetId, buff) { Proficiencies.insert(temp); }); -} + + let target; + if (targetId == buff.charId) { + target = "self"; + } else { + target = Characters.findOne(targetId) || {}; + target = target && target.name || "target" + } + GlobalUI.toast(`${buff.name || "Buff"} applied to ${target}`); +}; Template.customBuffView.helpers({ toSelf: function() { @@ -65,10 +74,9 @@ Template.customBuffView.events({ applyBuff(targetId, this.buff); }, }); - } - else { + } else { var targetId = this.buff.charId; applyBuff(targetId, this.buff); } }, -}); \ No newline at end of file +}); diff --git a/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html b/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html index ea002b05..7aae4d4c 100644 --- a/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html +++ b/rpg-docs/client/views/character/buffs/customBuffViewList/customBuffViewList.html @@ -5,7 +5,9 @@ Buffs {{#each buff in buffs}} - {{> customBuffView buff=buff}} +
+ {{> customBuffView buff=buff}} +
{{/each}} {{/if}} diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html index b3499845..d399b097 100644 --- a/rpg-docs/client/views/character/features/features.html +++ b/rpg-docs/client/views/character/features/features.html @@ -81,6 +81,7 @@ {{#if description}}
{{#markdown}}{{evaluateShortString charId description}}{{/markdown}} + {{> customBuffViewList charId=charId parentId=_id}}
{{/if}} {{#if hasUses}} @@ -159,4 +160,4 @@ - \ No newline at end of file + diff --git a/rpg-docs/client/views/characterList/characterSideList.js b/rpg-docs/client/views/characterList/characterSideList.js index d27d0941..a1faad12 100644 --- a/rpg-docs/client/views/characterList/characterSideList.js +++ b/rpg-docs/client/views/characterList/characterSideList.js @@ -34,7 +34,6 @@ Template.characterSideList.helpers({ }, isOpen(id) { var openedParties = Template.instance().openedParties.get(); - console.log(openedParties); return openedParties.has(id); }, }); From ef0deb20aa741c0350683d6786b2d9feec91f8c1 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 7 Sep 2017 14:36:45 +0200 Subject: [PATCH 24/24] Swapped dropdown box for full character list --- .../applyBuffDialog/applyBuffDialog.html | 42 +++++---------- .../buffs/applyBuffDialog/applyBuffDialog.js | 11 +--- .../characterPicker/characterPicker.css | 17 ++++++ .../characterPicker/characterPicker.html | 34 ++++++++++++ .../characterPicker/characterPicker.js | 53 +++++++++++++++++++ 5 files changed, 118 insertions(+), 39 deletions(-) create mode 100644 rpg-docs/client/views/characterList/characterPicker/characterPicker.css create mode 100644 rpg-docs/client/views/characterList/characterPicker/characterPicker.html create mode 100644 rpg-docs/client/views/characterList/characterPicker/characterPicker.js diff --git a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html index 1cfc4320..12634ba8 100644 --- a/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html +++ b/rpg-docs/client/views/character/buffs/applyBuffDialog/applyBuffDialog.html @@ -1,36 +1,20 @@