Removed custom Collection2 package
This commit is contained in:
@@ -4,7 +4,7 @@ import getEffectivePropTags from '/imports/api/engine/computation/utility/getEff
|
||||
import type { Creature } from '/imports/api/creature/creatures/Creatures';
|
||||
import type { CreatureProperty } from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
|
||||
type ComputationProperty = CreatureProperty & {
|
||||
export type ComputationProperty = CreatureProperty & {
|
||||
_computationDetails: {
|
||||
calculations: any[],
|
||||
emptyCalculations: any[],
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import walkDown from '/imports/api/engine/computation/utility/walkdown';
|
||||
import { getEffectTagTargets } from '/imports/api/engine/computation/buildComputation/linkTypeDependencies';
|
||||
import { Forest, TreeNode } from '/imports/api/parenting/parentingFunctions';
|
||||
import { CreatureProperty } from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
import { ComputationProperty } from '/imports/api/engine/computation/CreatureComputation';
|
||||
import CreatureComputation from '/imports/api/engine/computation/CreatureComputation';
|
||||
|
||||
export default function computeToggleDependencies(
|
||||
node: TreeNode<CreatureProperty>, computation: CreatureComputation, forest: Forest<CreatureProperty>
|
||||
node: TreeNode<ComputationProperty>, computation: CreatureComputation, forest: Forest<ComputationProperty>
|
||||
) {
|
||||
const prop = node.doc
|
||||
// Only for toggles
|
||||
|
||||
@@ -32,7 +32,11 @@ import type { Creature } from '/imports/api/creature/creatures/Creatures';
|
||||
|
||||
export default function buildCreatureComputation(creatureId: string) {
|
||||
const creature = getCreature(creatureId);
|
||||
if (!creature) return;
|
||||
if (!creature) {
|
||||
throw new Meteor.Error('not-found',
|
||||
'Build computation failed, the creature was not found'
|
||||
);
|
||||
}
|
||||
const variables = getVariables(creatureId);
|
||||
const properties = getProperties(creatureId);
|
||||
const computation = buildComputationFromProps(properties, creature, variables);
|
||||
@@ -81,7 +85,7 @@ export function buildComputationFromProps(
|
||||
});
|
||||
|
||||
// Get all the properties as a forest, with their nested set properties set
|
||||
const forest = applyNestedSetProperties(properties);
|
||||
const forest = applyNestedSetProperties(computation.props);
|
||||
|
||||
// Walk the property trees computing things that need to be inherited
|
||||
walkDown(forest.trees, node => {
|
||||
@@ -98,7 +102,7 @@ export function buildComputationFromProps(
|
||||
linkInventory(forest, dependencyGraph);
|
||||
|
||||
// Link functions that require the above to be complete
|
||||
properties.forEach(prop => {
|
||||
computation.props.forEach(prop => {
|
||||
linkTypeDependencies(dependencyGraph, prop, computation);
|
||||
linkCalculationDependencies(dependencyGraph, prop, computation);
|
||||
});
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import computeCreatureComputation from './computeCreatureComputation';
|
||||
import { buildComputationFromProps } from './buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
import CreatureProperties, { CreatureProperty } from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
import computeTests from './computeComputation/tests/index';
|
||||
import Creatures, { Creature } from 'imports/api/creature/creatures/Creatures';
|
||||
|
||||
describe('Compute compuation', function () {
|
||||
describe('Compute computation', function () {
|
||||
it('Computes something at all', function () {
|
||||
let computation = buildComputationFromProps(testProperties);
|
||||
const creature: Creature = Creatures.schema.clean({});
|
||||
const computation = buildComputationFromProps(testProperties, creature, {});
|
||||
computeCreatureComputation(computation);
|
||||
assert.exists(computation);
|
||||
});
|
||||
computeTests.forEach(test => it(test.text, test.fn));
|
||||
});
|
||||
|
||||
var testProperties = [
|
||||
const testProperties = [
|
||||
clean({
|
||||
_id: 'attributeId123',
|
||||
type: 'attribute',
|
||||
@@ -28,7 +30,8 @@ var testProperties = [
|
||||
}),
|
||||
];
|
||||
|
||||
function clean(prop) {
|
||||
let schema = CreatureProperties.simpleSchema(prop);
|
||||
function clean(prop: Partial<CreatureProperty>): CreatureProperty {
|
||||
// @ts-expect-error don't have types for .simpleSchema
|
||||
const schema = CreatureProperties.simpleSchema(prop);
|
||||
return schema.clean(prop);
|
||||
}
|
||||
Reference in New Issue
Block a user