Files
DiceCloud/app/imports/parser/parseTree/rollArray.js
Stefan Zermatten 59c69a46a8 Attacks can now be rolled with advantage from the stats tab
TODO the action viewer as well still
2022-02-25 13:44:09 +02:00

33 lines
618 B
JavaScript

import constant from './constant.js';
const rollArray = {
create({values, diceSize, diceNum}) {
return {
parseType: 'rollArray',
values,
diceSize,
diceNum,
};
},
compile(node, scope, context){
return {
result: node,
context
};
},
toString(node){
return `${node.diceNum || ''}d${node.diceSize} [ ${node.values.join(', ')} ]`;
},
reduce(node, scope, context){
const total = node.values.reduce((a, b) => a + b, 0);
return {
result: constant.create({
value: total,
}),
context,
};
},
}
export default rollArray;