diff --git a/rpg-docs/Model/Character/Attacks.js b/rpg-docs/Model/Character/Attacks.js index 4b88a60d..6d94466d 100644 --- a/rpg-docs/Model/Character/Attacks.js +++ b/rpg-docs/Model/Character/Attacks.js @@ -13,22 +13,28 @@ Schemas.Attack = new SimpleSchema({ defaultValue: "New Attack", trim: false }, - range: { + details: { type: String, optional: true, trim: false }, attackBonus: { type: String, - optional: true, defaultValue: "strengthMod + proficiencyBonus", + optional: true, trim: false }, - damage: { + damageBonus: { + type: String, + defaultValue: "strengthMod", + optional: true, + trim: false + }, + damageDice: { type: String, optional: true, - defaultValue: "1d8 + {strengthMod}", - trim: false + defaultValue: "1d8", + allowedValues: DAMAGE_DICE }, damageType: { type: String, @@ -36,10 +42,26 @@ Schemas.Attack = new SimpleSchema({ "poison", "psychic", "radiant", "thunder"], defaultValue: "slashing" }, + //indicates what the attack originated from + type: { + type: String, + defaultValue: "editable", + allowedValues: ["editable", "feature", "class", "buff", "equipment", "racial", "inate"] + }, + //the id of the feature, buff or item that created this effect + sourceId: { + type: String, + regEx: SimpleSchema.RegEx.Id, + optional: true + }, color: { type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q" + }, + enabled: { + type: Boolean, + defaultValue: true } }); diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index c6728d53..f65ca9aa 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -36,16 +36,22 @@ Items.helpers({ } }); -//remove effects if their item source is removed +//remove effects and attacks if their item source is removed Items.before.remove(function (userId, item) { Effects.find({sourceId: item._id, type: "equipment"}).forEach(function(effect){ Effects.remove(effect._id); }); + Attacks.find({sourceId: item._id, type: "equipment"}).forEach(function(attack){ + Attacks.remove(attack._id); + }); }); -//keep the effects on the correct character and enabled when equipped +//keep the effects and attacks on the correct character and enabled when equipped Items.after.update(function (userId, item, fieldNames, modifier, options) { Effects.find({sourceId: item._id, type: "equipment"}).forEach(function(effect){ - Effects.update(effect._id, { $set: {charId: item.charId, enabled: item.equipped} }); - }, {fetchPrevious: false}); -}); + Effects.update(effect._id, { $set: {charId: item.charId, enabled: item.equipped, name: item.name} }); + }); + Attacks.find({sourceId: item._id, type: "equipment"}).forEach(function(attack){ + Attacks.update(attack._id, { $set: {charId: item.charId, enabled: item.equipped, name: item.name} }); + }); +}, {fetchPrevious: false}); diff --git a/rpg-docs/client/globalHelpers/evaluate.js b/rpg-docs/client/globalHelpers/evaluate.js index 25653dca..e3d5b884 100644 --- a/rpg-docs/client/globalHelpers/evaluate.js +++ b/rpg-docs/client/globalHelpers/evaluate.js @@ -11,6 +11,15 @@ Template.registerHelper("evaluateSigned", function(charId, string){ } }); +Template.registerHelper("evaluateSignedSpaced", function(charId, string){ + var number = evaluate(charId, string); + if(_.isFinite(number)){ + return number > 0? "+ " + number : "- " + (-1 * number); + } else{ + return number; + } +}); + Template.registerHelper("evaluateString", function(charId, string){ return evaluateString(charId, string); }); diff --git a/rpg-docs/client/views/GeneralCSS/globalDetail.css b/rpg-docs/client/views/GeneralCSS/globalDetail.css index ebcf6a11..318ceb8c 100644 --- a/rpg-docs/client/views/GeneralCSS/globalDetail.css +++ b/rpg-docs/client/views/GeneralCSS/globalDetail.css @@ -29,7 +29,7 @@ padding: 24px; } -#addEffectButton { +.red-button { background: #d23f31; color: #fff; margin-top: 16px; diff --git a/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.html b/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.html new file mode 100644 index 00000000..f63ffd9e --- /dev/null +++ b/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.html @@ -0,0 +1,49 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/features/attackDialog/attackDialog.js b/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js similarity index 55% rename from rpg-docs/client/views/character/features/attackDialog/attackDialog.js rename to rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js index 0e6c5154..3141b228 100644 --- a/rpg-docs/client/views/character/features/attackDialog/attackDialog.js +++ b/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js @@ -1,17 +1,9 @@ var damageTypes = ["bludgeoning", "piercing", "slashing", "acid", "cold", "fire", "force", "lightning", "necrotic", "poison", "psychic", "radiant", "thunder"]; -Template.attackDialog.events({ - "color-change": function(event, instance){ - Attacks.update(instance.data.attackId, {$set: {color: event.color}}); - }, - "tap #deleteButton": function(event, instance){ - Attacks.remove(instance.data.attackId); - GlobalUI.closeDetail() - }, - "change #attackNameInput": function(event){ - var value = event.currentTarget.value; - Attacks.update(this._id, {$set: {name: value}}); +Template.attackEdit.events({ + "tap #deleteAttack": function(event, instance){ + Attacks.remove(this._id); }, "change #attackBonusInput": function(event){ var value = event.currentTarget.value; @@ -19,11 +11,11 @@ Template.attackDialog.events({ }, "change #damageInput": function(event){ var value = event.currentTarget.value; - Attacks.update(this._id, {$set: {damage: value}}); + Attacks.update(this._id, {$set: {damageBonus: value}}); }, - "change #rangeInput": function(event){ + "change #detailInput": function(event){ var value = event.currentTarget.value; - Attacks.update(this._id, {$set: {range: value}}); + Attacks.update(this._id, {$set: {details: value}}); }, "core-select #damageTypeDropdown": function(event){ var detail = event.originalEvent.detail; @@ -31,14 +23,21 @@ Template.attackDialog.events({ var value = detail.item.getAttribute("name"); if(value == this.damageType) return; Attacks.update(this._id, {$set: {damageType: value}}); + }, + "core-select #damageDiceDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + if(value == this.damageDice) return; + Attacks.update(this._id, {$set: {damageDice: value}}); } }); -Template.attackDialog.helpers({ - attack: function(){ - return Attacks.findOne(this.attackId); - }, +Template.attackEdit.helpers({ damageTypes: function(){ return damageTypes; + }, + DAMAGE_DICE: function(){ + return DAMAGE_DICE; } }); \ No newline at end of file diff --git a/rpg-docs/client/views/character/attacks/attackEditList/attackEditList.html b/rpg-docs/client/views/character/attacks/attackEditList/attackEditList.html new file mode 100644 index 00000000..789f916f --- /dev/null +++ b/rpg-docs/client/views/character/attacks/attackEditList/attackEditList.html @@ -0,0 +1,13 @@ + + diff --git a/rpg-docs/client/views/character/attacks/attackEditList/attackEditList.js b/rpg-docs/client/views/character/attacks/attackEditList/attackEditList.js new file mode 100644 index 00000000..36ba61fe --- /dev/null +++ b/rpg-docs/client/views/character/attacks/attackEditList/attackEditList.js @@ -0,0 +1,21 @@ +Template.attackEditList.helpers({ + attacks: function(){ + var cursor = Attacks.find({sourceId: this.sourceId, type: this.type}); + return cursor; + } +}); + +Template.attackEditList.events({ + "tap #addAttackButton": function(){ + if ( !_.isBoolean(this.enabled) ) { + this.enabled = true; + } + Attacks.insert({ + name: this.name, + charId: this.charId, + sourceId: this.sourceId, + type: this.type, + enabled: this.enabled + }); + }, +}); diff --git a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html index f710e0f6..80b77f0e 100644 --- a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html +++ b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js index e7ff7e3c..06c45b7f 100644 --- a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js +++ b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js @@ -11,6 +11,7 @@ Template.effectsEditList.events({ this.enabled = true; } Effects.insert({ + name: this.name, charId: this.charId, sourceId: this.sourceId, operation: "add", diff --git a/rpg-docs/client/views/character/features/attackDialog/attackDialog.html b/rpg-docs/client/views/character/features/attackDialog/attackDialog.html deleted file mode 100644 index dfe169bd..00000000 --- a/rpg-docs/client/views/character/features/attackDialog/attackDialog.html +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html index d32fa44e..6222ca57 100644 --- a/rpg-docs/client/views/character/features/features.html +++ b/rpg-docs/client/views/character/features/features.html @@ -19,7 +19,7 @@
Attacks
- +
{{#each attacks}} @@ -30,10 +30,17 @@ {{evaluateSigned ../_id attackBonus}}
-
{{name}}
-
- {{{evaluateString ../_id damage}}} {{damageType}} {{range}} +
+ {{name}}
+
+ {{damageDice}} {{{evaluateSignedSpaced ../_id damageBonus}}} {{damageType}} +
+ {{#if details}} +
+ {{details}} +
+ {{/if}}
diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js index 2faa4757..d43278c5 100644 --- a/rpg-docs/client/views/character/features/features.js +++ b/rpg-docs/client/views/character/features/features.js @@ -19,7 +19,7 @@ Template.features.helpers({ return _.indexOf(_.keys(colorOptions), this.color); }, attacks: function(){ - return Attacks.find({charId: this._id}, {sort: {color: 1, name: 1}}); + return Attacks.find({charId: this._id, enabled: true}, {sort: {color: 1, name: 1}}); }, characterProficiencies: function(){ var char = Characters.findOne(this._id); diff --git a/rpg-docs/client/views/character/inventory/inventory.html b/rpg-docs/client/views/character/inventory/inventory.html index cb7bbaaa..19adb60e 100644 --- a/rpg-docs/client/views/character/inventory/inventory.html +++ b/rpg-docs/client/views/character/inventory/inventory.html @@ -34,7 +34,7 @@ {{#with armor}}
- {{name}} + {{#if ne1 quantity}}{{quantity}} {{/if}}{{pluralName}}
{{/with}} @@ -42,7 +42,7 @@ {{#each equipment}}
- {{name}} + {{#if ne1 quantity}}{{quantity}} {{/if}}{{pluralName}}
{{/each}} diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html index 7d293ab5..d58cfedf 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html @@ -56,7 +56,9 @@ - {{> effectsEditList sourceId=_id charId=charId type="equipment" enabled=equipped}} + {{> effectsEditList sourceId=_id charId=charId type="equipment" enabled=equipped name=name}} + + {{> attackEditList sourceId=_id charId=charId type="equipment" enabled=equipped name=name}} {{/baseDialog}} {{/with}} \ No newline at end of file diff --git a/rpg-docs/lib/constants/abilities.js b/rpg-docs/lib/constants/abilities.js new file mode 100644 index 00000000..d6bde726 --- /dev/null +++ b/rpg-docs/lib/constants/abilities.js @@ -0,0 +1,8 @@ +abilities = [ + "strength", + "dexterity", + "constitution", + "intelligence", + "wisdom", + "charisma" +]; \ No newline at end of file diff --git a/rpg-docs/lib/constants/damageDice.js b/rpg-docs/lib/constants/damageDice.js new file mode 100644 index 00000000..7927d0c0 --- /dev/null +++ b/rpg-docs/lib/constants/damageDice.js @@ -0,0 +1,9 @@ +DAMAGE_DICE = [ + "1", + "1d4", + "1d6", + "1d8", + "1d10", + "1d12", + "2d6" +]