From 9b652fc133f5afa0e31a41cfa3fdb4843988175f Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 17 Aug 2022 13:42:47 +0200 Subject: [PATCH 01/14] Added point buy form --- app/imports/api/properties/PointBuys.js | 49 ++++++- .../computedOnlyPropertySchemasIndex.js | 2 + .../computedPropertySchemasIndex.js | 2 + .../api/properties/propertySchemasIndex.js | 2 + app/imports/constants/PROPERTIES.js | 8 +- app/imports/constants/STORAGE_LIMITS.js | 1 + .../ui/properties/forms/PointBuyForm.vue | 129 ++++++++++++++++++ .../forms/shared/propertyFormIndex.js | 2 + 8 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 app/imports/ui/properties/forms/PointBuyForm.vue diff --git a/app/imports/api/properties/PointBuys.js b/app/imports/api/properties/PointBuys.js index 95cc1634..3be53ae2 100644 --- a/app/imports/api/properties/PointBuys.js +++ b/app/imports/api/properties/PointBuys.js @@ -27,10 +27,18 @@ let PointBuySchema = createPropertySchema({ 'values': { type: Array, defaultValue: [], + maxCount: STORAGE_LIMITS.pointBuyRowsCount, }, 'values.$': { type: Object, }, + 'values.$._id': { + type: String, + regEx: SimpleSchema.RegEx.Id, + autoValue(){ + if (!this.isSet) return Random.id(); + } + }, 'values.$.name': { type: String, optional: true, @@ -47,6 +55,18 @@ let PointBuySchema = createPropertySchema({ type: Number, optional: true, }, + 'values.$.min': { + type: 'fieldToCompute', + optional: true, + }, + 'values.$.max': { + type: 'fieldToCompute', + optional: true, + }, + 'values.$.cost': { + type: 'fieldToCompute', + optional: true, + }, min: { type: 'fieldToCompute', optional: true, @@ -74,11 +94,31 @@ const ComputedOnlyPointBuySchema = createPropertySchema({ type: 'computedOnlyField', optional: true, }, - total: { + cost: { type: 'computedOnlyField', optional: true, }, - cost: { + 'values': { + type: Array, + defaultValue: [], + maxCount: STORAGE_LIMITS.pointBuyRowsCount, + }, + 'values.$': { + type: Object, + }, + 'values.$.min': { + type: 'computedOnlyField', + optional: true, + }, + 'values.$.max': { + type: 'computedOnlyField', + optional: true, + }, + 'values.$.cost': { + type: 'computedOnlyField', + optional: true, + }, + total: { type: 'computedOnlyField', optional: true, }, @@ -87,6 +127,11 @@ const ComputedOnlyPointBuySchema = createPropertySchema({ optional: true, removeBeforeCompute: true, }, + error: { + type: String, + optional: true, + removeBeforeCompute: true, + }, }); const ComputedPointBuySchema = new SimpleSchema() diff --git a/app/imports/api/properties/computedOnlyPropertySchemasIndex.js b/app/imports/api/properties/computedOnlyPropertySchemasIndex.js index d490e4e3..489f5b19 100644 --- a/app/imports/api/properties/computedOnlyPropertySchemasIndex.js +++ b/app/imports/api/properties/computedOnlyPropertySchemasIndex.js @@ -15,6 +15,7 @@ import { ComputedOnlyFeatureSchema } from '/imports/api/properties/Features.js'; import { ComputedOnlyFolderSchema } from '/imports/api/properties/Folders.js'; import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js'; import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js'; +import { ComputedOnlyPointBuySchema } from '/imports/api/properties/PointBuys.js'; import { ComputedOnlyProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { ComputedOnlyReferenceSchema } from '/imports/api/properties/References.js'; import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js'; @@ -44,6 +45,7 @@ const propertySchemasIndex = { folder: ComputedOnlyFolderSchema, item: ComputedOnlyItemSchema, note: ComputedOnlyNoteSchema, + pointBuy: ComputedOnlyPointBuySchema, proficiency: ComputedOnlyProficiencySchema, propertySlot: ComputedOnlySlotSchema, reference: ComputedOnlyReferenceSchema, diff --git a/app/imports/api/properties/computedPropertySchemasIndex.js b/app/imports/api/properties/computedPropertySchemasIndex.js index 9084e3b7..01741b49 100644 --- a/app/imports/api/properties/computedPropertySchemasIndex.js +++ b/app/imports/api/properties/computedPropertySchemasIndex.js @@ -15,6 +15,7 @@ import { ComputedFeatureSchema } from '/imports/api/properties/Features.js'; import { FolderSchema } from '/imports/api/properties/Folders.js'; import { ComputedItemSchema } from '/imports/api/properties/Items.js'; import { ComputedNoteSchema } from '/imports/api/properties/Notes.js'; +import { ComputedPointBuySchema } from '/imports/api/properties/PointBuys.js'; import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { ReferenceSchema } from '/imports/api/properties/References.js'; import { ComputedRollSchema } from '/imports/api/properties/Rolls.js'; @@ -42,6 +43,7 @@ const propertySchemasIndex = { feature: ComputedFeatureSchema, folder: FolderSchema, note: ComputedNoteSchema, + pointBuy: ComputedPointBuySchema, proficiency: ProficiencySchema, propertySlot: ComputedSlotSchema, reference: ReferenceSchema, diff --git a/app/imports/api/properties/propertySchemasIndex.js b/app/imports/api/properties/propertySchemasIndex.js index cc4b77ee..0f2f8cb0 100644 --- a/app/imports/api/properties/propertySchemasIndex.js +++ b/app/imports/api/properties/propertySchemasIndex.js @@ -13,6 +13,7 @@ import { EffectSchema } from '/imports/api/properties/Effects.js'; import { FeatureSchema } from '/imports/api/properties/Features.js'; import { FolderSchema } from '/imports/api/properties/Folders.js'; import { NoteSchema } from '/imports/api/properties/Notes.js'; +import { PointBuySchema } from '/imports/api/properties/PointBuys.js'; import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { ReferenceSchema } from '/imports/api/properties/References.js'; import { RollSchema } from '/imports/api/properties/Rolls.js'; @@ -42,6 +43,7 @@ const propertySchemasIndex = { feature: FeatureSchema, folder: FolderSchema, note: NoteSchema, + pointBuy: PointBuySchema, proficiency: ProficiencySchema, propertySlot: SlotSchema, reference: ReferenceSchema, diff --git a/app/imports/constants/PROPERTIES.js b/app/imports/constants/PROPERTIES.js index c2aa3be1..3d75bd06 100644 --- a/app/imports/constants/PROPERTIES.js +++ b/app/imports/constants/PROPERTIES.js @@ -96,7 +96,13 @@ const PROPERTIES = Object.freeze({ icon: 'mdi-note-outline', name: 'Note', helpText: 'Notes about your character and their adventures', - suggestedParents: ['folder'], + suggestedParents: ['note', 'folder'], + }, + pointBuy: { + icon: 'mdi-table', + name: 'Point Buy', + helpText: 'A point buy table that allows the user to select an array of values that match a given cost', + suggestedParents: [], }, proficiency: { icon: 'mdi-brightness-1', diff --git a/app/imports/constants/STORAGE_LIMITS.js b/app/imports/constants/STORAGE_LIMITS.js index 6e116b07..cbc647e6 100644 --- a/app/imports/constants/STORAGE_LIMITS.js +++ b/app/imports/constants/STORAGE_LIMITS.js @@ -32,6 +32,7 @@ const STORAGE_LIMITS = Object.freeze({ tagCount: 64, writersCount: 20, libraryCollectionCount: 32, + pointBuyRowsCount: 32, }); export default STORAGE_LIMITS; diff --git a/app/imports/ui/properties/forms/PointBuyForm.vue b/app/imports/ui/properties/forms/PointBuyForm.vue new file mode 100644 index 00000000..b50d1a36 --- /dev/null +++ b/app/imports/ui/properties/forms/PointBuyForm.vue @@ -0,0 +1,129 @@ + + + diff --git a/app/imports/ui/properties/forms/shared/propertyFormIndex.js b/app/imports/ui/properties/forms/shared/propertyFormIndex.js index 1aa8f42e..63c4fe45 100644 --- a/app/imports/ui/properties/forms/shared/propertyFormIndex.js +++ b/app/imports/ui/properties/forms/shared/propertyFormIndex.js @@ -14,6 +14,7 @@ const FeatureForm = () => import('/imports/ui/properties/forms/FeatureForm.vue') const FolderForm = () => import('/imports/ui/properties/forms/FolderForm.vue'); const ItemForm = () => import('/imports/ui/properties/forms/ItemForm.vue'); const NoteForm = () => import('/imports/ui/properties/forms/NoteForm.vue'); +const PointBuyForm = () => import('/imports/ui/properties/forms/PointBuyForm.vue'); const ProficiencyForm = () => import('/imports/ui/properties/forms/ProficiencyForm.vue'); const ReferenceForm = () => import('/imports/ui/properties/forms/ReferenceForm.vue'); const RollForm = () => import('/imports/ui/properties/forms/RollForm.vue'); @@ -43,6 +44,7 @@ export default { folder: FolderForm, item: ItemForm, note: NoteForm, + pointBuy: PointBuyForm, proficiency: ProficiencyForm, propertySlot: SlotForm, reference: ReferenceForm, From 28307e26c32ac39e43390229826bd16bdcb8efc3 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Fri, 19 Aug 2022 14:03:03 +0200 Subject: [PATCH 02/14] Fixed some issues with skill display --- .../computeByType/computeSkill.js | 2 +- .../computeVariable/computeVariableAsSkill.js | 5 ++- app/imports/api/properties/Skills.js | 1 + .../components/skills/SkillListTile.vue | 4 +- .../ui/properties/viewers/SkillViewer.vue | 44 ++++--------------- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/app/imports/api/engine/computation/computeComputation/computeByType/computeSkill.js b/app/imports/api/engine/computation/computeComputation/computeByType/computeSkill.js index 2e79d18a..9243adb4 100644 --- a/app/imports/api/engine/computation/computeComputation/computeByType/computeSkill.js +++ b/app/imports/api/engine/computation/computeComputation/computeByType/computeSkill.js @@ -4,7 +4,7 @@ // by computeVariableAsSkill export default function computeSkill(computation, node){ const prop = node.data; - prop.proficiency = prop.baseProficiency; + prop.proficiency = prop.baseProficiency || 0; let profBonus = computation.scope['proficiencyBonus']?.value || 0; // Multiply the proficiency bonus by the actual proficiency if(prop.proficiency === 0.49){ diff --git a/app/imports/api/engine/computation/computeComputation/computeByType/computeVariable/computeVariableAsSkill.js b/app/imports/api/engine/computation/computeComputation/computeByType/computeVariable/computeVariableAsSkill.js index 37b6afdd..01d34101 100644 --- a/app/imports/api/engine/computation/computeComputation/computeByType/computeVariable/computeVariableAsSkill.js +++ b/app/imports/api/engine/computation/computeComputation/computeByType/computeVariable/computeVariableAsSkill.js @@ -33,6 +33,9 @@ export default function computeVariableAsSkill(computation, node, prop){ const aggregator = node.data.effectAggregator; const aggregatorBase = aggregator?.base || 0; + // Store effects + prop.effects = node.data.effects; + // If there is no aggregator, determine if the prop can hide, then exit if (!aggregator){ prop.hide = statBase === undefined && @@ -71,8 +74,6 @@ export default function computeVariableAsSkill(computation, node, prop){ prop.fail = aggregator.fail; // Rollbonus prop.rollBonuses = aggregator.rollBonus; - // Store effects - prop.effects = node.data.effects; } function aggregateAbilityEffects({computation, skillNode, abilityNode}){ diff --git a/app/imports/api/properties/Skills.js b/app/imports/api/properties/Skills.js index 47ba2a76..d9f04791 100644 --- a/app/imports/api/properties/Skills.js +++ b/app/imports/api/properties/Skills.js @@ -135,6 +135,7 @@ let ComputedOnlySkillSchema = createPropertySchema({ effects: { type: Array, optional: true, + removeBeforeCompute: true, }, 'effects.$': { type: Object, diff --git a/app/imports/ui/properties/components/skills/SkillListTile.vue b/app/imports/ui/properties/components/skills/SkillListTile.vue index 45f8b138..e24ece45 100644 --- a/app/imports/ui/properties/components/skills/SkillListTile.vue +++ b/app/imports/ui/properties/components/skills/SkillListTile.vue @@ -8,7 +8,7 @@ -
+
{{ model.name }}