Start of action system re-write

This commit is contained in:
Stefan Zermatten
2021-10-09 12:36:06 +02:00
parent 0097696cc8
commit 0cdec4a429
41 changed files with 783 additions and 119 deletions

View File

@@ -43,11 +43,24 @@ export function traverse(node, fn){
return fn(node);
}
export function map(node, fn){
if (!node) return;
let type = nodeTypeIndex[node.parseType];
if (!type){
console.error(node);
throw new Meteor.Error('Not valid parse node');
}
if (type.map){
return type.map(node, fn);
}
return fn(node);
}
export class Context {
constructor({errors = [], rolls = [], doubleRolls} = {}){
constructor({errors = [], rolls = [], options = {}} = {}){
this.errors = errors;
this.rolls = rolls;
this.doubleRolls = doubleRolls;
this.options = options;
}
error(e){
if (!e) return;