mirror of
https://github.com/mehotkhan/BandersnatchInteractive.git
synced 2025-07-28 01:33:23 +00:00
assets/scripts.js: Check moment preconditions
This commit is contained in:
parent
59782b0707
commit
60fd4fa882
1 changed files with 7 additions and 7 deletions
|
@ -39,21 +39,21 @@ function preconditionToJS(cond) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPrecondition(preconditionId) {
|
function evalPrecondition(precondition, text) {
|
||||||
let precondition = bv.preconditions[preconditionId];
|
|
||||||
|
|
||||||
if (precondition) {
|
if (precondition) {
|
||||||
let cond = preconditionToJS(precondition);
|
let cond = preconditionToJS(precondition);
|
||||||
let match = eval(cond);
|
let match = eval(cond);
|
||||||
|
console.log(text, ':', cond, '==', match);
|
||||||
console.log(preconditionId, ':', cond, '==', match);
|
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkPrecondition(preconditionId) {
|
||||||
|
return evalPrecondition(bv.preconditions[preconditionId], preconditionId);
|
||||||
|
}
|
||||||
|
|
||||||
function resolveSegmentGroup(sg) {
|
function resolveSegmentGroup(sg) {
|
||||||
let results = [];
|
let results = [];
|
||||||
for (let v of segmentGroups[sg]) {
|
for (let v of segmentGroups[sg]) {
|
||||||
|
@ -99,7 +99,7 @@ function getMoments(segmentId, ms) {
|
||||||
let moments = momentsBySegment[segmentId] || [];
|
let moments = momentsBySegment[segmentId] || [];
|
||||||
for (let i = 0; i < moments.length; i++) {
|
for (let i = 0; i < moments.length; i++) {
|
||||||
let m = moments[i];
|
let m = moments[i];
|
||||||
if (ms >= m.startMs && ms < m.endMs) {
|
if (ms >= m.startMs && ms < m.endMs && evalPrecondition(m.precondition)) {
|
||||||
result[segmentId + '/' + i] = m;
|
result[segmentId + '/' + i] = m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue