From 8b215ce15937f1c0d82d3f9b6f704fee4cd8b4b1 Mon Sep 17 00:00:00 2001 From: Thaum Rystra Date: Mon, 7 Aug 2023 12:37:37 +0200 Subject: [PATCH 01/22] Fixed slot fill cards not column layouting --- .../ui/creature/slots/SlotCardsToFill.vue | 62 +++++++++---------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/app/imports/client/ui/creature/slots/SlotCardsToFill.vue b/app/imports/client/ui/creature/slots/SlotCardsToFill.vue index cddbc800..99bad92a 100644 --- a/app/imports/client/ui/creature/slots/SlotCardsToFill.vue +++ b/app/imports/client/ui/creature/slots/SlotCardsToFill.vue @@ -1,39 +1,35 @@ From f794dbf45a29a9c220fc50e92ffda3549db0c95a Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 11:21:39 +0200 Subject: [PATCH 10/22] Slots act as folder when used in actions --- app/imports/api/engine/actions/applyProperty.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/imports/api/engine/actions/applyProperty.js b/app/imports/api/engine/actions/applyProperty.js index 4dc1cb79..eb4ae157 100644 --- a/app/imports/api/engine/actions/applyProperty.js +++ b/app/imports/api/engine/actions/applyProperty.js @@ -19,6 +19,7 @@ const applyPropertyByType = { damage, folder, note, + propertySlot: folder, roll, savingThrow, spell: action, From 8b23a4bc24295f262c28a0625dca70d1cdfbcb28 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 11:28:02 +0200 Subject: [PATCH 11/22] Clean props when copying creature -> lib prevents creature specific fields from leaking into libraries --- .../methods/copyPropertyToLibrary.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js b/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js index 46e7d024..b46205b9 100644 --- a/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js +++ b/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js @@ -132,6 +132,9 @@ function insertNodeFromProperty(propId, ancestors, order, method) { prop.order = order; } + // Clean the props + props = cleanProps(props); + // Insert the props as library nodes LibraryNodes.batchInsert(props); return prop; @@ -186,4 +189,11 @@ function assertSourceLibraryCopyPermission(props, method) { }); } +function cleanProps(props) { + return props.map(prop => { + let schema = LibraryNodes.simpleSchema(prop); + return schema.clean(prop); + }); +} + export default copyPropertyToLibrary; From 0df7763366c4a195926f60ff54b5fae7f4b0febc Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 11:42:47 +0200 Subject: [PATCH 12/22] Cleaned up bad messy floats in container weights --- .../computeByType/computeContainer.js | 12 +++++++++--- .../utility/stripFloatingPointOddities.js | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/imports/api/engine/computation/computeComputation/computeByType/computeContainer.js b/app/imports/api/engine/computation/computeComputation/computeByType/computeContainer.js index 61b4b79a..0258692f 100644 --- a/app/imports/api/engine/computation/computeComputation/computeByType/computeContainer.js +++ b/app/imports/api/engine/computation/computeComputation/computeByType/computeContainer.js @@ -1,11 +1,17 @@ import aggregate from './computeVariable/aggregate/index.js'; +import { safeStrip } from '/imports/api/engine/computation/utility/stripFloatingPointOddities.js'; -export default function computeContainer(computation, node){ +export default function computeContainer(computation, node) { if (!node.data) node.data = {}; aggregateLinks(computation, node); + + // Clean up floating points + const prop = node.data; + prop.contentsWeight = safeStrip(prop.contentsWeight); + prop.carriedWeight = safeStrip(prop.carriedWeight); } -function aggregateLinks(computation, node){ +function aggregateLinks(computation, node) { computation.dependencyGraph.forEachLinkedNode( node.id, (linkedNode, link) => { @@ -13,7 +19,7 @@ function aggregateLinks(computation, node){ // Ignore inactive props if (linkedNode.data.inactive) return; // Aggregate inventory links - aggregate.inventory({node, linkedNode, link}); + aggregate.inventory({ node, linkedNode, link }); }, true // enumerate only outbound links ); diff --git a/app/imports/api/engine/computation/utility/stripFloatingPointOddities.js b/app/imports/api/engine/computation/utility/stripFloatingPointOddities.js index 8e55685c..3415ff1a 100644 --- a/app/imports/api/engine/computation/utility/stripFloatingPointOddities.js +++ b/app/imports/api/engine/computation/utility/stripFloatingPointOddities.js @@ -1,3 +1,8 @@ -export default function stripFloatingPointOddities(num, precision = 12){ +export default function stripFloatingPointOddities(num, precision = 12) { return +parseFloat(num.toPrecision(precision)) } + +export function safeStrip(num, precision = 12) { + if (!Number.isFinite(num)) return num; + return stripFloatingPointOddities(num, precision); +} From 1778111c75e235dfd6f23ba48d5ad1e22f635288 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 12:09:14 +0200 Subject: [PATCH 13/22] Toggles now wont apply tag targeting if deactivated --- .../computeComputation/computeToggles.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/imports/api/engine/computation/computeComputation/computeToggles.js b/app/imports/api/engine/computation/computeComputation/computeToggles.js index 657305d6..a39e8dc4 100644 --- a/app/imports/api/engine/computation/computeComputation/computeToggles.js +++ b/app/imports/api/engine/computation/computeComputation/computeToggles.js @@ -5,8 +5,26 @@ export default function evaluateToggles(computation, node) { if (!toggles) return; toggles.forEach(toggle => { if ( - (!toggle.enabled && !toggle.disabled && toggle.condition && !toggle.condition.value) - || (toggle.disabled) + ( + // Toggle isn't set to constantly enabled or disabled + !toggle.enabled && + !toggle.disabled && + // Toggle is not disabled by another toggle targeting it + // Ancestor toggles would've handled this child anyway, + // and tag targeted toggles break the link + !toggle.deactivatedByToggle && + !toggle.deactivatedByAncestor && + // Toggle has a condition with a falsy value + toggle.condition && + !toggle.condition.value + ) + || ( + // Toggle is disabled manually + toggle.disabled && + // Toggle isn't deactivated by something else + !toggle.deactivatedByToggle && + !toggle.deactivatedByAncestor + ) ) { prop.inactive = true; prop.deactivatedByToggle = true; From 90c92cdd8cb53472e077a8c12d7c63f115b8373d Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 12:15:32 +0200 Subject: [PATCH 14/22] Prevented character color button from going camo --- app/imports/client/ui/components/ColorPicker.vue | 3 ++- app/imports/client/ui/creature/CreatureFormDialog.vue | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/imports/client/ui/components/ColorPicker.vue b/app/imports/client/ui/components/ColorPicker.vue index ef73f90d..b008ccfc 100644 --- a/app/imports/client/ui/components/ColorPicker.vue +++ b/app/imports/client/ui/components/ColorPicker.vue @@ -18,7 +18,7 @@ {{ label }} mdi-format-paint @@ -148,6 +148,7 @@ type: Number, default: undefined, }, + noColorChange: Boolean, }, data(){ return { colors: [ diff --git a/app/imports/client/ui/creature/CreatureFormDialog.vue b/app/imports/client/ui/creature/CreatureFormDialog.vue index f3f3a058..f4c5ce87 100644 --- a/app/imports/client/ui/creature/CreatureFormDialog.vue +++ b/app/imports/client/ui/creature/CreatureFormDialog.vue @@ -10,6 +10,7 @@ From 0ee77d705affbc0b6ba44d1307322f7bc445548e Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 12:19:55 +0200 Subject: [PATCH 15/22] Fixed actions erroring with undefined resources --- .../api/engine/actions/applyPropertyByType/applyAction.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyAction.js b/app/imports/api/engine/actions/applyPropertyByType/applyAction.js index 4847e91d..115d1998 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyAction.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyAction.js @@ -272,9 +272,10 @@ function spendResources(prop, actionContext) { recalculateCalculation(attConsumed.quantity, actionContext); if (!attConsumed.quantity?.value) return; + if (!attConsumed.variableName) return; let stat = actionContext.scope[attConsumed.variableName]; if (!stat) { - spendLog.push(stat.name + ': ' + ' not found'); + spendLog.push(attConsumed.variableName + ': ' + ' not found'); return; } damagePropertyWork({ From d578a8763203387f8e7dc74fbf5b3cd84630a232 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 12:29:44 +0200 Subject: [PATCH 16/22] =?UTF-8?q?parser=20fix=20for=20chain=20indexing=20i?= =?UTF-8?q?nto=20nested=20arrays=20`[=20[=E2=80=98a1=E2=80=99,=20=E2=80=98?= =?UTF-8?q?a2=E2=80=99=20],=20[=E2=80=98b1=E2=80=99,=20=E2=80=98b2?= =?UTF-8?q?=E2=80=99]=20][2][1]`=20=3D>=20`'b1'`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/imports/parser/grammar.js | 4 ++-- app/imports/parser/grammar.ne | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/imports/parser/grammar.js b/app/imports/parser/grammar.js index 8f513674..2ef69a71 100644 --- a/app/imports/parser/grammar.js +++ b/app/imports/parser/grammar.js @@ -1,4 +1,4 @@ -// Generated automatically by nearley, version 2.20.1 +// Generated automatically by nearley, version 2.16.0 // http://github.com/Hardmath123/nearley function id(x) { return x[0]; } @@ -93,7 +93,7 @@ let ParserRules = [ d => [d[2], ...d[3]] }, {"name": "arguments", "symbols": [{"literal":"("}, "_", {"literal":")"}], "postprocess": d => []}, - {"name": "indexExpression", "symbols": ["arrayExpression", {"literal":"["}, "_", "expression", "_", {"literal":"]"}], "postprocess": d => node.index.create({array: d[0], index: d[3]})}, + {"name": "indexExpression", "symbols": ["indexExpression", {"literal":"["}, "_", "expression", "_", {"literal":"]"}], "postprocess": d => node.index.create({array: d[0], index: d[3]})}, {"name": "indexExpression", "symbols": ["arrayExpression"], "postprocess": id}, {"name": "arrayExpression$subexpression$1", "symbols": ["expression"], "postprocess": d => d[0]}, {"name": "arrayExpression$ebnf$1", "symbols": []}, diff --git a/app/imports/parser/grammar.ne b/app/imports/parser/grammar.ne index e008ac54..39407980 100644 --- a/app/imports/parser/grammar.ne +++ b/app/imports/parser/grammar.ne @@ -125,7 +125,7 @@ arguments -> | "(" _ ")" {% d => [] %} indexExpression -> - arrayExpression "[" _ expression _ "]" {% d => node.index.create({array: d[0], index: d[3]}) %} + indexExpression "[" _ expression _ "]" {% d => node.index.create({array: d[0], index: d[3]}) %} | arrayExpression {% id %} arrayExpression -> From d973463126301e09e4aebec5b61fa609191ec9e2 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 12:35:54 +0200 Subject: [PATCH 17/22] Prevented props deactivated by toggles from firing --- app/imports/api/engine/actions/applyProperty.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/imports/api/engine/actions/applyProperty.js b/app/imports/api/engine/actions/applyProperty.js index eb4ae157..18f35d32 100644 --- a/app/imports/api/engine/actions/applyProperty.js +++ b/app/imports/api/engine/actions/applyProperty.js @@ -27,6 +27,7 @@ const applyPropertyByType = { }; export default function applyProperty(node, actionContext, ...rest) { + if (node.node.deactivatedByToggle) return; actionContext.scope[`#${node.node.type}`] = node.node; applyPropertyByType[node.node.type]?.(node, actionContext, ...rest); } From 7fa993de47fcb9dd71268f985a6a6a9b2cd499ac Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 13:00:26 +0200 Subject: [PATCH 18/22] Slot fill now shows selected slots while searching --- .../ui/creature/slots/SlotFillDialog.vue | 12 ++++- .../server/publications/slotFillers.js | 53 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/app/imports/client/ui/creature/slots/SlotFillDialog.vue b/app/imports/client/ui/creature/slots/SlotFillDialog.vue index 197aedd0..1bda0853 100644 --- a/app/imports/client/ui/creature/slots/SlotFillDialog.vue +++ b/app/imports/client/ui/creature/slots/SlotFillDialog.vue @@ -58,7 +58,7 @@ multiple hover > -