Added XP, changed spellslot display

This commit is contained in:
Thaum
2015-02-20 10:09:53 +00:00
parent 93578709cd
commit bd86c1608e
18 changed files with 355 additions and 45 deletions

View File

@@ -11,10 +11,44 @@
height: 32px;
}
#spells .inventoryItem[disabled] {
color: #ccc !important;
color: rgba(0,0,0,0.26) !important;
pointer-events: initial !important;
cursor: pointer !important;
}
#spells .inventoryItem[disabled] core-icon{
color: #ccc !important;
color: rgba(0,0,0,0.26) !important;
}
#spells .inventoryItem paper-checkbox{
pointer-events: initial;
pointer-events: initial !important;
}
#spells paper-checkbox /deep/ #ink {
color: #009688;
}
#spells .inventoryItem.spellSlot {
height: 48px;
}
.slotName {
margin-right: 16px;
}
.slotBubble {
pointer-events: initial !important;
}
.slotBubble {
color: #000;
color: rgba(0,0,0,0.54);
}
.slotBubble[disabled] {
color: #cccccc;
color: rgba(0,0,0,0.26);
}

View File

@@ -1,19 +1,28 @@
<template name="spells">
<div fit>
<div id="spells" class="scroll-y" fit>
<div class="resourceCards" layout horizontal wrap>
{{>resource name="level1SpellSlots" title="Level 1" char=this}}
{{>resource name="level2SpellSlots" title="Level 2" char=this}}
{{>resource name="level3SpellSlots" title="Level 3" char=this}}
{{>resource name="level4SpellSlots" title="Level 4" char=this}}
{{>resource name="level5SpellSlots" title="Level 5" char=this}}
{{>resource name="level6SpellSlots" title="Level 6" char=this}}
{{>resource name="level7SpellSlots" title="Level 7" char=this}}
{{>resource name="level8SpellSlots" title="Level 8" char=this}}
{{>resource name="level9SpellSlots" title="Level 9" char=this}}
{{>gridPadding num="8" class="card container"}}
</div>
<div class="containers">
<paper-shadow class="card container" hero-id="main" {{detailHero}} style="order: {{containerOrder}};">
<div class="containerTop {{colorClass}}" layout horizontal center>
<div class="containerName subhead" hero-id="title" flex>Spell Slots</div>
</div>
<div flex class="containerMain">
{{#each levels}}{{#if showSlots ..}}
<div class="itemSlot">
<paper-item class="inventoryItem spellSlot" hero-id="main" {{detailHero}} layout horizontal>
<div class="slotName">
{{name}}
</div>
<div flex layout horizontal center>
{{#each slotBubbles ..}}
<paper-icon-button class="slotBubble" icon={{icon}} disabled={{disabled}}></paper-icon-button>
{{/each}}
</div>
</paper-item>
</div>
{{/if}}{{/each}}
</div>
</paper-shadow>
{{#each spellLists}}
<paper-shadow class="card container" hero-id="main" {{detailHero}} style="order: {{order}};">
<div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero}}>
@@ -39,17 +48,24 @@
<div class="containerMain">
{{#each levels}}
{{#if spellCount .. ../../_id}}
<div class="list-subhead" layout horizontal center>{{name}}</div>
<div class="list-subhead" layout horizontal center>
{{name}}
</div>
{{/if}}
{{#each spells ../_id ../../_id}}
{{#if showSpell ../../settings.showUnprepared}}
<div class="itemSlot">
<paper-item class="inventoryItem spell" hero-id="main" {{detailHero}} layout horizontal center>
<core-icon icon="social:whatshot" style="color: {{hexColor color}};"></core-icon>
<paper-item class="inventoryItem spell" hero-id="main" {{detailHero}}
layout horizontal center>
<!--disabled={{cantCast ../level ../../..}} to grey out spells above highest usable slot-->
<core-icon icon="social:whatshot"
style="color: {{hexColor color}};"
></core-icon>
<div flex layout vertical>
<div>{{name}}</div>
<div class="caption">
{{school}} {{castingTime}}{{#if ritual}} (ritual){{/if}} - {{spellComponents}}
{{school}} {{castingTime}}
{{#if ritual}}(ritual){{/if}}{{#if spellComponents}} - {{spellComponents}}{{/if}}
</div>
</div>
{{#if ../../settings.showUnprepared}}

View File

@@ -18,10 +18,10 @@ Template.spells.helpers({
spellCount: function(list, charId){
if(list.settings.showUnprepared){
return Spells.find( {charId: charId, listId: list._id, level: this.level},
{fields: {_id: 1, level: 1}} ).count() > 0;
{fields: {_id: 1, level: 1}} ).count() > 0;
} else{
return Spells.find( {charId: charId, listId: list._id, level: this.level, prepared: {$in: ["prepared", "always"]} },
{fields: {_id: 1, level: 1}} ).count() > 0;
{fields: {_id: 1, level: 1}} ).count() > 0;
}
},
spells: function(listId, charId){
@@ -65,10 +65,69 @@ Template.spells.helpers({
},
cantUnprepare: function(){
return this.prepared === "always";
},
cantCast: function(level, char){
for(var i = level; i <= 9; i++){
if (char.attributeValue("level"+i+"SpellSlots") > 0){
return false;
}
}
return true;
},
baseSlots: function(char){
return char.attributeBase("level" + this.level +"SpellSlots");
},
slots: function(char){
return char.attributeValue("level" + this.level +"SpellSlots");
},
showSlots: function(char){
return this.level && char.attributeBase("level" + this.level +"SpellSlots");
},
slotBubbles: function(char){
var baseSlots = char.attributeBase("level" + this.level +"SpellSlots"),
currentSlots = char.attributeValue("level" + this.level +"SpellSlots"),
slotsUsed = baseSlots - currentSlots,
bubbles = [], i;
for(i = 0; i < currentSlots; i++){
bubbles.push({
icon: "radio-button-on",
disabled: i !== currentSlots -1, //last full slot not disabled
attribute: "level" + this.level +"SpellSlots",
charId: char._id
});
}
for(i = 0; i < slotsUsed; i++){
bubbles.push({
icon: "radio-button-off",
disabled: i !== 0, //first empty slot not disabled
attribute: "level" + this.level +"SpellSlots",
charId: char._id
});
}
return bubbles;
}
});
Template.spells.events({
"tap .slotBubble": function(event){
if(!event.currentTarget.disabled){
var char = Characters.findOne(this.charId);
if(event.currentTarget.icon === "radio-button-off"){
if(char.attributeValue(this.attribute) < char.attributeBase(this.attribute)){
var modifier = {$inc: {}};
modifier.$inc[this.attribute + ".adjustment"] = 1;
Characters.update(this.charId, modifier, {validate: false});
}
} else {
if(char.attributeValue(this.attribute) > 0){
var modifier = {$inc: {}};
modifier.$inc[this.attribute + ".adjustment"] = -1;
Characters.update(this.charId, modifier, {validate: false});
}
}
}
event.stopPropagation();
},
"tap .containerTop": function(event){
GlobalUI.setDetail({
template: "spellListDialog",