Added resource forms to actions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import ResourceSchema from '/imports/api/properties/subSchemas/ResourceSchema.js'
|
||||
import ResourcesSchema from '/imports/api/properties/subSchemas/ResourcesSchema.js'
|
||||
import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js';
|
||||
|
||||
/*
|
||||
@@ -8,9 +8,7 @@ import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js';
|
||||
* Any actions that are children of this action will be considered alternatives
|
||||
* to this action
|
||||
*/
|
||||
let ActionSchema = new SimpleSchema({})
|
||||
.extend(ResourceSchema)
|
||||
.extend({
|
||||
let ActionSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -47,6 +45,10 @@ let ActionSchema = new SimpleSchema({})
|
||||
type: ResultsSchema,
|
||||
defaultValue: {},
|
||||
},
|
||||
resources: {
|
||||
type: ResourcesSchema,
|
||||
defaultValue: {},
|
||||
},
|
||||
// Calculation of how many times this action can be used
|
||||
// Only set if this action tracks its own uses, rather than adjusting
|
||||
// resources
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { Random } from 'meteor/random';
|
||||
|
||||
const AttributeConsumedSchema = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
autoValue(){
|
||||
if (!this.isSet) return Random.id();
|
||||
}
|
||||
},
|
||||
variableName: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
quantity: {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
},
|
||||
});
|
||||
|
||||
export default AttributeConsumedSchema;
|
||||
22
app/imports/api/properties/subSchemas/ItemConsumedSchema.js
Normal file
22
app/imports/api/properties/subSchemas/ItemConsumedSchema.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { Random } from 'meteor/random';
|
||||
|
||||
const ItemConsumedSchema = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
autoValue(){
|
||||
if (!this.isSet) return Random.id();
|
||||
}
|
||||
},
|
||||
tag: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
quantity: {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
},
|
||||
});
|
||||
|
||||
export default ItemConsumedSchema;
|
||||
@@ -1,34 +0,0 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
const ResourceSchema = new SimpleSchema({
|
||||
itemsConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'itemsConsumed.$': {
|
||||
type: Object,
|
||||
},
|
||||
'itemsConsumed.$.tag': {
|
||||
type: String,
|
||||
},
|
||||
'itemsConsumed.$.quantity': {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
},
|
||||
attributesConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'attributesConsumed.$': {
|
||||
type: Object,
|
||||
},
|
||||
'attributesConsumed.$.variableName': {
|
||||
type: String,
|
||||
},
|
||||
'attributesConsumed.$.quantity': {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
},
|
||||
});
|
||||
|
||||
export default ResourceSchema;
|
||||
22
app/imports/api/properties/subSchemas/ResourcesSchema.js
Normal file
22
app/imports/api/properties/subSchemas/ResourcesSchema.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import ItemConsumedSchema from '/imports/api/properties/subSchemas/ItemConsumedSchema.js';
|
||||
import AttributeConsumedSchema from '/imports/api/properties/subSchemas/AttributeConsumedSchema.js';
|
||||
|
||||
const ResourcesSchema = new SimpleSchema({
|
||||
itemsConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'itemsConsumed.$': {
|
||||
type: ItemConsumedSchema,
|
||||
},
|
||||
attributesConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'attributesConsumed.$': {
|
||||
type: AttributeConsumedSchema,
|
||||
},
|
||||
});
|
||||
|
||||
export default ResourcesSchema;
|
||||
Reference in New Issue
Block a user