Merge branch 'develop'

This commit is contained in:
Stefan Zermatten
2023-07-21 16:17:42 +02:00
9 changed files with 53 additions and 44 deletions

View File

@@ -151,11 +151,6 @@ let CreatureSchema = new SimpleSchema({
blackbox: true,
defaultValue: {}
},
variables: {
type: Object,
blackbox: true,
defaultValue: {}
},
computeErrors: {
type: Array,
optional: true,

View File

@@ -2,9 +2,8 @@ import operator from '/imports/parser/parseTree/operator.js';
import { parse } from '/imports/parser/parser.js';
import logErrors from './logErrors.js';
export default function applyEffectsToCalculationParseNode(calcObj, actionContext){
if (!calcObj.effects) return;
calcObj.effects.forEach(effect => {
export default function applyEffectsToCalculationParseNode(calcObj, actionContext) {
calcObj.effects?.forEach(effect => {
if (effect.operation !== 'add') return;
if (!effect.amount) return;
if (effect.amount.value === null) return;
@@ -17,8 +16,31 @@ export default function applyEffectsToCalculationParseNode(calcObj, actionContex
operator: '+',
fn: 'add'
});
} catch (e){
} catch (e) {
logErrors([e], actionContext)
}
});
// Add the highest proficiency as well
let highestProficiency;
calcObj.proficiencies?.forEach(proficiency => {
if (
proficiency.value > highestProficiency
|| (highestProficiency === undefined && Number.isFinite(proficiency.value))
) {
highestProficiency = proficiency.value;
}
});
if (highestProficiency) {
try {
let profParseNode = parse(highestProficiency.toString());
calcObj.parseNode = operator.create({
left: calcObj.parseNode,
right: profParseNode,
operator: '+',
fn: 'add'
});
} catch (e) {
logErrors([e], actionContext)
}
}
}

View File

@@ -2,7 +2,7 @@ import evaluateCalculation from '/imports/api/engine/computation/utility/evaluat
import applyEffectsToCalculationParseNode from '/imports/api/engine/actions/applyPropertyByType/shared/applyEffectsToCalculationParseNode.js';
import logErrors from './logErrors.js';
export default function recalculateCalculation(calc, actionContext, context){
export default function recalculateCalculation(calc, actionContext, context) {
if (!calc?.parseNode) return;
calc._parseLevel = 'reduce';
applyEffectsToCalculationParseNode(calc, actionContext);

View File

@@ -1,14 +1,14 @@
import resolve, { toString } from '/imports/parser/resolve.js';
export default function evaluateCalculation(calculation, scope, givenContext){
export default function evaluateCalculation(calculation, scope, givenContext) {
const parseNode = calculation.parseNode;
const fn = calculation._parseLevel;
const calculationScope = {...calculation._localScope, ...scope};
const {result: resultNode, context} = resolve(fn, parseNode, calculationScope, givenContext);
const calculationScope = { ...calculation._localScope, ...scope };
const { result: resultNode, context } = resolve(fn, parseNode, calculationScope, givenContext);
calculation.errors = context.errors;
if (resultNode?.parseType === 'constant'){
if (resultNode?.parseType === 'constant') {
calculation.value = resultNode.value;
} else if (resultNode?.parseType === 'error'){
} else if (resultNode?.parseType === 'error') {
calculation.value = null;
} else {
calculation.value = toString(resultNode);

View File

@@ -28,8 +28,8 @@ const duplicateLibraryNode = new ValidatedMethod({
}).validator(),
mixins: [RateLimiterMixin],
rateLimit: {
numRequests: 1,
timeInterval: 5000,
numRequests: 4,
timeInterval: 6000,
},
run({ _id }) {
let libraryNode = LibraryNodes.findOne(_id);

View File

@@ -16,42 +16,27 @@ export default {
wideColumns: Boolean,
},
};
/*
Removed to improve chrome layout performance, put it back if there are rendering errors
.column-layout>span>div {
display: table;
table-layout: fixed;
}
*/
</script>
<style lang="css">
.column-layout {
column-count: 12;
column-fill: balance;
column-gap: 0;
column-gap: 8px;
column-width: 240px;
transform: translateZ(0);
padding: 4px;
padding: 8px;
}
.column-layout.wide-columns {
column-count: 12;
column-fill: balance;
column-gap: 0;
column-width: 320px;
transform: translateZ(0);
padding: 4px;
}
.column-layout>div,
.column-layout>*,
.column-layout>span>div {
width: 100%;
backface-visibility: hidden;
transform: translateX(0);
page-break-inside: avoid;
display: inline-block;
break-inside: avoid;
padding: 4px;
page-break-inside: avoid;
margin-bottom: 8px;
width: 100%;
}
</style>

View File

@@ -596,7 +596,6 @@ export default {
margin-top: 4px;
margin-left: -30px;
padding-left: 34px;
z-index: -1;
}
.number-label .number {

View File

@@ -30,7 +30,7 @@
v-else-if="model.attributeType === 'resource'"
:model="model"
@click="$emit('click')"
@change="({ type, value }) => damageProperty({type, value: -value})"
@change="({ type, value, ack }) => damageProperty({type, value: -value, ack})"
@mouseover="hover = true"
@mouseleave="hover = false"
/>
@@ -96,6 +96,9 @@ export default {
_id: this.model._id,
operation: change.type,
value: change.value
}, e => {
console.log(change);
change.ack?.(e);
});
},
log({_id}) {

View File

@@ -41,16 +41,21 @@ Meteor.publish('slotFillers', function (slotId, searchTerm, isDummySlot) {
sort: { name: 1 }
});
// Build a filter for nodes in those libraries that match the slot
let filter = getSlotFillFilter({ slot, libraryIds });
this.autorun(function () {
// Build a filter for nodes in those libraries that match the slot
let filter = getSlotFillFilter({ slot, libraryIds });
// Get the limit of the documents the user can fetch
var limit = self.data('limit') || 50;
check(limit, Number);
let options = undefined;
if (searchTerm) {
filter.name = { $regex: escapeRegex(searchTerm), '$options': 'i' };
filter.$and.push({
$or: [
{ name: { $regex: escapeRegex(searchTerm), '$options': 'i' } },
{ libraryTags: searchTerm }
]
});
//filter.$text = { $search: searchTerm };
options = {
// relevant documents have a higher score.