This commit is contained in:
2025-11-19 22:01:25 +02:00
parent afef35b6f6
commit 3a7686713f
16 changed files with 276 additions and 212 deletions

View File

@@ -24,26 +24,28 @@ export type RegretevatorState = DeadUnknownState | InElevatorState;
export function getRegretevatorState(): null | RegretevatorState {
if (!existsSync(STATE_FILE_PATH)) return null;
try {
const {text, tooltip}: { text: string, tooltip: string } = JSON.parse(readFileSync(STATE_FILE_PATH).toString('utf-8'))
const { text, tooltip }: { text: string; tooltip: string } = JSON.parse(
readFileSync(STATE_FILE_PATH).toString("utf-8"),
);
if (/^On Floor ([0-9]+)$/.test(tooltip)) {
const floorNum = tooltip.match(/^On Floor ([0-9]+)$/)![1]
const floorNum = tooltip.match(/^On Floor ([0-9]+)$/)![1];
return {
floor: Number(floorNum),
state: "INGAME",
isGoingUp: false
}
isGoingUp: false,
};
}
if (/^Floor ([0-9]+)/.test(tooltip)) {
const floorNum = tooltip.match(/^Floor ([0-9]+)/)![1]
const floorNum = tooltip.match(/^Floor ([0-9]+)/)![1];
return {
floor: Number(floorNum),
state: "INGAME",
isGoingUp: true
}
isGoingUp: true,
};
}
return {
state: "UNKNOWN"
}
state: "UNKNOWN",
};
} catch {}
return null;
}