mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-09 17:04:30 +08:00
add helpers
This commit is contained in:
parent
ac24f4c38e
commit
4cefd8152b
2 changed files with 17 additions and 0 deletions
|
|
@ -54,6 +54,19 @@ export function getSelf(): TribeTypes.User | undefined {
|
|||
return room?.users?.[TribeSocket.getId()];
|
||||
}
|
||||
|
||||
export function isLeader(): boolean {
|
||||
return getSelf()?.isLeader ?? false;
|
||||
}
|
||||
|
||||
export function isInARoom(): boolean {
|
||||
return getState() >= 5;
|
||||
}
|
||||
|
||||
export function isRaceActive(): boolean {
|
||||
const s = getState();
|
||||
return s >= 10 && s <= 20;
|
||||
}
|
||||
|
||||
export function canChangeConfig(override: boolean): boolean {
|
||||
if (getState() <= 1) return true;
|
||||
if (getSelf()?.isLeader) {
|
||||
|
|
|
|||
|
|
@ -195,6 +195,10 @@ export function initRace(): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function readyUp(): void {
|
||||
TribeSocket.out.room.readyUpdate();
|
||||
}
|
||||
|
||||
async function connect(): Promise<void> {
|
||||
const versionCheck =
|
||||
await TribeSocket.out.system.versionCheck(expectedVersion);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue