Made proficiencies their own objects, added migration functionality
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<!--needs to be given charId, parentId and parentCollection-->
|
||||
<template name="effectsEditList">
|
||||
{{#if effects.count}}
|
||||
<hr style="margin: 16px 0 16px 0;">
|
||||
<hr class="vertMargin">
|
||||
<div id="effects">
|
||||
<h2>Effects</h2>
|
||||
{{#each effects}}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
{{/if}}
|
||||
|
||||
{{> effectsViewList charId=charId parentId=_id}}
|
||||
{{> proficiencyViewList charId=charId parentId=_id}}
|
||||
</template>
|
||||
|
||||
<template name="featureEdit">
|
||||
@@ -82,4 +83,5 @@
|
||||
</paper-input-decorator>
|
||||
|
||||
{{> effectsEditList parentId=_id parentCollection="Features" charId=charId name=name enabled=enabled}}
|
||||
{{> proficiencyEditList parentId=_id parentCollection="Features" charId=charId enabled=enabled}}
|
||||
</template>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<paper-input id="levelValueInput" label="Level" floatinglabel value={{level}}></paper-input>
|
||||
<!--Effects-->
|
||||
{{> effectsEditList parentId=_id parentCollection="Classes" charId=charId}}
|
||||
{{> proficiencyEditList parentId=_id parentCollection="Characters" charId=charId}}
|
||||
{{/baseDialog}}
|
||||
{{/with}}
|
||||
</template>
|
||||
@@ -2,5 +2,6 @@
|
||||
{{#baseDialog title="Race" class=colorClass hideColor="true" hideDelete="true"}}
|
||||
<paper-input id="raceInput" label="Race" floatinglabel value={{race}}></paper-input>
|
||||
{{> effectsEditList parentId=charId parentCollection="Characters" charId=charId}}
|
||||
{{> proficiencyEditList parentId=charId parentCollection="Characters" charId=charId}}
|
||||
{{/baseDialog}}
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
<template name="proficiencyEdit">
|
||||
<div layout horizontal around-justified>
|
||||
<paper-dropdown-menu class="typeDropDown" label="Stat Group" flex>
|
||||
<paper-dropdown layered class="dropdown">
|
||||
<core-menu class="menu typeMenu" selected={{type}}>
|
||||
{{#each proficiencyTypes}}
|
||||
<paper-item class="statGroupSelect" name={{type}}>{{name}}</paper-item>
|
||||
{{/each}}
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-dropdown-menu>
|
||||
{{> UI.dynamic template=nameInputTemplate}}
|
||||
<paper-dropdown-menu class="valueDropDown" label="Proficiency" flex>
|
||||
<paper-dropdown layered class="dropdown">
|
||||
<core-menu class="menu valueMenu" selected={{value}}>
|
||||
<paper-item name="1">Proficient</paper-item>
|
||||
<paper-item name="0.5">Half Prof. Bonus</paper-item>
|
||||
<paper-item name="2">Double Prof. Bonus</paper-item>
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template name="nameDropdown">
|
||||
<paper-dropdown-menu class="nameDropDown sideMargin" label="Proficiency" flex>
|
||||
<paper-dropdown layered class="dropdown">
|
||||
<core-menu class="menu nameMenu" selected={{name}}>
|
||||
{{#each nameDropdownItems}}
|
||||
<paper-item name={{stat}}>{{name}}</paper-item>
|
||||
{{/each}}
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-dropdown-menu>
|
||||
</template>
|
||||
|
||||
<template name="nameInput sideMargin">
|
||||
<paper-input class="nameInput"
|
||||
label="Name"
|
||||
floatinglabel
|
||||
value={{name}}
|
||||
flex></paper-input>
|
||||
</template>
|
||||
@@ -0,0 +1,86 @@
|
||||
var profTypes = [
|
||||
{type: "skill", name: "Skill"},
|
||||
{type: "save", name: "Saving Throw"},
|
||||
{type: "weapon", name: "Weapon"},
|
||||
{type: "armor", name: "Armor"},
|
||||
{type: "tool", name: "Tool"},
|
||||
{type: "language", name: "Language"}
|
||||
];
|
||||
|
||||
var saves = [
|
||||
{name: "Strength Save", stat: "strengthSave"},
|
||||
{name: "Dexterity Save", stat: "dexteritySave"},
|
||||
{name: "Constitution Save", stat: "constitutionSave"},
|
||||
{name: "Intelligence Save", stat: "intelligenceSave"},
|
||||
{name: "Wisdom Save", stat: "wisdomSave"},
|
||||
{name: "Charisma Save", stat: "charismaSave"},
|
||||
];
|
||||
|
||||
var skills = [
|
||||
{name: "Acrobatics", stat: "acrobatics"},
|
||||
{name: "Animal Handling", stat: "animalHandling"},
|
||||
{name: "Arcana", stat: "arcana"},
|
||||
{name: "Athletics", stat: "athletics"},
|
||||
{name: "Deception", stat: "deception"},
|
||||
{name: "History", stat: "history"},
|
||||
{name: "Insight", stat: "insight"},
|
||||
{name: "Intimidation", stat: "intimidation"},
|
||||
{name: "Investigation", stat: "investigation"},
|
||||
{name: "Medicine", stat: "medicine"},
|
||||
{name: "Nature", stat: "nature"},
|
||||
{name: "Perception", stat: "perception"},
|
||||
{name: "Performance", stat: "performance"},
|
||||
{name: "Persuasion", stat: "persuasion"},
|
||||
{name: "Religion", stat: "religion"},
|
||||
{name: "Sleight of Hand", stat: "sleightOfHand"},
|
||||
{name: "Stealth", stat: "stealth"},
|
||||
{name: "Survival", stat: "survival"},
|
||||
{name: "Initiative", stat: "initiative"},
|
||||
];
|
||||
|
||||
Template.proficiencyEdit.helpers({
|
||||
proficiencyTypes: function(){
|
||||
return profTypes;
|
||||
},
|
||||
nameInputTemplate: function(){
|
||||
if(!this.type) return null;
|
||||
if(this.type === "skill"||
|
||||
this.type === "save") return "nameDropdown";
|
||||
return "nameInput";
|
||||
}
|
||||
});
|
||||
|
||||
Template.proficiencyEdit.events({
|
||||
"core-select .typeDropDown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
if(!detail.isSelected) return;
|
||||
var type = detail.item.getAttribute("name");
|
||||
if (type == this.type) return;
|
||||
Proficiencies.update(this._id, {$set: {type: type}});
|
||||
},
|
||||
"core-select .valueDropDown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
if(!detail.isSelected) return;
|
||||
var value = +detail.item.getAttribute("name");
|
||||
if (value == this.value) return;
|
||||
Proficiencies.update(this._id, {$set: {value: value}});
|
||||
},
|
||||
"core-select .nameDropDown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
if(!detail.isSelected) return;
|
||||
var name = detail.item.getAttribute("name");
|
||||
if (name == this.name) return;
|
||||
Proficiencies.update(this._id, {$set: {name: name}});
|
||||
},
|
||||
"change .nameInput": function(event){
|
||||
var name = event.currentTarget.value;
|
||||
Proficiencies.update(this._id, {$set: {name: name}});
|
||||
}
|
||||
});
|
||||
|
||||
Template.nameDropdown.helpers({
|
||||
nameDropdownItems: function(){
|
||||
if (this.type === "skill") return skills;
|
||||
if (this.type === "save") return saves;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
<!--needs to be given charId, parentId and parentCollection-->
|
||||
<template name="proficiencyEditList">
|
||||
{{#if proficiencies.count}}
|
||||
<hr class="vertMargin">
|
||||
|
||||
<div id="proficiencies">
|
||||
<h2>Proficiencies</h2>
|
||||
{{#each proficiencies}}
|
||||
{{>proficiencyEdit}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<paper-button id="addProficiencyButton"
|
||||
class="red-button"
|
||||
raised>
|
||||
Add Proficiency
|
||||
</paper-button>
|
||||
</template>
|
||||
@@ -0,0 +1,24 @@
|
||||
Template.proficiencyEditList.helpers({
|
||||
proficiencies: function(){
|
||||
var cursor = Proficiencies.find({"parent.id": this.parentId, "parent.collection": this.parentCollection});
|
||||
return cursor;
|
||||
}
|
||||
});
|
||||
|
||||
Template.proficiencyEditList.events({
|
||||
"tap #addProficiencyButton": function(){
|
||||
if ( !_.isBoolean(this.enabled) ) {
|
||||
this.enabled = true;
|
||||
}
|
||||
Proficiencies.insert({
|
||||
charId: this.charId,
|
||||
parent: {
|
||||
id: this.parentId,
|
||||
collection: this.parentCollection
|
||||
},
|
||||
enabled: this.enabled,
|
||||
value: 1,
|
||||
type: "skill",
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
<template name="proficiencyView">
|
||||
<div class="proficiencyView" layout horizontal center>
|
||||
<core-icon icon="{{profIcon}}"></core-icon>
|
||||
<div class="sideMargin">{{getName}}</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,45 @@
|
||||
var saves = {
|
||||
strengthSave: "Strength Save",
|
||||
dexteritySave: "Dexterity Save",
|
||||
constitutionSave: "Constitution Save",
|
||||
intelligenceSave: "Intelligence Save",
|
||||
wisdomSave: "Wisdom Save",
|
||||
charismaSave: "Charisma Save",
|
||||
};
|
||||
|
||||
var skills = {
|
||||
acrobatics: "Acrobatics",
|
||||
animalHandling: "Animal Handling",
|
||||
arcana: "Arcana",
|
||||
athletics: "Athletics",
|
||||
deception: "Deception",
|
||||
history: "History",
|
||||
insight: "Insight",
|
||||
intimidation: "Intimidation",
|
||||
investigation: "Investigation",
|
||||
medicine: "Medicine",
|
||||
nature: "Nature",
|
||||
perception: "Perception",
|
||||
performance: "Performance",
|
||||
persuasion: "Persuasion",
|
||||
religion: "Religion",
|
||||
sleightOfHand: "Sleight of Hand",
|
||||
stealth: "Stealth",
|
||||
survival: "Survival",
|
||||
initiative: "Initiative",
|
||||
};
|
||||
|
||||
Template.proficiencyView.helpers({
|
||||
profIcon: function(){
|
||||
var prof = this.value;
|
||||
if(prof > 0 && prof < 1) return "image:brightness-2";
|
||||
if(prof === 1) return "image:brightness-1";
|
||||
if(prof > 1) return "av:album";
|
||||
return "radio-button-off";
|
||||
},
|
||||
getName: function(){
|
||||
if(this.type === "skill") return skills[this.name];
|
||||
if(this.type === "save") return saves[this.name];
|
||||
return this.name;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
<template name="proficiencyViewList">
|
||||
{{#if proficiencies.count}}
|
||||
<hr class="vertMargin">
|
||||
<div class="proficiencies">
|
||||
<h2 class="spaceAfter">Proficiencies</h2>
|
||||
{{#each proficiencies}}
|
||||
{{> proficiencyView}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
@@ -0,0 +1,5 @@
|
||||
Template.proficiencyViewList.helpers({
|
||||
proficiencies: function(){
|
||||
return Proficiencies.find({"parent.id": this.parentId, charId: this.charId});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user