Added resource forms to actions

This commit is contained in:
Thaum Rystra
2020-04-26 10:28:40 +02:00
parent 88ed912d18
commit 13cb9253c3
11 changed files with 373 additions and 38 deletions

View File

@@ -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

View File

@@ -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;

View 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;

View File

@@ -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;

View 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;