Removed unneeded "type" from schemas, use parent.collection instead.

This commit is contained in:
Thaum
2015-04-17 11:30:44 +00:00
parent 1352bd1178
commit 245867dae6
13 changed files with 14 additions and 47 deletions

View File

@@ -42,12 +42,6 @@ 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
parent: {
type: Schemas.Parent

View File

@@ -29,12 +29,6 @@ Schemas.Effect = new SimpleSchema({
optional: true,
trim: false
},
//indicates what the effect originated from
type: {
type: String,
defaultValue: "editable",
allowedValues: ["editable", "feature", "class", "buff", "equipment", "racial", "inate"]
},
//the thing that created this effect
parent: {
type: Schemas.Parent

View File

@@ -13,10 +13,6 @@ Schemas.Proficiency = new SimpleSchema({
type: Number,
allowedValues: [0, 0.5, 1],
},
type: {
type: String,
allowedValues: ["skill", "save", "weapon", "armor", "tool", "language"]
}
});
Proficiencies.attachSchema(Schemas.Proficiency);

View File

@@ -1,4 +1,4 @@
<!--needs to be given charId, parentId and type-->
<!--needs to be given charId, parentId and parentCollection-->
<template name="attackEditList">
{{#if attacks.count}}
<hr style="margin: 16px 0 16px 0;">

View File

@@ -1,6 +1,6 @@
Template.attackEditList.helpers({
attacks: function(){
var cursor = Attacks.find({"parent.id": this.parentId, type: this.type, charId: this.charId});
var cursor = Attacks.find({"parent.id": this.parentId, charId: this.charId});
return cursor;
}
});
@@ -12,8 +12,7 @@ Template.attackEditList.events({
parent: {
id: this.parentId,
collection: this.parentCollection
},
type: this.type,
}
});
},
});

View File

@@ -1,4 +1,4 @@
<!--needs to be given charId, parentId, parentCollection and type-->
<!--needs to be given charId, parentId and parentCollection-->
<template name="effectsEditList">
{{#if effects.count}}
<hr style="margin: 16px 0 16px 0;">

View File

@@ -1,6 +1,6 @@
Template.effectsEditList.helpers({
effects: function(){
var cursor = Effects.find({"parent.id": this.parentId, "parent.collection": this.parentCollection, type: this.type});
var cursor = Effects.find({"parent.id": this.parentId, "parent.collection": this.parentCollection});
return cursor;
}
});
@@ -18,7 +18,6 @@ Template.effectsEditList.events({
collection: this.parentCollection
},
operation: "add",
type: this.type,
enabled: this.enabled
});
},

View File

@@ -81,5 +81,5 @@
</paper-autogrow-textarea>
</paper-input-decorator>
{{> effectsEditList parentId=_id parentCollection="Features" charId=charId type="feature" name=name enabled=enabled}}
{{> effectsEditList parentId=_id parentCollection="Features" charId=charId name=name enabled=enabled}}
</template>

View File

@@ -80,9 +80,9 @@
</paper-autogrow-textarea>
</paper-input-decorator>
<!--Effects-->
{{> effectsEditList parentId=_id parentCollection="Items" charId=charId type="equipment" enabled=equipped name=name}}
{{> effectsEditList parentId=_id parentCollection="Items" charId=charId enabled=equipped name=name}}
<!--Attacks-->
{{> attackEditList parentId=_id parentCollection="Items" charId=charId type="equipment" enabled=equipped name=name}}
{{> attackEditList parentId=_id parentCollection="Items" charId=charId enabled=equipped name=name}}
</template>
<template name="containerDropdown">

View File

@@ -6,7 +6,7 @@
<!--Level-->
<paper-input id="levelValueInput" label="Level" floatinglabel value={{level}}></paper-input>
<!--Effects-->
{{> effectsEditList parentId=_id parentCollection="Classes" charId=charId type="class"}}
{{> effectsEditList parentId=_id parentCollection="Classes" charId=charId}}
{{/baseDialog}}
{{/with}}
</template>

View File

@@ -1,6 +1,6 @@
<template name="raceDialog">
{{#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 type="racial"}}
{{> effectsEditList parentId=charId parentCollection="Characters" charId=charId}}
{{/baseDialog}}
</template>

View File

@@ -152,27 +152,14 @@ Template.skillDialog.helpers({
return Characters.findOne(this.charId, {fields:{_id: 1}});
},
sourceName: function(){
var id = this.parent.id;
if(!id) return;
switch(this.type){
case "feature":
return Features.findOne(id, {fields: {name: 1}}).name;
case "class":
return Classes.findOne(id, {fields: {name: 1}}).name;
case "buff":
return Buffs.findOne(id, {fields: {name: 1}}).name;
case "equipment":
return Items.findOne(id, {fields: {name: 1}}).name;
case "racial":
return Characters.findOne(this.charId, {fields: {race: 1}}).race;
case "inate":
return "Inate"
}
if (this.parent.collection === "Characters") return "inate";
var parent = this.getParent();
return parent && parent.name;
},
operationName: function(){
if(this.operation === "proficiency") return null;
if(stats[this.stat].group === "Weakness/Resistance") return null;
return operations[this.operation] && operations[this.operation].name || "No Operation"
return operations[this.operation] && operations[this.operation].name || "No Operation";
},
statValue: function(){
if(this.operation === "advantage" ||

View File

@@ -17,7 +17,6 @@ var getPointBuyEffect = function(stat, value, pointsUsed, charId){
name: pointsUsed + " Point Buy",
operation: "base",
value: value,
type: "inate",
parent: {collection: "Characters", id: charId},
enabled: true,
},
@@ -25,7 +24,6 @@ var getPointBuyEffect = function(stat, value, pointsUsed, charId){
charId: charId,
stat: stat,
operation: "base",
type: "inate"
}
};
};