Skip to content

Instantly share code, notes, and snippets.

@nitinthewiz
Created June 12, 2017 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitinthewiz/f64cd1c3ad90178b90bfd830024d4092 to your computer and use it in GitHub Desktop.
Save nitinthewiz/f64cd1c3ad90178b90bfd830024d4092 to your computer and use it in GitHub Desktop.
superhex change your server to SA (South Africa)
"use strict";
var superhex = function() {
function e(e) {
return 0 == e ? tn[0] : e == Xt ? tn[(Xt - 1) % (tn.length - 1) + 1] : Xt > 0 && e > Xt ? $e[(e - 2) % $e.length] : $e[(e - 1) % $e.length]
}
function t(e) {
return 0 == e ? nn[0] : e == Xt ? nn[(Xt - 1) % (nn.length - 1) + 1] : e > Xt ? et[(e - 2) % et.length] : et[(e - 1) % et.length]
}
function n() {
var e = document.createElement("canvas").getContext("2d");
return (window.devicePixelRatio || 1) / (e.webkitBackingStorePixelRatio || e.mozBackingStorePixelRatio || e.msBackingStorePixelRatio || e.oBackingStorePixelRatio || e.backingStorePixelRatio || 1)
}
function i(e) {
on = e, 1 == e ? document.getElementById("button-quality-high").classList.remove("unselected") : document.getElementById("button-quality-high").classList.add("unselected"), .75 == e ? document.getElementById("button-quality-medium").classList.remove("unselected") : document.getElementById("button-quality-medium").classList.add("unselected"), .5 == e ? document.getElementById("button-quality-low").classList.remove("unselected") : document.getElementById("button-quality-low").classList.add("unselected"), "undefined" != typeof Storage && localStorage.setItem("quality", e)
}
function a(e) {
var t = new Array(e || 0),
n = e;
if (arguments.length > 1)
for (var i = Array.prototype.slice.call(arguments, 1); n--;) t[e - 1 - n] = a.apply(this, i);
return t
}
function r(e, t) {
Re = a(2 * at + 1, 2 * at + 1), Lt = !0, E(e, t)
}
function o(e, t) {
return Re[e + at] && Re[e + at][t + at] && Re[e + at][t + at].pid ? Re[e + at][t + at].pid : 0
}
function l(e, t) {
Re[e + at][t + at].pid = 0, ft[1 + e + at][1 + t + at] && w(b(e, t)), 0 != Re[e + at][t + at].aid && u(e, t, 0, Re[e + at][t + at].aid)
}
function s(e, t) {
Re[e + at][t + at] = {
pid: 0,
aid: 0
}, ft[1 + e + at][1 + t + at] && w(b(e, t)), g(e, t)
}
function d(e, n, i) {
if (Re[e + at] && Re[e + at][n + at] || (Re[e + at][n + at] = {
pid: 0,
aid: 0
}), Re[e + at][n + at].aid = i, ft[1 + e + at][1 + n + at]) {
var a = Re[e + at][n + at].pid;
w(b(e, n), t(a)), c(e, n, a, i)
}
}
function c(t, n, i, a) {
if (mt[1 + t + at][1 + n + at]) return void u(t, n, i, a);
var r = new PIXI.Sprite(Je.hexagon_white_contour);
r.tint = e(a), 0 == i && (r.alpha = .3), r.width = lt, r.height = st, r.position = y(t, n), r.hexPosition = {
q: t,
r: n
}, ze.addChild(r), mt[1 + t + at][1 + n + at] = r
}
function u(t, n, i, a) {
var r = mt[1 + t + at][1 + n + at];
r && (r.tint = e(a), 0 == i && (r.alpha = .3))
}
function g(e, t) {
mt[1 + e + at][1 + t + at] && (ze.removeChild(mt[1 + e + at][1 + t + at]), mt[1 + e + at][1 + t + at] = null)
}
function h(t, n) {
Re[t + at][n + at].aid = 0, ft[1 + t + at][1 + n + at] && w(b(t, n), e(Re[t + at][n + at].pid)), g(t, n)
}
function f(t, n, i) {
void 0 === i && (i = Xt), Re[t + at][n + at] = {
pid: i,
aid: 0
}, ft[1 + t + at][1 + n + at] && w(b(t, n), e(i))
}
function m(t, n, i, a) {
if (Re[t + at][n + at] = {
pid: i,
aid: a
}, ft[1 + t + at][1 + n + at])
if (0 == a) w(b(t, n), e(i)), g(t, n);
else {
var r = b(t, n);
w(r, e(i)), c(t, n, i, a)
}
}
function p(e, t) {
return Re[e + at][t + at] && Re[e + at][t + at].aid ? Re[e + at][t + at].aid : 0
}
function y(e, t) {
var n = 3 * ot / 2 * e,
i = ot * Math.sqrt(3) * (t + e / 2);
return new PIXI.Point(n, i)
}
function v(e, t) {
var n = 2 * e / 3 / ot,
i = (-e / 3 + Math.sqrt(3) / 3 * t) / ot,
a = n,
r = i,
o = -a - r,
l = Math.round(a),
s = Math.round(o),
d = Math.round(r),
c = Math.abs(l - a),
u = Math.abs(s - o),
g = Math.abs(d - r);
return c > u && c > g ? l = -s - d : u > g ? s = -l - d : d = -l - s, {
q: l,
r: d
}
}
function k(e, t, n, i, a, r) {
if (void 0 === e && (e = 5197647), void 0 === t && (t = 4868682), void 0 === n && (n = 1), void 0 === i && (i = 1), void 0 === a && (a = .1 * ot), void 0 === r && (r = !1), ht.length > 0) {
var o = ht.pop();
o.tint = e, o.alpha = n
} else {
var o = new PIXI.Sprite(Je.hexagon_white_degrade);
o.tint = e, o.alpha = n
}
return o.width = lt - .2 * ot, o.height = st - .2 * ot, o.visible = r, o
}
function w(e, t, n, i, a) {
void 0 === t && (t = 5197647), void 0 === n && (n = 4868682), void 0 === i && (i = 1), void 0 === a && (a = 1), e.tint = t, e.alpha = i
}
function I(e, t) {
var n = (Xt - 1) % (tn.length - 1) + 1;
De.texture = Je["player-" + n]
}
function b(n, i) {
if (ft[1 + n + at][1 + i + at]) return ft[1 + n + at][1 + i + at];
var a;
if (J(n, i)) a = k(16711680), a.isBorder = !0;
else {
var r = o(n, i),
l = p(n, i);
0 == l ? (a = k(e(r)), g(n, i)) : (a = k(t(r)), c(n, i, r, l))
}
return a.position = y(n, i), a.x += .1 * ot, a.y += .1 * ot, a.hexPosition = {
q: n,
r: i
}, ft[1 + n + at][1 + i + at] = a, Ue.addChild(a), a
}
function q(e, t) {
if (ft[1 + e + at][1 + t + at]) {
var n = ft[1 + e + at][1 + t + at];
Ue.removeChild(n), ft[1 + e + at][1 + t + at] = null, ht.push(n)
}
}
function E(e, t) {
var n = (new Date).getTime();
ft = a(2 * at + 1 + 2, 2 * at + 1 + 2), mt = a(2 * at + 1 + 2, 2 * at + 1 + 2);
for (var i = -rt; i <= rt; i++)
for (var r = -rt; r <= rt; r++) Math.abs(i + r) <= rt && K(e + i, t + r) && b(e + i, t + r);
var o = (new Date).getTime();
console.log("create map container in " + (o - n))
}
function x(t) {
Xt > 0 && t != Xt && e(t) == e(Xt) && console.error("encountered player with same color", t, Xt);
var n = Xt > 0 && t > Xt ? (t - 2) % tt.length : (t - 1) % tt.length;
for (yt[t] = new PIXI.Sprite(Je["player-" + (t == Xt ? (Xt - 1) % (tn.length - 1) + 1 : tt[n])]), yt[t].width = 2 * dt + 2 * ut, yt[t].height = 2 * dt + 2 * ut, yt[t].x = It[t] * ot - yt[t].width / 2, yt[t].y = bt[t] * ot - yt[t].height / 2, Fe.addChild(yt[t]), vt[t] = new PIXI.Text(Zt[t], {
fontFamily: "Arial",
fontSize: 16 / rn,
fill: 16777215
}); vt[t].context.measureText(vt[t].text).width > 160;) vt[t].text = vt[t].text.slice(0, -1);
Fe.addChild(vt[t])
}
function M(e) {
ln[e.z] = new WebSocket("ws://" + e.u), ln[e.z].binaryType = "arraybuffer", ln[e.z].pings = [], ln[e.z].sendPing = function() {
this.lastPingTime = (new Date).getTime();
var e = new Uint8Array(1);
e.set([99], 0), this.send(e)
}, ln[e.z].addEventListener("open", function(e) {
e.target.sendPing()
}), ln[e.z].addEventListener("close", function(e) {}), ln[e.z].addEventListener("message", function(t) {
var n = new DataView(t.data),
i = n.getUint8(0);
99 == i ? (t.target.pings.push((new Date).getTime() - t.target.lastPingTime), console.log("zone ping", e.z, t.target.pings[t.target.pings.length - 1]), t.target.pings.length >= 3 ? (t.target.close(), delete ln[e.z], gt[e.z] = Math.min.apply(Math, t.target.pings), console.log("kept zone ping", e.z, gt[e.z])) : t.target.sendPing()) : console.log("unexpected code from server", i)
})
}
function P() {
var e = new XMLHttpRequest;
e.onreadystatechange = function() {
if (4 == e.readyState && 200 == e.status) {
Te = JSON.parse(e.responseText), console.log("got server list: ", Te);
for (var t = 0; t < Te.length; t++) M(Te[t])
}
}, e.onerror = function() {
document.getElementById("button-play-text").innerHTML = "Retrying", document.getElementById("button-play-again-text").innerHTML = "Retrying", setTimeout(P, 5e3)
}, e.open("GET", MM_URL + "/serversv2", !0), e.send(null)
}
function B() {
var e, t = Te && 0 == Te.length,
n = null;
if (Te)
for (var i = 0; i < Te.length; i++) {
var a = Te[i].z;
gt[a] && (t = !0, gt[a] != -1 && (!n || e > gt[a]) && (n = a, e = gt[a]))
}
if (!$t || !t) return void setTimeout(B, 50);
console.log("best zone", n, "ping", e);
for (var a in ln) ln[a].close();
ln = [];
var r = new XMLHttpRequest;
r.onreadystatechange = function() {
4 == r.readyState && 200 == r.status && (WSERVER_URL = '191.96.137.166:9020', console.log("got server : ", WSERVER_URL), WSERVER_URL.startsWith("ERROR") ? (document.getElementById("button-play-text").innerHTML = "Retrying", document.getElementById("button-play-again-text").innerHTML = "Retrying", setTimeout(B, 5e3)) : X())
}, r.onerror = function() {
document.getElementById("button-play-text").innerHTML = "Retrying", document.getElementById("button-play-again-text").innerHTML = "Retrying", setTimeout(B, 5e3)
}, r.open("GET", MM_URL + "?zone=" + (n ? n : "") + (Ke ? "&pk=" + Ke : ""), !0), r.send(null)
}
function T() {
Tt || (en++, "undefined" != typeof Storage && localStorage.setItem("respawnCount", en), Ye = document.getElementById("username").value.substring(0, 15), "undefined" != typeof Storage && localStorage.setItem("username", Ye), Ye || (Ye = "Guest"), document.getElementById("networkError").style.display = "none", document.getElementById("button-play-text").innerHTML = "Connecting", Tt = !0, document.getElementById("button-play").classList.add("button-loading"), z(), B())
}
function C() {
if (Ft && !Tt) {
en++, "undefined" != typeof Storage && localStorage.setItem("respawnCount", en), Ye = document.getElementById("username").value.substring(0, 15), Ye || (Ye = "Guest"), document.getElementById("networkError").style.display = "none", document.getElementById("button-play-again-text").innerHTML = "Connecting", Tt = !0, document.getElementById("button-play-again").classList.add("button-loading"), document.getElementById("friendsScores") && (document.getElementById("friendsScores").style.display = "none"), document.getElementById("fps") && (document.getElementById("fps").style.display = Dt ? "block" : "none"), Ft = !1, Xt = -1, He.alpha = 1, ze.removeChildren(), Ue.removeChildren();
for (var e = 0; e < pt.length; e++) je.removeChild(pt[e]);
pt = [], Lt = !1, Pt = !1, Bt = !1, St = !1, At = 0, Oe = null;
for (var t = 0; t < It.length; t++) It[t] && (console.log("remove player ", t), fe(t));
Gt = [], _t = [], qt = [], Et = [], Mt = [], xt = [], Zt = [], Xe.x = 1e4, B()
}
}
function L() {
Lt ? C() : T(), document.getElementById("div-gpt-ad-1490263292583-0").style.display = "block"
}
function S() {
"undefined" != typeof ga && (Ke ? ga("send", "event", "Click", "Play", "InParty") : ga("send", "event", "Click", "Play", "NoParty")), "undefined" != typeof adplayer && (4 == en || en > 4 && (en - 4) % 3 == 0) ? adplayer.startPreRoll() : T()
}
function D() {
"undefined" != typeof ga && (Ke ? ga("send", "event", "Click", "PlayAgain", "InParty") : ga("send", "event", "Click", "PlayAgain", "NoParty")), Ae && clearTimeout(Ae), "undefined" != typeof adplayer && (4 == en || en > 4 && (en - 4) % 3 == 0) ? (adplayer.startPreRoll(), document.getElementById("div-gpt-ad-1490263292583-0").style.display = "none") : C()
}
function H() {
"undefined" != typeof ga && ga("send", "event", "Click", "MainMenu"), Ae && clearTimeout(Ae), Ce.close(), document.getElementById("button-main-menu").innerHTML = "Loading...", document.getElementById("button-main-menu").classList.add("button-loading"), window.location.reload()
}
function R(e) {
var t = (new Date).getTime();
if (t - Ut > 5e3) {
var n = new DataView(new ArrayBuffer(7));
n.setUint8(0, 50), n.setInt16(1, _e, !0), n.setInt16(3, jt, !0), n.setInt16(5, MainLoop.getFPS(), !0), jt = 0, Ne = e, Ge = e, Ce.send(n.buffer), Ut = t
}
_e ? (_e = .75 * _e + .25 * e, e > Ne && (Ne = e), e < Ge && (Ge = e)) : (_e = e, Ne = _e, Ge = _e)
}
function A(e) {
var t = new DataView(e.data);
switch (t.getUint8(0)) {
case 1:
re(t), MainLoop.start(), ae(), document.getElementById("respawn").style.display = "none", document.getElementById("homepage").style.display = "none";
var n = document.getElementById("div-gpt-ad-1490263292583-0");
n && (n.parentElement.removeChild(n), document.getElementById("respawn-ad").appendChild(n));
var i = document.getElementById("780560");
i && (i.parentElement.removeChild(i), document.getElementById("respawn-ad").appendChild(i)), document.getElementById("button-play-again").classList.remove("button-loading"), Tt = !1, document.getElementById("button-play-again-text").innerHTML = "Play Again", Le.view.style.display = "block";
break;
case 2:
document.getElementById("leaderboard").style.display = "block", document.getElementById("score").style.display = "block";
var a = (new Date).getTime(),
r = _t.shift();
Gt.shift(), R(a - r), console.log("first ping is ", a - r), At = a, Pt = !0, le(Xt, It[Xt], bt[Xt], kt[Xt], wt[Xt], 0), setTimeout(function() {
var e = (new Date).getTime(),
t = setInterval(function() {
var n = (new Date).getTime();
n - e > 1e3 ? (clearInterval(t), He.alpha = 0) : He.alpha = 1 - (n - e) / 1e3
}, 20)
}, 5e3);
break;
case 3:
if (Pt && Bt) {
var o = (new Date).getTime(),
r = _t.shift();
Gt.shift(), R(o - r), oe(t)
}
break;
case 4:
Bt && ge(t);
break;
case 5:
Bt && updatePlayersPosition(t);
break;
case 13:
Bt && se(t);
break;
case 6:
Vt = t.getUint32(1, !0), Ot = t.getUint32(5, !0), Qt = t.getInt16(9, !0), Yt = t.getInt16(11, !0);
for (var l = (t.byteLength - 13) / 6, s = 0; s < l; s++) Jt[s] = {
playerId: t.getInt16(13 + 6 * s, !0),
score: t.getUint32(13 + 6 * s + 2, !0)
};
be(), qe();
break;
case 14:
for (var d = t.getInt16(1, !0), c = [], s = 0; s < d; s++) c.push({
playerId: t.getInt16(3 + 8 * s, !0),
rank: t.getInt16(3 + 8 * s + 2, !0),
score: t.getUint32(3 + 8 * s + 4, !0)
});
Kt = c, Kt.sort(function(e, t) {
return e.rank - t.rank
}), Ee();
break;
case 7:
Bt && he(t);
break;
case 8:
Bt && me(t.getInt16(1, !0), t.getInt16(3, !0), t.getInt16(5, !0));
break;
case 9:
Bt && pe(t);
break;
case 10:
Bt && ve(t);
break;
case 11:
Bt && Ie(t);
break;
case 12:
document.getElementById("button-play-text").innerHTML = "Connecting", document.getElementById("button-play-again-text").innerHTML = "Connecting", console.log("server returned : map is full"), Pt = !1, Ct = !0, Ce.close(), B();
break;
case 99:
var u = (new Date).getTime() - We;
if (R(u), console.log("ping is ", u), ++zt < 3) ae();
else {
var g = new Uint8Array(1);
g.set([2], 0), Ce.send(g), _t.push((new Date).getTime()), Gt.push(wt[Xt])
}
}
}
function X() {
if (document.getElementById("button-play-text").innerHTML = "Joining", document.getElementById("button-play-again-text").innerHTML = "Joining", Ce && Ce.readyState <= 1 && Ce.url.startsWith("ws://" + WSERVER_URL)) return console.log("rejoining same map"), void ie();
Ce && Ce.readyState <= 1 && (console.log("close previous connection"), Ct = !0, Ce.close(), zt = 0, Ut = 0, jt = 0, Zt = [], Jt = [], Kt = []), Ce = new WebSocket("ws://" + WSERVER_URL), Ce.binaryType = "arraybuffer", Ce.addEventListener("open", function(e) {
console.log("socket connected"), ne()
}), Ce.addEventListener("close", function(e) {
console.log("socket closed"), Ct || (document.getElementById("networkError").style.display = "block"), Ct = !1, Pt = !1
});
Ce.addEventListener("message", A)
}
function z() {
PIXI.ticker.shared.stop();
PIXI.utils.isWebGLSupported(), Le = PIXI.autoDetectRenderer(256, 256, {
antialias: !0,
transparent: !1,
resolution: on
}), Le.plugins.interaction && (Le.plugins.interaction.destroy(), Le.plugins.interaction = null), window.addEventListener("resize", U, !0), Le.view.addEventListener("mousemove", F, !0), Le.view.addEventListener("touchstart", W, !0), Le.view.addEventListener("touchmove", W, !0), Le.view.style.display = "none", Le.backgroundColor = 4408131, Le.view.style.position = "absolute", Le.autoResize = !0, document.body.appendChild(Le.view), Se = new PIXI.Container, Xe = new PIXI.Container, Se.addChild(Xe), ze = new PIXI.Container, Xe.addChild(ze), Ue = new PIXI.Container, Xe.addChild(Ue), je = new PIXI.Container, Xe.addChild(je), Fe = new PIXI.Container, Xe.addChild(Fe), De = new PIXI.Sprite, Se.addChild(De), He = new PIXI.Text(Ye, {
fontFamily: "Arial",
fontSize: 16 / rn,
fill: 16777215
}), Se.addChild(He), U(), MainLoop.setBegin(Z).setUpdate($).setDraw(ee).setEnd(te)
}
function U() {
var i = ot;
if (rn = n(), console.log("PIXEL RATIO", rn, "window size", window.innerWidth, window.innerHeight), ot = Math.max(window.innerWidth / 40 / 2 / .75, window.innerHeight / 40 / Math.sqrt(3)), lt = 2 * ot, st = Math.sqrt(3) / 2 * lt, dt = .6 * ot, ct = 2 / 3 * dt, ut = dt / 3, Ue) {
Ue.x = -lt / 2, Ue.y = -st / 2;
for (var a = 0; a < Ue.children.length; a++)
if (Ue.children[a].width = lt - .2 * ot, Ue.children[a].height = st - .2 * ot, Ue.children[a].position = y(Ue.children[a].hexPosition.q, Ue.children[a].hexPosition.r), Ue.children[a].x += .1 * ot, Ue.children[a].y += .1 * ot, Y(Ue.children[a].hexPosition.q, Ue.children[a].hexPosition.r)) {
var r = o(Ue.children[a].hexPosition.q, Ue.children[a].hexPosition.r),
l = p(Ue.children[a].hexPosition.q, Ue.children[a].hexPosition.r);
0 == l ? w(Ue.children[a], e(r)) : w(Ue.children[a], t(r))
} else w(Ue.children[a], 16711680);
ze.x = -lt / 2, ze.y = -st / 2;
for (var a = 0; a < ze.children.length; a++) ze.children[a].width = lt, ze.children[a].height = st, ze.children[a].position = y(ze.children[a].hexPosition.q, ze.children[a].hexPosition.r);
De.width = 2 * dt + 2 * ut, De.height = 2 * dt + 2 * ut;
for (s in yt) yt[s].width = 2 * dt + 2 * ut, yt[s].height = 2 * dt + 2 * ut;
He.style.fontSize = 16 / rn;
for (s in vt) vt[s].style.fontSize = 16 / rn;
for (var s in Et)
for (var d = ot / i, a = 0; a < Et[s].length; a++) Et[s][a] *= d;
var c = ct / 20;
for (var s in pt) pt[s].scale.x = c, pt[s].scale.y = c;
Le.resize(window.innerWidth, window.innerHeight), De.x = window.innerWidth / 2 - De.width / 2, De.y = window.innerHeight / 2 - De.height / 2, He.x = window.innerWidth / 2 - He.width / 2, He.y = window.innerHeight / 2 - st - dt, Ft ? (Xe.x = window.innerWidth / 2 - Ve * ot, Xe.y = window.innerHeight / 2 - Qe * ot) : (Xe.x = window.innerWidth / 2 - It[Xt] * ot, Xe.y = window.innerHeight / 2 - bt[Xt] * ot)
}
}
function j() {
it = null;
var e = new DataView(new ArrayBuffer(5));
e.setUint8(0, 3), e.setFloat32(1, nt, !0), Ce && 1 == Ce.readyState && (_t.push((new Date).getTime()), Gt.push(nt), Ce.send(e.buffer))
}
function F(e) {
if (e.clientY != window.innerHeight / 2 || e.clientX != window.innerWidth / 2) {
var t = Math.atan2(e.clientY - window.innerHeight / 2, e.clientX - window.innerWidth / 2);
!Pt || Ft || St || (it && clearTimeout(it), nt = t, 0 != _t.length & (new Date).getTime() - _t[_t.length - 1] < 10 ? it = setTimeout(j, 10) : j())
}
}
function W(e) {
e.touches && 1 == e.touches.length && (F({
clientX: e.touches[0].clientX,
clientY: e.touches[0].clientY
}), e.preventDefault())
}
function _(e, t) {
for (var n = t - e; n < -Math.PI;) n += 2 * Math.PI;
for (; n > Math.PI;) n -= 2 * Math.PI;
return n
}
function G(e, t) {
return (Math.abs(e.q - t.q) + Math.abs(e.q + e.r - t.q - t.r) + Math.abs(e.r - t.r)) / 2
}
function N(e, t) {
var n = sn[t];
e.q += n.q, e.r += n.r
}
function O(e) {
for (var t = {
minQ: e[0].q,
maxQ: e[0].q,
minR: e[0].r,
maxR: e[0].r
}, n = 1; n < e.length; n++) e[n].q < t.minQ && (t.minQ = e[n].q), e[n].q > t.maxQ && (t.maxQ = e[n].q), e[n].r < t.minR && (t.minR = e[n].r), e[n].r > t.maxR && (t.maxR = e[n].r);
return t
}
function V(e, t) {
return e.r == t.r ? e.q > t.q ? 0 : 3 : e.q == t.q ? e.r > t.r ? 5 : 2 : e.q > t.q ? 1 : 4
}
function Q(e) {
var t = O(e),
n = e[0],
i = null;
e.push(n);
for (var a = 0; a < e.length; a++) {
var r = e[a];
if (null != i) {
var o = V(i, r);
r.angles || (r.angles = []), r.angles.push(o), i.angles || (i.angles = []), i.angles.push((o + 3) % 6)
}
i = r
}
e.pop();
var l = [];
for (var a in e) {
var s = e[a].q;
l[s] || (l[s] = []), l[s].push(e[a])
}
for (var a in l) l[a].sort(function(e, t) {
return e.r - t.r
});
for (var d = [], s = t.minQ; s <= t.maxQ; s++) {
var c = !1,
u = 0,
g = l[s],
h = null;
if (g)
for (var a = 0; a < g.length; a++) {
var f = g[a];
if (c)
for (var m = h.r + 1; m <= f.r - 1; m++) d.push({
q: s,
r: m
});
if (null != h && h.r - f.r > 1 && (u = 0), (3 == f.angles[1] || 4 == f.angles[1]) && f.angles[0] <= 1 || (3 == f.angles[0] || 4 == f.angles[0]) && f.angles[1] <= 1) c = !c, u = 0;
else if (2 == f.angles[0] && 5 != f.angles[1]) {
var p = f.angles[1] > 2 ? 1 : 2;
u > 0 && u != p ? (c = !c, u = 0) : u = p
} else if (2 == f.angles[1] && 5 != f.angles[0]) {
var p = f.angles[0] > 2 ? 1 : 2;
u > 0 && u != p ? (c = !c, u = 0) : u = p
} else if (5 == f.angles[0] && 2 != f.angles[1]) {
var p = f.angles[1] > 2 ? 1 : 2;
u > 0 && u != p ? (c = !c, u = 0) : u = p
} else if (5 == f.angles[1] && 2 != f.angles[0]) {
var p = f.angles[0] > 2 ? 1 : 2;
u > 0 && u != p ? (c = !c, u = 0) : u = p
}
h = f
}
}
return d
}
function Y(e, t) {
return !(Math.abs(t) > at) && (t <= 0 ? e >= -at - t && e <= at : e >= -at && e <= at - t)
}
function J(e, t) {
return (Math.abs(e) + Math.abs(e + t) + Math.abs(t)) / 2 == at + 1
}
function K(e, t) {
return !(Math.abs(t) > at + 1) && (t <= 0 ? e >= -(at + 1) - t && e <= at + 1 : e >= -(at + 1) && e <= at + 1 - t)
}
function Z() {}
function $(e) {
for (var t = Wt.length - 1; t >= 0; t--) {
var n = Wt[t];
if (n.time += e, "CAPTURING" === n.type || "UNCAPTURING" === n.type) {
for (var i = n.from + (n.to - n.from) * Math.min(1, n.time / n.length), a = 0; a < n.hexs.length; a++) {
var r = n.hexs[a];
r.width = (lt - .1 * ot * 2) * i, r.height = (st - .1 * ot * 2) * i, r.position = y(r.hexPosition.q, r.hexPosition.r), r.x += .1 * ot + (lt - .1 * ot * 2) * (1 - i) / 2, r.y += .1 * ot + (st - .1 * ot * 2) * (1 - i) / 2
}
if (n.time >= n.length)
for (var a = 0; a < n.hexs.length; a++) {
var r = n.hexs[a];
Ue.removeChild(r), "CAPTURING" === n.type && f(r.hexPosition.q, r.hexPosition.r, n.playerId), r.destroy()
}
} else if ("EXPLOSION" == n.type)
for (var a = 0; a < n.parts.length; a++) {
var o = n.parts[a];
o.graphicsData[0].fillAlpha = n.from + (n.to - n.from) * Math.min(1, n.time / n.length), o.graphicsData[0].lineAlpha = n.from + (n.to - n.from) * Math.min(1, n.time / n.length), o.dirty++, o.clearDirty++, n.time <= n.moveLength && (o.x += Math.cos(o.animationDirection) * o.animationSpeed, o.y += Math.sin(o.animationDirection) * o.animationSpeed), n.time >= n.length && (Fe.removeChild(o), o.destroy())
} else if ("TRAIL_DISAPPEAR" == n.type) {
var o = n.trailGraphics;
o.alpha = n.from + (n.to - n.from) * Math.min(1, n.time / n.length), n.time >= n.length && je.removeChild(o)
} else if (n.type = "IMPACT") {
var i = n.from + (n.to - n.from) * Math.min(1, n.time / n.length);
n.sprite.graphicsData[0].shape.radius = i * dt * 4, n.sprite.alpha = 1 * (1 - i), n.sprite.dirty++, n.sprite.clearDirty++, n.time >= n.length && Fe.removeChild(n.sprite)
}
n.time > n.length && Wt.splice(t, 1)
}
var l = (new Date).getTime();
for (var s in Nt)
for (var d = Nt[s]; d.length > 0 && d[0].time <= l;) {
for (var c = d.shift(), t = 0; t < c.points.length; t++) ue(c.points[t][0], c.points[t][1], c.points[t][2], c.points[t][3]);
Et[s] && xt[s] && Et[s].splice(2 * (xt[s] + 1)), le(c.playerId, c.x, c.y, c.dir, c.targetDir, c.time), ce(s)
}
if (Ze = l, Pt) {
if (!Ft) {
var u = wt[Xt];
if (_t.length > 0 && _t[0] < l - _e / 2) {
for (var t = 0; t < _t.length - 1 && _t[t + 1] < l - _e / 2;) t++;
u = Gt[t]
}
var g = _(kt[Xt], u);
kt[Xt] += 5 * g * e / 1e3, It[Xt] += 7 * Math.cos(kt[Xt]) * e / 1e3, bt[Xt] += 7 * Math.sin(kt[Xt]) * e / 1e3, Xe.x = window.innerWidth / 2 - It[Xt] * ot, Xe.y = window.innerHeight / 2 - bt[Xt] * ot, ye(), Me(), ce(Xt), document.getElementById("networkLag").style.display = l - qt[s] > 500 ? "block" : "none"
}
for (var s in It)
if (Ft || s != Xt) {
var h = G(v(ot * (Ft ? Ve : It[Xt]), ot * (Ft ? Qe : bt[Xt])), v(ot * It[s], ot * bt[s]));
if (h > rt + 1 || l - qt[s] > 2e3) console.log("removed player", s, "from view"), fe(s);
else {
var g = _(kt[s], wt[s]);
kt[s] += 5 * g * e / 1e3, It[s] += 7 * Math.cos(kt[s]) * e / 1e3, bt[s] += 7 * Math.sin(kt[s]) * e / 1e3, yt[s].x = It[s] * ot - yt[s].width / 2, yt[s].y = bt[s] * ot - yt[s].height / 2, vt[s].x = It[s] * ot - vt[s].width / 2, vt[s].y = bt[s] * ot - st - dt, ce(s)
}
}
}
}
function ee() {
(new Date).getTime();
Le.render(Se)
}
function te(e, t) {
document.getElementById("fps").textContent = "fps : " + Math.round(e) + " - ping = " + Math.round(_e) + " - jitter = " + jt, t && console.log("panic: simulation is too late")
}
function ne() {
var e = new DataView(new ArrayBuffer(2 + 2 * Ye.length + (Ke ? 1 + 2 * Ke.length : 0)));
e.setUint8(0, 1), e.setUint8(1, Ye.length);
for (var t = 0; t < Ye.length; t++) {
var n = Ye.charCodeAt(t);
e.setUint8(2 + 2 * t, 255 & n), e.setUint8(2 + 2 * t + 1, n >>> 8)
}
if (Ke) {
var i = 1 + 2 * Ye.length + 1;
e.setUint8(i, Ke.length);
for (var t = 0; t < Ke.length; t++) {
var n = Ke.charCodeAt(t);
e.setUint8(i + 1 + 2 * t, 255 & n), e.setUint8(i + 1 + 2 * t + 1, n >>> 8)
}
}
Ce.send(e.buffer), Bt = !0
}
function ie() {
Vt = 7, Ot = 0;
var e = new DataView(new ArrayBuffer(1));
e.setUint8(0, 4), Ce.send(e.buffer), Bt = !0
}
function ae() {
We = (new Date).getTime();
var e = new Uint8Array(1);
e.set([99], 0), Ce.send(e)
}
function re(n) {
Xt = n.getInt16(1, !0), console.log("player id is ", Xt), Zt[Xt] = Ye, at = n.getInt16(3, !0), rt = n.getInt16(5, !0), Yt = n.getInt16(7, !0), Qt = Yt;
var i = n.getInt16(9, !0),
a = n.getInt16(11, !0);
console.log("Player starts at ", i, a), wt[Xt] = n.getFloat32(13, !0), kt[Xt] = wt[Xt], r(i, a);
var o = y(i, a);
It[Xt] = o.x / ot, bt[Xt] = o.y / ot, Xe.x = window.innerWidth / 2 - o.x, Xe.y = window.innerHeight / 2 - o.y, ye(), $e = tn.slice(1), et = nn.slice(1), $e.splice((Xt - 1) % $e.length, 1), et.splice((Xt - 1) % et.length, 1), I(e(Xt), t(Xt)), tt = an.slice(0), tt.splice((Xt - 1) % tt.length, 1), De.visible = !0, He.visible = !0;
var l = (n.byteLength - 17) / 4 / 2,
s = n.getInt16(17, !0),
d = n.getInt16(19, !0),
c = n.getInt16(21, !0),
u = n.getInt16(23, !0),
g = 0,
h = 0,
f = -rt,
p = -1,
v = -1;
do Y(i + h, a + f) && (s == i + h && d == a + f && (p = c, v = u, ++g < l && (s = n.getInt16(17 + 8 * g + 0, !0), d = n.getInt16(17 + 8 * g + 2, !0), c = n.getInt16(17 + 8 * g + 4, !0), u = n.getInt16(17 + 8 * g + 6, !0))), p == -1 && v == -1 || m(i + h, a + f, p, v)), h++, (f <= 0 && h > rt || f > 0 && h > rt - f) && (f++, h = f <= 0 ? -rt - f : -rt); while (f <= rt);
be(), document.getElementById("minimap").style.display = "block", Me()
}
function oe(e) {
var t = (e.getFloat32(1, !0), e.getFloat32(5, !0), e.getFloat32(9, !0), e.getFloat32(13, !0));
wt[Xt] = t
}
function le(e, t, n, i, a, r) {
if (r = 0, Ft || e != Xt)
for (; r > 17;) {
var o = _(i, a);
i += 5 * o * 17 / 1e3, t += 7 * Math.cos(i) * 17 / 1e3, n += 7 * Math.sin(i) * 17 / 1e3, r -= 17
} else
for (var l = (new Date).getTime(), s = l - r, d = 0; r > 17;) {
for (; d < _t.length && _t[d] < s - _e / 2;) a = Gt[d], d++;
var o = _(i, a);
i += 5 * o * 17 / 1e3, t += 7 * Math.cos(i) * 17 / 1e3, n += 7 * Math.sin(i) * 17 / 1e3, r -= 17, s += 17
}
if (It[e]) {
var c = Math.sqrt(Math.pow(t - It[e], 2) + Math.pow(n - bt[e], 2)),
u = c > 3 ? c : c > 1 ? .2 : Math.min(c, .05);
c > 0 && u > 0 && (It[e] += (t - It[e]) * u / c, bt[e] += (n - bt[e]) * u / c, Ft || e != Xt || (Xe.x = window.innerWidth / 2 - It[Xt] * ot, Xe.y = window.innerHeight / 2 - bt[Xt] * ot, ye()))
} else console.log("set initial position for player", e, t, n), It[e] = t, bt[e] = n;
(Ft || Xt > 0 && e != Xt) && (yt[e] || x(e), yt[e].x = It[e] * ot - yt[e].width / 2, yt[e].y = bt[e] * ot - yt[e].height / 2, vt[e].x = It[e] * ot - vt[e].width / 2, vt[e].y = bt[e] * ot - st - dt), kt[e] = i, wt[e] = a
}
function se(e) {
var t = (new Date).getTime(),
n = e.getUint32(1, !0),
i = At + 17 * n,
a = e.getInt16(5, !0);
if (a == Xt && !Ft && qt[Xt]) {
var r = Math.abs((new Date).getTime() - qt[Xt] - 51);
r > jt && (jt = r)
}
qt[a] = t;
var o = e.getFloat32(7, !0),
l = e.getFloat32(11, !0),
s = e.getFloat32(15, !0),
d = e.getFloat32(19, !0),
c = [];
if (e.byteLength > 23)
for (var u = e.getInt16(23, !0), g = e.getInt16(25, !0), h = 0; h < u; h++) {
var f = e.getFloat32(27 + 8 * h + 0, !0),
m = e.getFloat32(27 + 8 * h + 4, !0);
c.push([a, g + h, f, m])
}
if (i < t) {
for (var h = 0; h < c.length; h++) ue(c[h][0], c[h][1], c[h][2], c[h][3]);
Et[a] && xt[a] && Et[a].splice(2 * (xt[a] + 1)), le(a, o, l, s, d, t - i), ce(a)
} else Nt[a] || (Nt[a] = []), Nt[a].push({
playerId: a,
x: o,
y: l,
dir: s,
targetDir: d,
time: i,
points: c
})
}
function de(t, n, i) {
var a = ct / 20;
if (!pt[t]) {
new PIXI.Point(It[t] * ot, bt[t] * ot), new PIXI.Point(It[t] * ot + 50, bt[t] * ot + 50);
dn[t] = [], pt[t] = new PIXI.mesh.Rope(PIXI.loader.resources["img/traine.png"].texture, dn[t]), pt[t].tint = e(t), pt[t].scale.x = a, pt[t].scale.y = a, je.addChild(pt[t])
}
for (var r = 0; r < Et[t].length / 2; r++) dn[t][r] ? (dn[t][r].x = Et[t][2 * r] / a, dn[t][r].y = Et[t][2 * r + 1] / a) : dn[t][r] = new PIXI.Point(Et[t][2 * r] / a, Et[t][2 * r + 1] / a);
pt[t].refresh();
for (var o = .034 * 7 * ot / PIXI.loader.resources["img/traine.png"].texture.width / a, l = pt[t].uvs, s = 0, r = 0; r < l.length / 4; r++) l[4 * r] = s, l[4 * r + 2] = s, s += o
}
function ce(e) {
var t = (new Date).getTime();
if (Et[e] && Et[e].length >= 4) {
var n = It[e] * ot,
i = bt[e] * ot,
a = Et[e][Et[e].length - 1],
r = Et[e][Et[e].length - 2];
Math.sqrt(Math.pow(r - n, 2) + Math.pow(a - i, 2)) > dt && (Et[e].push(n, i), Mt[e].push(t), de(e, Et.length / 2 - 1, Et.length / 2 - 1))
}
}
function ue(e, t, n, i, a) {
if (void 0 === a && (a = (new Date).getTime()), Et[e] || (Et[e] = []), Mt[e] || (Mt[e] = []), Et[e][2 * t] = n * ot, Et[e][2 * t + 1] = i * ot, Mt[e][t] = a, (!xt[e] || xt[e] < t) && (xt[e] = t), Lt) {
de(e, t, t);
var r = v(n * ot, i * ot),
l = o(r.q, r.r),
s = p(r.q, r.r);
l != e && s != e && Y(r.q, r.r) && d(r.q, r.r, e)
}
}
function ge(t) {
for (var n = t.getInt16(1, !0), i = t.getInt16(3, !0), a = [], r = 0; r < i; r++) {
var l = t.getInt16(5 + 4 * r, !0),
s = t.getInt16(5 + 4 * r + 2, !0);
a.push({
q: l,
r: s
})
}
var d = Q(a);
console.log("read capture for player", n, "and path count :", i, "hexs to fill :", d.length), Array.prototype.push.apply(d, a);
for (var c = Ft || !Pt ? v(Ve * ot, Qe * ot) : v(It[Xt] * ot, bt[Xt] * ot), u = [], h = 0, r = 0; r < a.length; r++) g(a[r].q, a[r].r);
for (var r = 0; r < d.length; r++) {
var f = o(d[r].q, d[r].r);
if (f != n && (f == Xt && Vt--, h++, G(d[r], c) <= rt)) {
w(b(d[r].q, d[r].r), e(0)), g(d[r].q, d[r].r);
var m = k(e(n), void 0, void 0, void 0, 0, !0);
m.hexPosition = d[r], m.position = y(d[r].q, d[r].r), m.width = .5 * (lt - .1 * ot * 2), m.height = .5 * (st - .1 * ot * 2), m.x += .1 * ot + .25 * (lt - .1 * ot * 2), m.y += .1 * ot + .25 * (st - .1 * ot * 2), Ue.addChild(m), u.push(m)
}
}
if (Wt.push({
type: "CAPTURING",
hexs: u,
from: .5,
to: 1,
time: 0,
length: 200,
playerId: n
}), n == Xt && (Vt += h, h >= 100 && xe(h)), be(), delete Et[n], delete Mt[n], delete dn[n], delete xt[n], je.removeChild(pt[n]), delete pt[n], Nt[n])
for (var r = 0; r < Nt[n].length; r++) Nt[n][r].points = []
}
function he(n) {
var i = n.getInt16(1, !0),
a = n.getInt16(3, !0);
console.log("player is dead", i, "killer is ", a);
for (var r = [], s = Ft || !Pt ? v(Ve * ot, Qe * ot) : v(It[Xt] * ot, bt[Xt] * ot), d = {
q: 0,
r: 0
}, c = -rt; c <= rt; c++)
for (var u = -rt; u <= rt; u++)
if (d.q = s.q + c, d.r = s.r + u, Y(d.q, d.r))
if (o(d.q, d.r) == i) {
if (l(d.q, d.r), G(s, d) <= rt) {
var g = k(e(i), void 0, void 0, void 0, 0, !0);
g.hexPosition = {
q: d.q,
r: d.r
}, g.position = y(d.q, d.r), g.width = lt - .1 * ot * 2, g.height = st - .1 * ot * 2, g.x += .1 * ot, g.y += .1 * ot, Ue.addChild(g), r.push(g)
}
} else p(d.q, d.r) == i && h(d.q, d.r);
if (r.length > 0 && setTimeout(function() {
Wt.push({
type: "UNCAPTURING",
hexs: r,
from: 1,
to: 0,
time: 0,
length: 500,
playerId: i
})
}, 500), n.byteLength >= 13) {
var f = n.getFloat32(5, !0),
m = n.getFloat32(9, !0),
w = new PIXI.Graphics,
I = .01 * dt;
w.beginFill(16777215), w.drawCircle(f * ot, m * ot, I), w.endFill(), w.alpha = 1, Fe.addChild(w), Wt.push({
type: "IMPACT",
from: 0,
to: 1,
time: 0,
length: 300,
playerId: i,
impactX: f,
impactY: m,
sprite: w
})
}
for (var b = [], q = 0; q < 9; q++) {
var w = new PIXI.Graphics,
I = ot / 6 + Math.random() * ot / 9;
w.lineStyle(ut * I / dt, e(i), 1), w.beginFill(t(i)), w.drawCircle(It[i] * ot, bt[i] * ot, I), w.endFill(), b.push(w), w.animationDirection = Math.random() * Math.PI * 2, w.animationSpeed = 2 * Math.random() + 2, Fe.addChild(w)
}
if (Wt.push({
type: "EXPLOSION",
parts: b,
from: 1,
to: 0,
time: 0,
length: 500,
moveLength: 500,
playerId: i
}), pt[i] && (Wt.push({
type: "TRAIL_DISAPPEAR",
trailGraphics: pt[i],
from: 1,
to: 0,
time: 0,
length: 200,
playerId: i
}), delete pt[i], delete Et[i], delete Mt[i], delete dn[i], delete xt[i]), Ft || i != Xt) fe(i);
else {
Ft = !0, Ve = It[Xt], Qe = bt[Xt], delete It[Xt], delete bt[Xt], delete kt[Xt], delete wt[Xt], delete Nt[Xt], De.visible = !1, He.visible = !1, document.getElementById("rankValue").innerHTML = "", document.getElementById("finalScore").innerHTML = Vt + 500 * Ot;
var E = 100 * Vt / (1 + 3 * at * (at + 1));
document.getElementById("finalMapPercent").innerHTML = E.toString().match(/^-?\d+(?:\.\d{0,1})?/)[0], document.getElementById("finalKills").innerHTML = Ot, document.getElementById("finalBlocks").innerHTML = Vt, "undefined" != typeof googletag && googletag.pubads && googletag.pubads().refresh(), setTimeout(function() {
document.getElementById("fps") && (document.getElementById("fps").style.display = "none"), document.getElementById("respawn").style.display = "block", document.getElementById("victory").style.display = "none", Ae = setTimeout(function() {
location.reload()
}, 9e5), "undefined" != typeof ga && (ga("set", "page", "/respawn"), ga("send", "pageview"))
}, 1e3)
}
Ft || Yt--, Ft || i == Xt || a != Xt || (Ot++, xe(500)), be()
}
function fe(e) {
Fe.removeChild(yt[e]), Fe.removeChild(vt[e]), delete yt[e], delete vt[e], delete It[e], delete bt[e], delete kt[e], delete wt[e], delete Nt[e], delete qt[e]
}
function me(e, t, n) {
console.log("player joins", e), f(t, n, e);
for (var i = 0; i < 6; i++) Y(t + sn[i].q, n + sn[i].r) && f(t + sn[i].q, n + sn[i].r, e);
Ft || Yt++
}
function pe(e) {
for (var t = e.getInt16(1, !0), n = e.getInt16(3, !0), i = e.getInt16(5, !0), a = e.getInt16(7, !0), r = V({
q: i,
r: a
}, {
q: t,
r: n
}), o = {
q: i + sn[(r + 5) % 6].q * rt,
r: a + sn[(r + 5) % 6].r * rt
}, l = (r + 1) % 6, d = 0; d < rt; d++) Y(o.q, o.r) && s(o.q, o.r), N(o, l);
for (var c = (r + 2) % 6, d = 0; d < rt; d++) Y(o.q, o.r) && s(o.q, o.r), N(o, c);
Y(o.q, o.r) && s(o.q, o.r);
for (var u = e.getInt16(9, !0), g = 0; g < u; g++) {
m(e.getInt16(11 + 8 * g + 0, !0), e.getInt16(11 + 8 * g + 2, !0), e.getInt16(11 + 8 * g + 4, !0), e.getInt16(11 + 8 * g + 6, !0))
}
}
function ye() {
var e = v(It[Xt] * ot, bt[Xt] * ot);
if (!Oe || Math.abs(e.q - Oe.q) > 4 || Math.abs(e.r - Oe.r) > 4) {
b(e.q, e.r).visible = !0;
for (var t = 1; t <= rt; t++)
for (var n = {
q: e.q + sn[4].q * t,
r: e.r + sn[4].r * t
}, i = 0; i < 6; i++)
for (var a = 0; a < t; a++) K(n.q, n.r) && (b(n.q, n.r).visible = !0), N(n, i);
Oe = e
} else if (e.q != Oe.q || e.r != Oe.r)
do {
var r = {
q: e.q - Oe.q,
r: e.r - Oe.r
};
r.q = 0 == r.q ? 0 : r.q / Math.abs(r.q), r.r = 0 == r.r ? 0 : r.r / Math.abs(r.r);
for (var o = {
q: Oe.q + r.q,
r: Oe.r + r.r
}, l = V(o, Oe), n = {
q: o.q + sn[(l + 5) % 6].q * rt,
r: o.r + sn[(l + 5) % 6].r * rt
}, s = (l + 1) % 6, a = 0; a < rt; a++) K(n.q, n.r) && (b(n.q, n.r).visible = !0), N(n, s);
for (var d = (l + 2) % 6, a = 0; a < rt; a++) K(n.q, n.r) && (b(n.q, n.r).visible = !0), N(n, d);
K(n.q, n.r) && (b(n.q, n.r).visible = !0), n = {
q: Oe.q + sn[(l + 2) % 6].q * rt,
r: Oe.r + sn[(l + 2) % 6].r * rt
};
for (var c = (l + 4) % 6, a = 0; a < rt; a++) K(n.q, n.r) && (q(n.q, n.r), g(n.q, n.r)), N(n, c);
for (var u = (l + 5) % 6, a = 0; a < rt; a++) K(n.q, n.r) && (q(n.q, n.r), g(n.q, n.r)), N(n, u);
K(n.q, n.r) && (q(n.q, n.r), g(n.q, n.r)), Oe = o
} while (Oe.q != e.q || Oe.r != e.r)
}
function ve(e) {
for (var t = e.getInt16(1, !0), n = 3, i = 0; i < t; i++) {
var a = e.getInt16(n, !0),
r = e.getInt16(n + 2, !0),
o = e.getInt16(n + 4, !0);
console.log("part for player", a, "point from ", r, "to", o);
for (var l = 0; l <= o - r; l++) {
var s = e.getFloat32(n + 6 + 8 * l, !0),
d = e.getFloat32(n + 6 + 8 * l + 4, !0);
Et[a] || (Et[a] = []), Mt[a] || (Mt[a] = []), Et[a][2 * (r + l)] = s * ot, Et[a][2 * (r + l) + 1] = d * ot
}
n += 6 + 8 * (o - r + 1), Lt && de(a, r, o)
}
}
function ke(e) {
return e.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;")
}
function we(e) {
for (var t = e.split(" "), n = 0; n < t.length; n++) {
var i = t[n].toUpperCase(),
a = i.charAt(0);
if (void 0 !== un[a])
for (var r = 0; r < un[a].length; r++) {
var o = un[a][r];
i == o && (t[n] = "❤")
}
}
e = t.join(" ");
for (var r = 0; r < un[" "].length; r++) {
var o = un[" "][r];
e.toUpperCase().indexOf(o.toUpperCase()) !== -1 && (e = e.replace(new RegExp(un[" "][r], "ig"), "❤"))
}
return e
}
function Ie(e) {
for (var t = e.getInt16(1, !0), n = e.getUint8(3, !0), i = "", a = 0; a < n; a++) {
var r = e.getUint8(4 + 2 * a, !0) | e.getUint8(4 + 2 * a + 1, !0) << 8;
i += String.fromCharCode(r)
}
console.log("username received for player", t, i), Zt[t] = we(ke(i)), Ft || t != Xt || (Ye = i, Se.removeChild(He), He = new PIXI.Text(Ye, {
fontFamily: "Arial",
fontSize: 16 / rn,
fill: 16777215
}), He.x = window.innerWidth / 2 - He.width / 2, He.y = window.innerHeight / 2 - st - dt, Se.addChild(He))
}
function be() {
document.getElementById("scoreValue").innerHTML = Vt + 500 * Ot;
var e = 100 * Vt / (1 + 3 * at * (at + 1));
document.getElementById("mapPercent").innerHTML = e.toString().match(/^-?\d+(?:\.\d{0,1})?/)[0], document.getElementById("blocksValue").innerHTML = Vt, document.getElementById("killsValue").innerHTML = Ot, document.getElementById("rankValue").innerHTML = Qt, document.getElementById("totalPlayers").innerHTML = Yt, Pt && !St && e >= 100 && (St = !0, Rt = (new Date).getTime(), document.getElementById("victory").style.display = "block")
}
function qe() {
for (var e = 0; e < Jt.length; e++) Jt[e].playerId > 0 ? (document.getElementById("lb" + (e + 1) + "Name").innerHTML = Zt[Jt[e].playerId], document.getElementById("lb" + (e + 1) + "Score").innerHTML = Jt[e].score) : (document.getElementById("lb" + (e + 1) + "Name").innerHTML = "", document.getElementById("lb" + (e + 1) + "Score").innerHTML = "")
}
function Ee() {
document.getElementById("friendsScores").style.display = Kt.length > 0 ? "block" : "none";
for (var e = '<table class="table">', t = 0; t < Kt.length; t++) Kt[t].rank > 0 && (e += '<tr><td class="rank">' + Kt[t].rank + '.</td><td class="name">' + Zt[Kt[t].playerId] + '</td><td class="fscore">' + Kt[t].score + "</td></tr>");
e += '</table><div class="separator"></div>', document.getElementById("friends-detail").innerHTML = e
}
function xe(e) {
document.getElementById("bonusDisplay").innerHTML = "+" + e, document.getElementById("bonusDisplay").classList.remove("shown"), setTimeout(function() {
document.getElementById("bonusDisplay").classList.add("shown")
}, 100)
}
function Me() {
var e = v(It[Xt] * ot, bt[Xt] * ot),
t = e.q / at * .866,
n = (e.r + e.q / 2) / at;
document.getElementById("minimap-position").setAttribute("cx", t),
document.getElementById("minimap-position").setAttribute("cy", n)
}
function Pe() {
document.getElementById("button-create-party").style.display = "none", document.getElementById("spinner-create-party").style.display = "block", "undefined" != typeof ga && ga("send", "event", "Click", "CreateParty");
var e, t = Te && 0 == Te.length,
n = null;
if (Te)
for (var i = 0; i < Te.length; i++) {
var a = Te[i].z;
gt[a] && (t = !0, gt[a] != -1 && (!n || e > gt[a]) && (n = a, e = gt[a]))
}
if (!t) return void setTimeout(Pe, 50);
var r = new XMLHttpRequest;
r.onreadystatechange = function() {
4 == r.readyState && 200 == r.status && (Ke = r.responseText, document.getElementById("create-party").style.display = "none", document.getElementById("in-party").style.display = "block", window.location.hash = Ke, document.getElementById("party-share-link").value = "http://" + window.location.hostname + (window.location.port ? ":" + window.location.port : "") + window.location.pathname + "#" + Ke)
}, r.onerror = function() {
console.log("Error with createParty, retrying in 5s"), setTimeout(Pe, 5e3)
}, r.open("GET", MM_URL + "/createParty" + (n ? "?zone=" + n : ""), !0), r.send(null)
}
function Be() {
Ke = null, window.location.hash = "", document.getElementById("button-create-party").style.display = "block", document.getElementById("spinner-create-party").style.display = "none", document.getElementById("create-party").style.display = "block", document.getElementById("in-party").style.display = "none", "undefined" != typeof ga && ga("send", "event", "Click", "LeaveParty")
}
var WSERVER_URL, Te, Ce, Le, Se, De, He, Re, Ae, Xe, ze, Ue, je, Fe, We, _e, Ge, Ne, Oe, Ve, Qe, Ye, Je, Ke, Ze, $e, et, tt, nt, it, at = 15,
rt = 15,
ot = Math.max(window.innerWidth / 40 / 2 / .75, window.innerHeight / 40 / Math.sqrt(3)),
lt = 2 * ot,
st = Math.sqrt(3) / 2 * lt,
dt = .6 * ot,
ct = 2 / 3 * dt,
ut = dt / 3,
gt = [],
ht = [],
ft = [],
mt = [],
pt = [],
yt = [],
vt = [],
kt = [],
wt = [],
It = [],
bt = [],
qt = [],
Et = [],
xt = [],
Mt = [],
Pt = !1,
Bt = !1,
Tt = !1,
Ct = !1,
Lt = !1,
St = !1,
Dt = !1,
Ht = !1,
Rt = 0,
At = 0,
Xt = -1,
zt = 0,
Ut = 0,
jt = 0,
Ft = !1,
Wt = [],
_t = [],
Gt = [],
Nt = [],
Ot = 0,
Vt = 7,
Qt = 0,
Yt = 0,
Jt = [],
Kt = [],
Zt = [],
$t = !1,
en = "undefined" != typeof Storage && localStorage.getItem("respawnCount") ? localStorage.getItem("respawnCount") : 0,
tn = [5197647, 16776518, 16594229, 16735861, 2948860, 16657620, 9764642, 16747050, 16762930, 16718941, 1295871, 16147199, 2293637, 15597449, 9043927, 10289033],
nn = [5197647, 7631624, 13116195, 9389135, 1486766, 13836207, 6271494, 13133334, 9596687, 12849990, 38599, 11682745, 962133, 8556345, 3192970, 4832562],
an = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
rn = n(),
on = 1,
ln = [],
sn = [{
q: 1,
r: 0
}, {
q: 1,
r: -1
}, {
q: 0,
r: -1
}, {
q: -1,
r: 0
}, {
q: -1,
r: 1
}, {
q: 0,
r: 1
}];
document.addEventListener("DOMContentLoaded", function() {
if ("undefined" != typeof Storage) {
localStorage.getItem("username") && (document.getElementById("username").value = localStorage.getItem("username"));
var e = localStorage.getItem("quality");
e && i(e)
}
window.location.hash && (6 == window.location.hash.length || 7 == window.location.hash.length && window.location.hash.startsWith("#")) && (Ke = window.location.hash.startsWith("#") ? window.location.hash.substr(1) : window.location.hash, document.getElementById("create-party").style.display = "none", document.getElementById("in-party").style.display = "block", document.getElementById("party-share-link").value = "http://" + window.location.hostname + (window.location.port ? ":" + window.location.port : "") + window.location.pathname + "#" + Ke)
}, !1), window.addEventListener("load", function() {
PIXI.loader.add("img/texturepack.json").add("img/traine.png").load(function(e, t) {
$t = !0, P();
for (var n = 0; n < t.length; n++) t[n].error && console.error("error loading asset", t[n]);
Je = PIXI.loader.resources["img/texturepack.json"].textures, PIXI.loader.resources["img/traine.png"].texture.baseTexture.wrapMode = PIXI.WRAP_MODES.REPEAT
})
}, !1);
var dn = [],
cn = ["4r5e", "5h1t", "5hit", "a_s_s", "a55", "anal", "analconda", "anus", "ar5e", "arrse", "arse", "arsehole", "ass", "ass fuck", "asses", "assfucker", "ass-fucker", "assfukka", "asshole", "assholes", "assmucus", "asswhole", "b!tch", "b00bs", "b17ch", "b1tch", "ballbag", "balls", "ballsack", "bastard", "bastards", "beastial", "beastiality", "bellend", "bestial", "bestiality", "bi+ch", "biatch", "bitch", "bitcher", "bitchers", "bitches", "bitchin", "bitching", "bloody", "blow job", "blowjob", "blowjobs", "blumpkin", "boiolas", "bollock", "bollocks", "bollok", "boner", "boob", "boobs", "booobs", "boooobs", "booooobs", "booooooobs", "breasts", "buceta", "bugger", "buggery", "bum", "bunny fucker", "butt", "butthole", "buttmuch", "buttplug", "c0ck", "c0cksucker", "carpet muncher", "cawk", "chink", "cipa", "cl1t", "clit", "clitoris", "clits", "cnut", "cock", "cockface", "cockhead", "cockmunch", "cockmuncher", "cocks", "cocksuck", "cocksucked", "cocksucker", "cock-sucker", "cocksucker", "cocksucking", "cocksucks", "cocksuka", "cocksukka", "cok", "cokmuncher", "coksucka", "coon", "cox", "crap", "cum", "cum freak", "cumdump", "cumjunkie", "cummer", "cumming", "cums", "cumshot", "cunilingus", "cunillingus", "cunnilingus", "cunt", "cuntbag", "cuntlick", "cuntlicker", "cuntlicking", "cunts", "cuntsicle", "cyalis", "cyberfuc", "cyberfuck", "cyberfucked", "cyberfucker", "cyberfuckers", "cyberfucking", "d1ck", "damn", "darn", "dick", "dickhead", "dildo", "dildos", "dink", "dinks", "dirsa", "dlck", "dog-fucker", "doggin", "dogging", "donkeyribber", "doosh", "douche", "duche", "dyke", "ejaculate", "ejaculated", "ejaculates", "ejaculating", "ejaculatings", "ejaculation", "ejakulate", "f u c k", "f u c k e r", "f_u_c_k", "f4nny", "facialize", "fag", "fagging", "faggitt", "faggot", "faggs", "fagot", "fagots", "fags", "fanny", "fannyflaps", "fannyfucker", "fanyy", "fart", "fatass", "fcuk", "fcuker", "fcuking", "feck", "fecker", "felch", "felching", "fellate", "fellatio", "fingerfuck", "fingerfucked", "fingerfucker", "fingerfuckers", "fingerfucking", "fingerfucks", "fistfuck", "fistfucked", "fistfucker", "fistfuckers", "fistfucking", "fistfuckings", "fistfucks", "flange", "fook", "fooker", "fuck", "fucka", "fuck-bitch", "fucked", "fucker", "fuckers", "fuckhead", "fuckheads", "fuckin", "fucking", "fucking ", "fuckings", "fuckingshitmotherfucker", "fuckme", "fuckmeat", "fucks", "fucktoy", "fuckwhit", "fuckwit", "fudge packer", "fudgepacker", "fuk", "fuker", "fukker", "fukkin", "fuks", "fukwhit", "fukwit", "fux", "fux0r", "gangbang", "gangbang", "gangbanged", "gangbangs", "gaylord", "gaysex", "goatse", "God", "god-dam", "goddamn", "goddamned", "god-damned", "hardcoresex", "hell", "heshe", "hoar", "hoare", "hoer", "homo", "hore", "horniest", "horny", "hotsex", "jackoff", "jack-off", "jap", "jerk-off", "jism", "jiz", "jizm", "jizz", "kawk", "knob", "knobead", "knobed", "knobend", "knobhead", "knobjocky", "knobjokey", "kock", "kondum", "kondums", "kum", "kummer", "kumming", "kums", "kunilingus", "l3i+ch", "l3itch", "labia", "liter", "lust", "lusting", "m0f0", "m0fo", "m45terbate", "ma5terb8", "ma5terbate", "masochist", "masterb8", "masterbat*", "masterbat3", "masterbate", "master-bate", "masterbation", "masterbations", "masturbate", "mof0", "mofo", "mo-fo", "mothafuck", "mothafucka", "mothafuckas", "mothafuckaz", "mothafucked", "mothafucker", "mothafuckers", "mothafuckin", "mothafucking", "mothafuckings", "mothafucks", "mother fucker", "motherfuck", "motherfucked", "motherfucker", "motherfucker", "motherfuckers", "motherfuckin", "motherfucking", "motherfucking", "motherfuckings", "motherfuckka", "motherfucks", "muff", "mutha", "muthafecker", "muthafuckker", "muther", "mutherfucker", "n1gga", "n1gger", "nazi", "nigg3r", "nigg4h", "nigga", "niggah", "niggas", "niggaz", "nigger", "niggers", "nob", "nob jokey", "nobhead", "nobjocky", "nobjokey", "numbnuts", "nutsack", "orgasim", "orgasims", "orgasm", "orgasms", "p0rn", "pawn", "pecker", "penis", "penisfucker", "phonesex", "phuck", "phuk", "phuked", "phuking", "phukked", "phukking", "phuks", "phuq", "pigfucker", "pimpis", "piss", "pissed", "pisser", "pissers", "pisses", "pissflaps", "pissin", "pissing", "pissoff", "poop", "porn", "porno", "pornography", "pornos", "prick", "pricks", "pron", "pube", "pusse", "pussi", "pussies", "pussy", "pussys", "rectum", "retard", "rimjaw", "rimming", "s hit", "s_h_i_t", "sadist", "schlong", "screwing", "scroat", "scrote", "scrotum", "semen", "sex", "sh!+", "sh!t", "sh1t", "shag", "shagger", "shaggin", "shagging", "shemale", "shi+", "shit", "shit ass", "shitass", "shitdick", "shite", "shited", "shitey", "shitfuck", "shitfull", "shithead", "shiting", "shitings", "shits", "shitted", "shitter", "shitters", "shitting", "shittings", "shitty", "skank", "skullfuck", "slaptard", "slich", "slut", "sluts", "smegma", "smut", "snatch", "sob", "son-of-a-bitch", "spac", "spunk", "sucker", "t1tt1e5", "t1tties", "teets", "teez", "testical", "testicle", "tit", "titfuck", "tits", "titt", "tittie5", "tittiefucker", "titties", "tittyfuck", "tittywank", "titwank", "tosser", "turd", "tw4t", "twat", "twathead", "twatty", "twunt", "twunter", "v14gra", "v1gra", "vagina", "viagra", "vulva", "w00se", "wang", "wank", "wanker", "wanky", "whoar", "whore", "willies", "willy", "xrated", "xxx"],
un = {};
! function() {
for (var e = 0; e < cn.length; e++) {
var t = cn[e].toUpperCase(),
n = t.charAt(0);
t.indexOf(" ") !== -1 && (n = " "), void 0 === un[n] && (un[n] = []), un[n].push(t)
}
}();
document.addEventListener("keyup", function(e) {
Pt && (Pt && 83 == e.keyCode ? (Dt = !Dt, document.getElementById("fps") && (document.getElementById("fps").style.display = Dt ? "block" : "none")) : Pt && 70 == e.keyCode && (Ht = !Ht, document.getElementById("friends-detail").style.display = Ht ? "block" : "none"))
});
var gn = {
clickPlay: S,
clickPlayAgain: D,
clickMainMenu: H,
aipComplete: L,
setQuality: i,
createParty: Pe,
leaveParty: Be
};
return gn
}();
//# sourceMappingURL=game.min.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment