Updated forms and some UI for new data structure

This commit is contained in:
Stefan Zermatten
2021-09-28 14:25:11 +02:00
parent b471d0c5cf
commit cb10b53a10
52 changed files with 304 additions and 301 deletions

View File

@@ -7,10 +7,12 @@ export default function(){
const computation = buildComputationFromProps(testProperties);
computeCreatureComputation(computation);
const prop = id => computation.propsById[id];
const scope = variableName => computation.scope[variableName];
assert.equal(prop('emptyId').value, 0);
assert.equal(prop('noVariableNameId').value, 8);
assert.equal(prop('strengthId').value, 12);
assert.equal(prop('strengthId').modifier, 1);
assert.equal(scope('strength').modifier, 1);
assert.equal(prop('referencesDexId').value, 4);
assert.equal(prop('hitDiceId').constitutionMod, 5);
assert.equal(

View File

@@ -36,9 +36,6 @@ function addChangedKeysToOp(op, keys, original, changed) {
// and compile an operation that sets all those keys
for (let key of keys){
if (!isEqual(original[key], changed[key])){
console.log('not equal: ', key);
console.log(original[key])
console.log(changed[key])
if (!op) op = newOperation(original._id, changed.type);
let value = changed[key];
if (value === undefined){
@@ -86,7 +83,6 @@ function addUnsetOp(op, key){
// compensation without needing to roll back changes, which causes multiple
// expensive redraws of the character sheet
function writePropertiesSequentially(bulkWriteOps){
console.log({opsLength: bulkWriteOps.length});
bulkWriteOps.forEach(op => {
let updateOneOrMany = op.updateOne || op.updateMany;
CreatureProperties.update(updateOneOrMany.filter, updateOneOrMany.update, {
@@ -95,7 +91,7 @@ function writePropertiesSequentially(bulkWriteOps){
bypassCollection2: true,
});
});
console.log('finished writing ops');
if (bulkWriteOps.length) console.log(`Wrote ${bulkWriteOps.length} props`);
}
// This is more efficient on the database, but significantly less efficient

View File

@@ -3,9 +3,11 @@ import computeCreatureComputation from './computation/computeCreatureComputation
import writeAlteredProperties from './computation/writeComputation/writeAlteredProperties.js';
export default function computeCreature(creatureId){
console.time('Compute creature');
const computation = buildCreatureComputation(creatureId);
computeCreatureComputation(computation);
writeAlteredProperties(computation);
console.timeEnd('Compute creature');
}
// For now just recompute the whole creature, TODO only recompute a single

View File

@@ -9,7 +9,7 @@ export default function applyAttack({
let value = roll(1, 20)[0];
actionContext.attackRoll = {value};
let criticalHitTarget = creature.variables.criticalHitTarget &&
creature.variables.criticalHitTarget.currentValue || 20;
creature.variables.criticalHitTarget.value || 20;
let criticalHit = value >= criticalHitTarget;
if (criticalHit) actionContext.criticalHit = {value: true};
let result = value + prop.rollBonusResult;

View File

@@ -49,7 +49,7 @@ const castSpellWithSlot = new ValidatedMethod({
throw new Meteor.Error('No slot',
'Slot not found to cast spell');
}
if (!slot.currentValue){
if (!slot.value){
throw new Meteor.Error('No slot',
'Slot depleted');
}