Made Attacks come from items
This commit is contained in:
@@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
#addEffectButton {
|
||||
.red-button {
|
||||
background: #d23f31;
|
||||
color: #fff;
|
||||
margin-top: 16px;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<template name="attackEdit">
|
||||
<div layout horizontal>
|
||||
<div layout vertical flex>
|
||||
<div layout horizontal>
|
||||
<!--attackBonus-->
|
||||
<paper-input id="attackBonusInput"
|
||||
label="Attack Bonus"
|
||||
floatinglabel
|
||||
value={{attackBonus}}
|
||||
flex></paper-input>
|
||||
<!--details-->
|
||||
<paper-input id="detailInput"
|
||||
label="Details"
|
||||
floatinglabel
|
||||
value={{details}}></paper-input>
|
||||
</div>
|
||||
<div layout horizontal>
|
||||
<!--DamageType-->
|
||||
<paper-dropdown-menu id="damageDiceDropdown" label="Damage Dice">
|
||||
<paper-dropdown layered class="dropdown">
|
||||
<core-menu class="menu" selected={{damageDice}}>
|
||||
{{#each DAMAGE_DICE}}
|
||||
<paper-item name={{this}} class="containerMenuItem">{{this}}</paper-item>
|
||||
{{/each}}
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-dropdown-menu>
|
||||
<!--damageBonus-->
|
||||
<paper-input id="damageInput"
|
||||
label="Damage Bonus"
|
||||
floatinglabel
|
||||
value={{damageBonus}}
|
||||
flex></paper-input>
|
||||
<!--DamageType-->
|
||||
<paper-dropdown-menu id="damageTypeDropdown" label="Damage Type">
|
||||
<paper-dropdown layered class="dropdown">
|
||||
<core-menu class="menu" selected={{damageType}}>
|
||||
{{#each damageTypes}}
|
||||
<paper-item name={{this}} class="containerMenuItem">{{this}}</paper-item>
|
||||
{{/each}}
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</div>
|
||||
<!--Delete Button-->
|
||||
<paper-icon-button id="deleteAttack" role="button" tabindex="0" icon="delete" aria-label="Delete"></paper-icon-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
<!--needs to be given charId, sourceId and type-->
|
||||
<template name="attackEditList">
|
||||
{{#if attacks.count}}
|
||||
<hr style="margin: 16px 0 16px 0;">
|
||||
<div id="attacks">
|
||||
<h2>Attacks</h2>
|
||||
{{#each attacks}}
|
||||
{{>attackEdit}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<paper-button id="addAttackButton" class="red-button" raised>Add Attack</paper-button>
|
||||
</template>
|
||||
@@ -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
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--needs to be given charId, sourceId and type-->
|
||||
<template name="effectsEditList">
|
||||
{{#if effects}}
|
||||
{{#if effects.count}}
|
||||
<hr style="margin: 16px 0 16px 0;">
|
||||
<div id="effects">
|
||||
<h2>Effects</h2>
|
||||
@@ -9,7 +9,5 @@
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<div layout horizontal end-justified>
|
||||
<paper-button id="addEffectButton" raised>Add Effect</paper-button>
|
||||
</div>
|
||||
<paper-button id="addEffectButton" class="red-button" raised>Add Effect</paper-button>
|
||||
</template>
|
||||
@@ -11,6 +11,7 @@ Template.effectsEditList.events({
|
||||
this.enabled = true;
|
||||
}
|
||||
Effects.insert({
|
||||
name: this.name,
|
||||
charId: this.charId,
|
||||
sourceId: this.sourceId,
|
||||
operation: "add",
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<template name="attackDialog">
|
||||
{{#with attack}}
|
||||
{{#baseDialog title=name class=colorClass}}
|
||||
<div layout horizontal>
|
||||
<!--Name-->
|
||||
<paper-input id="attackNameInput" label="Name" floatinglabel value={{name}}></paper-input>
|
||||
</div>
|
||||
<!--attackBonus-->
|
||||
<paper-input id="attackBonusInput" label="Attack Bonus" floatinglabel value={{attackBonus}}></paper-input>
|
||||
<!--damage-->
|
||||
<paper-input id="damageInput" label="Damage" floatinglabel value={{damage}}></paper-input>
|
||||
<!--range-->
|
||||
<paper-input id="rangeInput" label="Range" floatinglabel value={{range}}></paper-input>
|
||||
<!--DamageType-->
|
||||
<paper-dropdown-menu id="damageTypeDropdown" label="DamageType">
|
||||
<paper-dropdown layered class="dropdown">
|
||||
<core-menu class="menu" selected={{damageType}}>
|
||||
{{#each damageTypes}}
|
||||
<paper-item name={{this}} class="containerMenuItem">{{this}}</paper-item>
|
||||
{{/each}}
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-dropdown-menu>
|
||||
{{/baseDialog}}
|
||||
{{/with}}
|
||||
</template>
|
||||
@@ -19,7 +19,7 @@
|
||||
<div flex>
|
||||
<div class="containerName subhead">Attacks</div>
|
||||
</div>
|
||||
<paper-icon-button class="black54" id="addAttackButton" icon="add"></paper-icon-button>
|
||||
<!--<paper-icon-button class="black54" id="addAttackButton" icon="add"></paper-icon-button>-->
|
||||
</div>
|
||||
<div class="containerMain listPadded">
|
||||
{{#each attacks}}
|
||||
@@ -30,10 +30,17 @@
|
||||
{{evaluateSigned ../_id attackBonus}}
|
||||
</div>
|
||||
<div layout vertical flex>
|
||||
<div>{{name}}</div>
|
||||
<div class="caption">
|
||||
{{{evaluateString ../_id damage}}} {{damageType}} {{range}}
|
||||
<div class="body2">
|
||||
{{name}}
|
||||
</div>
|
||||
<div>
|
||||
{{damageDice}} {{{evaluateSignedSpaced ../_id damageBonus}}} {{damageType}}
|
||||
</div>
|
||||
{{#if details}}
|
||||
<div class="caption">
|
||||
{{details}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</paper-item>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{{#with armor}}
|
||||
<div class="itemSlot">
|
||||
<paper-item class="inventoryItem armorItem" hero-id="main" {{detailHero}} layout horizontal>
|
||||
{{name}}
|
||||
{{#if ne1 quantity}}{{quantity}} {{/if}}{{pluralName}}
|
||||
</paper-item>
|
||||
</div>
|
||||
{{/with}}
|
||||
@@ -42,7 +42,7 @@
|
||||
{{#each equipment}}
|
||||
<div class="itemSlot">
|
||||
<paper-item class="inventoryItem" hero-id="main" {{detailHero}} layout horizontal>
|
||||
{{name}}
|
||||
{{#if ne1 quantity}}{{quantity}} {{/if}}{{pluralName}}
|
||||
</paper-item>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
@@ -56,7 +56,9 @@
|
||||
</paper-autogrow-textarea>
|
||||
</paper-input-decorator>
|
||||
<!--Effects-->
|
||||
{{> effectsEditList sourceId=_id charId=charId type="equipment" enabled=equipped}}
|
||||
{{> effectsEditList sourceId=_id charId=charId type="equipment" enabled=equipped name=name}}
|
||||
<!--Attacks-->
|
||||
{{> attackEditList sourceId=_id charId=charId type="equipment" enabled=equipped name=name}}
|
||||
{{/baseDialog}}
|
||||
{{/with}}
|
||||
</template>
|
||||
8
rpg-docs/lib/constants/abilities.js
Normal file
8
rpg-docs/lib/constants/abilities.js
Normal file
@@ -0,0 +1,8 @@
|
||||
abilities = [
|
||||
"strength",
|
||||
"dexterity",
|
||||
"constitution",
|
||||
"intelligence",
|
||||
"wisdom",
|
||||
"charisma"
|
||||
];
|
||||
9
rpg-docs/lib/constants/damageDice.js
Normal file
9
rpg-docs/lib/constants/damageDice.js
Normal file
@@ -0,0 +1,9 @@
|
||||
DAMAGE_DICE = [
|
||||
"1",
|
||||
"1d4",
|
||||
"1d6",
|
||||
"1d8",
|
||||
"1d10",
|
||||
"1d12",
|
||||
"2d6"
|
||||
]
|
||||
Reference in New Issue
Block a user