mirror of
https://github.com/mehotkhan/BandersnatchInteractive.git
synced 2025-07-27 17:23:22 +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) {
|
||||
let precondition = bv.preconditions[preconditionId];
|
||||
|
||||
function evalPrecondition(precondition, text) {
|
||||
if (precondition) {
|
||||
let cond = preconditionToJS(precondition);
|
||||
let match = eval(cond);
|
||||
|
||||
console.log(preconditionId, ':', cond, '==', match);
|
||||
|
||||
console.log(text, ':', cond, '==', match);
|
||||
return match;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkPrecondition(preconditionId) {
|
||||
return evalPrecondition(bv.preconditions[preconditionId], preconditionId);
|
||||
}
|
||||
|
||||
function resolveSegmentGroup(sg) {
|
||||
let results = [];
|
||||
for (let v of segmentGroups[sg]) {
|
||||
|
@ -99,7 +99,7 @@ function getMoments(segmentId, ms) {
|
|||
let moments = momentsBySegment[segmentId] || [];
|
||||
for (let i = 0; i < moments.length; 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue