yolkbot 0.1.2-alpha.8 → 0.1.2

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.
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;
@@ -175,6 +177,7 @@ export interface BotState {
175
177
  swappingGun: boolean;
176
178
  usingMelee: boolean;
177
179
  shotsFired: number;
180
+ quit: boolean;
178
181
  }
179
182
 
180
183
  export interface ChiknWinnerResponse {
@@ -229,11 +232,12 @@ export class Bot {
229
232
  createPrivateGame(opts: { region: string; mode: string; map: string }): Promise<RawGameData>;
230
233
  join(botName: string, data: string | RawGameData): Promise<void>;
231
234
 
235
+ processPacket(data: number[]): void;
232
236
  dispatch(disp: ADispatch): void;
233
237
  update(): void;
234
238
 
235
239
  canSee(player: GamePlayer): boolean;
236
- getBestTarget(customFilter: (player: GamePlayer) => boolean): GamePlayer | undefined;
240
+ getBestTarget(customFilter?: (player: GamePlayer) => boolean): GamePlayer | undefined;
237
241
 
238
242
  onAny(cb: Function): void;
239
243
 
@@ -274,7 +278,7 @@ export class Bot {
274
278
  on(event: 'tick', cb: () => void): void;
275
279
 
276
280
  checkChiknWinner(): Promise<ChiknWinnerStatus>;
277
- playChiknWinner(): Promise<ChiknWinnerResponse | string>;
281
+ playChiknWinner(doPrematureCooldownCheck: boolean): Promise<ChiknWinnerResponse | string>;
278
282
  resetChiknWinner(): Promise<ChiknWinnerStatus>;
279
283
 
280
284
  refreshBalance(): Promise<number>;