Moved views out of private folder

This commit is contained in:
Stefan Zermatten
2017-01-12 15:28:59 +02:00
parent 37268495ae
commit 38ea89995a
162 changed files with 6 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
html /deep/ .operationDropDown {
width: 152px;
}
html /deep/ .statDropDown {
width: 152px;
}
html /deep/ .damageMultiplierDropDown {
width: 152px;
}
html /deep/ .effectEdit paper-input {
position: relative;
bottom: 5px;
}
html /deep/ .effectEdit {
height: 64px;
display: flex;
align-items: flex-end;
}

View File

@@ -0,0 +1,66 @@
<template name="effectEdit">
<div class="effectEdit" layout horizontal center>
<paper-dropdown-menu class="statDropDown"
label="Stat">
<paper-dropdown layered
class="dropdown">
<core-menu class="menu statMenu" selected={{stat}}>
{{#each statGroups}}
<div style="font-weight: bold;
margin-top: 16px;">{{this}}</div>
{{#each stats}}
<paper-item name={{stat}}>{{name}}</paper-item>
{{/each}}
{{/each}}
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
{{#if operations}}
<paper-dropdown-menu class="operationDropDown"
label="Operation">
<paper-dropdown layered class="dropdown">
<core-menu class="menu operationMenu" selected={{operation}}>
{{#each operations}}
<paper-item name={{operation}}>{{name}}</paper-item>
{{/each}}
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
{{/if}}
{{#if effectValueTemplate}}
{{> Template.dynamic template=effectValueTemplate}}
{{else}}
<div flex></div>
{{/if}}
<paper-icon-button class="deleteEffect"
icon="delete">
</paper-icon-button>
<br>
</div>
</template>
<template name="regularEffectValue">
<paper-input class="effectValueInput"
label="Value"
floatinglabel
value={{effectValue}}
flex
style="flex-basis: 100px;">
</paper-input>
</template>
<template name="multiplierEffectValue">
<paper-dropdown-menu class="damageMultiplierDropDown"
label="Damage Multiplier">
<paper-dropdown layered
class="dropdown">
<core-menu class="menu multiplierMenu"
selected={{value}}>
<paper-item name="0.5">Resistance</paper-item>
<paper-item name="2">Vulnerability</paper-item>
<paper-item name="0">Immunity</paper-item>
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
<div flex></div>
</template>

View File

@@ -0,0 +1,178 @@
//TODO add dexterity armor
var stats = [
{stat: "strength", name: "Strength", group: "Ability Scores"},
{stat: "dexterity", name: "Dexterity", group: "Ability Scores"},
{stat: "constitution", name: "Constitution", group: "Ability Scores"},
{stat: "intelligence", name: "Intelligence", group: "Ability Scores"},
{stat: "wisdom", name: "Wisdom", group: "Ability Scores"},
{stat: "charisma", name: "Charisma", group: "Ability Scores"},
{name: "Strength Save", stat: "strengthSave", group: "Saving Throws"},
{name: "Dexterity Save", stat: "dexteritySave", group: "Saving Throws"},
{name: "Constitution Save", stat: "constitutionSave", group: "Saving Throws"},
{name: "Intelligence Save", stat: "intelligenceSave", group: "Saving Throws"},
{name: "Wisdom Save", stat: "wisdomSave", group: "Saving Throws"},
{name: "Charisma Save", stat: "charismaSave", group: "Saving Throws"},
{name: "Acrobatics", stat: "acrobatics", group: "Skills"},
{name: "Animal Handling", stat: "animalHandling", group: "Skills"},
{name: "Arcana", stat: "arcana", group: "Skills"},
{name: "Athletics", stat: "athletics", group: "Skills"},
{name: "Deception", stat: "deception", group: "Skills"},
{name: "History", stat: "history", group: "Skills"},
{name: "Insight", stat: "insight", group: "Skills"},
{name: "Intimidation", stat: "intimidation", group: "Skills"},
{name: "Investigation", stat: "investigation", group: "Skills"},
{name: "Medicine", stat: "medicine", group: "Skills"},
{name: "Nature", stat: "nature", group: "Skills"},
{name: "Perception", stat: "perception", group: "Skills"},
{name: "Performance", stat: "performance", group: "Skills"},
{name: "Persuasion", stat: "persuasion", group: "Skills"},
{name: "Religion", stat: "religion", group: "Skills"},
{name: "Sleight of Hand", stat: "sleightOfHand", group: "Skills"},
{name: "Stealth", stat: "stealth", group: "Skills"},
{name: "Survival", stat: "survival", group: "Skills"},
{name: "Initiative", stat: "initiative", group: "Skills"},
{stat: "hitPoints", name: "Hit Points", group: "Stats"},
{stat: "armor", name: "Armor", group: "Stats"},
{stat: "dexterityArmor", name: "Dexterity Armor Bonus", group: "Stats"},
{stat: "speed", name: "Speed", group: "Stats"},
{stat: "proficiencyBonus", name: "Proficiency Bonus", group: "Stats"},
{stat: "ki", name: "Ki Points", group: "Stats"},
{stat: "sorceryPoints", name: "Sorcery Points", group: "Stats"},
{stat: "rages", name: "Rages", group: "Stats"},
{stat: "rageDamage", name: "Rage Damage", group: "Stats"},
{stat: "expertiseDice", name: "Expertise Dice", group: "Stats"},
{stat: "superiorityDice", name: "Superiority Dice", group: "Stats"},
{stat: "carryMultiplier", name: "Carry Capacity Multiplier", group: "Stats"},
{stat: "level1SpellSlots", name: "level 1", group: "Spell Slots"},
{stat: "level2SpellSlots", name: "level 2", group: "Spell Slots"},
{stat: "level3SpellSlots", name: "level 3", group: "Spell Slots"},
{stat: "level4SpellSlots", name: "level 4", group: "Spell Slots"},
{stat: "level5SpellSlots", name: "level 5", group: "Spell Slots"},
{stat: "level6SpellSlots", name: "level 6", group: "Spell Slots"},
{stat: "level7SpellSlots", name: "level 7", group: "Spell Slots"},
{stat: "level8SpellSlots", name: "level 8", group: "Spell Slots"},
{stat: "level9SpellSlots", name: "level 9", group: "Spell Slots"},
{stat: "d6HitDice", name: "d6", group: "Hit Dice"},
{stat: "d8HitDice", name: "d8", group: "Hit Dice"},
{stat: "d10HitDice", name: "d10", group: "Hit Dice"},
{stat: "d12HitDice", name: "d12", group: "Hit Dice"},
{stat: "acidMultiplier", name: "Acid", group: "Weakness/Resistance"},
{stat: "bludgeoningMultiplier", name: "Bludgeoning", group: "Weakness/Resistance"},
{stat: "coldMultiplier", name: "Cold", group: "Weakness/Resistance"},
{stat: "fireMultiplier", name: "Fire", group: "Weakness/Resistance"},
{stat: "forceMultiplier", name: "Force", group: "Weakness/Resistance"},
{stat: "lightningMultiplier", name: "Lightning", group: "Weakness/Resistance"},
{stat: "necroticMultiplier", name: "Necrotic", group: "Weakness/Resistance"},
{stat: "piercingMultiplier", name: "Piercing", group: "Weakness/Resistance"},
{stat: "poisonMultiplier", name: "Poison", group: "Weakness/Resistance"},
{stat: "psychicMultiplier", name: "Psychic", group: "Weakness/Resistance"},
{stat: "radiantMultiplier", name: "Radiant", group: "Weakness/Resistance"},
{stat: "slashingMultiplier", name: "Slashing", group: "Weakness/Resistance"},
{stat: "thunderMultiplier", name: "Thunder", group: "Weakness/Resistance"}
];
var statsDict = _.indexBy(stats, "stat");
var statGroups = _.groupBy(stats, "group");
var statGroupNames = _.keys(statGroups);
var attributeOperations = [
{name: "Base Value", operation: "base"},
{name: "Add", operation: "add"},
{name: "Multiply", operation: "mul"},
{name: "Min", operation: "min"},
{name: "Max", operation: "max"}
];
var skillOperations = [
{name: "Add", operation: "add"},
{name: "Multiply", operation: "mul"},
{name: "Min", operation: "min"},
{name: "Max", operation: "max"},
{name: "Advantage", operation: "advantage"},
{name: "Disadvantage", operation: "disadvantage"},
{name: "Passive Bonus", operation: "passiveAdd"},
{name: "Automatically Fail", operation: "fail"},
{name: "Conditional Benefit", operation: "conditional"}
];
Template.effectEdit.helpers({
statGroups: function(){
return statGroupNames;
},
stats: function(){
var group = this;
return statGroups[group];
},
operations: function(){
var stat = statsDict[this.stat];
var group = stat && stat.group;
if (group === "Weakness/Resistance") return null;
if (group === "Saving Throws" || group === "Skills"){
return skillOperations;
} else {
return attributeOperations;
}
},
effectValueTemplate: function(){
//resistance/vulnerability template
var stat = statsDict[this.stat];
var group = stat && stat.group;
if (group === "Weakness/Resistance") return "multiplierEffectValue";
var op = this.operation;
if (!op) return null;
//operations that don't need templates
if (op === "advantage" || op === "disadvantage" || op === "fail") return null;
//default template
return "regularEffectValue";
}
});
Template.regularEffectValue.helpers({
effectValue: function(){
return this.calculation || this.value;
}
});
Template.effectEdit.events({
"tap .deleteEffect": function(event){
Effects.softRemoveNode(this._id);
GlobalUI.deletedToast(this._id, "Effects", "Effect");
},
"core-select .statDropDown": function(event){
var detail = event.originalEvent.detail;
if (!detail.isSelected) return;
var statName = detail.item.getAttribute("name");
if (statName == this.stat) return;
Effects.update(this._id, {$set: {stat: statName}});
},
"core-select .operationDropDown": function(event){
var detail = event.originalEvent.detail;
if (!detail.isSelected) return;
var opName = detail.item.getAttribute("name");
if (opName == this.operation) return;
Effects.update(this._id, {$set: {operation: opName}});
},
"core-select .damageMultiplierDropDown": function(event){
var detail = event.originalEvent.detail;
if (!detail.isSelected) return;
var value = +detail.item.getAttribute("name");
if (value == this.value) return;
Effects.update(this._id, {$set: {
value: value,
calculation: "",
operation: "mul"
}});
},
"change .effectValueInput": function(event){
var value = event.currentTarget.value;
var numValue = +value;
if (_.isFinite(numValue)){
if (this.value === numValue) return;
Effects.update(this._id, {$set: {value: numValue, calculation: ""}});
} else if (_.isString(value)){
if (this.calculation === value) return;
Effects.update(this._id, {$set: {value: "", calculation: value}});
}
}
});

View File

@@ -0,0 +1,6 @@
<template name="effectView">
<tr>
<td>{{statName}}</td>
<td>{{operationName}}{{statValue}}</td>
</tr>
</template>

View File

@@ -0,0 +1,169 @@
//TODO add dexterity armor
var stats = {
"strength":{"name":"Strength"},
"dexterity":{"name":"Dexterity"},
"constitution":{"name":"Constitution"},
"intelligence":{"name":"Intelligence"},
"wisdom":{"name":"Wisdom"},
"charisma":{"name":"Charisma"},
"strengthSave":{"name":"Strength Save"},
"dexteritySave":{"name":"Dexterity Save"},
"constitutionSave":{"name":"Constitution Save"},
"intelligenceSave":{"name":"Intelligence Save"},
"wisdomSave":{"name":"Wisdom Save"},
"charismaSave":{"name":"Charisma Save"},
"acrobatics":{"name":"Acrobatics"},
"animalHandling":{"name":"Animal Handling"},
"arcana":{"name":"Arcana"},
"athletics":{"name":"Athletics"},
"deception":{"name":"Deception"},
"history":{"name":"History"},
"insight":{"name":"Insight"},
"intimidation":{"name":"Intimidation"},
"investigation":{"name":"Investigation"},
"medicine":{"name":"Medicine"},
"nature":{"name":"Nature"},
"perception":{"name":"Perception"},
"performance":{"name":"Performance"},
"persuasion":{"name":"Persuasion"},
"religion":{"name":"Religion"},
"sleightOfHand":{"name":"Sleight of Hand"},
"stealth":{"name":"Stealth"},
"survival":{"name":"Survival"},
"initiative":{"name":"Initiative"},
"hitPoints":{"name":"Hit Points"},
"armor":{"name":"Armor"},
"dexterityArmor":{"name":"Dexterity Armor Bonus"},
"speed":{"name":"Speed"},
"proficiencyBonus":{"name":"Proficiency Bonus"},
"ki":{"name":"Ki Points"},
"sorceryPoints":{"name":"Sorcery Points"},
"rages":{"name":"Rages"},
"rageDamage":{"name":"Rage Damage"},
"expertiseDice":{"name":"Expertise Dice"},
"superiorityDice":{"name":"Superiority Dice"},
"carryMultiplier": {"name": "Carry Capacity Multiplier"},
"level1SpellSlots":{"name":"level 1 Spell Slots"},
"level2SpellSlots":{"name":"level 2 Spell Slots"},
"level3SpellSlots":{"name":"level 3 Spell Slots"},
"level4SpellSlots":{"name":"level 4 Spell Slots"},
"level5SpellSlots":{"name":"level 5 Spell Slots"},
"level6SpellSlots":{"name":"level 6 Spell Slots"},
"level7SpellSlots":{"name":"level 7 Spell Slots"},
"level8SpellSlots":{"name":"level 8 Spell Slots"},
"level9SpellSlots":{"name":"level 9 Spell Slots"},
"d6HitDice":{"name":"d6 Hit Dice"},
"d8HitDice":{"name":"d8 Hit Dice"},
"d10HitDice":{"name":"d10 Hit Dice"},
"d12HitDice":{"name":"d12 Hit Dice"},
"acidMultiplier":{"name":"Acid damage", "group": "Weakness/Resistance"},
"bludgeoningMultiplier":{
"name":"Bludgeoning damage", "group": "Weakness/Resistance",
},
"coldMultiplier":{
"name":"Cold damage", "group": "Weakness/Resistance",
},
"fireMultiplier":{
"name":"Fire damage", "group": "Weakness/Resistance",
},
"forceMultiplier":{
"name":"Force damage", "group": "Weakness/Resistance",
},
"lightningMultiplier":{
"name":"Lightning damage", "group": "Weakness/Resistance",
},
"necroticMultiplier":{
"name":"Necrotic damage", "group": "Weakness/Resistance",
},
"piercingMultiplier":{
"name":"Piercing damage", "group": "Weakness/Resistance",
},
"poisonMultiplier":{
"name":"Poison damage", "group": "Weakness/Resistance",
},
"psychicMultiplier":{
"name":"Psychic damage", "group": "Weakness/Resistance",
},
"radiantMultiplier":{
"name":"Radiant damage", "group": "Weakness/Resistance",
},
"slashingMultiplier":{
"name":"Slashing damage", "group": "Weakness/Resistance",
},
"thunderMultiplier":{
"name":"Thunder damage", "group": "Weakness/Resistance",
},
};
var operations = {
base: {name: "Base Value: "},
proficiency: {name: "Proficiency"},
add: {name: "+"},
mul: {name: "×"},
min: {name: "Min: "},
max: {name: "Max: "},
advantage: {name: "Advantage"},
disadvantage: {name: "Disadvantage"},
passiveAdd: {name: "Passive Bonus: "},
fail: {name: "Automatically Fail"},
};
Template.effectView.helpers({
sourceName: function(){
var id = this.parent.id;
if (!id) return;
switch (this.parent.collection){
case "Features":
return "Feature - " + Features.findOne(id, {fields: {name: 1}}).name;
case "Classes":
return Classes.findOne(id, {fields: {name: 1}}).name;
case "Buffs":
return "Buff - " + Buffs.findOne(id, {fields: {name: 1}}).name;
case "Items":
return "Equipment - " + Items.findOne(id, {fields: {name: 1}}).name;
case "Characters":
return Characters.findOne(this.charId, {fields: {race: 1}}).race;
default:
return "Inate";
}
},
statName: function(){
return stats[this.stat] && stats[this.stat].name || "No Stat";
},
operationName: function(){
if (this.operation === "proficiency" ||
this.operation === "conditional") return null;
if (stats[this.stat] && stats[this.stat].group === "Weakness/Resistance")
return null;
if (this.operation === "add" && evaluateEffect(this.charId, this) < 0)
return null;
return operations[this.operation] &&
operations[this.operation].name || "No Operation";
},
statValue: function(){
if (this.operation === "advantage" ||
this.operation === "disadvantage" ||
this.operation === "fail"){
return null;
}
if (this.operation === "proficiency"){
if (this.value == 0.5 || this.calculation == 0.5)
return "Half Proficiency";
if (this.value == 1 || this.calculation == 1)
return "Proficiency";
if (this.value == 2 || this.calculation == 2)
return "Double Proficiency";
}
if (this.operation === "conditional"){
return this.calculation || this.value;
}
if (stats[this.stat] && stats[this.stat].group === "Weakness/Resistance"){
if (this.value === 0.5) return "Resistance";
if (this.value === 2) return "Vulnerability";
if (this.value === 0) return "Immunity";
}
var value = evaluateEffect(this.charId, this);
if (_.isNumber(value)) return value;
return this.calculation || this.value;
},
});

View File

@@ -0,0 +1,13 @@
<!--needs to be given charId, parentId and parentCollection-->
<template name="effectsEditList">
{{#if effects.count}}
<hr class="vertMargin">
<div id="effects">
<h2>Effects</h2>
{{#each effects}}
{{>effectEdit}}
{{/each}}
</div>
{{/if}}
<paper-button id="addEffectButton" class="red-button" raised>Add Effect</paper-button>
</template>

View File

@@ -0,0 +1,33 @@
Template.effectsEditList.helpers({
effects: function(){
var selector = {
"parent.id": this.parentId,
"parent.collection": this.parentCollection,
"charId": this.charId,
};
if (this.parentGroup){
selector["parent.group"] = this.parentGroup;
}
var cursor = Effects.find(selector);
return cursor;
}
});
Template.effectsEditList.events({
"tap #addEffectButton": function(){
if (!_.isBoolean(this.enabled)) {
this.enabled = true;
}
Effects.insert({
name: this.name,
charId: this.charId,
parent: {
id: this.parentId,
collection: this.parentCollection,
group: this.parentGroup,
},
operation: "add",
enabled: this.enabled,
});
},
});

View File

@@ -0,0 +1,14 @@
<!--needs to be given charId, (parentId or stat) and type-->
<template name="effectsViewList">
{{#if effects.count}}
<hr style="margin: 16px 0 16px 0;">
<div class="effects">
<h2 class="spaceAfter">Effects</h2>
<table class="wideTable">
{{#each effects}}
{{>effectView}}
{{/each}}
</table>
</div>
{{/if}}
</template>

View File

@@ -0,0 +1,12 @@
Template.effectsViewList.helpers({
effects: function(){
var selector = {
"parent.id": this.parentId,
"charId": this.charId
};
if (this.parentGroup){
selector["parent.group"] = this.parentGroup;
}
return Effects.find(selector, {fields: {parent: 0}});
}
});