yolkbot 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +200 -1
  4. package/dist/bot/GamePlayer.js +74 -1
  5. package/dist/bot.js +1679 -1
  6. package/dist/comm/CommIn.js +79 -1
  7. package/dist/comm/CommOut.js +60 -1
  8. package/dist/comm/index.js +11 -1
  9. package/dist/constants/CloseCode.js +27 -1
  10. package/dist/constants/CommCode.js +53 -1
  11. package/dist/constants/challenges.js +1821 -1
  12. package/dist/constants/findItemById.js +2 -3
  13. package/dist/constants/guns.js +277 -1
  14. package/dist/constants/index.js +139 -1
  15. package/dist/constants/items.js +45042 -1
  16. package/dist/constants/maps.js +1263 -1
  17. package/dist/constants/regions.js +30 -1
  18. package/dist/dispatches/BanPlayerDispatch.js +32 -1
  19. package/dist/dispatches/BootPlayerDispatch.js +21 -1
  20. package/dist/dispatches/ChatDispatch.js +32 -1
  21. package/dist/dispatches/FireDispatch.js +15 -1
  22. package/dist/dispatches/GameOptionsDispatch.js +66 -1
  23. package/dist/dispatches/GoToAmmoDispatch.js +38 -1
  24. package/dist/dispatches/GoToCoopDispatch.js +38 -1
  25. package/dist/dispatches/GoToGrenadeDispatch.js +38 -1
  26. package/dist/dispatches/GoToPlayerDispatch.js +39 -1
  27. package/dist/dispatches/GoToSpatulaDispatch.js +26 -1
  28. package/dist/dispatches/LookAtDispatch.js +35 -1
  29. package/dist/dispatches/LookAtPosDispatch.js +29 -1
  30. package/dist/dispatches/MeleeDispatch.js +26 -1
  31. package/dist/dispatches/MovementDispatch.js +26 -1
  32. package/dist/dispatches/PauseDispatch.js +18 -1
  33. package/dist/dispatches/ReloadDispatch.js +28 -1
  34. package/dist/dispatches/ReportPlayerDispatch.js +42 -1
  35. package/dist/dispatches/ResetGameDispatch.js +19 -1
  36. package/dist/dispatches/SaveLoadoutDispatch.js +105 -1
  37. package/dist/dispatches/SpawnDispatch.js +22 -1
  38. package/dist/dispatches/SwapWeaponDispatch.js +25 -1
  39. package/dist/dispatches/SwitchTeamDispatch.js +33 -1
  40. package/dist/dispatches/ThrowGrenadeDispatch.js +21 -1
  41. package/dist/dispatches/index.js +74 -1
  42. package/dist/env/fetch.js +97 -10
  43. package/dist/env/globals.js +15 -1
  44. package/dist/index.js +14 -2
  45. package/dist/matchmaker.js +141 -1
  46. package/dist/pathing/astar.js +55 -1
  47. package/dist/pathing/binaryheap.js +79 -1
  48. package/dist/pathing/mapnode.js +179 -1
  49. package/dist/socket.js +97 -1
  50. package/dist/util.js +68 -1
  51. package/dist/wasm/bytes.js +8 -1
  52. package/dist/wasm/direct.js +84 -1
  53. package/dist/wasm/legacy.js +170 -1
  54. package/dist/wasm/util.js +19 -1
  55. package/package.json +38 -39
  56. /package/dist/{types/api.d.ts → api.d.ts} +0 -0
  57. /package/dist/{types/bot → bot}/GamePlayer.d.ts +0 -0
  58. /package/dist/{types/bot.d.ts → bot.d.ts} +0 -0
  59. /package/dist/{types/comm → comm}/CommIn.d.ts +0 -0
  60. /package/dist/{types/comm → comm}/CommOut.d.ts +0 -0
  61. /package/dist/{types/comm → comm}/index.d.ts +0 -0
  62. /package/dist/{types/constants → constants}/CloseCode.d.ts +0 -0
  63. /package/dist/{types/constants → constants}/CommCode.d.ts +0 -0
  64. /package/dist/{types/constants → constants}/challenges.d.ts +0 -0
  65. /package/dist/{types/constants → constants}/changelog.d.ts +0 -0
  66. /package/dist/{types/constants → constants}/findItemById.d.ts +0 -0
  67. /package/dist/{types/constants → constants}/guns.d.ts +0 -0
  68. /package/dist/{types/constants → constants}/housePromo.d.ts +0 -0
  69. /package/dist/{types/constants → constants}/index.d.ts +0 -0
  70. /package/dist/{types/constants → constants}/items.d.ts +0 -0
  71. /package/dist/{types/constants → constants}/language.d.ts +0 -0
  72. /package/dist/{types/constants → constants}/maps.d.ts +0 -0
  73. /package/dist/{types/constants → constants}/notices.d.ts +0 -0
  74. /package/dist/{types/constants → constants}/regions.d.ts +0 -0
  75. /package/dist/{types/constants → constants}/shellNews.d.ts +0 -0
  76. /package/dist/{types/constants → constants}/shellYoutube.d.ts +0 -0
  77. /package/dist/{types/constants → constants}/shopItems.d.ts +0 -0
  78. /package/dist/{types/constants → constants}/sounds.d.ts +0 -0
  79. /package/dist/{types/dispatches → dispatches}/BanPlayerDispatch.d.ts +0 -0
  80. /package/dist/{types/dispatches → dispatches}/BootPlayerDispatch.d.ts +0 -0
  81. /package/dist/{types/dispatches → dispatches}/ChatDispatch.d.ts +0 -0
  82. /package/dist/{types/dispatches → dispatches}/FireDispatch.d.ts +0 -0
  83. /package/dist/{types/dispatches → dispatches}/GameOptionsDispatch.d.ts +0 -0
  84. /package/dist/{types/dispatches → dispatches}/GoToAmmoDispatch.d.ts +0 -0
  85. /package/dist/{types/dispatches → dispatches}/GoToCoopDispatch.d.ts +0 -0
  86. /package/dist/{types/dispatches → dispatches}/GoToGrenadeDispatch.d.ts +0 -0
  87. /package/dist/{types/dispatches → dispatches}/GoToPlayerDispatch.d.ts +0 -0
  88. /package/dist/{types/dispatches → dispatches}/GoToSpatulaDispatch.d.ts +0 -0
  89. /package/dist/{types/dispatches → dispatches}/LookAtDispatch.d.ts +0 -0
  90. /package/dist/{types/dispatches → dispatches}/LookAtPosDispatch.d.ts +0 -0
  91. /package/dist/{types/dispatches → dispatches}/MeleeDispatch.d.ts +0 -0
  92. /package/dist/{types/dispatches → dispatches}/MovementDispatch.d.ts +0 -0
  93. /package/dist/{types/dispatches → dispatches}/PauseDispatch.d.ts +0 -0
  94. /package/dist/{types/dispatches → dispatches}/ReloadDispatch.d.ts +0 -0
  95. /package/dist/{types/dispatches → dispatches}/ReportPlayerDispatch.d.ts +0 -0
  96. /package/dist/{types/dispatches → dispatches}/ResetGameDispatch.d.ts +0 -0
  97. /package/dist/{types/dispatches → dispatches}/SaveLoadoutDispatch.d.ts +0 -0
  98. /package/dist/{types/dispatches → dispatches}/SpawnDispatch.d.ts +0 -0
  99. /package/dist/{types/dispatches → dispatches}/SwapWeaponDispatch.d.ts +0 -0
  100. /package/dist/{types/dispatches → dispatches}/SwitchTeamDispatch.d.ts +0 -0
  101. /package/dist/{types/dispatches → dispatches}/ThrowGrenadeDispatch.d.ts +0 -0
  102. /package/dist/{types/dispatches → dispatches}/index.d.ts +0 -0
  103. /package/dist/{types/matchmaker.d.ts → matchmaker.d.ts} +0 -0
  104. /package/dist/{types/pathing → pathing}/astar.d.ts +0 -0
  105. /package/dist/{types/pathing → pathing}/binaryheap.d.ts +0 -0
  106. /package/dist/{types/pathing → pathing}/mapnode.d.ts +0 -0
  107. /package/dist/{types/socket.d.ts → socket.d.ts} +0 -0
  108. /package/dist/{types/util.d.ts → util.d.ts} +0 -0
  109. /package/dist/{types/wasm → wasm}/bytes.d.ts +0 -0
  110. /package/dist/{types/wasm → wasm}/direct.d.ts +0 -0
  111. /package/dist/{types/wasm → wasm}/legacy.d.ts +0 -0
  112. /package/dist/{types/wasm → wasm}/util.d.ts +0 -0
