Implemented Feature editing UI
This commit is contained in:
@@ -213,8 +213,6 @@ Schemas.Character = new SimpleSchema({
|
||||
},
|
||||
|
||||
//mechanics
|
||||
features: { type: [String], defaultValue: [], regEx: SimpleSchema.RegEx.Id,},
|
||||
customFeatures: { type: [Schemas.Feature], defaultValue: []},
|
||||
actions: { type: [Schemas.Action], defaultValue: []},
|
||||
deathSave: { type: Schemas.DeathSave },
|
||||
time: { type: Number, min: 0, decimal: true, defaultValue: 0},
|
||||
|
||||
@@ -1,28 +1,9 @@
|
||||
//Features are features that can be selected but not edited
|
||||
//they are the things that come in the player's handbook and
|
||||
//facilitate the quick building of characters
|
||||
//They are the primary means of collecting cease and desist letters :(
|
||||
//
|
||||
//Should only be edited by admins
|
||||
//
|
||||
//TODO add a Meteor Method that lets users add a feature to their character
|
||||
//and pushes the effects and actions accordingly
|
||||
//
|
||||
//TODO add a Method that updates every character with a given feature if that feature should change
|
||||
|
||||
Features = new Meteor.Collection("features");
|
||||
|
||||
Schemas.Feature = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
autoValue: function(){
|
||||
if(!this.isSet) return Random.id();
|
||||
}
|
||||
},
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true},
|
||||
name: {type: String},
|
||||
description:{type: String, optional: true},
|
||||
source: {type: String, optional: true},
|
||||
effects: {type: [Schemas.Effect], defaultValue: []},
|
||||
actions: {type: [Schemas.Action], defaultValue: []},
|
||||
attacks: {type: [Schemas.Attack], defaultValue: []},
|
||||
@@ -31,12 +12,24 @@ Schemas.Feature = new SimpleSchema({
|
||||
|
||||
Features.attachSchema(Schemas.Feature);
|
||||
|
||||
//observe standard features for changes and update characters using them
|
||||
Features.find().observe({
|
||||
//update the features of the items as needed
|
||||
Features.find({}, {fields: {name: 0, description: 0}}).observe({
|
||||
added: function(newFeature){
|
||||
if(newFeature.charId){
|
||||
//make sure existing versions of this feature's effects aren't duplicated
|
||||
removeFeatureEffects(newFeature.charId, newFeature);
|
||||
//add the new feature's effects
|
||||
addFeatureEffects(newFeature.charId, newFeature);
|
||||
}
|
||||
},
|
||||
changed: function(newFeature, oldFeature){
|
||||
//TODO
|
||||
if(oldFeature.charId)
|
||||
removeFeatureEffects(oldFeature.charId, oldFeature);
|
||||
if(newFeature.charId)
|
||||
addFeatureEffects(newFeature.charId, newFeature);
|
||||
},
|
||||
removed: function(oldFeature){
|
||||
//TODO
|
||||
if(oldFeature.charId)
|
||||
removeFeatureEffects(oldFeature.charId, oldFeature);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,11 +7,11 @@ Schemas.Attribute = new SimpleSchema({
|
||||
},
|
||||
//effect arrays
|
||||
effects: { type: [Schemas.Effect], defaultValue: [] },
|
||||
reset: {
|
||||
type: String,
|
||||
defaultValue: "longRest",
|
||||
allowedValues: ["longRest", "shortRest"]
|
||||
}
|
||||
reset: {
|
||||
type: String,
|
||||
defaultValue: "longRest",
|
||||
allowedValues: ["longRest", "shortRest"]
|
||||
}
|
||||
});
|
||||
|
||||
//note that to make an invulnerability add a new max of zero value
|
||||
@@ -22,12 +22,16 @@ Schemas.Vulnerability = new SimpleSchema({
|
||||
defaultValue: 0
|
||||
},
|
||||
//effect arrays
|
||||
mul: { type: [Schemas.Effect], defaultValue: [] },
|
||||
min: { type: [Schemas.Effect], defaultValue: [{name: "Resistance doesn't stack", value: 0.5}] },
|
||||
max: { type: [Schemas.Effect], defaultValue: [{name: "Vulnerability doesn't stack", value: 2}] },
|
||||
reset: {
|
||||
type: String,
|
||||
defaultValue: "longRest",
|
||||
allowedValues: ["longRest", "shortRest"]
|
||||
}
|
||||
effects: {
|
||||
type: [Schemas.Effect],
|
||||
defaultValue: [
|
||||
{type: "inate", name: "Resistance doesn't stack", operation: "min", value: 0.5},
|
||||
{type: "inate", name: "Vulnerability doesn't stack", operation: "max", value: 2}
|
||||
]
|
||||
},
|
||||
reset: {
|
||||
type: String,
|
||||
defaultValue: "longRest",
|
||||
allowedValues: ["longRest", "shortRest"]
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ Schemas.Effect = new SimpleSchema({
|
||||
operation: {
|
||||
type: String,
|
||||
defaultValue: "add",
|
||||
allowedValues: ["base", "proficiency","add","mul","min","max","advantage","disadvantage","passiveAdd","fail","conditional","passiveAdd"]
|
||||
allowedValues: ["base", "proficiency","add","mul","min","max","advantage","disadvantage","passiveAdd","fail","conditional"]
|
||||
},
|
||||
value: {
|
||||
type: Number,
|
||||
@@ -31,7 +31,7 @@ Schemas.Effect = new SimpleSchema({
|
||||
type: {
|
||||
type: String,
|
||||
defaultValue: "editable",
|
||||
allowedValues: ["editable", "feat", "buff", "equipment", "inate"]
|
||||
allowedValues: ["editable", "feature", "buff", "equipment", "inate"]
|
||||
},
|
||||
//which stat the effect is applied to
|
||||
stat: {
|
||||
@@ -1,9 +1,10 @@
|
||||
//set up the collection for containers
|
||||
Containers = new Meteor.Collection("containers");
|
||||
|
||||
|
||||
Schemas.Container = new SimpleSchema({
|
||||
name: { type: String },
|
||||
owner: { type: String, regEx: SimpleSchema.RegEx.Id},
|
||||
charId: { type: String, regEx: SimpleSchema.RegEx.Id},
|
||||
isCarried: { type: Boolean }
|
||||
});
|
||||
|
||||
|
||||
@@ -4,14 +4,20 @@ Schemas.Item = new SimpleSchema({
|
||||
name: {type: String, defaultValue: "New Item"},
|
||||
plural: {type: String, optional: true},
|
||||
description:{type: String, defaultValue: ""},
|
||||
container: {type: String}, //id of container it normally is stowed in
|
||||
character: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of owner
|
||||
container: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, //id of container it normally is stowed in
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, //id of owner
|
||||
quantity: {type: Number, min: 0, defaultValue: 1},
|
||||
weight: {type: Number, min: 0, defaultValue: 0, decimal: true},
|
||||
value: {type: Number, min: 0, defaultValue: 0, decimal: true},
|
||||
tradeGood: {type: Boolean, defaultValue: false},
|
||||
stackable: {type: Boolean, defaultValue: false},
|
||||
feature: {type: Schemas.Feature},
|
||||
"feature.name": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
"feature.description": {type: String, autoValue: function(){return this.field("description").value}},
|
||||
"feature.source": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
"feature.effects.$.name": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
"feature.effects.$.type": {type: String, autoValue: function(){return "equipment"}},
|
||||
"feature.attacks.$.name": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
equipmentSlot: {
|
||||
type: String,
|
||||
defaultValue: "none",
|
||||
@@ -23,20 +29,20 @@ Schemas.Item = new SimpleSchema({
|
||||
Items.attachSchema(Schemas.Item);
|
||||
|
||||
//update the features of the items as needed
|
||||
Items.find({}, {fields: {feature: 1, character: 1, equipped: 1}}).observe({
|
||||
Items.find({}, {fields: {feature: 1, charId: 1, equipped: 1}}).observe({
|
||||
added: function(newItem){
|
||||
if(newItem.feature && newItem.character)
|
||||
addFeatureEffects(newItem.character, newItem.feature);
|
||||
if(newItem.feature && newItem.charId)
|
||||
addFeatureEffects(newItem.charId, newItem.feature);
|
||||
},
|
||||
changed: function(newItem, oldItem){
|
||||
if(oldItem.feature && oldItem.character)
|
||||
removeFeatureEffects(oldItem.character, oldItem.feature);
|
||||
if(newItem.feature && newItem.character)
|
||||
addFeatureEffects(newItem.character, newItem.feature);
|
||||
if(oldItem.feature && oldItem.charId)
|
||||
removeFeatureEffects(oldItem.charId, oldItem.feature);
|
||||
if(newItem.feature && newItem.charId)
|
||||
addFeatureEffects(newItem.charId, newItem.feature);
|
||||
},
|
||||
removed: function(oldItem){
|
||||
if(oldItem.feature && oldItem.character)
|
||||
removeFeatureEffects(oldItem.character, oldItem.feature);
|
||||
if(oldItem.feature && oldItem.charId)
|
||||
removeFeatureEffects(oldItem.charId, oldItem.feature);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user