yolkbot 0.1.2-alpha.3 → 0.1.2-alpha.30

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.
@@ -70,10 +70,12 @@ export class SaveLoadoutDispatch {
70
70
  }
71
71
 
72
72
  execute(bot) {
73
- if (this.changes.classIdx && this.changes.classIdx !== bot.me.selectedGun) {
73
+ if (bot.me && this.changes.classIdx && this.changes.classIdx !== bot.me.selectedGun) {
74
74
  bot.me.weapons[0] = new GunList[this.changes.classIdx]();
75
75
  }
76
76
 
77
+ bot.state.weaponIdx = this.changes.classIdx || bot.state.weaponIdx;
78
+
77
79
  const loadout = {
78
80
  ...bot.account.loadout,
79
81
  ...this.changes
@@ -89,7 +91,7 @@ export class SaveLoadoutDispatch {
89
91
 
90
92
  bot.account.loadout = loadout;
91
93
 
92
- saveLoadout.then(() => {
94
+ if (bot.me) saveLoadout.then(() => {
93
95
  if (bot.state.joinedGame) {
94
96
  const out = CommOut.getBuffer();
95
97
  out.packInt8(CommCode.changeCharacter);
package/src/globals.js CHANGED
@@ -5,11 +5,11 @@ if (typeof process !== 'undefined') {
5
5
  globals.SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
6
6
  globals.ProxyAgent = (await import('undici')).ProxyAgent;
7
7
  globals.WebSocket = (await import('ws')).default;
8
- } else {
9
- globals.fetch = fetch;
8
+ } else if (typeof window !== 'undefined') {
9
+ globals.fetch = fetch.bind(window);
10
10
  globals.SocksProxyAgent = undefined;
11
11
  globals.ProxyAgent = class {};
12
12
  globals.WebSocket = WebSocket;
13
- }
13
+ } else throw new Error('unknown environment...could not detect node.js or browser...open an issue in the yolkbot github');
14
14
 
15
15
  export default globals;
package/src/matchmaker.js CHANGED
@@ -103,7 +103,7 @@ export class Matchmaker {
103
103
  this.on('msg', listener);
104
104
 
105
105
  this.ws.onerror = (e2) => {
106
- throw new Error('Failed to get regions', e2);
106
+ throw new Error('failed to get regions', e2);
107
107
  }
108
108
 
109
109
  this.ws.send(JSON.stringify({ command: 'regionList' }));
@@ -116,17 +116,15 @@ export class Matchmaker {
116
116
  // params.region
117
117
  // params.mode -> params.gameType
118
118
  // params.isPublic -> params.playType
119
- if (!params.region) { throw new Error('did not specify a region in findGame, use <Matchmaker>.getRegions() for a list') }
119
+ if (!params.region) throw new Error('did not specify a region in findGame, use <Matchmaker>.getRegions() for a list')
120
120
 
121
121
  if (this.regionList) {
122
122
  const region = this.regionList.find(r => r.id == params.region);
123
- if (!region) {
124
- throw new Error('did not find region in regionList, if you are attempting to force a region, avoid calling getRegions()')
125
- }
123
+ if (!region) throw new Error('did not find region in regionList, if you are attempting to force a region, avoid calling getRegions()')
126
124
  } // else { console.log('regionList not found, not validating findGame region, use <Matchmaker>.regionList() to check region') }
127
125
 
128
- if (!params.mode) { throw new Error('did not specify a mode in findGame') }
129
- if (GameModes[params.mode] === undefined) { throw new Error('invalid mode in findGame, see GameModes for a list') }
126
+ if (!params.mode) throw new Error('did not specify a mode in findGame')
127
+ if (GameModes[params.mode] === undefined) throw new Error('invalid mode in findGame, see GameModes for a list')
130
128
 
131
129
  return new Promise((res) => {
132
130
  const opts = {
@@ -16,6 +16,7 @@ export interface QueryResponse {
16
16
  }
17
17
 
18
18
  export function queryServices(request: QueryRequest, proxy?: string, instance?: string): Promise<QueryResponse | string>;
19
- export function loginWithCredentials(email: string, password: string, prox?: string, instance?: string): Promise<QueryResponse | string>;
20
- export function loginWithRefreshToken(refreshToken: string, prox?: string, instance?: string): Promise<QueryResponse | string>;
21
- export function loginAnonymously(prox?: string, instance?: string): Promise<QueryResponse | string>;
19
+ export function loginWithCredentials(email: string, password: string, proxy?: string, instance?: string): Promise<QueryResponse | string>;
20
+ export function loginWithRefreshToken(refreshToken: string, proxy?: string, instance?: string): Promise<QueryResponse | string>;
21
+ export function loginAnonymously(proxy?: string, instance?: string): Promise<QueryResponse | string>;
22
+ export function createAccount(email: string, password: string, proxy?: string, instance?: string): Promise<QueryResponse | string>;
@@ -66,6 +66,8 @@ export interface Account {
66
66
  firebaseId: string;
67
67
  sessionId: string;
68
68
  session: string;
69
+ email: string;
70
+ password: string;
69
71
  cw: ChiknWinnerStatus;
70
72
  loadout: {
71
73
  hatId: number | null;
@@ -170,10 +172,12 @@ export interface Pathing {
170
172
 
171
173
  export interface BotState {
172
174
  name: string;
175
+ weaponIdx: number;
173
176
  reloading: boolean;
174
177
  swappingGun: boolean;
175
178
  usingMelee: boolean;
176
179
  shotsFired: number;
180
+ quit: boolean;
177
181
  }
178
182
 
179
183
  export interface ChiknWinnerResponse {
@@ -190,7 +194,8 @@ type intents = {
190
194
  PING: 5,
191
195
  COSMETIC_DATA: 6,
192
196
  PLAYER_HEALTH: 7,
193
- PACKET_HOOK: 8
197
+ PACKET_HOOK: 8,
198
+ MONITOR: 9
194
199
  }
195
200
 
196
201
  export class Bot {
@@ -227,11 +232,12 @@ export class Bot {
227
232
  createPrivateGame(opts: { region: string; mode: string; map: string }): Promise<RawGameData>;
228
233
  join(botName: string, data: string | RawGameData): Promise<void>;
229
234
 
235
+ processPacket(data: number[]): void;
230
236
  dispatch(disp: ADispatch): void;
231
237
  update(): void;
232
238
 
233
239
  canSee(player: GamePlayer): boolean;
234
- getBestTarget(customFilter: (player: GamePlayer) => boolean): GamePlayer | undefined;
240
+ getBestTarget(customFilter?: (player: GamePlayer) => boolean): GamePlayer | undefined;
235
241
 
236
242
  onAny(cb: Function): void;
237
243
 
@@ -272,7 +278,7 @@ export class Bot {
272
278
  on(event: 'tick', cb: () => void): void;
273
279
 
274
280
  checkChiknWinner(): Promise<ChiknWinnerStatus>;
275
- playChiknWinner(): Promise<ChiknWinnerResponse | string>;
281
+ playChiknWinner(doPrematureCooldownCheck: boolean): Promise<ChiknWinnerResponse | string>;
276
282
  resetChiknWinner(): Promise<ChiknWinnerStatus>;
277
283
 
278
284
  refreshBalance(): Promise<number>;