diff options
| -rw-r--r-- | webAO/client.js | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/webAO/client.js b/webAO/client.js index f9cdc52..d1bbe79 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -470,28 +470,28 @@ class Client extends EventEmitter { content: this.prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), sound: safe_tags(args[7]).toLowerCase(), - blips: msg_blips, - type: args[8], - charid: args[9], - snddelay: args[10], - objection: args[11], - evidence: args[12], - flip: args[13], - flash: args[14], - color: args[15], + blips: safe_tags(msg_blips), + type: Number(args[8]), + charid: Number(args[9]), + snddelay: Number(args[10]), + objection: Number(args[11]), + evidence: safe_tags(args[12]), + flip: Number(args[13]), + flash: Number(args[14]), + color: Number(args[15]), isnew: true, }; if (extrafeatures.includes("cccc_ic_support")) { const extra_options = { showname: safe_tags(args[16]), - other_charid: args[17], + other_charid: Number(args[17]), other_name: safe_tags(args[18]), other_emote: safe_tags(args[19]), - self_offset: args[20], - other_offset: args[21], - other_flip: args[22], - noninterrupting_preanim: args[23] + self_offset: Number(args[20]), + other_offset: Number(args[21]), + other_flip: Number(args[22]), + noninterrupting_preanim: Number(args[23]) }; chatmsg = Object.assign(extra_options, chatmsg); if (chatmsg.showname && document.getElementById("showname").checked) { @@ -1052,8 +1052,8 @@ class Client extends EventEmitter { updateActionCommands(me.side); for (let i = 1; i <= ini.emotions.number; i++) { const emoteinfo = ini.emotions[i].split("#"); - const esfx = ini.soundn[i] ? ini.soundn[i] : "0"; - const esfxd = ini.soundt[i] ? ini.soundt[i] : "0"; + const esfx = ini.soundn[i] || "0"; + const esfxd = Number(ini.soundt[i] || 0); // Make sure the asset server is case insensitive, or that everything on it is lowercase emotes[i] = { desc: emoteinfo[0].toLowerCase(), @@ -1082,27 +1082,27 @@ class Viewport { this.chatmsg = { "isnew": false, "content": "", - "objection": "0", + "objection": 0, "sound": "", "startpreanim": false, "startspeaking": false, "side": null, - "color": "0", + "color": 0, "snddelay": 0, "preanimdelay": 0 }; - this.colors = { - "0": "#ffffff", // white - "1": "#00ff00", // green - "2": "#ff0000", // red - "3": "#ffa500", // orange - "4": "#4596ff", // blue - "5": "#ffff00", // yellow - "6": "#fedcba", // 6 is rainbow. - "7": "#ffc0cb", // pink - "8": "#00ffff" // cyan - }; + this.colors = [ + "#ffffff", // white + "#00ff00", // green + "#ff0000", // red + "#ffa500", // orange + "#4596ff", // blue + "#ffff00", // yellow + "#fedcba", // 6 is rainbow. + "#ffc0cb", // pink + "#00ffff" // cyan + ]; this.blip = new Audio(AO_HOST + "sounds/general/sfx-blipmale.wav"); this.blip.volume = 0.5; @@ -1354,7 +1354,7 @@ class Viewport { const chatBoxInner = document.getElementById("client_inner_chat"); // Flip the character - if (this.chatmsg.flip === "1") { + if (this.chatmsg.flip === 1) { charSprite.style.transform = "scaleX(-1)"; } else { charSprite.style.transform = "scaleX(1)"; @@ -1362,7 +1362,7 @@ class Viewport { if (extrafeatures.includes("cccc_ic_support")) { // Flip the pair character - if (this.chatmsg.other_flip === "1") { + if (this.chatmsg.other_flip === 1) { pairSprite.style.transform = "scaleX(-1)"; } else { pairSprite.style.transform = "scaleX(1)"; @@ -1382,11 +1382,12 @@ class Viewport { chatBoxInner.className = ""; eviBox.style.opacity = "0"; eviBox.style.height = "0%"; - const shouts = { - "1": "holdit", - "2": "objection", - "3": "takethat" - }; + const shouts = [ + undefined, + "holdit", + "objection", + "takethat" + ]; // gets which shout shall played const shout = shouts[this.chatmsg.objection]; @@ -1406,14 +1407,14 @@ class Viewport { // TODO: preanims sometimes play when they're not supposed to if (this.textTimer >= this.shoutTimer && this.chatmsg.startpreanim) { // Effect stuff - if (this.chatmsg.flash === "2") { + if (this.chatmsg.flash === 2) { // Shake screen this.sfxaudio.pause(); this.sfxplayed = 1; this.sfxaudio.src = AO_HOST + "sounds/general/sfx-stab.wav"; this.sfxaudio.play(); document.getElementById("client_gamewindow").style.animation = "shake 0.2s 1"; - } else if (this.chatmsg.flash === "1") { + } else if (this.chatmsg.flash === 1) { // Flash screen this.sfxaudio.pause(); this.sfxplayed = 1; @@ -1479,7 +1480,7 @@ class Viewport { chatBox.style.display = "block"; chatBox.style.fontSize = (chatBox.offsetHeight * 0.25) + "px"; - if (this.chatmsg.color === "6") + if (this.chatmsg.color === 6) chatBoxInner.className = "rainbow-text"; else { chatBoxInner.className = ""; @@ -1648,7 +1649,7 @@ export function onEnter(event) { const pairchar = document.getElementById("pair_select").value; const pairoffset = document.getElementById("pair_offset").value; let sfxname = "0"; - let sfxdelay = "0"; + let sfxdelay = 0; if (document.getElementById("sendsfx").checked) { sfxname = myemo.sfx; sfxdelay = myemo.sfxdelay; @@ -1929,7 +1930,7 @@ async function changeBackground(position) { const { bg, desk, speedLines } = positions[position]; - if (viewport.chatmsg.type === "5") { + if (viewport.chatmsg.type === 5) { document.getElementById("client_court").src = `${AO_HOST}themes/default/${encodeURI(speedLines)}`; document.getElementById("client_bench").style.display = "none"; } else { |
