mirror of
https://github.com/mehotkhan/BandersnatchInteractive.git
synced 2025-07-28 01:33:23 +00:00
assets/scripts.js: Rename generateJs to preconditionToJS
This commit is contained in:
parent
350a2caead
commit
588036f80e
1 changed files with 5 additions and 5 deletions
|
@ -21,21 +21,21 @@ function getCurrentMs() {
|
||||||
return Math.round(document.getElementById("video").currentTime * 1000.0);
|
return Math.round(document.getElementById("video").currentTime * 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateJs(cond) {
|
function preconditionToJS(cond) {
|
||||||
if (cond[0] == 'persistentState') {
|
if (cond[0] == 'persistentState') {
|
||||||
return '!!persistentState["' + cond[1] + '"]';
|
return '!!persistentState["' + cond[1] + '"]';
|
||||||
} else if (cond[0] == 'not') {
|
} else if (cond[0] == 'not') {
|
||||||
return '!(' + generateJs(cond[1]) + ')';
|
return '!(' + preconditionToJS(cond[1]) + ')';
|
||||||
} else if (cond[0] == 'and') {
|
} else if (cond[0] == 'and') {
|
||||||
let conds = [];
|
let conds = [];
|
||||||
for (let i = 1; i < cond.length; i++) {
|
for (let i = 1; i < cond.length; i++) {
|
||||||
conds.push('(' + generateJs(cond[i]) + ')');
|
conds.push('(' + preconditionToJS(cond[i]) + ')');
|
||||||
}
|
}
|
||||||
return '(' + conds.join(' && ') + ')';
|
return '(' + conds.join(' && ') + ')';
|
||||||
} else if (cond[0] == 'or') {
|
} else if (cond[0] == 'or') {
|
||||||
let conds = [];
|
let conds = [];
|
||||||
for (let i = 1; i < cond.length; i++) {
|
for (let i = 1; i < cond.length; i++) {
|
||||||
conds.push('(' + generateJs(cond[i]) + ')');
|
conds.push('(' + preconditionToJS(cond[i]) + ')');
|
||||||
}
|
}
|
||||||
return '(' + conds.join(' || ') + ')';
|
return '(' + conds.join(' || ') + ')';
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,7 +48,7 @@ function checkPrecondition(segmentId) {
|
||||||
let precondition = bv.preconditions[segmentId];
|
let precondition = bv.preconditions[segmentId];
|
||||||
|
|
||||||
if (precondition) {
|
if (precondition) {
|
||||||
let cond = generateJs(precondition);
|
let cond = preconditionToJS(precondition);
|
||||||
let match = eval(cond);
|
let match = eval(cond);
|
||||||
|
|
||||||
console.log(cond, '==', match);
|
console.log(cond, '==', match);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue