Skip to content

Commit

Permalink
feat: require vzero to recover from an alerter penalty
Browse files Browse the repository at this point in the history
According to Noah Belzoni, this is standard for Northeast railroads.
  • Loading branch information
YoRyan committed Jul 16, 2024
1 parent 14a2855 commit 7917046
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/lib/alerter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ export function create({
e.createPlayerWithKeyUpdateStream(),
frp.merge(acknowledgeStream$),
frp.fold((remainingS, input) => {
if (!frp.snapshot(cutIn)) {
return startS;
} else if (input === undefined) {
return startS;
} else if (frp.snapshot(acknowledge)) {
if (!frp.snapshot(cutIn)) return startS;

const ack = input === undefined || frp.snapshot(acknowledge);
if (remainingS <= 0) {
if (ack && frp.snapshot(vZero)) {
return startS;
} else {
return 0;
}
} else if (ack) {
return startS;
} else if (remainingS > 0 && frp.snapshot(vZero)) {
} else if (frp.snapshot(vZero)) {
return startS;
} else {
return Math.max(remainingS - input.dt, 0);
Expand Down

0 comments on commit 7917046

Please sign in to comment.