diff --git a/app/imports/api/library/librarySchemas.js b/app/imports/api/library/librarySchemas.js index 83352ed7..ea00d431 100644 --- a/app/imports/api/library/librarySchemas.js +++ b/app/imports/api/library/librarySchemas.js @@ -13,6 +13,7 @@ import { NoteSchema } from '/imports/api/properties/Notes.js'; import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { RollSchema } from '/imports/api/properties/Rolls.js'; import { SkillSchema } from '/imports/api/properties/Skills.js'; +import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; import { SpellListSchema } from '/imports/api/properties/SpellLists.js'; import { SpellSchema } from '/imports/api/properties/Spells.js'; import { ContainerSchema } from '/imports/api/properties/Containers.js'; @@ -32,6 +33,7 @@ const librarySchemas = { note: NoteSchema, proficiency: ProficiencySchema, roll: RollSchema, + savingThrow: SavingThrowSchema, skill: SkillSchema, spellList: SpellListSchema, spell: SpellSchema, diff --git a/app/imports/api/parenting/deleteRemovedDocuments.js b/app/imports/api/parenting/deleteRemovedDocuments.js index 31938ec3..295b55a2 100644 --- a/app/imports/api/parenting/deleteRemovedDocuments.js +++ b/app/imports/api/parenting/deleteRemovedDocuments.js @@ -1,4 +1,6 @@ -import creatureCollections from '/imports/api/creature/creatureCollections.js'; +import LibraryNodes from '/imports/api/library/LibraryNodes.js'; + +let collections = [LibraryNodes]; if (Meteor.isServer) Meteor.startup(() => { /** @@ -8,7 +10,7 @@ if (Meteor.isServer) Meteor.startup(() => { const deleteOldSoftRemovedDocs = function(){ const now = new Date(); const thirtyMinutesAgo = new Date(now.getTime() - 30*60000); - creatureCollections.forEach(collection => { + collections.forEach(collection => { collection.remove({ removed: true, removedAt: {$lt: thirtyMinutesAgo} // dates *before* 30 minutes ago diff --git a/app/imports/api/properties/Actions.js b/app/imports/api/properties/Actions.js index 04024a8b..cc6eedbf 100644 --- a/app/imports/api/properties/Actions.js +++ b/app/imports/api/properties/Actions.js @@ -1,7 +1,5 @@ import SimpleSchema from 'simpl-schema'; -import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; -import DamageSchema from '/imports/api/properties/subSchemas/DamageSchema.js'; -import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js'; +import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js'; /* * Actions are things a character can do @@ -35,8 +33,6 @@ let ActionSchema = new SimpleSchema({ 'multipleTargets', ], }, - // Effects can apply to this tag specifically - // Ranged spell attack, Ranged weapon attack, etc. tags: { type: Array, defaultValue: [], @@ -44,29 +40,9 @@ let ActionSchema = new SimpleSchema({ 'tags.$': { type: String, }, - // Adjustments applied when taking this action - // Ideally, if these adjustments can't be made, the action should be unusable - adjustments: { - type: Array, - defaultValue: [], - }, - 'adjustments.$': { - type: AdjustmentSchema, - }, - damages: { - type: Array, - defaultValue: [], - }, - 'damages.$': { - type: DamageSchema, - }, - // Buffs applied when taking this action - buffs: { - type: Array, - defaultValue: [], - }, - 'buffs.$': { - type: StoredBuffWithIdSchema, + results: { + type: ResultsSchema, + defaultValue: {}, }, // Calculation of how many times this action can be used // Only set if this action tracks its own uses, rather than adjusting diff --git a/app/imports/api/properties/Rolls.js b/app/imports/api/properties/Rolls.js index 57756add..2c8c251c 100644 --- a/app/imports/api/properties/Rolls.js +++ b/app/imports/api/properties/Rolls.js @@ -34,11 +34,11 @@ let RollSchema = new SimpleSchema({ 'tags.$': { type: String, }, - results: { + rollResults: { type: Array, defaultValue: [], }, - 'results.$': { + 'rollResults.$': { type: RollResultsSchema, }, }); diff --git a/app/imports/api/properties/SavingThrows.js b/app/imports/api/properties/SavingThrows.js index 5d234c0e..ba35f658 100644 --- a/app/imports/api/properties/SavingThrows.js +++ b/app/imports/api/properties/SavingThrows.js @@ -1,6 +1,5 @@ import SimpleSchema from 'simpl-schema'; -import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; -import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js'; +import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js'; // These are the rolls made when saves are called for // For the saving throw bonus or proficiency, see ./Skills.js @@ -14,34 +13,14 @@ let SavingThrowSchema = new SimpleSchema ({ type: String, optional: true, }, - passAdjustments: { - type: Array, - defaultValue: [], - }, - 'passAdjustments.$': { - type: AdjustmentSchema, - }, - passBuffs: { - type: Array, - defaultValue: [], - }, - 'passBuffs.$': { - type: StoredBuffWithIdSchema, - }, - failAdjustments: { - type: Array, - defaultValue: [], - }, - 'failAdjustments.$': { - type: AdjustmentSchema, - }, - failBuffs: { - type: Array, - defaultValue: [], - }, - 'failBuffs.$': { - type: StoredBuffWithIdSchema, + passResults: { + type: ResultsSchema, + defaultValue: {}, }, + failResults: { + type: ResultsSchema, + defaultValue: {}, + }, }); export { SavingThrowSchema }; diff --git a/app/imports/api/properties/propertySchemas.js b/app/imports/api/properties/propertySchemas.js index 4abfa65d..0f45e1ca 100644 --- a/app/imports/api/properties/propertySchemas.js +++ b/app/imports/api/properties/propertySchemas.js @@ -1,5 +1,5 @@ import { ActionSchema } from '/imports/api/properties/Actions.js'; -import { AttackSchema } from 'app/imports/api/properties/Attacks.js'; +import { AttackSchema } from '/imports/api/properties/Attacks.js'; import { AttributeSchema } from '/imports/api/properties/Attributes.js'; import { StoredBuffSchema } from '/imports/api/properties/Buffs.js'; import { ClassLevelSchema } from '/imports/api/properties/ClassLevels.js'; @@ -11,7 +11,6 @@ import { FolderSchema } from '/imports/api/properties/Folders.js'; import { NoteSchema } from '/imports/api/properties/Notes.js'; import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { RollSchema } from '/imports/api/properties/Rolls.js'; -import { RollResultSchema } from '/imports/api/properties/RollResult.js'; import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; import { SkillSchema } from '/imports/api/properties/Skills.js'; import { SpellListSchema } from '/imports/api/properties/SpellLists.js'; @@ -33,7 +32,6 @@ const propertySchemas = { note: NoteSchema, proficiency: ProficiencySchema, roll: RollSchema, - rollResult: RollResultSchema, savingThrow: SavingThrowSchema, skill: SkillSchema, spellList: SpellListSchema, diff --git a/app/imports/api/properties/subSchemas/ResultsSchema.js b/app/imports/api/properties/subSchemas/ResultsSchema.js new file mode 100644 index 00000000..c5b6231c --- /dev/null +++ b/app/imports/api/properties/subSchemas/ResultsSchema.js @@ -0,0 +1,36 @@ +import SimpleSchema from 'simpl-schema'; + +import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; +import DamageSchema from '/imports/api/properties/subSchemas/DamageSchema.js'; +import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js'; + +let ResultsSchema = new SimpleSchema({ + // Adjustments applied when taking this action + // Ideally, if these adjustments can't be made, the action should be unusable + adjustments: { + type: Array, + defaultValue: [], + }, + 'adjustments.$': { + type: AdjustmentSchema, + }, + // Damage is done to hitpoints or hitpoint-like stats + // has a damage type, can be mitigated by resistances, etc. + damages: { + type: Array, + defaultValue: [], + }, + 'damages.$': { + type: DamageSchema, + }, + // Buffs applied when taking this action + buffs: { + type: Array, + defaultValue: [], + }, + 'buffs.$': { + type: StoredBuffWithIdSchema, + }, +}); + +export default ResultsSchema; diff --git a/app/imports/api/properties/subSchemas/RollResultsSchema.js b/app/imports/api/properties/subSchemas/RollResultsSchema.js index cd8ddadd..4ce64b88 100644 --- a/app/imports/api/properties/subSchemas/RollResultsSchema.js +++ b/app/imports/api/properties/subSchemas/RollResultsSchema.js @@ -1,7 +1,5 @@ import SimpleSchema from 'simpl-schema'; -import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; -import DamageSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; -import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js'; +import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js'; let RollResultsSchema = new SimpleSchema ({ // Expression of whether or not to apply the roll @@ -11,26 +9,9 @@ let RollResultsSchema = new SimpleSchema ({ type: String, optional: true, }, - damages: { - type: Array, - defaultValue: [], - }, - 'damages.$': { - type: DamageSchema, - }, - adjustments: { - type: Array, - defaultValue: [], - }, - 'adjustments.$': { - type: AdjustmentSchema, - }, - buffs: { - type: Array, - defaultValue: [], - }, - 'buffs.$': { - type: StoredBuffWithIdSchema, + results: { + type: ResultsSchema, + defaultValue: {}, }, }); diff --git a/app/imports/constants/PROPERTIES.js b/app/imports/constants/PROPERTIES.js index 8e762d67..90e49ce2 100644 --- a/app/imports/constants/PROPERTIES.js +++ b/app/imports/constants/PROPERTIES.js @@ -51,6 +51,10 @@ const PROPERTIES = Object.freeze({ icon: 'flare', name: 'Roll' }, + savingThrow: { + icon: 'all_out', + name: 'Saving throw' + }, skill: { icon: 'check_box', name: 'Skill' diff --git a/app/imports/ui/components/tree/TreeNode.vue b/app/imports/ui/components/tree/TreeNode.vue index 763b6b6d..529f0389 100644 --- a/app/imports/ui/components/tree/TreeNode.vue +++ b/app/imports/ui/components/tree/TreeNode.vue @@ -35,8 +35,8 @@ :class="selected && 'primary--text'" />