about summary refs log tree commit diff
path: root/assets/src/state/constant_state.ts
blob: aeda86e889294c864871531a5542a0a4a2951075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Cannot be changed after being set.

import { RookType } from "../models/rook_type";

let clientType: RookType = null;

export function setClientType(type: RookType) {
    if (clientType !== null) {
        clientType = type;
    } else {
        throw new Error("Tried changing client type after initialization.");
    }
}

export function isClientShare() {
    if (clientType === null) {
        throw new Error(
            "Tried accessing client type before initialization was completed."
        );
    }

    return clientType === RookType.SHARE;
}

export function isClientRequest() {
    if (clientType === null) {
        throw new Error(
            "Tried accessing client type before initialization was completed."
        );
    }

    return clientType === RookType.REQUEST;
}