mirror of
https://github.com/mehotkhan/BandersnatchInteractive.git
synced 2025-07-27 17:23:22 +00:00
assets/scripts.js: Simplify some precondition code
This commit is contained in:
parent
60fd4fa882
commit
f9b7bc840c
1 changed files with 2 additions and 10 deletions
|
@ -22,17 +22,9 @@ function preconditionToJS(cond) {
|
|||
} else if (cond[0] == 'not') {
|
||||
return '!(' + preconditionToJS(cond[1]) + ')';
|
||||
} else if (cond[0] == 'and') {
|
||||
let conds = [];
|
||||
for (let i = 1; i < cond.length; i++) {
|
||||
conds.push('(' + preconditionToJS(cond[i]) + ')');
|
||||
}
|
||||
return '(' + conds.join(' && ') + ')';
|
||||
return '(' + cond.slice(1).map(preconditionToJS).join(' && ') + ')';
|
||||
} else if (cond[0] == 'or') {
|
||||
let conds = [];
|
||||
for (let i = 1; i < cond.length; i++) {
|
||||
conds.push('(' + preconditionToJS(cond[i]) + ')');
|
||||
}
|
||||
return '(' + conds.join(' || ') + ')';
|
||||
return '(' + cond.slice(1).map(preconditionToJS).join(' || ') + ')';
|
||||
} else {
|
||||
console.log('unsupported condition!', cond);
|
||||
return 'true';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue