Fixed loading filtered properties in contexts where iterators don't have .filter
This commit is contained in:
@@ -211,7 +211,7 @@ describe('Apply Damage Properties', function () {
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only('Applies effects when doing damage', async function () {
|
it('Applies effects when doing damage', async function () {
|
||||||
const action = await runActionById(damageWithEffectsId, [targetCreatureId]);
|
const action = await runActionById(damageWithEffectsId, [targetCreatureId]);
|
||||||
assert.exists(action);
|
assert.exists(action);
|
||||||
assert.deepEqual(allMutations(action), [{
|
assert.deepEqual(allMutations(action), [{
|
||||||
|
|||||||
@@ -84,10 +84,9 @@ export function getProperties(creatureId: string): CreatureProperty[] {
|
|||||||
export function getPropertiesOfType(creatureId, propType) {
|
export function getPropertiesOfType(creatureId, propType) {
|
||||||
const creature = loadedCreatures.get(creatureId);
|
const creature = loadedCreatures.get(creatureId);
|
||||||
if (creature) {
|
if (creature) {
|
||||||
const props = Array.from(
|
const props = Array.from(creature.properties.values())
|
||||||
creature.properties.values()
|
.filter(prop => !prop.removed && prop.type === propType)
|
||||||
.filter(prop => !prop.removed && prop.type === propType)
|
.sort((a, b) => a.left - b.left);
|
||||||
).sort((a, b) => a.left - b.left);
|
|
||||||
return EJSON.clone(props);
|
return EJSON.clone(props);
|
||||||
}
|
}
|
||||||
// console.time(`Cache miss on creature properties: ${creatureId}`)
|
// console.time(`Cache miss on creature properties: ${creatureId}`)
|
||||||
@@ -111,10 +110,9 @@ export function getPropertiesOfType(creatureId, propType) {
|
|||||||
export function getPropertiesByFilter(creatureId, filterFn: (any) => boolean, mongoFilter: Mongo.Selector<object>) {
|
export function getPropertiesByFilter(creatureId, filterFn: (any) => boolean, mongoFilter: Mongo.Selector<object>) {
|
||||||
const creature = loadedCreatures.get(creatureId);
|
const creature = loadedCreatures.get(creatureId);
|
||||||
if (creature) {
|
if (creature) {
|
||||||
const props: CreatureProperty[] = Array.from(
|
const props: CreatureProperty[] = Array.from(creature.properties.values())
|
||||||
creature.properties.values()
|
.filter(filterFn)
|
||||||
.filter(filterFn)
|
.sort((a, b) => a.left - b.left);
|
||||||
).sort((a, b) => a.left - b.left);
|
|
||||||
return EJSON.clone(props);
|
return EJSON.clone(props);
|
||||||
}
|
}
|
||||||
// console.time(`Cache miss on creature properties: ${creatureId}`)
|
// console.time(`Cache miss on creature properties: ${creatureId}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user