mirror of
https://github.com/mehotkhan/BandersnatchInteractive.git
synced 2025-07-28 01:33:23 +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') {
|
} else if (cond[0] == 'not') {
|
||||||
return '!(' + preconditionToJS(cond[1]) + ')';
|
return '!(' + preconditionToJS(cond[1]) + ')';
|
||||||
} else if (cond[0] == 'and') {
|
} else if (cond[0] == 'and') {
|
||||||
let conds = [];
|
return '(' + cond.slice(1).map(preconditionToJS).join(' && ') + ')';
|
||||||
for (let i = 1; i < cond.length; i++) {
|
|
||||||
conds.push('(' + preconditionToJS(cond[i]) + ')');
|
|
||||||
}
|
|
||||||
return '(' + conds.join(' && ') + ')';
|
|
||||||
} else if (cond[0] == 'or') {
|
} else if (cond[0] == 'or') {
|
||||||
let conds = [];
|
return '(' + cond.slice(1).map(preconditionToJS).join(' || ') + ')';
|
||||||
for (let i = 1; i < cond.length; i++) {
|
|
||||||
conds.push('(' + preconditionToJS(cond[i]) + ')');
|
|
||||||
}
|
|
||||||
return '(' + conds.join(' || ') + ')';
|
|
||||||
} else {
|
} else {
|
||||||
console.log('unsupported condition!', cond);
|
console.log('unsupported condition!', cond);
|
||||||
return 'true';
|
return 'true';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue