Implemented remaining core features

This commit is contained in:
Thaum
2015-02-25 12:48:45 +00:00
parent 52b8c8b8d6
commit 56f8e95d81
38 changed files with 748 additions and 100 deletions

View File

@@ -0,0 +1,40 @@
<template name="attackDialog">
{{#with attack}}
<core-header-panel fit>
<core-toolbar class={{colorClass}} hero-id="toolbar" hero>
<paper-icon-button id="backButton" role="button" tabindex="0" icon="arrow-back" aria-label="close"></paper-icon-button>
<div flex>{{name}}</div>
<paper-icon-button id="deleteAttack"
role="button"
tabindex="0"
icon="delete"
aria-label="Delete Attack"
noink></paper-icon-button>
</core-toolbar>
<div class="detailContent">
<div layout horizontal>
<!--Name-->
<paper-input id="attackNameInput" label="Name" floatinglabel value={{name}}></paper-input>
<!--color-->
{{> colorDropdown}}
</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>
</div>
</core-header-panel>
{{/with}}
</template>

View File

@@ -0,0 +1,78 @@
var damageTypes = ["bludgeoning", "piercing", "slashing", "acid", "cold", "fire", "force", "lightning", "necrotic",
"poison", "psychic", "radiant", "thunder"];
Template.attackDialog.rendered = function(){
var self = this;
//update all autogrows after they've been filled
var pata = this.$("paper-autogrow-textarea");
pata.each(function(index, el){
el.update($(el).children().get(0));
})
//update all input fields as well
var input = this.$("paper-input");
input.each(function(index, el){
el.valueChanged();
})
//after the dialog is built, open it
if (!this.alreadyRendered){
Session.set("global.ui.detailShow", true);
this.alreadyRendered = true;
}
}
Template.attackDialog.events({
"tap #backButton": function(){
GlobalUI.closeDetail()
},
"tap #deleteAttack": function(){
Attacks.remove(this._id);
GlobalUI.closeDetail()
},
"tap #addEffectButton": function(){
Effects.insert({
charId: this.charId,
sourceId: this._id,
operation: "add",
type: "attack"
});
},
"change #attackNameInput": function(event){
var value = event.currentTarget.value;
Attacks.update(this._id, {$set: {name: value}});
},
"change #attackBonusInput": function(event){
var value = event.currentTarget.value;
Attacks.update(this._id, {$set: {attackBonus: value}});
},
"change #damageInput": function(event){
var value = event.currentTarget.value;
Attacks.update(this._id, {$set: {damage: value}});
},
"change #rangeInput": function(event){
var value = event.currentTarget.value;
Attacks.update(this._id, {$set: {range: value}});
},
"core-select #damageTypeDropdown": function(event){
var detail = event.originalEvent.detail;
if(!detail.isSelected) return;
var value = detail.item.getAttribute("name");
if(value == this.damageType) return;
Attacks.update(this._id, {$set: {damageType: value}});
},
"core-select .colorDropdown": function(event){
var detail = event.originalEvent.detail;
if(!detail.isSelected) return;
var value = detail.item.getAttribute("name");
if(value == this.color) return;
Attacks.update(this._id, {$set: {color: value}});
},
});
Template.attackDialog.helpers({
attack: function(){
return Attacks.findOne(this.attackId);
},
damageTypes: function(){
return damageTypes;
}
});

View File

@@ -20,5 +20,4 @@
.resourceCards paper-shadow.healthCard {
width: 100%;
padding: 0 16px 0 0;
}

View File

@@ -12,6 +12,48 @@
{{>resource name="sorceryPoints" title="Sorcery Points" color="teal" char=this}}
<!--superiorityDice-->
{{>resource name="superiorityDice" title="Superiority Dice" color="teal" char=this}}
<!--Attacks-->
<paper-shadow class="card container" hero-id="main" {{detailHero}}>
<div class="whiteTop" hero-id="toolbar" layout horizontal center {{detailHero}}>
<div flex>
<div class="containerName subhead">Attacks</div>
</div>
<paper-icon-button class="black54" id="addAttackButton" icon="add"></paper-icon-button>
</div>
<div class="containerMain listPadded">
{{#each attacks}}
<div class="itemSlot">
<paper-item class="white attack" hero-id="main" {{detailHero}}>
<div layout horizontal class="fullwidth">
<div class="headline rightPadded" layout horizontal center>
{{evaluateSigned ../_id attackBonus}}
</div>
<div layout vertical flex>
<div>{{name}}</div>
<div class="caption">
{{{evaluateString ../_id damage}}} {{damageType}} {{range}}
</div>
</div>
</div>
</paper-item>
</div>
{{/each}}
</div>
</paper-shadow>
<!--Proficiencies-->
<paper-shadow class="card container" hero-id="main" {{detailHero "proficiencies"}}>
<div id="proficiencies"
class="containerTop grey white-text"
hero-id="toolbar"
layout horizontal center
{{detailHero "proficiencies"}}>
<div class="containerName subhead">Proficiencies</div>
</div>
<div flex class="containerMain padded preline">{{characterProficiencies}}</div>
</paper-shadow>
<!--features-->
{{#each features}}
<paper-shadow class="card container featureCard" hero-id="main" {{detailHero}}>

View File

@@ -11,6 +11,13 @@ Template.features.helpers({
},
featureOrder: function(){
return _.indexOf(_.keys(colorOptions), this.color);
},
attacks: function(){
return Attacks.find({charId: this._id}, {sort: {color: 1, name: 1}});
},
characterProficiencies: function(){
var char = Characters.findOne(this._id);
return char && char.proficiencies;
}
});
@@ -23,7 +30,21 @@ Template.features.events({
heroId: featureId
})
},
"tap .containerTop": function(event){
"tap #addAttackButton": function(event){
var charId = this._id;
Attacks.insert({
charId: charId
}, function(error, id){
if(!error){
GlobalUI.setDetail({
template: "attackDialog",
data: {attackId: id, charId: charId},
heroId: id
});
}
});
},
"tap .featureCard .containerTop": function(event){
var featureId = this._id;
var charId = Template.parentData()._id;
GlobalUI.setDetail({
@@ -32,6 +53,15 @@ Template.features.events({
heroId: featureId
});
},
"tap .attack": function(event){
var attackId = this._id;
var charId = Template.parentData()._id;
GlobalUI.setDetail({
template: "attackDialog",
data: {attackId: attackId, charId: charId},
heroId: attackId
});
},
"tap .useFeature": function(event){
var featureId = this._id;
Features.update(featureId, {$inc: {used: 1}});
@@ -39,6 +69,14 @@ Template.features.events({
"tap .resetFeature": function(event){
var featureId = this._id;
Features.update(featureId, {$set: {used: 0}});
},
"tap #proficiencies": function(event){
var charId = this._id;
GlobalUI.setDetail({
template: "textDialog",
data: {charId: charId, field: "proficiencies", title: "Proficiencies", color: "q"},
heroId: this._id + "proficiencies"
});
}
});