-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
540f7e7
commit e024003
Showing
15 changed files
with
1,168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
export type Side = 'CT' | 'T'; | ||
export type RoundOutcome = 'ct_win_elimination' | 't_win_elimination' | 'ct_win_time' | 'ct_win_defuse' | 't_win_bomb'; | ||
|
||
export type WeaponType = 'Knife' | 'Pistol' | 'Grenade' | 'Rifle' | 'SniperRifle' | 'C4' | 'Submachine Gun'; | ||
|
||
export interface WeaponRaw { | ||
name: string; | ||
paintkit: string; | ||
type?: WeaponType; | ||
ammo_clip?: number; | ||
ammo_clip_max?: number; | ||
ammo_reserve?: number; | ||
state: 'active' | 'holstered'; | ||
} | ||
|
||
export interface TeamRaw { | ||
score: number; | ||
consecutive_round_losses: number; | ||
timeouts_remaining: number; | ||
matches_won_this_series: number; | ||
name?: string; | ||
flag?: string; | ||
} | ||
|
||
export interface PlayerRaw { | ||
steamid?: string; | ||
name: string; | ||
clan?: string; | ||
observer_slot?: number; | ||
team: Side; | ||
match_stats: { | ||
kills: number; | ||
assists: number; | ||
deaths: number; | ||
mvps: number; | ||
score: number; | ||
}; | ||
weapons: { | ||
[key: string]: WeaponRaw; | ||
}; | ||
state: { | ||
health: number; | ||
armor: number; | ||
helmet: boolean; | ||
defusekit?: boolean; | ||
flashed: number; | ||
smoked?: number; | ||
burning: number; | ||
money: number; | ||
round_kills: number; | ||
round_killhs: number; | ||
round_totaldmg: number; | ||
equip_value: number; | ||
}; | ||
position: string; | ||
forward: string; | ||
} | ||
|
||
export interface PlayerObservedRaw { | ||
steamid: string; | ||
clan?: string; | ||
name: string; | ||
observer_slot?: number; | ||
team?: Side; | ||
activity: 'playing' | 'textinput' | 'menu'; | ||
state: { | ||
health: number; | ||
armor: number; | ||
helmet: boolean; | ||
flashed: number; | ||
smoked: number; | ||
burning: number; | ||
money: number; | ||
round_kills: number; | ||
round_killhs: number; | ||
round_totaldmg: number; | ||
equip_value: number; | ||
}; | ||
spectarget: 'free' | string; | ||
position: string; | ||
forward: string; | ||
} | ||
|
||
export interface PlayersRaw { | ||
[key: string]: PlayerRaw; | ||
} | ||
|
||
export interface Provider { | ||
name: 'Counter-Strike: Global Offensive'; | ||
appid: 730; | ||
version: number; | ||
steamid: string; | ||
timestamp: number; | ||
} | ||
|
||
export interface MapRaw { | ||
mode: 'competitive'; | ||
name: string; | ||
phase: 'warmup' | 'live' | 'intermission' | 'gameover'; | ||
round: number; | ||
team_ct: TeamRaw; | ||
team_t: TeamRaw; | ||
num_matches_to_win_series: number; | ||
current_spectators: number; | ||
souvenirs_total: number; | ||
round_wins: { | ||
[key: string]: RoundOutcome; | ||
}; | ||
} | ||
|
||
export interface RoundRaw { | ||
phase: 'freezetime' | 'live' | 'over'; | ||
bomb?: 'planted' | 'exploded' | 'defused'; | ||
win_team?: Side; | ||
} | ||
|
||
export interface BombRaw { | ||
state: 'carried' | 'planted' | 'dropped' | 'defused' | 'defusing' | 'planting' | 'exploded'; | ||
countdown?: string; | ||
player?: string; | ||
position: string; | ||
} | ||
export interface PhaseRaw { | ||
phase?: 'freezetime' | 'bomb' | 'warmup' | 'live' | 'over' | 'defuse' | 'paused' | 'timeout_ct' | 'timeout_t'; | ||
phase_ends_in: string; | ||
} | ||
|
||
export interface CSGORaw { | ||
provider: Provider; | ||
map?: MapRaw; | ||
round?: RoundRaw; | ||
player?: PlayerObservedRaw; | ||
allplayers?: PlayersRaw; | ||
bomb?: BombRaw; | ||
grenades?: { | ||
[key: string]: any; | ||
/*{ | ||
owner:number, | ||
position:string, | ||
velocity:string, | ||
lifetime:string, | ||
type:string, | ||
effecttime?:string | ||
}*/ | ||
}; | ||
previously?: any; | ||
phase_countdowns?: PhaseRaw; | ||
auth?: { | ||
token: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as I from './interfaces'; | ||
|
||
export interface Events { | ||
raw: (data: I.CSGORaw) => void; | ||
data: (data: I.CSGO) => void; | ||
roundEnd: (team: I.Score) => void; | ||
matchEnd: (score: I.Score) => void; | ||
kill: (kill: I.KillEvent) => void; | ||
hurt: (kill: I.HurtEvent) => void; | ||
timeoutStart: (team: any) => void; | ||
timeoutEnd: () => void; | ||
/*roundStart: (round: number) => void, | ||
warmupStart: () => void, | ||
warmupEnd: () => void,*/ | ||
mvp: (player: I.Player) => void; | ||
freezetimeStart: () => void; | ||
freezetimeEnd: () => void; | ||
intermissionStart: () => void; | ||
intermissionEnd: () => void; | ||
defuseStart: (player: I.Player) => void; | ||
defuseStop: (player: I.Player) => void; | ||
bombPlantStart: (player: I.Player) => void; | ||
bombPlant: (player: I.Player) => void; | ||
bombExplode: () => void; | ||
bombDefuse: (player: I.Player) => void; | ||
newListener: <K extends keyof Events>(eventName: K, listener: Events[K]) => void; | ||
removeListener: <K extends keyof Events>(eventName: K, listener: Events[K]) => void; | ||
} | ||
|
||
export type AnyEventName<T> = T | (string & {}); | ||
|
||
export type BaseEvents = keyof Events; | ||
|
||
export type EventNames = AnyEventName<BaseEvents>; | ||
|
||
export type EmptyListener = () => void; | ||
|
||
export type Callback<K> = K extends BaseEvents ? Events[K] | EmptyListener : EmptyListener; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { | ||
CSGO, | ||
CSGORaw, | ||
Events, | ||
KillEvent, | ||
PlayerExtension, | ||
RawKill, | ||
Score, | ||
TeamExtension, | ||
Callback, | ||
EventNames, | ||
BaseEvents | ||
} from './interfaces'; | ||
import { RawHurt } from './mirv'; | ||
import { DigestMirvType, HurtEvent } from './parsed'; | ||
import { mapSteamIDToPlayer, parseTeam, getHalfFromRound, didTeamWinThatRound } from './utils.js'; | ||
interface EventDescriptor { | ||
listener: Events[BaseEvents]; | ||
once: boolean; | ||
} | ||
declare type RoundPlayerDamage = { | ||
steamid: string; | ||
damage: number; | ||
}; | ||
declare type RoundDamage = { | ||
round: number; | ||
players: RoundPlayerDamage[]; | ||
}; | ||
declare class CSGOGSI { | ||
private descriptors; | ||
private maxListeners; | ||
teams: { | ||
left: TeamExtension | null; | ||
right: TeamExtension | null; | ||
}; | ||
damage: RoundDamage[]; | ||
players: PlayerExtension[]; | ||
overtimeMR: number; | ||
regulationMR: number; | ||
last?: CSGO; | ||
current?: CSGO; | ||
constructor(); | ||
eventNames: () => EventNames[]; | ||
getMaxListeners: () => number; | ||
listenerCount: (eventName: EventNames) => number; | ||
listeners: ( | ||
eventName: EventNames | ||
) => ( | ||
| ((data: CSGORaw) => void) | ||
| ((data: CSGO) => void) | ||
| ((team: Score) => void) | ||
| ((score: Score) => void) | ||
| ((kill: KillEvent) => void) | ||
| ((kill: HurtEvent) => void) | ||
| ((team: any) => void) | ||
| (() => void) | ||
| ((player: import('./parsed').Player) => void) | ||
| (() => void) | ||
| (() => void) | ||
| (() => void) | ||
| (() => void) | ||
| ((player: import('./parsed').Player) => void) | ||
| ((player: import('./parsed').Player) => void) | ||
| ((player: import('./parsed').Player) => void) | ||
| ((player: import('./parsed').Player) => void) | ||
| (() => void) | ||
| ((player: import('./parsed').Player) => void) | ||
| (<K extends keyof Events>(eventName: K, listener: Events[K]) => void) | ||
| (<K_1 extends keyof Events>(eventName: K_1, listener: Events[K_1]) => void) | ||
)[]; | ||
removeListener: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
off: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
addListener: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
on: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
once: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
prependListener: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
emit: (eventName: EventNames, arg?: any, arg2?: any) => boolean; | ||
prependOnceListener: <K extends EventNames>(eventName: K, listener: Callback<K>) => this; | ||
removeAllListeners: (eventName: EventNames) => this; | ||
setMaxListeners: (n: number) => this; | ||
rawListeners: (eventName: EventNames) => EventDescriptor[]; | ||
digest: (raw: CSGORaw) => CSGO | null; | ||
digestMIRV: (raw: RawKill | RawHurt, eventType?: string) => DigestMirvType; | ||
static findSite(mapName: string, position: number[]): 'A' | 'B' | null; | ||
} | ||
export { CSGOGSI, mapSteamIDToPlayer, parseTeam, getHalfFromRound, didTeamWinThatRound, RoundDamage }; | ||
export { | ||
CSGO, | ||
CSGORaw, | ||
Side, | ||
RoundOutcome, | ||
WeaponType, | ||
Observer, | ||
RawHurt, | ||
WeaponRaw, | ||
TeamRaw, | ||
PlayerRaw, | ||
PlayerObservedRaw, | ||
PlayersRaw, | ||
Provider, | ||
HurtEvent, | ||
RoundWins, | ||
MapRaw, | ||
RoundRaw, | ||
BombRaw, | ||
PhaseRaw, | ||
Events, | ||
Team, | ||
Player, | ||
Bomb, | ||
Map, | ||
Round, | ||
Score, | ||
KillEvent, | ||
RawKill, | ||
TeamExtension, | ||
RoundInfo, | ||
PlayerExtension, | ||
Orientation | ||
} from './interfaces'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export * from './csgo'; | ||
export * from './events'; | ||
export * from './parsed'; | ||
export * from './mirv'; | ||
|
||
export interface TeamExtension { | ||
id: string; | ||
name: string; | ||
country: string | null; | ||
logo: string | null; | ||
map_score: number; | ||
extra: Record<string, string>; | ||
} | ||
|
||
export interface PlayerExtension { | ||
id: string; | ||
name: string; | ||
steamid: string; | ||
realName: string | null; | ||
country: string | null; | ||
avatar: string | null; | ||
extra: Record<string, string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export interface RawKill { | ||
name: 'player_death'; | ||
clientTime: number; | ||
keys: { | ||
userid: { | ||
value: number; | ||
xuid: string; | ||
}; | ||
attacker: { | ||
value: number; | ||
xuid: string; | ||
}; | ||
assister: { | ||
value: number; | ||
xuid: string; | ||
}; | ||
assistedflash: boolean; | ||
weapon: string; | ||
weapon_itemid: string; | ||
weapon_fauxitemid: string; | ||
weapon_originalowner_xuid: string; | ||
headshot: boolean; | ||
dominated: number; | ||
revenge: number; | ||
wipe: number; | ||
attackerblind: boolean; | ||
thrusmoke: boolean; | ||
noscope: boolean; | ||
penetrated: number; | ||
noreplay: boolean; | ||
}; | ||
} | ||
|
||
export interface RawHurt { | ||
name: 'player_hurt'; | ||
clientTime: number; | ||
keys: { | ||
userid: { | ||
value: number; | ||
xuid: string; | ||
}; | ||
attacker: { | ||
value: number; | ||
xuid: string; | ||
}; | ||
health: number; | ||
armor: number; | ||
weapon: string; | ||
dmg_health: number; | ||
dmg_armor: number; | ||
hitgroup: number; | ||
}; | ||
} |
Oops, something went wrong.