Advertisement
JOOTAA

Untitled

Jun 12th, 2018
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 85.87 KB | None | 0 0
  1. ! function(t) {
  2. var e = {};
  3.  
  4. function s(i) {
  5. if (e[i]) return e[i].exports;
  6. var n = e[i] = {
  7. i: i,
  8. l: !1,
  9. exports: {}
  10. };
  11. return t[i].call(n.exports, n, n.exports, s), n.l = !0, n.exports
  12. }
  13. s.m = t, s.c = e, s.d = function(t, e, i) {
  14. s.o(t, e) || Object.defineProperty(t, e, {
  15. configurable: !1,
  16. enumerable: !0,
  17. get: i
  18. })
  19. }, s.r = function(t) {
  20. Object.defineProperty(t, "__esModule", {
  21. value: !0
  22. })
  23. }, s.n = function(t) {
  24. var e = t && t.__esModule ? function() {
  25. return t.default
  26. } : function() {
  27. return t
  28. };
  29. return s.d(e, "a", e), e
  30. }, s.o = function(t, e) {
  31. return Object.prototype.hasOwnProperty.call(t, e)
  32. }, s.p = "", s(s.s = 36)
  33. }([function(t, e) {
  34. t.exports = class {
  35. constructor(t) {
  36. this.game = t, this.loaded = !1
  37. }
  38. openPanel() {
  39. this.appendPanel(), this.loaded || (this.appendLanguages(), this.loaded = !0), $(".problem, .back").hide(), $("#languagesModal").css({
  40. display: "table!important"
  41. }), $("#languagesModal").addClass("bouncein")
  42. }
  43. appendPanel() {
  44. $("#languagesModal").show()
  45. }
  46. appendLanguages() {
  47. if ($("#languagesModalBody").is(":empty")) {
  48. for (var t = ["Russian", "Spanish", "English", "French", "Italian", "Arabic", "Turkish", "Dutch"], e = t.sort(function(t, e) {
  49. return t < e ? -1 : t > e ? 1 : 0
  50. }), s = "", i = 0; i < t.length; i++) s += `<button class="btn btnLanguages" onclick="window.translate('${e[i].toLowerCase()}')"> <font style="vertical-align: inherit;">${e[i]}</font> </button>`;
  51. $("#languagesModalBody").append(s)
  52. }
  53. }
  54. closePanel() {
  55. $("#languagesModal").addClass("bounceout"), $("#languagesModal").removeClass("bouncein"), setTimeout(this.removePanel, 500)
  56. }
  57. removePanel() {
  58. $("#languagesModal").removeClass("bounceout"), $("#languagesModal").hide()
  59. }
  60. }
  61. }, function(t, e) {
  62. t.exports = class {
  63. constructor(t) {
  64. this.game = t, this.hotkeys = {}, this.init()
  65. }
  66. init() {
  67. this.hotkeys = {
  68. split: {
  69. name: "Split",
  70. value: "SPACE",
  71. keyCode: 32
  72. },
  73. macroFeed: {
  74. name: "Macro Feed",
  75. value: "W",
  76. keyCode: 87
  77. },
  78. doubleSplit: {
  79. name: "Double Split",
  80. value: "Q",
  81. keyCode: 81
  82. },
  83. x16Split: {
  84. name: "x16 Split",
  85. value: "T",
  86. keyCode: 84
  87. }
  88. }, this.loadLocalStorage()
  89. }
  90. loadLocalStorage() {
  91. var t = localStorage.getItem("hotkeys");
  92. try {
  93. var e = JSON.parse(t);
  94. e && (this.hotkeys = e)
  95. } catch (t) {}
  96. }
  97. openPanel() {
  98. this.appendPanel(), this.appendHotkeys(), $(".problem, .back").hide(), $("#hotkeysModal").css({
  99. display: "table!important"
  100. }), $("#hotkeysModal").addClass("bouncein")
  101. }
  102. appendPanel() {
  103. $("#game").append('\n\t\t\t<div class="modal fade" id="hotkeysModal" role="dialog">\n\t\t <div class="modal-dialog" style="width: 500px!important;">\n\t\t <div class="modal-content" id="hotkeysModal">\n\t\t <div class="modal-header">\n\t\t <h4 class="modal-title">Change Hotkeys</h4>\n\t\t </div>\n\t\t <div id="hotkeysModalBody" class="modal-body" style="max-height: 445px;overflow: auto;"></div>\n\t\t <div class="modal-footer">\n\t \t<button id="btnShopClose" type="button" class="btn btn-danger" onclick="game.hotkeys.closePanel(); return false;">Close</button>\n\t \t</div>\n\t \t</div>\n\t \t</div>\n\t </div>\n\t ')
  104. }
  105. appendHotkeys() {
  106. if ($("#hotkeysModalBody").is(":empty")) {
  107. var t = "";
  108. for (var e in this.hotkeys) {
  109. var s = this.hotkeys[e];
  110. t += `<div id="hotkeySection"> <div class="hotkeyName"> <p class="hotkeyTrigger">${s.name}</p> </div> <div class="hotkeyCode"> <input class="form-control key" id="hotkey${e}" type="text" onkeydown="game.hotkeys.changeKey('hotkey${e}', event)" code="${e}" value="${s.value}"> </div> </div>`
  111. }
  112. $("#hotkeysModalBody").append(t)
  113. }
  114. }
  115. changeKey(t, e) {
  116. var s = $("#" + t);
  117. s.val(this.getPressedKey(e)), this.hotkeys[s.attr("code")].keyCode = e.keyCode, this.hotkeys[s.attr("code")].value = this.getPressedKey(e), localStorage.setItem("hotkeys", JSON.stringify(this.hotkeys)), e.preventDefault()
  118. }
  119. getPressedKey(t) {
  120. var e = "";
  121. return 8 == t.keyCode || 46 == t.keyCode ? e += "" : 9 == t.keyCode ? e += "TAB" : 16 == t.keyCode ? e += "SHIFT" : 32 == t.keyCode ? e += "SPACE" : e += String.fromCharCode(t.keyCode), e
  122. }
  123. closePanel() {
  124. $("#hotkeysModal").addClass("bounceout"), $("#hotkeysModal").removeClass("bouncein"), setTimeout(this.removePanel, 500)
  125. }
  126. removePanel() {
  127. $("#hotkeysModal").remove()
  128. }
  129. }
  130. }, function(t, e) {
  131. t.exports = '<div id="skinsPage">\n <ul id="tabHolder" class="nav nav-tabs skinTabs"></ul>\n\t<div id="navBar"></div>\n</div>\n'
  132. }, function(t, e) {
  133. t.exports = '<div id="coins">\n <div id="coin">\n <p class="coinsAmount">1,000</p>\n <img src="http://i.imgur.com/5mW0rX7.png" class="buyCoinImg">\n <p class="coinPrice">USD$1.00</p>\n <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\n <input type="hidden" name="cmd" value="_s-xclick">\n <input type="hidden" name="hosted_button_id" value="6VL43CC55HFEA">\n <input id="fbId" type="hidden" name="custom" value="none">\n <button onclick="" class="btn buyCoin">BUY</button>\n </form>\n </div>\n <div id="coin"> \n <p class="coinsAmount">5,000</p>\n <img src="http://i.imgur.com/5mW0rX7.png" class="buyCoinImg">\n <p class="coinPrice">USD$4.50</p>\n <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\n <input type="hidden" name="cmd" value="_s-xclick">\n <input type="hidden" name="hosted_button_id" value="8TG76M4XNF4AL">\n <input type="hidden" name="custom" value="">\n <button onclick="" class="btn buyCoin">BUY</button>\n </form>\n </div>\n <div id="coin"> \n <p class="coinsAmount">10,000</p>\n <img src="http://i.imgur.com/5mW0rX7.png" class="buyCoinImg">\n <p class="coinPrice">USD$8.00</p>\n <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\n <input type="hidden" name="cmd" value="_s-xclick">\n <input type="hidden" name="hosted_button_id" value="3JVEWUU8WV43W">\n <input type="hidden" name="custom" value="">\n <button onclick="" class="btn buyCoin">BUY</button>\n </form>\n </div>\n <div id="coin"> \n <p class="coinsAmount">50,000</p>\n <img src="http://i.imgur.com/5mW0rX7.png" class="buyCoinImg">\n <p class="coinPrice">USD$30.00</p>\n <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\n <input type="hidden" name="cmd" value="_s-xclick">\n <input type="hidden" name="hosted_button_id" value="RW7FEQCSE9MAG">\n <input type="hidden" name="custom" value="">\n <button onclick="" class="btn buyCoin">BUY</button>\n </form>\n </div>\n <div id="coin"> \n <p class="coinsAmount">100,000</p>\n <img src="http://i.imgur.com/5mW0rX7.png" class="buyCoinImg">\n <p class="coinPrice">USD$50.00</p> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\n <input type="hidden" name="cmd" value="_s-xclick">\n <input type="hidden" name="hosted_button_id" value="M8796SVT7RYFG">\n <input type="hidden" name="custom" value="">\n <button onclick="" class="btn buyCoin">BUY</button>\n </form>\n </div>\n</div>'
  134. }, function(t, e) {
  135. t.exports = '<div id="xpBoost">\n <div class="item1">\n <p class="itemTitle">Double XP Boost</p> \n <div class="doubleXp">\n <img src="images/xp-x2.png" class="imgDoubleXp"> \n <p class="time1">1 Hour</p> \n <button id="boostx2" class="btn buyBoost doubleXP1hr">290</button> \n <hr class="divider"> \n <p class="time2">24 Hours</p> \n <button id="boostx3" class="btn buyBoost doubleXP24hr">780</button> \n </div> \n </div>\n <div class="item2">\n <p class="itemTitle">Triple XP Boost</p>\n <div class="tripleXp">\n <img src="images/xp-x3.png" class="imgTripleXp"> \n <p class="time1">1 Hour</p> \n <button id="boostx2" class="btn buyBoost tripleXP1hr">490</button> \n <hr class="divider"> \n <p class="time2">24 Hours</p> \n <button id="boostx3" class="btn buyBoost tripleXP24hr">990</button> \n </div> \n </div>\n</div>'
  136. }, function(t, e) {
  137. t.exports = '<div id="shopMenu">\r\n\t<div id="coinsShop">\r\n\t\t<img src="http://cellz.io/path/img/Coins.png" id="shopImg">\r\n\t</div>\r\n\t<div id="massShop">\r\n\t\t<img src="http://cellz.io/path/img/Mass.png" id="shopImg">\r\n\t</div>\r\n\t<div id="xpShop">\r\n\t\t<img src="http://cellz.io/path/img/XP.png" id="shopImg">\r\n\t</div>\r\n\t<div id="skinsShop">\r\n\t\t<img src="http://cellz.io/path/img/Skins.png" id="shopImg">\r\n\t</div>\r\n</div>'
  138. }, function(t, e) {
  139. t.exports = '<div id="massBoost">\n <div class="item1">\n <p class="itemTitle">Double Mass Boost</p> \n <div class="doubleMass">\n <img src="images/mass-x2.png" class="imgDoubleMass"> \n <p class="time1">1 Hour</p> \n <button id="boostx2" class="btn buyBoost doubleMass1hr">290</button> \n <hr class="divider"> \n <p class="time2">24 Hours</p> \n <button id="boostx3" class="btn buyBoost doubleMass24hr">780</button> \n </div> \n </div>\n <div class="item2">\n <p class="itemTitle">Triple Mass Boost</p>\n <div class="tripleMass">\n <img src="images/mass-x3.png" class="imgTripleMass"> \n <p class="time1">1 Hour</p> \n <button id="boostx2" class="btn buyBoost tripleMass1hr">490</button> \n <hr class="divider"> \n <p class="time2">24 Hours</p> \n <button id="boostx3" class="btn buyBoost tripleMass24hr">990</button>\n </div> \n </div>\n</div>'
  140. }, function(t, e) {
  141. window.genKey = function(t) {
  142. return t ^= 1614, t >>>= 2, t |= 6215, t ^= 21571791
  143. }
  144. }, function(t, e, s) {
  145. "use strict";
  146. s.r(e);
  147. var i = s(2),
  148. n = s.n(i);
  149. var o = function(t, e) {
  150. var s, i = [];
  151. for (s = 0; s < t.length; s += e) i.push(t.slice(s, s + e));
  152. return i
  153. };
  154. e.default = class {
  155. constructor(t) {
  156. this.api = t, this.loaded = !1, this.skinContents = {
  157. Owned: {},
  158. Premium: {},
  159. Youtuber: {}
  160. }, this.selectedTab = "Premium", this.page = 0, this.pages = [], this.sortedSkins = {}, this.selectedSkin = t.game.settings.get("selectedSkin"), this.id = "skinsPage"
  161. }
  162. show() {
  163. this.loaded || ($("#shopModalBody").append(n.a), this.loaded = !0), this.refresh(), $("#" + this.id).show()
  164. }
  165. async refresh() {
  166. for (var t in $("#skinsPage").html('<ul id="tabHolder" class="nav nav-tabs skinTabs"></ul>'), this.skinContents) $("#tabHolder").append(`\n\t\t\t <li id="${t}Holder" class="">\n\t\t\t\t <a href="#">${t}</a>\n\t\t\t </li>\n\t\t\t`);
  167. for (var t in $(`#${this.selectedTab}Holder`).addClass("active"), await this.getSortedSkins(), this.skinContents) this.createTab(t);
  168. this.setPage(this.page), $(".ytQ").remove(), "Youtuber" == name && $(".modal-footer").append('<p class="problem ytQ">Are you a YouTuber and want your skin here too? Contact us on <a href="https://discord.gg/Tz79P5t" target="_blank">Discord!</a></p>')
  169. }
  170. createTab(t) {
  171. $("#skinsPage").append(`<div id="${t}Tab" stlye="display:none"></div>`), $(`#${t}Holder`).click(function() {
  172. this.switchTab(t)
  173. }.bind(this))
  174. }
  175. async switchTab(t) {
  176. if (console.log(t), t == this.selectedTab) return;
  177. $(`#${this.selectedTab}Tab`).hide(), $(`#${this.selectedTab}Tab`).html(""), $(`#${this.selectedTab}Holder`).removeClass("active"), $(`#${t}Holder`).addClass("active"), $(`#${t}Tab`).show(), await this.getSortedSkins(), this.selectedTab = t, this.setPage(0);
  178. let e = null;
  179. for (var s in this.skinContents.Owned) this.skinContents.Owned[s].name == this.selectedSkin && (e = this.skinContents.Owned[s]);
  180. "Owned" == t && this.selectedSkin && this.handleSkinClick(e), $(".ytQ").remove(), "Youtuber" == t && $(".modal-footer").append('<p class="problem ytQ">Are you a YouTuber and want your skin here too? Contact us on <a href="https://discord.gg/Tz79P5t" target="_blank">Discord!</a></p>')
  181. }
  182. setPage(t) {
  183. let e = o(this.skinContents[this.selectedTab], 3);
  184. if (0 == e.length && $(`#${this.selectedTab}Tab`).html('<p class="noSkins">No Skins Avaliable!</p>'), !e[t]) return;
  185. for (var s in console.log("setting page", t), this.page = t, $(`#${this.selectedTab}Tab`).html(""), e[this.page]) {
  186. let t = e[this.page][s],
  187. n = this.getSkinName(t.name),
  188. o = ` \n\t\t\t\t<div id="skin">\n\t\t\t\t\t<div id="skinBlock">\n\t\t\t\t\t\t<p class="skinTitle ${t.name}">${n}</p>\n\t\t\t\t\t\t<img src="http://cellz.io/skins/${t.name}.png" id="skinImage">\n\t\t\t\t\t</div>\n\t\t\t\t\t<button id="button-${t.name}" class="btn buySkin">${t.owned?"USE":t.cost}</button>\n\t\t\t\t</div>`;
  189. $(`#${this.selectedTab}Tab`).append(o);
  190. var i = this;
  191. $(`#button-${t.name}`).click(function() {
  192. i.handleSkinClick(t)
  193. })
  194. }
  195. let n = null;
  196. for (var s in this.skinContents.Owned) this.skinContents.Owned[s].name == this.selectedSkin && (n = this.skinContents.Owned[s]);
  197. "Owned" == this.selectedTab && this.selectedSkin && this.handleSkinClick(n), this.updateNavBar()
  198. }
  199. handleSkinClick(t) {
  200. if (t)
  201. if (t.owned) {
  202. console.log(t, this.selectedSkin), this.selectedSkin && ($(`#button-${this.selectedSkin}`).attr("style", ""), $(`#button-${this.selectedSkin}`).text("USE"));
  203. let e = $(`#button-${t.name}`);
  204. e.css("background-color", "rgb(217, 83, 79)"), e.text("CANCEL"), this.selectedSkin = t.name, this.api.game.settings.set("selectedSkin", this.selectedSkin, "value"), this.api.game.socket.skin = t.name
  205. } else this.api.utils.buyItem(t.name).then(function() {
  206. this.refresh(), t.owned = !0, this.handleSkinClick(t)
  207. }.bind(this));
  208. else console.log("returning", t)
  209. }
  210. updateNavBar() {
  211. var t = $(`#${this.selectedTab}Tab`),
  212. e = function(t, e) {
  213. var s = [];
  214. return 1 == e && (s = [0, 1]), e < 2 ? s : (t < e && 0 !== t ? s = [t - 1, t, t + 1] : t == e && 0 !== t ? s = [t - 2, t - 1, t] : 0 == t && (s = [t, t + 1, t + 2]), s)
  215. }(this.page, o(this.skinContents[this.selectedTab], 3).length - 1),
  216. s = "";
  217. for (var i in e) e[i], this.page, s += `<li id="navPage${e[i]}" class="page-item"><a class="page-link" href="#">${e[i]+1}</a></li>`;
  218. t.append(`<nav><ul class="pagination"><li id="backwardNav" class="page-item"><a class="page-link" href="#" aria-label="Previous"><span aria-hidden="true">&#xAB;</span><span class="sr-only">Previous</span></a></li>${s}<li id="forwardNav" class="page-item"><a class="page-link" href="#" aria-label="Next"><span aria-hidden="true">&#xBB;</span><span class="sr-only">Next</span></a></li></ul></nav>`);
  219. var n = this;
  220. for (var i in e) $(`#navPage${e[i]}`).off(), $(`#navPage${e[i]}`).click(function() {
  221. console.log(parseInt(this.id.split("navPage")[1])), n.setPage(parseInt(this.id.split("navPage")[1]))
  222. });
  223. $("#backwardNav").click(function() {
  224. this.setPage(this.page - 1)
  225. }.bind(this)), $("#forwardNav").click(function() {
  226. this.setPage(this.page + 1)
  227. }.bind(this))
  228. }
  229. getSkinName(t) {
  230. var e = t.split("_").splice(1, 3);
  231. for (var s in e) {
  232. var i = e[s].split("");
  233. i[0] = i[0].toUpperCase(), e[s] = i.join("")
  234. }
  235. return e = e.join(" ")
  236. }
  237. getSortedSkins() {
  238. return new Promise(async function(t, e) {
  239. let s = await this.api.utils.getShopItems();
  240. for (var i in this.skinContents = {
  241. Owned: [],
  242. Premium: [],
  243. Youtuber: []
  244. }, s) {
  245. let t = s[i];
  246. if (t.name.indexOf("skin_") >= 0) {
  247. if (!t.showInShop) continue;
  248. let e = !1;
  249. for (var i in this.api.info.items) this.api.info.items[i].name == t.name && (e = !0);
  250. e ? (t.owned = !0, this.skinContents.Owned.push(t)) : t.youtuber ? this.skinContents.Youtuber.push(t) : this.skinContents.Premium.push(t)
  251. }
  252. }
  253. for (var i in this.skinContents) this.skinContents[i] = this.skinContents[i].sort(function(t, e) {
  254. return t.cost - e.cost
  255. });
  256. t()
  257. }.bind(this))
  258. }
  259. close() {
  260. $("#" + this.id).hide()
  261. }
  262. }
  263. }, function(t, e, s) {
  264. "use strict";
  265. s.r(e);
  266. var i = s(3),
  267. n = s.n(i);
  268. e.default = class {
  269. constructor(t) {
  270. this.api = t, this.loaded = !1, this.id = "coins"
  271. }
  272. show() {
  273. this.loaded || ($("#shopModalBody").append(n.a), this.loaded = !0), $("#" + this.id).show(), $(".modal-footer").append('<p class="problem">Problem with purchasing coins? Contact us on <a href="https://discord.gg/Tz79P5t" target="_blank">Discord!</a></p>')
  274. }
  275. close() {
  276. $(".problem").remove(), $("#" + this.id).hide()
  277. }
  278. }
  279. }, function(t, e, s) {
  280. "use strict";
  281. s.r(e);
  282. var i = s(4),
  283. n = s.n(i);
  284. e.default = class {
  285. constructor(t) {
  286. this.api = t, this.loaded = !1, this.id = "xpBoost"
  287. }
  288. show() {
  289. this.loaded || ($("#shopModalBody").append(n.a), $(".doubleXP1hr").click(function() {
  290. this.api.utils.buyItem("xp_boost_2_1")
  291. }.bind(this)), $(".doubleXP24hr").click(function() {
  292. this.api.utils.buyItem("xp_boost_2_24")
  293. }.bind(this)), $(".tripleXP1hr").click(function() {
  294. this.api.utils.buyItem("xp_boost_3_1")
  295. }.bind(this)), $(".tripleXP24hr").click(function() {
  296. this.api.utils.buyItem("xp_boost_3_24")
  297. }.bind(this)), this.loaded = !0), $("#" + this.id).show()
  298. }
  299. close() {
  300. $("#" + this.id).hide()
  301. }
  302. }
  303. }, function(t, e, s) {
  304. "use strict";
  305. s.r(e);
  306. var i = s(5),
  307. n = s.n(i);
  308. e.default = class {
  309. constructor(t) {
  310. this.api = t, this.loaded = !1, this.id = "shopMenu"
  311. }
  312. show() {
  313. if (!this.loaded) {
  314. for (var t in $("#shopModalBody").append(n.a), this.api.shop.pages)
  315. if ("menu" !== t) {
  316. var e = this;
  317. $(`#${t}Shop > img`).click(function() {
  318. e.api.shop.switchPage($(this).parent()[0].id.split("Shop")[0])
  319. })
  320. }
  321. this.loaded = !0
  322. }
  323. $("#shopBack").hide(), $("#" + this.id).show()
  324. }
  325. close() {
  326. $("#" + this.id).hide()
  327. }
  328. }
  329. }, function(t, e, s) {
  330. "use strict";
  331. s.r(e);
  332. var i = s(6),
  333. n = s.n(i);
  334. e.default = class {
  335. constructor(t) {
  336. this.api = t, this.loaded = !1, this.id = "massBoost"
  337. }
  338. show() {
  339. this.loaded || ($("#shopModalBody").append(n.a), console.log($(".doubleMass1hr")), $(".doubleMass1hr").click(function() {
  340. this.api.utils.buyItem("mass_boost_2_1")
  341. }.bind(this)), $(".doubleMass24hr").click(function() {
  342. this.api.utils.buyItem("mass_boost_2_24")
  343. }.bind(this)), $(".tripleMass1hr").click(function() {
  344. this.api.utils.buyItem("mass_boost_3_1")
  345. }.bind(this)), $(".tripleMass24hr").click(function() {
  346. this.api.utils.buyItem("mass_boost_3_24")
  347. }.bind(this)), this.loaded = !0), $("#" + this.id).show()
  348. }
  349. close() {
  350. $("#" + this.id).hide()
  351. }
  352. }
  353. }, function(t, e, s) {
  354. t.exports = class {
  355. constructor(t) {
  356. this.api = t, this.pages = {
  357. mass: new(s(12).default)(t),
  358. menu: new(s(11).default)(t),
  359. xp: new(s(10).default)(t),
  360. coins: new(s(9).default)(t),
  361. skins: new(s(8).default)(t)
  362. }, this.init()
  363. }
  364. init() {
  365. $("#btnShopClose").click(function() {
  366. this.close()
  367. }.bind(this)), $("#shopBack").click(function() {
  368. this.switchPage("menu")
  369. }.bind(this));
  370. var t = this;
  371. $("#infoModal").ready(function() {
  372. $("#btnProfileClose").click(function() {
  373. $("#infoModal").removeClass("bouncein"), $("#infoModal").addClass("bounceout"), setTimeout(function() {
  374. $("#infoModal").removeClass("bounceout")
  375. }, 500)
  376. }), $("#level").click(async function() {
  377. if (t.api.loggedIn) {
  378. $("#infoModal").removeClass("bounceout"), $("#infoModal").addClass("bouncein");
  379. let e = await t.api.platform.getInfo(),
  380. s = await t.api.platform.getId();
  381. $(".accountName").text(e.name), $(".accountId").text("G+ ID: " + s)
  382. } else t.api.utils.showError("You must login to view your profile")
  383. })
  384. });
  385. for (var e = 0; e < 2; e++) $($(".coinBox")[e]).click(function() {
  386. this.open(), this.switchMenu("coins")
  387. }.bind(this))
  388. }
  389. open() {
  390. this.api.loggedIn ? ($("[name='custom']").val(this.id), this.hideAllPages(), this.switchPage("menu"), $("#shopModal").css({
  391. display: "table!important"
  392. }), $("#shopModal").addClass("bouncein")) : this.api.utils.showError("You must login to access the shop")
  393. }
  394. close() {
  395. $("#shopModal").addClass("bounceout"), $("#shopModal").removeClass("bouncein"), setTimeout(() => {
  396. $("#shopModal").removeClass("bounceout")
  397. }, 500)
  398. }
  399. hideAllPages() {
  400. for (var t in this.pages) this.pages[t].close()
  401. }
  402. switchPage(t) {
  403. this.hideAllPages(), $("#shopBack").show();
  404. var e = !this.pages[t].loaded;
  405. this.pages[t].show(), e && window.reTranslate()
  406. }
  407. }
  408. }, function(t, e) {
  409. t.exports = class {
  410. constructor(t) {
  411. this.api = t
  412. }
  413. getJWT(t, e) {
  414. return new Promise(function(s, i) {
  415. $.get(`${this.api.baseURL}?id=${t}&token=${e}&platform=${this.api.platform.type}`, t => {
  416. s(t)
  417. })
  418. }.bind(this))
  419. }
  420. getUser(t) {
  421. return new Promise(function(e, s) {
  422. $.get(`${this.api.baseURL}/user/${t}`, t => {
  423. e(JSON.parse(t))
  424. })
  425. }.bind(this))
  426. }
  427. buyItem(t) {
  428. return new Promise(function(e, s) {
  429. $.post(`${this.api.baseURL}/buy`, {
  430. jwt: this.api.game.socket.jwt,
  431. item: t
  432. }, async function(t) {
  433. await this.api.updateInfo();
  434. let s = await this.api.platform.getId(),
  435. i = await this.api.platform.getAccessToken();
  436. this.api.game.socket.jwt = await this.getJWT(s, i), this.api.game.socket.sendJWT();
  437. let n = await this.api.platform.getInfo(),
  438. o = await this.api.updateInfo();
  439. this.api.setInfo(n, o), "You Have Successfully Bought This Item!" == t ? this.showSuccess(t) : this.showError(t), e(t)
  440. }.bind(this))
  441. }.bind(this))
  442. }
  443. showSuccess(t) {
  444. t = getText(t), swal({
  445. title: t,
  446. icon: "success"
  447. }), this.closeSwal()
  448. }
  449. showError(t) {
  450. t = getText(t), swal({
  451. title: t,
  452. icon: "error"
  453. }), this.closeSwal()
  454. }
  455. showAlert(t) {
  456. t = getText(t), swal({
  457. title: "Are you sure?",
  458. text: t,
  459. icon: "warning",
  460. buttons: !0,
  461. dangerMode: !0
  462. }), this.closeSwal()
  463. }
  464. closeSwal() {
  465. $(".swal-button").click(() => {
  466. $(".swal-overlay").addClass("bounceout"), $(".swal-overlay").removeClass("bouncein"), setTimeout(() => {
  467. $(".swal-overlay").remove()
  468. }, 1e3)
  469. })
  470. }
  471. getShopItems() {
  472. return new Promise(function(t, e) {
  473. $.get("http://main.cellz.io:8081/shop", function(e) {
  474. t(JSON.parse(e))
  475. })
  476. })
  477. }
  478. }
  479. }, function(t, e) {
  480. t.exports = class {
  481. constructor() {
  482. this.googleUser = null, this.type = "google"
  483. }
  484. loggedIn() {
  485. return new Promise(async function(t, e) {
  486. gapi.auth2.getAuthInstance().isSignedIn.get() ? (this.googleUser = gapi.auth2.getAuthInstance().currentUser.get(), t(!0)) : t(!1)
  487. }.bind(this))
  488. }
  489. login() {
  490. return new Promise(async function(t, e) {
  491. let s = await auth2.signIn();
  492. this.googleUser = s, t()
  493. }.bind(this))
  494. }
  495. logout() {
  496. return new Promise(async function(t, e) {
  497. await auth2.signOut(), t()
  498. }.bind(this))
  499. }
  500. getInfo() {
  501. return new Promise(function(t, e) {
  502. let s = {
  503. profilePic: "",
  504. name: "",
  505. id: this.getId()
  506. },
  507. i = this.googleUser.getBasicProfile();
  508. s.profilePic = i.getImageUrl(), s.name = i.getName().split(" ")[0], t(s)
  509. }.bind(this))
  510. }
  511. getAccessToken() {
  512. return new Promise(function(t, e) {
  513. t(this.googleUser.getAuthResponse().id_token)
  514. }.bind(this))
  515. }
  516. getId() {
  517. return this.googleUser.getBasicProfile().getId()
  518. }
  519. }
  520. }, function(t, e) {
  521. t.exports = class {
  522. constructor() {
  523. console.log("init facebook!")
  524. }
  525. }
  526. }, function(t, e, s) {
  527. const i = s(16),
  528. n = s(15),
  529. o = s(14),
  530. a = s(13);
  531. t.exports = class {
  532. constructor(t) {
  533. this.platforms = {
  534. facebook: new i(this),
  535. google: new n(this)
  536. }, this.platform = this.platforms.google, this.baseURL = "http://main.cellz.io:8081", this.game = t, this.utils = new o(this), this.shop = new a(this), this.info = {}, this.loggedIn = !1
  537. }
  538. async init() {
  539. await this.platform.loggedIn() && this.handleLogin()
  540. }
  541. handleLogin() {
  542. return new Promise(async function(t, e) {
  543. let s = await this.platform.getInfo(),
  544. i = await this.platform.getAccessToken(),
  545. n = await this.utils.getJWT(s.id, i);
  546. this.loggedIn = !0, this.game.socket.jwt = n, this.game.socket.sendJWT();
  547. let o = await this.updateInfo();
  548. this.setInfo(s, o), $("#login").hide(), $("#logout").show()
  549. }.bind(this))
  550. }
  551. updateInfo() {
  552. return new Promise(async function(t, e) {
  553. let s = await this.utils.getUser(this.platform.getId());
  554. this.info = s, t(s)
  555. }.bind(this))
  556. }
  557. login() {
  558. if (!this.loggedIn) return new Promise(async function(t, e) {
  559. await this.platform.login(), await this.handleLogin(), t(!0)
  560. }.bind(this))
  561. }
  562. logout() {
  563. return new Promise(async function(t, e) {
  564. await this.platform.logout(), this.loggedIn = !1, this.setInfo({
  565. profilePic: "http://cellz.io/path/img/profile.png",
  566. name: "Guest"
  567. }, {
  568. coins: 0,
  569. xp: 0
  570. }), $("#logout").hide(), $("#login").show(), t(!0)
  571. }.bind(this))
  572. }
  573. async setInfo(t, e) {
  574. $(".userImg").attr("src", t.profilePic), $(".userName").html(t.name), $(".coinAmount").html(e.coins);
  575. let s = e.xp,
  576. i = Math.ceil(Math.sqrt(s / 1e3)),
  577. n = (Math.floor(i) + 1) ** 2 * 1e3;
  578. $(".progressImg").html(i), $(".xp").html(s + " / " + n), $(".xpProgress").css("width", `${(s/n*87.5).toFixed(2)}%`)
  579. }
  580. }
  581. }, function(t, e) {
  582. t.exports = class {
  583. constructor() {
  584. this.accepted = JSON.parse(localStorage.getItem("acceptedCookies")), this.init()
  585. }
  586. init() {
  587. window.addEventListener("load", function() {
  588. this.accepted || game.cookie.decline(), window.cookieconsent.initialise({
  589. palette: {
  590. popup: {
  591. background: "#fff",
  592. text: "#000"
  593. },
  594. button: {
  595. background: "#eee"
  596. }
  597. },
  598. theme: "edgeless",
  599. position: "bottom-right",
  600. content: {
  601. message: "We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services. You consent to our cookies if you continue to use our website. <br><a href='/pp.html' target='_blank' style='color: #000!important; text-decoration: underline;''>Privacy & Cookie Policy</a> or",
  602. dismiss: "ACCEPT",
  603. link: "Read more"
  604. }
  605. }), game.cookie.run()
  606. }.bind(this))
  607. }
  608. run() {
  609. $(".cc-btn").replaceWith('\n\t\t\t<a aria-label="dismiss cookie message" role="button" tabindex="0" class="cc-btn cc-dismiss accept" style="min-width:120px;width:125px;">Accept</a>\n\t\t\t<a aria-label="dismiss cookie message" role="button" tabindex="0" class="cc-btn cc-dismiss decline" style="min-width:120px;width:125px;">Decline</a>\n\t\t'), $(".accept").click(function() {
  610. game.cookie.accept()
  611. }), $(".decline").click(function() {
  612. localStorage.setItem("acceptedCookies", "false"), game.cookie.decline(), aiptag.consented = !1
  613. }), console.log("User not from Europe")
  614. }
  615. accept() {
  616. localStorage.setItem("acceptedCookies", "true")
  617. }
  618. decline() {
  619. localStorage.clear();
  620. for (var t = document.cookie.split(";"), e = 0; e < t.length; e++) {
  621. var s = t[e],
  622. i = s.indexOf("="),
  623. n = i > -1 ? s.substr(0, i) : s;
  624. document.cookie = n + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"
  625. }
  626. }
  627. }
  628. }, function(t, e) {
  629. t.exports = class {
  630. constructor(t) {
  631. this.game = t, this.ip = "ws://main.cellz.io:9091", this.socket = null, this.init()
  632. }
  633. init() {
  634. this.connect(), setInterval(function() {
  635. this.sendInfo()
  636. }.bind(this), 800)
  637. }
  638. connect() {
  639. this.socket = io(this.ip)
  640. }
  641. sendInfo() {
  642. this.socket.emit("info", {
  643. fps: this.game.scene.fps
  644. })
  645. }
  646. }
  647. }, function(t, e) {
  648. t.exports = {
  649. NA: {
  650. "FFA-1": {
  651. gamemode: "FFA",
  652. port: 443,
  653. stats: 88,
  654. ip: "149.56.99.188"
  655. },
  656. "Big-FFA-1": {
  657. gamemode: "BIG-FFA",
  658. port: 444,
  659. stats: 89,
  660. ip: "149.56.99.188"
  661. },
  662. "Instant-1": {
  663. gamemode: "INSTANT",
  664. port: 8080,
  665. stats: 90,
  666. ip: "149.56.99.188"
  667. },
  668. "MegaSplit-1": {
  669. gamemode: "MEGASPLIT",
  670. port: 1001,
  671. stats: 92,
  672. ip: "149.56.99.188"
  673. }
  674. },
  675. EU: {
  676. "FFA-1": {
  677. gamemode: "FFA",
  678. port: 443,
  679. stats: 88,
  680. ip: "51.38.185.177"
  681. },
  682. "Big-FFA-1": {
  683. gamemode: "BIG-FFA",
  684. port: 444,
  685. stats: 89,
  686. ip: "51.38.185.177"
  687. },
  688. "Instant-1": {
  689. gamemode: "INSTANT",
  690. port: 8080,
  691. stats: 90,
  692. ip: "51.38.185.177"
  693. },
  694. "MegaSplit-1": {
  695. gamemode: "MEGASPLIT",
  696. port: 1001,
  697. stats: 92,
  698. ip: "51.38.185.177"
  699. }
  700. },
  701. AS: {
  702. "FFA-1": {
  703. gamemode: "FFA",
  704. port: 443,
  705. stats: 88,
  706. ip: "139.59.18.142"
  707. },
  708. "Big-FFA-1": {
  709. gamemode: "BIG-FFA",
  710. port: 444,
  711. stats: 89,
  712. ip: "139.59.18.142"
  713. },
  714. "Instant-1": {
  715. gamemode: "INSTANT",
  716. port: 8080,
  717. stats: 90,
  718. ip: "139.59.18.142"
  719. },
  720. "MegaSplit-1": {
  721. gamemode: "MEGASPLIT",
  722. port: 1001,
  723. stats: 92,
  724. ip: "139.59.18.142"
  725. }
  726. }
  727. }
  728. }, function(t, e, s) {
  729. t.exports = class {
  730. constructor(t) {
  731. this.game = t, this.region = "NA", this.gamemode = "FFA", this.selectedServer = null, this.servers = s(20)
  732. }
  733. init() {
  734. var t = localStorage.getItem("region");
  735. t ? (this.setRegion(t), $("#chooseRegion").val(this.region), this.updatePanel()) : this.getRegion(function(t) {
  736. this.setRegion(t), this.updatePanel()
  737. }.bind(this))
  738. }
  739. setGamemode(t) {
  740. this.gamemode = t, console.log(this.region), this.updatePanel(), this.setServer(this.region, this.gamemode)
  741. }
  742. setRegion(t) {
  743. this.region = t, this.updatePanel(), this.setServer(this.region, this.gamemode)
  744. }
  745. updatePanel() {
  746. let t = this.servers[this.region],
  747. e = [];
  748. for (var s in t) t[s].gamemode == this.gamemode && e.push(s);
  749. var i = '<div id="selectServers"> <h1 class="selectServer">Select A Server</h1>';
  750. for (var s in console.log(e), e) i += `<a class="server" href="#" onclick="game.socket.connect('ws://${t[e[s]].ip}:${t[e[s]].port}')">${this.region} ${this.gamemode}<span class="label serverNum blue">${parseInt(s)+1}</span></a>`;
  751. $(".serverPanel").html(i + "</div>")
  752. }
  753. setServer(t, e) {
  754. localStorage.setItem("region", this.region);
  755. let s = this.servers[t],
  756. i = [];
  757. for (var n in s) s[n].gamemode == e && i.push(n);
  758. let o = s[i[Math.floor(Math.random() * i.length)]];
  759. this.selectedServer = o, this.game.socket.connect("ws://" + o.ip + ":" + o.port)
  760. }
  761. getRegion(t) {
  762. $.get("http://ip-api.com/json", function(e) {
  763. t({
  764. BD: "AS",
  765. BE: "EU",
  766. BF: "AF",
  767. BG: "EU",
  768. BA: "EU",
  769. BB: "NA",
  770. WF: "OC",
  771. BL: "NA",
  772. BM: "NA",
  773. BN: "AS",
  774. BO: "SA",
  775. BH: "AS",
  776. BI: "AF",
  777. BJ: "AF",
  778. BT: "AS",
  779. JM: "NA",
  780. BV: "AN",
  781. BW: "AF",
  782. WS: "OC",
  783. BQ: "NA",
  784. BR: "SA",
  785. BS: "NA",
  786. JE: "EU",
  787. BY: "EU",
  788. BZ: "NA",
  789. RU: "EU",
  790. RW: "AF",
  791. RS: "EU",
  792. TL: "OC",
  793. RE: "AF",
  794. TM: "AS",
  795. TJ: "AS",
  796. RO: "EU",
  797. TK: "OC",
  798. GW: "AF",
  799. GU: "OC",
  800. GT: "NA",
  801. GS: "AN",
  802. GR: "EU",
  803. GQ: "AF",
  804. GP: "NA",
  805. JP: "AS",
  806. GY: "SA",
  807. GG: "EU",
  808. GF: "SA",
  809. GE: "AS",
  810. GD: "NA",
  811. GB: "EU",
  812. GA: "AF",
  813. SV: "NA",
  814. GN: "AF",
  815. GM: "AF",
  816. GL: "NA",
  817. GI: "EU",
  818. GH: "AF",
  819. OM: "AS",
  820. TN: "AF",
  821. JO: "AS",
  822. HR: "EU",
  823. HT: "NA",
  824. HU: "EU",
  825. HK: "AS",
  826. HN: "NA",
  827. HM: "AN",
  828. VE: "SA",
  829. PR: "NA",
  830. PS: "AS",
  831. PW: "OC",
  832. PT: "EU",
  833. SJ: "EU",
  834. PY: "SA",
  835. IQ: "AS",
  836. PA: "NA",
  837. PF: "OC",
  838. PG: "OC",
  839. PE: "SA",
  840. PK: "AS",
  841. PH: "AS",
  842. PN: "OC",
  843. PL: "EU",
  844. PM: "NA",
  845. ZM: "AF",
  846. EH: "AF",
  847. EE: "EU",
  848. EG: "AF",
  849. ZA: "AF",
  850. EC: "SA",
  851. IT: "EU",
  852. VN: "AS",
  853. SB: "OC",
  854. ET: "AF",
  855. SO: "AF",
  856. ZW: "AF",
  857. SA: "AS",
  858. ES: "EU",
  859. ER: "AF",
  860. ME: "EU",
  861. MD: "EU",
  862. MG: "AF",
  863. MF: "NA",
  864. MA: "AF",
  865. MC: "EU",
  866. UZ: "AS",
  867. MM: "AS",
  868. ML: "AF",
  869. MO: "AS",
  870. MN: "AS",
  871. MH: "OC",
  872. MK: "EU",
  873. MU: "AF",
  874. MT: "EU",
  875. MW: "AF",
  876. MV: "AS",
  877. MQ: "NA",
  878. MP: "OC",
  879. MS: "NA",
  880. MR: "AF",
  881. IM: "EU",
  882. UG: "AF",
  883. TZ: "AF",
  884. MY: "AS",
  885. MX: "NA",
  886. IL: "AS",
  887. FR: "EU",
  888. IO: "AS",
  889. SH: "AF",
  890. FI: "EU",
  891. FJ: "OC",
  892. FK: "SA",
  893. FM: "OC",
  894. FO: "EU",
  895. NI: "NA",
  896. NL: "EU",
  897. NO: "EU",
  898. NA: "AF",
  899. VU: "OC",
  900. NC: "OC",
  901. NE: "AF",
  902. NF: "OC",
  903. NG: "AF",
  904. NZ: "OC",
  905. NP: "AS",
  906. NR: "OC",
  907. NU: "OC",
  908. CK: "OC",
  909. XK: "EU",
  910. CI: "AF",
  911. CH: "EU",
  912. CO: "SA",
  913. CN: "AS",
  914. CM: "AF",
  915. CL: "SA",
  916. CC: "AS",
  917. CA: "NA",
  918. CG: "AF",
  919. CF: "AF",
  920. CD: "AF",
  921. CZ: "EU",
  922. CY: "EU",
  923. CX: "AS",
  924. CR: "NA",
  925. CW: "NA",
  926. CV: "AF",
  927. CU: "NA",
  928. SZ: "AF",
  929. SY: "AS",
  930. SX: "NA",
  931. KG: "AS",
  932. KE: "AF",
  933. SS: "AF",
  934. SR: "SA",
  935. KI: "OC",
  936. KH: "AS",
  937. KN: "NA",
  938. KM: "AF",
  939. ST: "AF",
  940. SK: "EU",
  941. KR: "AS",
  942. SI: "EU",
  943. KP: "AS",
  944. KW: "AS",
  945. SN: "AF",
  946. SM: "EU",
  947. SL: "AF",
  948. SC: "AF",
  949. KZ: "AS",
  950. KY: "NA",
  951. SG: "AS",
  952. SE: "EU",
  953. SD: "AF",
  954. DO: "NA",
  955. DM: "NA",
  956. DJ: "AF",
  957. DK: "EU",
  958. VG: "NA",
  959. DE: "EU",
  960. YE: "AS",
  961. DZ: "AF",
  962. US: "NA",
  963. UY: "SA",
  964. YT: "AF",
  965. UM: "OC",
  966. LB: "AS",
  967. LC: "NA",
  968. LA: "AS",
  969. TV: "OC",
  970. TW: "AS",
  971. TT: "NA",
  972. TR: "AS",
  973. LK: "AS",
  974. LI: "EU",
  975. LV: "EU",
  976. TO: "OC",
  977. LT: "EU",
  978. LU: "EU",
  979. LR: "AF",
  980. LS: "AF",
  981. TH: "AS",
  982. TF: "AN",
  983. TG: "AF",
  984. TD: "AF",
  985. TC: "NA",
  986. LY: "AF",
  987. VA: "EU",
  988. VC: "NA",
  989. AE: "AS",
  990. AD: "EU",
  991. AG: "NA",
  992. AF: "AS",
  993. AI: "NA",
  994. VI: "NA",
  995. IS: "EU",
  996. IR: "AS",
  997. AM: "AS",
  998. AL: "EU",
  999. AO: "AF",
  1000. AQ: "AN",
  1001. AS: "OC",
  1002. AR: "SA",
  1003. AU: "OC",
  1004. AT: "EU",
  1005. AW: "NA",
  1006. IN: "AS",
  1007. AX: "EU",
  1008. AZ: "AS",
  1009. IE: "EU",
  1010. ID: "AS",
  1011. UA: "EU",
  1012. QA: "AS",
  1013. MZ: "AF"
  1014. }[e.countryCode])
  1015. }.bind(this), "jsonp")
  1016. }
  1017. }
  1018. }, function(t, e) {
  1019. t.exports = class {
  1020. constructor(t) {
  1021. this.game = t, this.focused = !1, this.init()
  1022. }
  1023. init() {
  1024. $("#chatInput").ready(function() {
  1025. document.getElementById("chatInput").onblur = function() {
  1026. this.focused = !1
  1027. }.bind(this), document.getElementById("chatInput").onfocus = function() {
  1028. this.focused = !0
  1029. }.bind(this)
  1030. }.bind(this))
  1031. }
  1032. escape(t) {
  1033. var e = {
  1034. "&": "&amp;",
  1035. "<": "&lt;",
  1036. ">": "&gt;",
  1037. '"': "&quot;",
  1038. "'": "&#39;",
  1039. "/": "&#x2F;"
  1040. };
  1041. return String(t).replace(/[&<>"'\/]/g, function(t) {
  1042. return e[t]
  1043. })
  1044. }
  1045. onChat(t) {
  1046. var e = $(".chatMessages")[0],
  1047. s = e.scrollHeight - e.clientHeight <= e.scrollTop + 1;
  1048. $(".chatMessages").append(`<li class='chatItem'><span class='chatName' style="color: rgb(${t.color.r}, ${t.color.g}, ${t.color.b})">${this.escape(t.name)}:</span><span class='chatMsg'>${this.escape(t.msg)}</span></li>`), $(".chatMessages").scrollTop($(".chatMessages").height()), s && (e.scrollTop = e.scrollHeight - e.clientHeight)
  1049. }
  1050. sendChat(t) {
  1051. this.game.socket.sendChat(t)
  1052. }
  1053. }
  1054. }, function(t, e, s) {
  1055. t.exports = class {
  1056. constructor() {
  1057. this.game = game, this.panels = {
  1058. HotkeyPanel: new(s(1))(game),
  1059. LanguagePanel: new(s(0))(game)
  1060. }, this.init()
  1061. }
  1062. init() {
  1063. console.log(this.panels)
  1064. }
  1065. showPanel(t) {
  1066. this.panels[t] && this.panels[t].show()
  1067. }
  1068. }
  1069. }, function(t, e) {
  1070. class s {
  1071. static getCanvas(t, e) {
  1072. const s = document.createElement("canvas");
  1073. return t && (s.width = t), e && (s.height = e), s
  1074. }
  1075. static getContext(t, e) {
  1076. return this.getCanvas(t, e).getContext("2d")
  1077. }
  1078. static mesureText(t, e, s) {
  1079. return this.element || this.createMesuringDiv(), this.element.textContent = t, this.element.style.font = e, this.element.style.strokeWidth = s, {
  1080. height: this.element.clientHeight + 1,
  1081. width: this.element.clientWidth + 1
  1082. }
  1083. }
  1084. static isFontLoaded(t) {
  1085. this.element || this.createMesuringDiv();
  1086. const e = `${t.slice(0,t.lastIndexOf(" "))} FAKEFONTLOOL`;
  1087. this.element.style.font = t;
  1088. const s = this.mesureText("TESTTEXTTT X").width;
  1089. return this.element.style.font = e, s !== this.mesureText("TESTTEXTTT X").width
  1090. }
  1091. static createMesuringDiv() {
  1092. this.element = document.createElement("div"), this.element.id = "text-util-abc", this.element.style.position = "absolute", this.element.style.visibility = "hidden", this.element.style.height = "auto", this.element.style.width = "auto", this.element.style["white-space"] = "nowrap", document.body.appendChild(this.element)
  1093. }
  1094. }
  1095. class i {
  1096. constructor({
  1097. text: t = "",
  1098. fontSetting: e,
  1099. fillStyle: s,
  1100. strokeStyle: i,
  1101. strokeSize: n
  1102. }) {
  1103. this.text = t, this.fontSetting = e, this.fillStyle = s, this.strokeStyle = i, this.strokeSize = n, this.width = 0, this.height = 0, this.caches = [], this.fontLoaded = !1
  1104. }
  1105. mesureText() {
  1106. const t = this.getFontSetting(100),
  1107. e = 100 * this.strokeSize,
  1108. {
  1109. width: i,
  1110. height: n
  1111. } = s.mesureText(this.text, t, e);
  1112. return {
  1113. width: i / 100,
  1114. height: n / 100
  1115. }
  1116. }
  1117. getFontSetting(t) {
  1118. return this.fontSetting.replace("{pt}", t)
  1119. }
  1120. getLevel(t) {
  1121. return Math.round(Math.sqrt(t) / 2)
  1122. }
  1123. getSize(t) {
  1124. return (2 * (t + .5)) ** 2
  1125. }
  1126. isFontLoaded() {
  1127. if (this.fontLoaded) return !0;
  1128. return !!s.isFontLoaded(this.getFontSetting(100)) && (this.fontLoaded = !0, !0)
  1129. }
  1130. getCache(t) {
  1131. if (!this.isFontLoaded()) return s.getCanvas(10, 10);
  1132. if (!this.width && !this.height) {
  1133. const {
  1134. width: t,
  1135. height: e
  1136. } = this.mesureText();
  1137. this.width = t, this.height = e
  1138. }
  1139. const e = this.getLevel(t);
  1140. if (!this.caches[e]) {
  1141. const t = this.generateCache(e);
  1142. this.caches[e] = t
  1143. }
  1144. return this.caches[e]
  1145. }
  1146. findLarger(t) {
  1147. return this.caches.find((e, s) => s > t)
  1148. }
  1149. generateCache(t) {
  1150. "xAz" === this.text && console.log(t);
  1151. const e = this.getSize(t),
  1152. i = e * this.width + 10,
  1153. n = e * this.height + 10,
  1154. o = s.getContext(i, n),
  1155. a = this.findLarger(t);
  1156. return a ? o.drawImage(a, 0, 0, i, n) : (o.font = this.getFontSetting(e), o.fillStyle = this.fillStyle, o.strokeStyle = this.strokeStyle, o.lineWidth = e * this.strokeSize, o.textBaseline = "middle", o.textAlign = "center", this.strokeSize && o.strokeText(this.text, i / 2, n / 2), o.fillText(this.text, i / 2, n / 2)), o.canvas
  1157. }
  1158. }
  1159. t.exports = {
  1160. Cache: class {
  1161. constructor(t) {
  1162. this.caches = new Map, this.cacheSettings = Object.assign({
  1163. fontSetting: "500 {pt}pt Ubuntu",
  1164. fillStyle: "#fff",
  1165. strokeStyle: "#000",
  1166. strokeSize: .1
  1167. }, t), this.cleanInterval = setInterval(() => this.clean(), 3e4)
  1168. }
  1169. getCache(t) {
  1170. if (!this.caches.get(t)) {
  1171. const e = new i({ ...this.cacheSettings,
  1172. text: t
  1173. });
  1174. this.caches.set(t, e)
  1175. }
  1176. const e = this.caches.get(t);
  1177. return e.updateTime = Date.now(), e
  1178. }
  1179. clean() {
  1180. this.caches.forEach((t, e) => {
  1181. e.updateTime < Date.now() - 12e4 && this.caches.delete(t)
  1182. })
  1183. }
  1184. },
  1185. Text: i,
  1186. CanvasUtils: s
  1187. }
  1188. }, function(t, e) {
  1189. t.exports = class {
  1190. constructor(t) {
  1191. this.game = t, this.settings = {}, this.settingsConf = JSON.parse(localStorage.getItem("settingsConf")) || {}, this.domQueue = [], this.init()
  1192. }
  1193. init() {
  1194. this.loadSettings(), this.loadEvents()
  1195. }
  1196. handleDomQueue() {
  1197. for (var t in this.domQueue) $(this.domQueue[t].id).val(this.domQueue[t].val)
  1198. }
  1199. loadEvents() {
  1200. var t = ["noSkins", "noNames", "darkTheme", "showMass", "smoothRender", "hideChat"];
  1201. for (var e in t) $("#" + t[e]).click(this.toggleCheckBox.bind(this, t[e]))
  1202. }
  1203. toggleCheckBox(t) {
  1204. let e = document.getElementById(t).checked;
  1205. switch (this.set(t, e, "checkbox"), t) {
  1206. case "hideChat":
  1207. 1 == e ? $("#chatbox").hide() : $("#chatbox").show()
  1208. }
  1209. }
  1210. loadSettings() {
  1211. for (var t in this.settingsConf) {
  1212. this.settings[t] = this.get(t);
  1213. var e = this.settingsConf[t];
  1214. "input" == e.type && (this.domQueue.push({
  1215. id: `#${t}`,
  1216. val: this.settings[t]
  1217. }), console.log(this.settings[t], `#${t}`)), "checkbox" == e.type && (document.getElementById(t).checked = this.settings[t], this.toggleCheckBox(t))
  1218. }
  1219. }
  1220. get(t) {
  1221. if (this.settings[t]) return this.settings[t]; {
  1222. let e = localStorage.getItem(t);
  1223. if (!e) return null;
  1224. try {
  1225. return JSON.parse(e)
  1226. } catch (t) {
  1227. return e
  1228. }
  1229. }
  1230. }
  1231. set(t, e, s) {
  1232. this.settings[t] = e, this.settingsConf[t] = {
  1233. type: s
  1234. }, localStorage.setItem(t, e), localStorage.setItem("settingsConf", JSON.stringify(this.settingsConf))
  1235. }
  1236. remove(t) {
  1237. delete this.settings[t], delete this.settingsConf[t], localStorage.removeItem(t), localStorage.setItem("settingsConf", JSON.stringify(this.settingsConf))
  1238. }
  1239. }
  1240. }, function(t, e) {
  1241. t.exports = class {
  1242. constructor(t) {
  1243. this.game = t, this.hotkeys = {
  1244. split: {
  1245. key: t.settings.get("split") || 32,
  1246. type: "simple",
  1247. name: "Split",
  1248. handler: function() {
  1249. t.socket.split()
  1250. }
  1251. },
  1252. doubleSplit: {
  1253. key: t.settings.get("doubleSplit") || 81,
  1254. type: "simple",
  1255. name: "Double Split",
  1256. handler: function() {
  1257. t.socket.split(), setTimeout(function() {
  1258. t.socket.split()
  1259. }.bind(this), 40)
  1260. }
  1261. },
  1262. x16: {
  1263. key: t.settings.get("x16") || 84,
  1264. type: "simple",
  1265. name: "16 Split",
  1266. handler: function() {
  1267. t.socket.split(), setTimeout(function() {
  1268. t.socket.split()
  1269. }.bind(this), 40), setTimeout(function() {
  1270. t.socket.split()
  1271. }.bind(this), 80), setTimeout(function() {
  1272. t.socket.split()
  1273. }.bind(this), 120)
  1274. }
  1275. },
  1276. feedMacro: {
  1277. key: t.settings.get("feedMacro") || 87,
  1278. type: "continuous",
  1279. name: "Feed",
  1280. interval: 100,
  1281. handler: function() {
  1282. t.socket.eject()
  1283. }
  1284. },
  1285. esc: {
  1286. key: 27,
  1287. type: "simple",
  1288. custom: !1,
  1289. handler: function() {
  1290. $(".menu").show()
  1291. }
  1292. },
  1293. sendChat: {
  1294. key: 13,
  1295. type: "simple",
  1296. custom: !1,
  1297. chatFocus: !0,
  1298. handler: function() {
  1299. console.log("test"), t.chat.focused ? (console.log(t.chat.focused), t.socket.sendChat($("#chatInput").val()), $("#chatInput").val("").blur()) : ($("#chatInput").focus(), t.chat.focused = !0)
  1300. }
  1301. },
  1302. spectate: {
  1303. key: 81,
  1304. type: "simple",
  1305. custom: !1,
  1306. handler: function() {
  1307. t.socket.send(new Uint8Array([18]))
  1308. }
  1309. }
  1310. }, this.init()
  1311. }
  1312. init() {
  1313. window.addEventListener("keydown", this.onKeyDown.bind(this)), window.addEventListener("keyup", this.onKeyUp.bind(this)), $("#hotkeyModal").ready(function() {
  1314. for (var t in this.hotkeys) {
  1315. let s = this.hotkeys[t];
  1316. if (void 0 == this.hotkeys[t].custom) {
  1317. $("#hotkeysModalBody").append(`<div id="hotkeySection"> <div class="hotkeyName"> <p class="hotkeyTrigger">${s.name}</p> </div> <div class="hotkeyCode"> <input class="form-control key" id="hotkey${t}" type="text" value="${this.getPressedKey({keyCode:s.key})}"> </div> </div>`);
  1318. var e = this;
  1319. $(`#hotkey${t}`).keydown(function(t) {
  1320. e.handleKey(this.id.split("hotkey")[1], this, t)
  1321. })
  1322. }
  1323. }
  1324. $("#btnHotkeysClose").click(function() {
  1325. return $("#hotkeysModal").removeClass("bouncein"), $("#hotkeysModal").addClass("bounceout"), setTimeout(function() {
  1326. $("#hotkeysModal").removeClass("bounceout")
  1327. }, 500), !1
  1328. }.bind(this)), $(".btnControls").click(function() {
  1329. return $("#hotkeysModal").removeClass("bounceout"), $("#hotkeysModal").addClass("bouncein"), !1
  1330. }.bind(this))
  1331. }.bind(this))
  1332. }
  1333. onKeyDown(t) {
  1334. for (var e in this.hotkeys) {
  1335. let s = this.hotkeys[e];
  1336. if (s.key == t.keyCode) {
  1337. if (s.pressed) return;
  1338. if (this.game.chat.focused && !s.chatFocus) return;
  1339. s.handler(), "continuous" == s.type && (s.keyInterval = setInterval(function() {
  1340. s.handler()
  1341. }.bind(this), s.interval || 120)), s.pressed = !0
  1342. }
  1343. }
  1344. }
  1345. onKeyUp(t) {
  1346. for (var e in this.hotkeys) {
  1347. let s = this.hotkeys[e];
  1348. s.key == t.keyCode && (s.pressed = !1, "continuous" == s.type && clearInterval(s.keyInterval))
  1349. }
  1350. }
  1351. handleKey(t, e, s) {
  1352. e.value.length > 0 && (e.value = this.getPressedKey(s), s.preventDefault()), this.game.settings.set(e.id, this.getPressedKey(s), "input"), this.hotkeys[t].key = s.keyCode, this.game.settings.set(e.id.split("hotkey")[1], s.keyCode, "value")
  1353. }
  1354. getPressedKey(t) {
  1355. var e = "";
  1356. return 8 == t.keyCode || 46 == t.keyCode ? e += "" : 9 == t.keyCode ? e += "TAB" : 16 == t.keyCode ? e += "SHIFT" : 32 == t.keyCode ? e += "SPACE" : e += String.fromCharCode(t.keyCode), e
  1357. }
  1358. }
  1359. }, function(t, e) {
  1360. t.exports = class {
  1361. constructor(t) {
  1362. this.game = t, this.canvas = null, this.ctx = null, this.camera = {
  1363. oldX: 0,
  1364. oldY: 0,
  1365. x: 0,
  1366. y: 0,
  1367. newX: 0,
  1368. newY: 0
  1369. }, this.zoom = .6, this.newZoom = .6, this.wheelZoom = 1, this.mouse = {
  1370. rawX: 0,
  1371. rawY: 0,
  1372. x: 0,
  1373. y: 0
  1374. }, this.maxScore = 0, this.scenes = [], this.fps = 0, this.fpsTimes = []
  1375. }
  1376. init() {
  1377. this.canvas = document.getElementById("canvas"), this.ctx = this.canvas.getContext("2d"), this.canvas.width = window.innerWidth, this.canvas.height = window.innerHeight, window.addEventListener("resize", () => {
  1378. this.canvas.width = window.innerWidth, this.canvas.height = window.innerHeight
  1379. }), window.addEventListener("wheel", function(t) {
  1380. t.deltaY < 0 && (this.wheelZoom += this.wheelZoom / 15), t.deltaY > 0 && (this.wheelZoom -= this.wheelZoom / 15)
  1381. }.bind(this)), this.canvas.onmousemove = this.onMouseMove.bind(this), setInterval(function() {
  1382. "DISCONNECTED" !== this.game.socket.state && this.sendMouseMove()
  1383. }.bind(this), 100), requestAnimationFrame(this.drawGame.bind(this))
  1384. }
  1385. onMouseMove(t) {
  1386. this.mouse.rawX = t.clientX, this.mouse.rawY = t.clientY
  1387. }
  1388. sendMouseMove() {
  1389. this.mouse.x = (this.mouse.rawX - this.canvas.width / 2) / this.newZoom + this.camera.x, this.mouse.y = (this.mouse.rawY - this.canvas.height / 2) / this.newZoom + this.camera.y, this.game.socket.move(this.mouse.x, this.mouse.y)
  1390. }
  1391. drawGrid() {
  1392. this.ctx.fillStyle = this.game.settings.get("darkTheme") ? "#111111" : "#F2FBFF", this.ctx.lineWidth = 1, this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.save(), this.ctx.strokeStyle = this.game.settings.get("darkTheme") ? "#AAAAAA" : "#000000", this.ctx.globalAlpha = .2, this.ctx.scale(this.newZoom, this.newZoom);
  1393. for (var t = this.canvas.width / this.newZoom, e = this.canvas.height / this.newZoom, s = (-this.camera.x + t / 2) % 50 - .5; s < t; s += 50) this.ctx.moveTo(s, 0), this.ctx.lineTo(s, e);
  1394. for (this.ctx.stroke(), this.ctx.beginPath(), s = (-this.camera.y + e / 2) % 50 - .5; s < e; s += 50) this.ctx.moveTo(0, s), this.ctx.lineTo(t, s);
  1395. this.ctx.stroke(), this.ctx.restore()
  1396. }
  1397. lerp(t, e, s) {
  1398. return (1 - s) * t + s * e
  1399. }
  1400. updateViewPort() {
  1401. var t = {};
  1402. for (var e in this.game.playerCells) 0 !== this.game.playerCells[e] && (t[e] = this.game.playerCells[e]);
  1403. if (Object.keys(t).length > 0) {
  1404. var s = 0,
  1405. i = 0;
  1406. for (var e in t) t[e].updatePos(), s += t[e].x / Object.keys(t).length, i += t[e].y / Object.keys(t).length;
  1407. s = (this.camera.x + s) / 2, i = (this.camera.y + i) / 2, this.camera = {
  1408. x: s,
  1409. y: i
  1410. }, this.zoom = this.getViewZoom()
  1411. }
  1412. }
  1413. getViewZoom() {
  1414. var t = 0,
  1415. e = this;
  1416. for (var s in this.game.playerCells) this.game.playerCells[s] && (t += this.game.playerCells[s].size);
  1417. return t = Math.pow(Math.min(64 / t, 1), .4) * (Math.max(e.canvas.height / 1080, e.canvas.width / 1920) * e.wheelZoom)
  1418. }
  1419. clearCanvas() {
  1420. this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
  1421. }
  1422. drawGame() {
  1423. var t = Date.now();
  1424. game.timestamp = t;
  1425. const e = performance.now();
  1426. for (; this.fpsTimes.length > 0 && this.fpsTimes[0] <= e - 1e3;) this.fpsTimes.shift();
  1427. this.fpsTimes.push(e), this.fps = this.fpsTimes.length, this.updateViewPort();
  1428. let s = 0;
  1429. for (var i in this.game.playerCells) 0 !== (o = this.game.playerCells[i]) && (s += o.size * o.size / 100);
  1430. s > this.maxScore && (this.maxScore = s, $("#score").text("Score: " + Math.round(s))), this.ctx.setTransform(1, 0, 0, 1, 0, 0), this.clearCanvas(), this.drawGrid(), this.newZoom = this.lerp(this.newZoom, this.zoom, .1), this.ctx.translate(this.canvas.width / 2, this.canvas.height / 2), this.ctx.scale(this.newZoom, this.newZoom), this.ctx.translate(-this.camera.x, -this.camera.y);
  1431. var n = Object.keys(game.cells).sort(function(t, e) {
  1432. return game.cells[t].size - game.cells[e].size
  1433. });
  1434. for (var i in n) {
  1435. var o;
  1436. (o = this.game.cells[n[i]]).render(this.ctx)
  1437. }
  1438. window.stopCanvas || requestAnimationFrame(this.drawGame.bind(this))
  1439. }
  1440. }
  1441. }, function(t, e) {
  1442. t.exports = function(t, e) {
  1443. function s() {
  1444. for (var e = ""; 0 !== (char = t.getUint16(i, !0));) e += String.fromCharCode(char), i += 2;
  1445. return i += 2, e
  1446. }
  1447. var i = 1,
  1448. n = (t.getUint8(i++), {
  1449. r: t.getUint8(i++),
  1450. g: t.getUint8(i++),
  1451. b: t.getUint8(i++)
  1452. }),
  1453. o = {
  1454. name: s(),
  1455. msg: s(),
  1456. color: n
  1457. };
  1458. e.game.chat.onChat(o)
  1459. }
  1460. }, function(t, e) {
  1461. t.exports = function(t, e) {
  1462. e.game.map.minX = t.getFloat64(1, !0), e.game.map.minY = t.getFloat64(9, !0), e.game.map.maxX = t.getFloat64(17, !0), e.game.map.maxY = t.getFloat64(25, !0), Object.keys(game.playerCells).length
  1463. }
  1464. }, function(t, e) {
  1465. t.exports = function(t, e) {
  1466. let s = 1;
  1467. var i = [],
  1468. n = t.getUint32(s, !0);
  1469. s += 4;
  1470. for (var o = 0; o < n; o++) {
  1471. var a = t.getUint32(s, !0);
  1472. s += 4;
  1473. for (var h, l = ""; h = t.getUint16(s, !0), s += 2, 0 != h;) l += String.fromCharCode(h);
  1474. i.push({
  1475. name: l,
  1476. id: a
  1477. })
  1478. }
  1479. game.leaderboard = i, game.drawLeaderboard()
  1480. }
  1481. }, function(t, e) {
  1482. t.exports = function(t, e) {
  1483. let s = e.game;
  1484. var i = t.getUint32(1, !0);
  1485. s.ownedCells.push(i), 1 == Object.keys(s.playerCells).length && (e.state = "SPAWNED")
  1486. }
  1487. }, function(t, e) {
  1488. t.exports = function(t, e) {
  1489. var s = e.game.scene;
  1490. s.camera.x = s.lerp(s.camera.x, t.getFloat32(1, !0), .05), s.camera.y = s.lerp(s.camera.y, t.getFloat32(5, !0), .05), s.zoom = t.getFloat32(9, !0) * s.wheelZoom, game.socket.state = "SPECTATING"
  1491. }
  1492. }, function(t, e) {
  1493. window.pelletCache = {};
  1494. var s = ["073CFF", "FF076E", "07FF9B", "07E0FF", "9E07FF", "FF0E07", "FF7C07"],
  1495. i = new Image;
  1496. i.src = "virus.png";
  1497. var n = new Image;
  1498. n.src = "mothercell.png";
  1499. t.exports = class {
  1500. constructor(t, e, s, i, n) {
  1501. this.id = t, this.oldX = this.x = e, this.oldY = this.y = s, this.newX = 0, this.newY = 0, this.oldSize = this.size = i, this.newSize = 0, this.color = "", this.pelletColor = "", this.name = "", this.isVirus = !1, this.isPellet = !1, this.updateTime = 0, this.game = n, this.nameCache = null, this.extras = {}
  1502. }
  1503. updatePos() {
  1504. var t, e = 0 > (t = 0 > (t = (this.game.timestamp - this.updateTime) / 120) ? 0 : 1 < t ? 1 : t) ? 0 : 1 < t ? 1 : t;
  1505. return this.x = t * (this.newX - this.oldX) + this.oldX, this.y = t * (this.newY - this.oldY) + this.oldY, this.size = e * (this.newSize - this.oldSize) + this.oldSize, e
  1506. }
  1507. setName(t) {
  1508. this.name || (this.name = t, this.nameCache = this.game.nameCache.getCache(t))
  1509. }
  1510. getStrokeStyle() {
  1511. var t = (~~(.9 * parseInt(this.color.substr(1, 2), 16))).toString(16),
  1512. e = (~~(.9 * parseInt(this.color.substr(3, 2), 16))).toString(16),
  1513. s = (~~(.9 * parseInt(this.color.substr(5, 2), 16))).toString(16);
  1514. return 1 == t.length && (t = "0" + t), 1 == e.length && (e = "0" + e), 1 == s.length && (s = "0" + s), "#" + t + e + s
  1515. }
  1516. render(t) {
  1517. if (this.updatePos(), this.isVirus) {
  1518. var e = 2 * this.size + 5,
  1519. s = i;
  1520. return "#ce6363" == this.color && (s = n), void t.drawImage(s, this.x - e / 2, this.y - e / 2, e, e)
  1521. }
  1522. if (this.size < 15) return this.isPellet = !0, void this.renderPellet(t);
  1523. t.beginPath(), t.lineWidth = .03 * this.size, t.lineCap = "round", t.fillStyle = this.color, t.strokeStyle = this.getStrokeStyle(), t.arc(this.x, this.y, this.size + 5, 0, 2 * Math.PI), t.fill(), t.stroke(), this.extras.skin && !this.game.settings.get("noSkins") && (this.game.skinCache[this.extras.skin] || (this.game.skinCache[this.extras.skin] = new Image, this.game.skinCache[this.extras.skin].src = "http://cellz.io/skins/" + this.extras.skin + ".png"), t.save(), t.clip(), t.drawImage(this.game.skinCache[this.extras.skin], this.x - this.size, this.y - this.size, 2 * this.size, 2 * this.size), t.restore());
  1524. var o = !0;
  1525. this.extras.pID && this.game.players[this.extras.pID].sorted.indexOf(this.id.toString()) > 3 && (o = !1);
  1526. let a = 0;
  1527. if (this.name && !this.game.settings.get("noNames") && o) {
  1528. const e = this.game.scene.newZoom,
  1529. s = .25 * this.size,
  1530. i = this.nameCache.getCache(s * e),
  1531. n = this.nameCache.width * s,
  1532. o = this.nameCache.height * s;
  1533. t.drawImage(i, this.x - n / 2, this.y - o / 2, n, o), a = o
  1534. }
  1535. if (this.game.settings.get("showMass") && this.size > 60 && o) {
  1536. const e = this.game.scene.newZoom,
  1537. s = .25 * this.size;
  1538. let i = this.getMassText();
  1539. this.game.massCache[i] || (this.game.massCache[i] = this.game.nameCache.getCache(i));
  1540. let n = this.game.massCache[i].getCache(s * e);
  1541. const o = this.game.massCache[i].width * s,
  1542. h = this.game.massCache[i].height * s;
  1543. t.drawImage(n, this.x - o / 2, this.y + a - h / 1.2, o, h)
  1544. }
  1545. t.closePath()
  1546. }
  1547. getMassText() {
  1548. var t = this.size * this.size / 100;
  1549. return t >= 1e3 ? (t / 1e3).toFixed(1) + "k" : (6 * Math.round(t / 6)).toString()
  1550. }
  1551. renderPellet(t) {
  1552. var e = this.getPellet();
  1553. e && (t.beginPath(), t.drawImage(e, this.x, this.y, e.width, e.height), t.closePath())
  1554. }
  1555. getPellet() {
  1556. this.pelletColor || (this.pelletColor = "#" + s[Math.floor(Math.random() * s.length)]);
  1557. var t = this.pelletColor;
  1558. if (pelletCache[t]) return pelletCache[t];
  1559. var e = document.createElement("canvas");
  1560. e.width = this.size + 15, e.height = this.size + 15;
  1561. var i = e.getContext("2d");
  1562. return i.beginPath(), console.log(t), i.fillStyle = t, i.arc(e.width / 2, e.height / 2, this.size, 0, 2 * Math.PI), i.fill(), i.closePath(), pelletCache[t] = e, pelletCache[e]
  1563. }
  1564. destroy() {
  1565. if (this.game.playerCells.hasOwnProperty(this.id) && delete this.game.playerCells[this.id], this.extras.pID && this.game.players[this.extras.pID]) {
  1566. delete this.game.players[this.extras.pID][this.id];
  1567. var t = Object.keys(this.game.players[this.extras.pID]);
  1568. t.splice(t.indexOf("sorted"), 1), game.players[this.extras.pID].sorted = t.sort(function(t, e) {
  1569. return game.players[this.extras.pID][e].size - game.players[this.extras.pID][t].size
  1570. }.bind(this))
  1571. }
  1572. var e = game.ownedCells.indexOf(this.id); - 1 != e && game.ownedCells.splice(e, 1), delete this.game.cells[this.id]
  1573. }
  1574. }
  1575. }, function(t, e, s) {
  1576. const i = s(33);
  1577. t.exports = function(t, e) {
  1578. let s = 1,
  1579. n = e.game;
  1580. n.timestamp = Date.now();
  1581. const o = t.getUint16(s, !0);
  1582. s += 2;
  1583. for (var a = 0; a < o; a++) {
  1584. t.getUint32(s, !0);
  1585. var h = t.getUint32(s + 4, !0);
  1586. s += 8, n.cells[h].destroy()
  1587. }
  1588. for (;;) {
  1589. let e = t.getUint32(s, !0);
  1590. if (s += 4, 0 == e) break;
  1591. let o = t.getInt32(s, !0);
  1592. s += 4;
  1593. let h = t.getInt32(s, !0);
  1594. s += 4;
  1595. let p = t.getInt16(s, !0);
  1596. s += 2;
  1597. let g = null;
  1598. n.cells.hasOwnProperty(e) && 0 !== n.cells[e] ? ((g = n.cells[e]).updatePos(), g.oldX = g.x, g.oldY = g.y, g.oldSize = g.size) : (g = new i(e, o, h, p, n), n.cells[e] = g), g.newX = o, g.newY = h, g.newSize = p, g.updateTime = Date.now();
  1599. for (var l = (t.getUint8(s++) << 16 | t.getUint8(s++) << 8 | t.getUint8(s++)).toString(16); 6 > l.length;) l = "0" + l;
  1600. g.color = "#" + l;
  1601. const m = t.getUint8(s++);
  1602. 1 & m && (g.isVirus = !0);
  1603. var r, c = "";
  1604. if (4 & m)
  1605. for (;;) {
  1606. const e = t.getUint16(s, !0);
  1607. if (s += 2, 0 == e) break;
  1608. c += String.fromCharCode(e)
  1609. }
  1610. if (c) try {
  1611. var d = JSON.parse(c);
  1612. g.extras = d, d && d.pID && (n.players[d.pID] || (n.players[d.pID] = {
  1613. sorted: []
  1614. }), n.players[d.pID][g.id] = g, (r = Object.keys(n.players[d.pID])).splice(r.indexOf("sorted"), 1), n.players[d.pID].sorted = r.sort(function(t, e) {
  1615. return n.players[d.pID][e].size - n.players[d.pID][t].size
  1616. }))
  1617. } catch (t) {}
  1618. if (g.extras.pID) d = g.extras, (r = Object.keys(n.players[d.pID])).splice(r.indexOf("sorted"), 1), n.players[d.pID].sorted = r.sort(function(t, e) {
  1619. return n.players[d.pID][e].size - n.players[d.pID][t].size
  1620. });
  1621. let f = [];
  1622. for (;;) {
  1623. const e = t.getUint16(s, !0);
  1624. if (s += 2, 0 == e) break;
  1625. f.push(e)
  1626. }
  1627. var u = "";
  1628. for (var a in f) u += String.fromCharCode(f[a]);
  1629. g.setName(u), !n.playerCells[e] && n.ownedCells.indexOf(e) >= 0 && (n.playerCells[e] = g, g && (n.playerId = g.extras.pID))
  1630. }
  1631. const p = t.getUint32(s, !0);
  1632. s += 4;
  1633. for (let e = 0; e < p; e++) {
  1634. const e = t.getUint32(s, !0);
  1635. s += 4, n.cells[e] && n.cells[e].destroy()
  1636. }
  1637. 0 == n.cellsLength() && "SPAWNED" == n.socket.state && (n.onDeath(), n.socket.state = "DEAD")
  1638. }
  1639. }, function(t, e, s) {
  1640. let i = new Uint8Array([254, 5, 0, 0, 0]),
  1641. n = new Uint8Array([255, 0, 0, 0, 0]),
  1642. o = new Uint8Array([17]),
  1643. a = new Uint8Array([21]),
  1644. h = {
  1645. 16: s(34),
  1646. 17: s(32),
  1647. 18: function(t, e) {
  1648. var s = e.game;
  1649. s.playerCells = {}, s.cells = {}
  1650. },
  1651. 20: function(t, e) {
  1652. e.game.playerCells = {}
  1653. },
  1654. 32: s(31),
  1655. 49: s(30),
  1656. 64: s(29),
  1657. 99: s(28)
  1658. };
  1659. t.exports = class {
  1660. constructor(t) {
  1661. this.game = t, this.ws = null, this.state = "STARTING", this.jwt = "", this.ip = "", this.skin = this.game.settings.get("selectedSkin") || ""
  1662. }
  1663. connect(t) {
  1664. this.ws && (this.ws.onopen = null, this.ws.onmessage = null, this.ws.onerror = null, this.ws.onclose = null, this.ws.close()), this.ws = new WebSocket(t), this.ip = t, this.ws.binaryType = "arraybuffer", this.ws.onopen = this.onOpen.bind(this), this.ws.onmessage = this.onMessage.bind(this), this.ws.onerror = this.onError.bind(this), this.ws.onclose = this.onClose.bind(this)
  1665. }
  1666. onOpen() {
  1667. console.log("Connection Opened!"), this.state = "CONNECTED", this.sendInitKeys(), this.ws.wasConnected = !0
  1668. }
  1669. sendInitKeys() {
  1670. this.send(i), this.send(n), this.sendVerifyToken(), this.jwt && this.sendJWT()
  1671. }
  1672. onClose(t) {
  1673. console.log("Connection Closed!", t.reason), this.state = "DISCONNECTED", this.ws.wasConnected && this.game.onDeath(), this.connect(this.ip)
  1674. }
  1675. onError() {}
  1676. onMessage(t) {
  1677. let e = new DataView(t.data),
  1678. s = e.getUint8(0);
  1679. h[s] && h[s](e, this)
  1680. }
  1681. sendVerifyToken() {
  1682. let t = this.game.verifyToken;
  1683. console.log(t);
  1684. var e = new DataView(new ArrayBuffer(2 + t.length));
  1685. e.setUint8(0, 32);
  1686. for (var s = 0; s < t.length; s++) e.setUint8(s + 1, t.charCodeAt(s));
  1687. this.send(e)
  1688. }
  1689. sendJWT(t) {
  1690. var e = new DataView(new ArrayBuffer(2 + this.jwt.length));
  1691. e.setUint8(0, 30);
  1692. for (var s = 0; s < this.jwt.length; s++) e.setUint8(s + 1, this.jwt.charCodeAt(s));
  1693. this.send(e)
  1694. }
  1695. split() {
  1696. this.send(o)
  1697. }
  1698. eject() {
  1699. this.send(a)
  1700. }
  1701. sendNick(t) {
  1702. console.log(t);
  1703. const e = JSON.stringify({
  1704. name: t || "Cellz.io",
  1705. skin: this.skin
  1706. }),
  1707. s = new DataView(new ArrayBuffer(1 + 2 * e.length));
  1708. s.setUint8(0, 0);
  1709. for (let t = 0; t < e.length; t++) s.setUint16(1 + 2 * t, e.charCodeAt(t), !0);
  1710. this.state = "SPAWNING", this.send(s)
  1711. }
  1712. move(t, e) {
  1713. const s = new DataView(new ArrayBuffer(13));
  1714. s.setUint8(0, 16), s.setInt32(1, t, !0), s.setInt32(5, e, !0), s.setUint32(9, 0), this.send(new Uint8Array(s.buffer))
  1715. }
  1716. sendChat(t) {
  1717. var e = new DataView(new ArrayBuffer(2 + 2 * t.length)),
  1718. s = 0;
  1719. e.setUint8(s++, 99), e.setUint8(s++, 0);
  1720. for (var i = 0; i < t.length; ++i) e.setUint16(s, t.charCodeAt(i), !0), s += 2;
  1721. this.send(e)
  1722. }
  1723. send(t) {
  1724. this.ws && this.ws.readyState === WebSocket.OPEN && this.ws.send(t)
  1725. }
  1726. }
  1727. }, function(t, e, s) {
  1728. const i = s(35),
  1729. n = s(27),
  1730. o = s(26),
  1731. a = s(25),
  1732. h = s(24),
  1733. l = s(23),
  1734. r = s(0),
  1735. c = (s(1), s(22)),
  1736. d = s(21),
  1737. u = s(19),
  1738. p = s(18),
  1739. g = s(17);
  1740. s(7);
  1741. window.game = new class {
  1742. constructor() {
  1743. this.cookie = new p, this.settings = new a(this), this.socket = new i(this), this.scene = new n(this), this.hotkeys = new o(this), this.languages = new r, this.panelHandler = new l(this), this.chat = new c(this), this.servers = new d(this), this.nameCache = new h.Cache, this.masterServer = new u(this), this.api = new g(this), this.cells = {}, this.players = {}, this.playerCells = {}, this.ownedCells = [], this.skinCache = {}, this.playerId = 0, this.leaderboard = [], this.nick = "", this.timestamp = 0, this.verifyToken = "", this.map = {
  1744. minX: 0,
  1745. minY: 0,
  1746. maxX: 0,
  1747. maxY: 0
  1748. }, this.massCache = {}
  1749. }
  1750. async initApp() {
  1751. this.verifyToken = await this.getVerifyToken(), this.servers.init(), this.scene.init(), this.settings.get("shownUpdatePanel") || ($(".updateButton").click(function() {
  1752. $(".updateModal").fadeOut(1500)
  1753. }), $(".updateModal").addClass("isActive").fadeIn(1500), this.settings.set("shownUpdatePanel", !0, "val")), $(document.body).ready(function() {
  1754. window.onresize = function() {
  1755. this.resizeScreen()
  1756. }.bind(this), this.resizeScreen(), this.settings.handleDomQueue(), $("#settings").click(function() {
  1757. this.toggleSettings()
  1758. }.bind(this)), $("#spectate").click(function() {
  1759. this.spectate()
  1760. }.bind(this)), $("#login").click(function() {
  1761. this.api.login()
  1762. }.bind(this)), $("#logout").click(function() {
  1763. this.api.logout()
  1764. }.bind(this)), $(".btnShop").click(function() {
  1765. this.api.shop.open()
  1766. }.bind(this)), $(".btnLanguages").click(function() {
  1767. this.languages.openPanel()
  1768. }.bind(this)), $("#btnLanguagesClose").click(function() {
  1769. this.languages.closePanel()
  1770. }.bind(this)), $(".updateText").text(getText("Hello Cellz.io Player & welcome to the new Cellz.io! Cellz.io has had a major update!")), $(".secondText").text(getText("We have remade the Cellz.io client from scratch, we would like you to help us find any problems witth the new client and report them back to us!")), $(".noteText").text(getText("Note: If you find any bugs/glitches, please report them in the discord!"))
  1771. }.bind(this))
  1772. }
  1773. resizeScreen() {
  1774. innerWidth > 1174 && (document.getElementsByClassName("container")[0].style["margin-left"] = "");
  1775. for (var t = 100 * parseFloat(window.innerHeight / 974), e = -119.5, s = 15.5, i = 100 * Math.round(innerWidth / 100), n = 0; n < i / 100; n++) e += s, s -= 1 - .004 * n;
  1776. var o = e;
  1777. innerWidth !== i && (o += (innerWidth - i) * (s / 100)), document.getElementsByClassName("container")[0].style.transform = `scale(${innerHeight/974}, ${innerHeight/974})`;
  1778. var a = 0;
  1779. innerHeight > 858 && (a = .003 * innerHeight), document.getElementsByClassName("container")[0].style["margin-top"] = `${.02*innerHeight-17.26-a}%`, innerWidth < 1174 && (document.getElementsByClassName("container")[0].style["margin-left"] = `${o}%`);
  1780. var h = .007;
  1781. innerHeight < 350 && (h = .005), innerHeight > 560 && (h = .0049), document.getElementById("adsTop").style["margin-top"] = `${innerHeight*h+(-2.45-500*h)}%`, document.getElementById("adsBottom").style["margin-bottom"] = `${innerHeight*h+(-2.45-500*h)}%`, document.getElementById("adsBottom").style.transform = `scale(${innerHeight/974},${innerHeight/974})`, document.getElementById("adsTop").style.transform = `scale(${innerHeight/974},${innerHeight/974})`, document.getElementsByClassName("infoBox")[0].style.zoom = `${t}%`, document.getElementById("languagesModal").style.zoom = `${t}%`, document.getElementById("hotkeysModal").style.zoom = `${t}%`, document.getElementsByClassName("infoBox")[0].style.zoom = `${t}%`, document.getElementById("shopModal").style.zoom = `${t}%`, document.getElementsByClassName("continuePanel")[0].style.transform = `scale(${innerHeight/974}, ${innerHeight/974})`, window.innerWidth <= 750 ? $(".ended").css({
  1782. left: "-46%"
  1783. }) : window.innerWidth <= 800 ? $(".ended").css({
  1784. left: "-44%"
  1785. }) : window.innerWidth <= 850 ? $(".ended").css({
  1786. left: "-42%"
  1787. }) : window.innerWidth <= 900 ? $(".ended").css({
  1788. left: "-40%"
  1789. }) : window.innerWidth <= 950 ? $(".ended").css({
  1790. left: "-38%"
  1791. }) : window.innerWidth <= 1100 ? $(".ended").css({
  1792. left: "-36%"
  1793. }) : window.innerWidth <= 1250 ? $(".ended").css({
  1794. left: "-30%"
  1795. }) : window.innerWidth <= 1300 ? $(".ended").css({
  1796. left: "-28%"
  1797. }) : window.innerWidth <= 1350 ? $(".ended").css({
  1798. left: "-26%"
  1799. }) : window.innerWidth <= 1400 ? $(".ended").css({
  1800. left: "-25%"
  1801. }) : window.innerWidth <= 1450 ? $(".ended").css({
  1802. left: "-24%"
  1803. }) : window.innerWidth <= 1500 ? $(".ended").css({
  1804. left: "-23%"
  1805. }) : window.innerWidth <= 1550 ? $(".ended").css({
  1806. left: "-22%"
  1807. }) : window.innerWidth <= 1950 ? $(".ended").css({
  1808. left: "-18%"
  1809. }) : $(".ended").css({
  1810. left: "0%"
  1811. })
  1812. }
  1813. onDeath() {
  1814. window.onShow(), $(".btnContinue").click(function(t) {
  1815. $(".ended").hide(), $(".menu").show(), t.preventDefault()
  1816. }), $("#score").css("z-index", "0"), $(".ended").fadeIn(3e3)
  1817. }
  1818. getVerifyToken() {
  1819. return new Promise(function(t, e) {
  1820. $.get("http://main.cellz.io/num", function(e) {
  1821. var s = genKey(parseInt(e));
  1822. console.log(s), $.get("http://main.cellz.io/token?num=" + s, function(e) {
  1823. t(e)
  1824. })
  1825. })
  1826. })
  1827. }
  1828. spawn() {
  1829. $(".menu").hide(), $("#score").css("z-index", "300"), this.settings.set("nick", $("#nick").val(), "input"), this.socket.sendNick($("#nick").val())
  1830. }
  1831. spectate() {
  1832. $(".menu").hide(), this.scene.zoom = .16, this.socket.send(new Uint8Array([1]))
  1833. }
  1834. cellsLength() {
  1835. return Object.keys(this.playerCells).length
  1836. }
  1837. drawLeaderboard() {
  1838. var t = "",
  1839. e = !1;
  1840. for (let i = 0; i < this.leaderboard.length; i++) {
  1841. var s = "";
  1842. this.playerCells[this.leaderboard[i].id] && (s = "color: #FFAAAA"), t += `<span class="pos" style="${s}">${i+1}. ${this.chat.escape(this.leaderboard[i].name)}</span>`, e = !0
  1843. }
  1844. e && (document.getElementById("lb").innerHTML = t)
  1845. }
  1846. toggleSettings() {
  1847. var t = document.getElementById("options");
  1848. t.style.display = "block" == t.style.display ? "none" : "block"
  1849. }
  1850. }, game.initApp()
  1851. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement