Skip to content

Commit

Permalink
Edited types
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon committed Feb 13, 2021
1 parent 468f5a9 commit 6992bf1
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 16 deletions.
18 changes: 18 additions & 0 deletions src/extension/example-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GameSettings } from '../../types/game-settings';
import { BundleStatus } from '../../types/bundle-status';
import { PlayerDataAll, TeamData as ITeamData } from '../../types/extra-data';
import { TeamsPreset } from '../../types/team-preset';
import { MapPlayerData } from '../../types/map-player';

export const match: Map = {
mode: 'competitive',
Expand Down Expand Up @@ -195,6 +196,20 @@ export const game: CSGO = {
},
};

export const mapPostions: MapPlayerData[] = [
{
steamId: '0',
beingObserved: true,
ct: true,
position: [0, 0, 0],
rotation: [0, 0, 0],
observerSlot: 1,
health: 100,
},
];

export const interpMapPositions: { [key: string]: MapPlayerData } = {};

const ExampleData = {
match,
player,
Expand All @@ -209,6 +224,9 @@ const ExampleData = {
grenadesAll,
teamPlayerPreset,
game,
mapPostions,
interpMapPositions,
};

export const ExampleDataObj = ExampleData;
export default ExampleData;
6 changes: 3 additions & 3 deletions src/extension/team-import-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash';
import { HLTV } from 'hltv';
const nodecg = nodecgApiContext.get();

import { TeamsPreset, Team, Player } from '../../types/team-preset';
import { TeamsPreset, TeamMeta, Player } from '../../types/team-preset';
import { PlayerDataAll } from '../../types/extra-data';

interface Asset {
Expand Down Expand Up @@ -70,7 +70,7 @@ function updateTeamPreset(newVal: Asset[]): void {
try {
const teamsJSON = JSON.parse(jsonString);
if (teamsJSON.teams) {
teamsJSON.teams.forEach((team: Team) => {
teamsJSON.teams.forEach((team: TeamMeta) => {
newTeamPresets.teams[team.name] = team;
});
}
Expand Down Expand Up @@ -110,7 +110,7 @@ nodecg.listenFor('pushNewPlayerData', (player: TeamsPreset['players'][0]) => {

nodecg.listenFor('newTeam', (data: { name: string; alias: string; logo?: string }) => {
nodecg.log.info('Adding ' + data.alias);
const teamObj: Team = {
const teamObj: TeamMeta = {
alias: data.alias,
name: data.name,
logo: data.logo,
Expand Down
1 change: 1 addition & 0 deletions types/csgo-gsi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,6 @@ export interface Provider {
}

export interface Round {
win_team?: string;
phase: string;
}
232 changes: 232 additions & 0 deletions types/example-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
/* eslint-disable camelcase */
import {
Map,
CSGOAllplayer,
CSGOPlayer,
CSGOBomb,
CSGOPhaseCountdowns,
CSGOOutputGrenade,
CSGOGrenadesAll,
CSGO,
} from './csgo-gsi';
import { GameSettings } from './game-settings';
import { BundleStatus } from './bundle-status';
import { PlayerDataAll, TeamData as ITeamData } from './extra-data';
import { TeamsPreset } from './team-preset';
import { MapPlayerData } from './map-player';

export const match: Map = {
mode: 'competitive',
name: 'de_dust2',
phase: 'live',
round: 0,
team_ct: {
score: 0,
consecutive_round_losses: 0,
timeouts_remaining: 0,
matches_won_this_series: 0,
},
team_t: {
score: 0,
consecutive_round_losses: 0,
timeouts_remaining: 0,
matches_won_this_series: 0,
},
num_matches_to_win_series: 0,
current_spectators: 0,
souvenirs_total: 0,
round_wins: {},
};

export const player: CSGOAllplayer[] = [
{
steamId: '-1',
name: 'Username',
observer_slot: 0,
team: 'T',
state: {
health: 100,
armor: 0,
helmet: false,
flashed: 0,
burning: 0,
money: 0,
round_kills: 0,
round_killhs: 0,
round_totaldmg: 0,
equip_value: 0,
},
match_stats: {
kills: 0,
assists: 0,
deaths: 0,
mvps: 0,
score: 0,
},
weapons: {
weapon_0: {
name: 'weapon_knife_t',
paintkit: 'default',
type: 'Knife',
state: 'holstered',
},
},
position: '0, 0, 0',
forward: '0, 0, 0',
},
];

export const observingPlayer: CSGOPlayer = {
steamid: '-1',
clan: '',
name: 'PlayerName',
observer_slot: 0,
team: 'T',
activity: 'textinput',
state: {
health: 100,
armor: 0,
helmet: false,
flashed: 0,
smoked: 0,
burning: 0,
money: 0,
round_kills: 0,
round_killhs: 0,
round_totaldmg: 0,
equip_value: 0,
},
spectarget: '0',
position: '0, 0, 0',
forward: '0, 0, 0',
};

export const bomb: CSGOBomb = {
state: 'carried',
position: '0, 0, 0',
player: '-1',
};

export const phase: CSGOPhaseCountdowns = {
phase: 'live',
phase_ends_in: '120',
};

export const bundleStatus: BundleStatus = {
isServerOn: false,
};

export const gameSettings: GameSettings = {
bombPlantTime: 3,
bombTime: 40,
kitDefuseTime: 5,
noKitDefuseTime: 10,
};

export const extraData: PlayerDataAll = {
'-1': {
totalDamage: 0,
adr: 0,
},
};

export const teamData: ITeamData = {
equipmentValue: 10000,
totalMoney: 10000,
grenades: {
he: 0,
flash: 0,
smoke: 0,
fire: 0,
decoy: 0,
},
players: [],
score: 0,
consecutiveRoundLosses: 0,
matchesWonThisSeries: 0,
};

export const grenades: CSGOOutputGrenade = {
owner: '-1',
position: '0, 0, 0',
velocity: '0, 0, 0',
lifetime: '0',
type: '',
};

export const grenadesAll: CSGOGrenadesAll = {
'100': grenades,
};

export const teamPlayerPreset: TeamsPreset = {
teams: {},
players: {},
};

export const game: CSGO = {
provider: {
name: 'Counter-Strike: Global Offensive',
appid: 730,
version: 13697,
steamid: '76561198046005090',
timestamp: 1558521542,
},
allplayers: {},
bomb: bomb,
grenades: grenadesAll,
map: match,
phase_countdowns: phase,
player: observingPlayer,
round: {
phase: 'live',
},
previously: {
player: {
position: '0.00, 0.00, 0.00',
forward: '0.00, 0.00, 0.00',
},
allplayers: {},
phase_countdowns: {
phaseEndsIn: '120',
},
grenades: {},
bomb: {
position: '0.00, 0.00, 0.00',
},
},
};

export const mapPostions: MapPlayerData[] = [
{
steamId: '0',
beingObserved: true,
ct: true,
position: [0, 0, 0],
rotation: [0, 0, 0],
observerSlot: 1,
health: 100,
},
];

export const interpMapPositions: { [key: string]: MapPlayerData } = {};

const ExampleData = {
match,
player,
observingPlayer,
bomb,
phase,
bundleStatus,
gameSettings,
extraData,
teamData,
grenades,
grenadesAll,
teamPlayerPreset,
game,
mapPostions,
interpMapPositions,
};

export const ExampleDataObj = ExampleData;
export default ExampleData;
29 changes: 21 additions & 8 deletions types/hlae.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export interface PlayerDeath {
}

interface PlayerDeathKeys {
userid: Assister;
attacker: Assister;
assister: Assister;
userid: Userid;
attacker: Userid;
assister: Userid;
assistedflash: boolean;
weapon: string;
weaponItemid: string;
Expand All @@ -33,9 +33,22 @@ interface PlayerDeathKeys {
distance: number;
}

interface Assister {
value: number;
xuid: string;
eyeOrigin: number[];
eyeAngles: number[];
export interface WeaponFire {
name: string;
clientTime: number;
keys: WeaponFireKeys;
round: number;
}

export interface WeaponFireKeys {
userid: Userid;
weapon: string;
silenced: boolean;
}

export interface Userid {
value: number;
xuid: string;
eyeOrigin: number[];
eyeAngles: number[];
}
9 changes: 9 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * as BundleStatus from './bundle-status';
export * as CSGO from './csgo-gsi';
export * as ExtraData from './extra-data';
export * as GameSettings from './game-settings';
export * as HLAE from './hlae';
export * as MapPlayer from './map-player';
export * as Matches from './matches';
export * as TeamPreset from './team-preset';
export * as Tournament from './tournament';
6 changes: 3 additions & 3 deletions types/matches.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Team } from './team-preset';
import { TeamMeta } from './team-preset';

export type Matches = Match[];

Expand All @@ -11,8 +11,8 @@ export interface NewMatch {
}

export interface Match {
teamA: Team;
teamB: Team;
teamA: TeamMeta;
teamB: TeamMeta;
maps: MapInfo[];
status: string;
time: string;
Expand Down
4 changes: 2 additions & 2 deletions types/team-preset.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface Team {
interface TeamMeta {
alias: string;
name: string;
logo?: string;
Expand All @@ -13,6 +13,6 @@ interface Player {
}

export interface TeamsPreset {
teams: Record<string, Team>;
teams: Record<string, TeamMeta>;
players: Record<string, Player>;
}

0 comments on commit 6992bf1

Please sign in to comment.