aboutsummaryrefslogtreecommitdiff
path: root/webAO/packets/handlers/handleSI.ts
blob: f20f4b2d2a240abb930a69cf0000a88d2c166dcb (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
34
35
36
37
import { client, extrafeatures, oldLoading } from "../../client";
import { fetchExtensions } from "../../client/fetchLists";

/**
 * Received when the server announces its server info,
 * but we use it as a cue to begin retrieving characters.
 * @param {Array} args packet arguments
 */
export const handleSI = (args: string[]) => {
  client.char_list_length = Number(args[1]);
  client.evidence_list_length = Number(args[2]);
  client.music_list_length = Number(args[3]);

  fetchExtensions();

  // create the charselect grid, to be filled by the character loader
  document.getElementById("client_chartable")!.innerHTML = "";

  for (let i = 0; i < client.char_list_length; i++) {
    const demothing = document.createElement("img");

    demothing.className = "demothing";
    demothing.id = `demo_${i}`;
    const demoonclick = document.createAttribute("onclick");
    demoonclick.value = `pickChar(${i})`;
    demothing.setAttributeNode(demoonclick);

    document.getElementById("client_chartable")!.appendChild(demothing);
  }

  // this is determined at the top of this file
  if (!oldLoading) {
    client.sender.sendServer("RC#%");
  } else {
    client.sender.sendServer("askchar2#%");
  }
};