package/dist/api.js CHANGED
@@ -1 +1,200 @@
1
- import a from"./env/globals.js";import h from"./socket.js";import{FirebaseKey as c,UserAgent as d}from"./constants/index.js";const l={origin:"https://shellshock.io","user-agent":d,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};export class API{constructor(e={}){this.proxy=e.proxy;this.instance=e.instance||"shellshock.io";this.protocol=e.protocol||"wss";this.maxRetries=e.maxRetries||5;this.suppressErrors=e.suppressErrors||!1;this.connectionTimeout=e.connectionTimeout||5000}queryServices=async(e)=>{const r=new h(`${this.protocol}://${this.instance}/services/`,this.proxy);r.connectionTimeout=this.connectionTimeout;if(!await r.tryConnect(-2)||r.socket.readyState!==1)return"websocket_connect_fail";return new Promise((t)=>{let s=!1;r.onmessage=(i)=>{s=!0;try{const n=JSON.parse(i.data);t(n)}catch{if(!this.suppressErrors){console.error("queryServices: Bad API JSON response with call:",e.cmd,"and data:",JSON.stringify(e));console.error("queryServices: Full data sent:",JSON.stringify(e))}t("bad_json")}r.close()};r.onerror=()=>!s&&t("unknown_socket_error");r.onclose=()=>!s&&t("services_closed_early");r.send(JSON.stringify(e))})};#e=async(e,r,o)=>{if(!e||!r)return"firebase_no_credentials";let t,s;try{t=await(await a.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${o}?key=${c}`,{method:"POST",body:JSON.stringify({email:e,password:r,returnSecureToken:!0}),headers:{...l,"content-type":"application/json"},proxy:this.proxy})).json();s=t.idToken}catch(n){if(n.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(n.code==="auth/missing-email")return"firebase_no_credentials";else if(n.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",e,r);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t||n);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",e,r,n);return"firebase_unknown_error"}if(!s){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",t);return"firebase_no_token"}this.idToken=s;const i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:t,...i}:i};createAccount=async(e,r)=>await this.#e(e,r,"signUp");loginWithCredentials=async(e,r)=>await this.#e(e,r,"signInWithPassword");loginWithRefreshToken=async(e)=>{if(!e)return"firebase_no_credentials";const r=new URLSearchParams;r.append("grant_type","refresh_token");r.append("refresh_token",e);let o,t;try{o=await(await a.fetch(`https://securetoken.googleapis.com/v1/token?key=${c}`,{method:"POST",body:r,headers:{...l,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json();t=o.id_token}catch(i){if(i.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(i.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",i,e);return"firebase_unknown_error"}if(!t){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",o);return"firebase_no_token"}this.idToken=t;const s=await this.queryServices({cmd:"auth",firebaseToken:t});return typeof s==="object"?{firebase:o,...s}:s};loginAnonymously=async()=>{const r=await(await a.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${c}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...l,"content-type":"application/json"},proxy:this.proxy})).json(),o=r.idToken;if(!o){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",r);return"firebase_no_token"}this.idToken=o;const t=await this.queryServices({cmd:"auth",firebaseToken:o});return typeof t==="object"?{firebase:r,...t}:t};sendEmailVerification=async(e=this.idToken)=>{if(!e)return"no_idtoken_passed";const o=await(await a.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${c}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:e}),headers:{...l,"content-type":"application/json"},proxy:this.proxy})).json();if(o.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",o);return"firebase_invalid_response"}return{email:o.email}};verifyOobCode=async(e)=>{if(!e)return"no_oob_code_passed";const o=await(await a.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${c}`,{method:"POST",body:JSON.stringify({oobCode:e}),headers:{...l,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!o.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",o);return"firebase_invalid_response"}return o.email}}export default API;
1
+ import globals from "./env/globals.js";
2
+ import yolkws from "./socket.js";
3
+ import { FirebaseKey, UserAgent } from "./constants/index.js";
4
+ const baseHeaders = {
5
+ origin: "https://shellshock.io",
6
+ "user-agent": UserAgent,
7
+ "x-client-version": "Chrome/JsCore/9.17.2/FirebaseCore-web",
8
+ "x-firebase-locale": "en"
9
+ };
10
+
11
+ export class API {
12
+ constructor(params = {}) {
13
+ this.proxy = params.proxy;
14
+ this.instance = params.instance || "shellshock.io";
15
+ this.protocol = params.protocol || "wss";
16
+ this.maxRetries = params.maxRetries || 5;
17
+ this.suppressErrors = params.suppressErrors || false;
18
+ this.connectionTimeout = params.connectionTimeout || 5000;
19
+ }
20
+ queryServices = async (request) => {
21
+ const ws = new yolkws(`${this.protocol}://${this.instance}/services/`, this.proxy);
22
+ ws.connectionTimeout = this.connectionTimeout;
23
+ const didConnect = await ws.tryConnect(-2);
24
+ if (!didConnect || ws.socket.readyState !== 1)
25
+ return "websocket_connect_fail";
26
+ return new Promise((resolve) => {
27
+ let resolved = false;
28
+ ws.onmessage = (mes) => {
29
+ resolved = true;
30
+ try {
31
+ const resp = JSON.parse(mes.data);
32
+ resolve(resp);
33
+ } catch {
34
+ if (!this.suppressErrors) {
35
+ console.error("queryServices: Bad API JSON response with call:", request.cmd, "and data:", JSON.stringify(request));
36
+ console.error("queryServices: Full data sent:", JSON.stringify(request));
37
+ }
38
+ resolve("bad_json");
39
+ }
40
+ ws.close();
41
+ };
42
+ ws.onerror = () => !resolved && resolve("unknown_socket_error");
43
+ ws.onclose = () => !resolved && resolve("services_closed_early");
44
+ ws.send(JSON.stringify(request));
45
+ });
46
+ };
47
+ #authWithEmailPass = async (email, password, endpoint) => {
48
+ if (!email || !password)
49
+ return "firebase_no_credentials";
50
+ let body, firebaseToken;
51
+ try {
52
+ const request = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${endpoint}?key=${FirebaseKey}`, {
53
+ method: "POST",
54
+ body: JSON.stringify({
55
+ email,
56
+ password,
57
+ returnSecureToken: true
58
+ }),
59
+ headers: {
60
+ ...baseHeaders,
61
+ "content-type": "application/json"
62
+ },
63
+ proxy: this.proxy
64
+ });
65
+ body = await request.json();
66
+ firebaseToken = body.idToken;
67
+ } catch (error) {
68
+ if (error.code === "auth/network-request-failed") {
69
+ if (!this.suppressErrors)
70
+ console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");
71
+ return "firebase_network_failed";
72
+ } else if (error.code === "auth/missing-email") {
73
+ return "firebase_no_credentials";
74
+ } else if (error.code === "ERR_BAD_REQUEST") {
75
+ if (!this.suppressErrors)
76
+ console.error("loginWithCredentials: Error:", email, password);
77
+ if (!this.suppressErrors)
78
+ console.error("loginWithCredentials: Error:", body || error);
79
+ return "firebase_bad_request";
80
+ }
81
+ if (!this.suppressErrors)
82
+ console.error("loginWithCredentials: Error:", email, password, error);
83
+ return "firebase_unknown_error";
84
+ }
85
+ if (!firebaseToken) {
86
+ if (!this.suppressErrors)
87
+ console.error("loginWithCredentials: the game sent no idToken", body);
88
+ return "firebase_no_token";
89
+ }
90
+ this.idToken = firebaseToken;
91
+ const servicesQuery = await this.queryServices({ cmd: "auth", firebaseToken });
92
+ return typeof servicesQuery === "object" ? { firebase: body, ...servicesQuery } : servicesQuery;
93
+ };
94
+ createAccount = async (email, password) => await this.#authWithEmailPass(email, password, "signUp");
95
+ loginWithCredentials = async (email, password) => await this.#authWithEmailPass(email, password, "signInWithPassword");
96
+ loginWithRefreshToken = async (refreshToken) => {
97
+ if (!refreshToken)
98
+ return "firebase_no_credentials";
99
+ const formData = new URLSearchParams;
100
+ formData.append("grant_type", "refresh_token");
101
+ formData.append("refresh_token", refreshToken);
102
+ let body, token;
103
+ try {
104
+ const request = await globals.fetch(`https://securetoken.googleapis.com/v1/token?key=${FirebaseKey}`, {
105
+ method: "POST",
106
+ body: formData,
107
+ headers: {
108
+ ...baseHeaders,
109
+ "content-type": "application/x-www-form-urlencoded"
110
+ },
111
+ proxy: this.proxy
112
+ });
113
+ body = await request.json();
114
+ token = body.id_token;
115
+ } catch (error) {
116
+ if (error.code === "auth/network-request-failed") {
117
+ if (!this.suppressErrors)
118
+ console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");
119
+ return "firebase_network_failed";
120
+ } else if (error.code === "auth/missing-email") {
121
+ return "firebase_no_credentials";
122
+ }
123
+ if (!this.suppressErrors)
124
+ console.error("loginWithRefreshToken: Error:", error, refreshToken);
125
+ return "firebase_unknown_error";
126
+ }
127
+ if (!token) {
128
+ if (!this.suppressErrors)
129
+ console.error("loginWithRefreshToken: the game sent no idToken", body);
130
+ return "firebase_no_token";
131
+ }
132
+ this.idToken = token;
133
+ const response = await this.queryServices({ cmd: "auth", firebaseToken: token });
134
+ return typeof response === "object" ? { firebase: body, ...response } : response;
135
+ };
136
+ loginAnonymously = async () => {
137
+ const req = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${FirebaseKey}`, {
138
+ method: "POST",
139
+ body: JSON.stringify({ returnSecureToken: true }),
140
+ headers: {
141
+ ...baseHeaders,
142
+ "content-type": "application/json"
143
+ },
144
+ proxy: this.proxy
145
+ });
146
+ const body = await req.json();
147
+ const firebaseToken = body.idToken;
148
+ if (!firebaseToken) {
149
+ if (!this.suppressErrors)
150
+ console.error("loginAnonymously: the game sent no idToken", body);
151
+ return "firebase_no_token";
152
+ }
153
+ this.idToken = firebaseToken;
154
+ const query = await this.queryServices({ cmd: "auth", firebaseToken });
155
+ return typeof query === "object" ? { firebase: body, ...query } : query;
156
+ };
157
+ sendEmailVerification = async (idToken = this.idToken) => {
158
+ if (!idToken)
159
+ return "no_idtoken_passed";
160
+ const req = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${FirebaseKey}`, {
161
+ method: "POST",
162
+ body: JSON.stringify({ requestType: "VERIFY_EMAIL", idToken }),
163
+ headers: {
164
+ ...baseHeaders,
165
+ "content-type": "application/json"
166
+ },
167
+ proxy: this.proxy
168
+ });
169
+ const body = await req.json();
170
+ if (body.kind !== "identitytoolkit#GetOobConfirmationCodeResponse") {
171
+ if (!this.suppressErrors)
172
+ console.error("sendEmailVerification: the game sent an invalid response", body);
173
+ return "firebase_invalid_response";
174
+ }
175
+ return { email: body.email };
176
+ };
177
+ verifyOobCode = async (oobCode) => {
178
+ if (!oobCode)
179
+ return "no_oob_code_passed";
180
+ const req = await globals.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${FirebaseKey}`, {
181
+ method: "POST",
182
+ body: JSON.stringify({ oobCode }),
183
+ headers: {
184
+ ...baseHeaders,
185
+ "x-client-version": "Chrome/JsCore/3.7.5/FirebaseCore-web",
186
+ referer: "https://shellshockio-181719.firebaseapp.com/",
187
+ "content-type": "application/json"
188
+ },
189
+ proxy: this.proxy
190
+ });
191
+ const body = await req.json();
192
+ if (!body.emailVerified) {
193
+ if (!this.suppressErrors)
194
+ console.error("verifyOobCode: the game sent an invalid response", body);
195
+ return "firebase_invalid_response";
196
+ }
197
+ return body.email;
198
+ };
199
+ }
200
+ export default API;
@@ -1 +1,74 @@
1
- import{GunList as c,Movement as o,ShellStreak as h,SocialMedia as m}from"../constants/index.js";import{Cluck9mm as d}from"../constants/guns.js";const u=Object.fromEntries(Object.entries(m).map(([s,t])=>[t,s.toLowerCase()]));export class GamePlayer{constructor(s,t=null){this.id=s.id;this.uniqueId=s.uniqueId;this.name=s.name;this.safeName=s.safeName;this.team=s.team;this.playing=s.playing;this.socials=s.social&&JSON.parse(s.social);if(this.socials)this.socials.forEach((i)=>i.type=u[i.id]);this.isVip=s.upgradeProductId>0;this.showBadge=!s.hideBadge||!1;this.streak=s.score;this.streakRewards=Object.values(h).filter((i)=>s.activeShellStreaks&i);this.scale=this.streakRewards.includes(h.MiniEgg)?0.5:1;this.position={x:s.x,y:s.y,z:s.z};this.jumping=s.$controlKeys&o.Jump;this.scoping=s.$controlKeys&o.Scope;this.climbing=!1;this.view={yaw:s.yaw,pitch:s.pitch};this.updateKotcZone(t);this.character={eggColor:s.shellColor,primaryGun:s.primaryWeaponItem,secondaryGun:s.secondaryWeaponItem,stamp:s.stampItem,hat:s.hatItem,grenade:s.grenadeItem,melee:s.meleeItem,stampPos:{x:s.stampPosX,y:s.stampPosY}};this.stats={totalKills:s.totalKills,totalDeaths:s.totalDeaths,bestStreak:s.bestStreak};this.activeGun=s.weaponIdx;this.selectedGun=s.charClass;this.weapons=[];if(this.character.primaryGun){this.weapons[0]=new c[this.selectedGun];this.weapons[1]=new d}this.grenades=1;this.hp=s.hp;this.hpShield=0;this.spawnShield=s.shield;this.randomSeed=0}updateKotcZone(s){if(!s)return this.inKotcZone=!1;const t=Math.floor(this.position.x),i=Math.floor(this.position.y),n=Math.floor(this.position.z);this.inKotcZone=s.some((e)=>e.x===t&&e.y===i&&e.z===n)&&this.playing}}export default GamePlayer;
1
+ import { GunList, Movement, ShellStreak, SocialMedia } from "../constants/index.js";
2
+ import { Cluck9mm } from "../constants/guns.js";
3
+ const RSocialMedia = Object.fromEntries(Object.entries(SocialMedia).map(([key, value]) => [value, key.toLowerCase()]));
4
+
5
+ export class GamePlayer {
6
+ constructor(playerData, activeZone = null) {
7
+ this.id = playerData.id;
8
+ this.uniqueId = playerData.uniqueId;
9
+ this.name = playerData.name;
10
+ this.safeName = playerData.safeName;
11
+ this.team = playerData.team;
12
+ this.playing = playerData.playing;
13
+ this.socials = playerData.social && JSON.parse(playerData.social);
14
+ if (this.socials)
15
+ this.socials.forEach((social) => social.type = RSocialMedia[social.id]);
16
+ this.isVip = playerData.upgradeProductId > 0;
17
+ this.showBadge = !playerData.hideBadge || false;
18
+ this.streak = playerData.score;
19
+ this.streakRewards = Object.values(ShellStreak).filter((streak) => playerData.activeShellStreaks & streak);
20
+ this.scale = this.streakRewards.includes(ShellStreak.MiniEgg) ? 0.5 : 1;
21
+ this.position = {
22
+ x: playerData.x,
23
+ y: playerData.y,
24
+ z: playerData.z
25
+ };
26
+ this.jumping = playerData.$controlKeys & Movement.Jump;
27
+ this.scoping = playerData.$controlKeys & Movement.Scope;
28
+ this.climbing = false;
29
+ this.view = {
30
+ yaw: playerData.yaw,
31
+ pitch: playerData.pitch
32
+ };
33
+ this.updateKotcZone(activeZone);
34
+ this.character = {
35
+ eggColor: playerData.shellColor,
36
+ primaryGun: playerData.primaryWeaponItem,
37
+ secondaryGun: playerData.secondaryWeaponItem,
38
+ stamp: playerData.stampItem,
39
+ hat: playerData.hatItem,
40
+ grenade: playerData.grenadeItem,
41
+ melee: playerData.meleeItem,
42
+ stampPos: {
43
+ x: playerData.stampPosX,
44
+ y: playerData.stampPosY
45
+ }
46
+ };
47
+ this.stats = {
48
+ totalKills: playerData.totalKills,
49
+ totalDeaths: playerData.totalDeaths,
50
+ bestStreak: playerData.bestStreak
51
+ };
52
+ this.activeGun = playerData.weaponIdx;
53
+ this.selectedGun = playerData.charClass;
54
+ this.weapons = [];
55
+ if (this.character.primaryGun) {
56
+ this.weapons[0] = new GunList[this.selectedGun];
57
+ this.weapons[1] = new Cluck9mm;
58
+ }
59
+ this.grenades = 1;
60
+ this.hp = playerData.hp;
61
+ this.hpShield = 0;
62
+ this.spawnShield = playerData.shield;
63
+ this.randomSeed = 0;
64
+ }
65
+ updateKotcZone(activeZone) {
66
+ if (!activeZone)
67
+ return this.inKotcZone = false;
68
+ const fx = Math.floor(this.position.x);
69
+ const fy = Math.floor(this.position.y);
70
+ const fz = Math.floor(this.position.z);
71
+ this.inKotcZone = activeZone.some((coordSets) => coordSets.x === fx && coordSets.y === fy && coordSets.z === fz) && this.playing;
72
+ }
73
+ }
74
+ export default GamePlayer;