- take_off_field(p, t, live_since, offense);
+ take_off_field(p, t, live_since, offense, keep);
+ if (keep && !keep_event(players, filters)) {
+ // A player needed for the filters went off the field,
+ // so we need to attribute time for all the others.
+ // Pretend they walked off and then immediately on again.
+ //
+ // TODO: We also need to take care of this to get the globals right.
+ for (const [q,p2] of Object.entries(players)) {
+ if (p2.on_field_since !== null) {
+ take_off_field(p2, t, live_since, offense, keep);
+ p2.on_field_since = t;
+ }
+ }
+ }