<commit_before>"use strict"

let io: WebSocket | null
let connectionInfo: PIXI.Text
let states: IState[] = []

interface IState {
    actors: IActor[], // TODO: Somehow use a Map for this
    timestamp: number,
    tick: number,
}

type Id = string
interface IActor {
    id: Id,
    kind: ActorKind
}
enum ActorKind {
    Player = "Player",
    Ball = "Ball",
}

interface IInput {
    id: number,
    key: string,
    pressed: boolean,
}

enum OpCode {
    Greeting = "Greeting",
    Spawn = "Spawn",
    Despawn = "Despawn",
    WorldUpdate = "WorldUpdate",
}

let ownId: Id

interface IServerMessage {
    opcode: OpCode,
    payload: any,
    tick: number
}

const unconfirmedInputs: IInput[] = []
const MIN_WAIT = 100
let wait = MIN_WAIT
let actors = new Map<Id, PIXI.Sprite>()
function connect (address: string): void {
    io = new WebSocket(address)
    io.onopen = () => {
        resetWait()
        connectionInfo.visible = false
    }

    io.onmessage = (serializedMsg) => {
        const msg: IServerMessage = JSON.parse(serializedMsg.data, (_, value) => value === "" ? 0 : value)

        switch (msg.opcode) {
        case OpCode.Greeting:
            ownId = msg.payload[0]
            const presentActors = msg.payload[1]
            for (const actor of presentActors) {
                spawnActor(actor)
            }
            break
        case OpCode.Spawn:
            spawnActor(msg.payload)
            break
        case OpCode.Despawn:
            removeActor(msg.payload)
            break
        case OpCode.WorldUpdate:
            const state: IState = {
                actors: msg.payload.actors,
                timestamp: performance.now(),
                tick: msg.tick
            }
            states.push(state)
            const index = unconfirmedInputs.findIndex((input) => input.id === msg.payload.last_input) + 1
            if (index > 0) {
                unconfirmedInputs.splice(0, index)
            }
            break<commit_msg>Client: Accomodate to TSLint<commit_after>"use strict"

let io: WebSocket | null
let connectionInfo: PIXI.Text
let states: IState[] = []

interface IState {
    actors: IActor[], // TODO: Somehow use a Map for this
    timestamp: number,
    tick: number,
}

type Id = string
interface IActor {
    id: Id,
    kind: ActorKind
}
enum ActorKind {
    Player = "Player",
    Ball = "Ball",
}

interface IInput {
    id: number,
    key: string,
    pressed: boolean,
}

enum OpCode {
    Greeting = "Greeting",
    Spawn = "Spawn",
    Despawn = "Despawn",
    WorldUpdate = "WorldUpdate",
}

let ownId: Id

interface IServerMessage {
    opcode: OpCode,
    payload: any,
    tick: number
}

const unconfirmedInputs: IInput[] = []
const MIN_WAIT = 100
let wait = MIN_WAIT
let actors = new Map<Id, PIXI.Sprite>()
function connect (address: string): void {
    io = new WebSocket(address)
    io.onopen = () => {
        resetWait()
        connectionInfo.visible = false
    }

    io.onmessage = (serializedMsg) => {
        const msg: IServerMessage = JSON.parse(serializedMsg.data, (_, value) => value === "" ? 0 : value)

        switch (msg.opcode) {
        case OpCode.Greeting:
            ownId = msg.payload[0]
            const presentActors = msg.payload[1]
            for (const actor of presentActors) {
                spawnActor(actor)
            }
            break
        case OpCode.Spawn:
            spawnActor(msg.payload)
            break
        case OpCode.Despawn:
            removeActor(msg.payload)
            break
        case OpCode.WorldUpdate:
            const state: IState = {
                actors: msg.payload.actors,
                tick: msg.tick,
                timestamp: performance.now(),
            }
            states.push(state)
            const index = unconfirmedInputs.findIndex((input) => input.id === msg.payload.last_input) + 1
            if (index > 0) {
                unconfirmedInputs.splice(0, index)
            }
            break
{'fraction_non_alphanumeric': 0.10737581535373808, 'fraction_numerical': 0.004515805318615153, 'mean_word_length': 1.9533333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3360154', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1201, 'n_words': 312}