+ if (type === 'pull') {
+ last_pull_was_ours = true;
+ } else if (type === 'their_pull') {
+ last_pull_was_ours = false;
+ } else if (type === 'set_offense' && last_pull_was_ours === null) {
+ // set_offense could either be “changed to offense for some reason
+ // we could not express”, or “we started in the middle of a point,
+ // and we are offense”. We assume that if we already saw the pull,
+ // it's the former, and if not, it's the latter; thus, the === null
+ // test above. (It could also be “we set offense before the pull,
+ // so that we get the right button enabled”, in which case it will
+ // be overwritten by the next pull/their_pull event anyway.)
+ last_pull_was_ours = false;
+ } else if (type === 'set_defense' && last_pull_was_ours === null) {
+ // Similar.
+ last_pull_was_ours = true;
+ } else if (type === 'goal' || type === 'their_goal') {
+ last_pull_was_ours = null;
+ }