Skip to content

Commit

Permalink
Add testing and rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon committed Feb 10, 2021
1 parent bde142a commit 7f3d215
Show file tree
Hide file tree
Showing 21 changed files with 1,400,442 additions and 85 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"file": "schedule.html",
"workspace": "Setup"
},
{
"name": "test",
"title": "Test",
"width": 2,
"file": "test.html",
"workspace": "Setup"
},
{
"name": "currentmatch",
"title": "Current Match",
Expand Down
5 changes: 2 additions & 3 deletions src/dashboard/setup/schedule/schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { theme } from '../../theme';
import { useReplicant } from 'use-nodecg';

import { TeamsPreset } from '../../../types/team-preset';
import { DummyTeamsPreset } from '../../../extension/dummyData';
import { teamPlayerPreset } from '../../../extension/example-data';
import { Match, Matches, NewMatch } from '../../../types/matches';

import { Grid, Select, MenuItem, FormControl, InputLabel, TextField, Chip } from '@material-ui/core';
Expand Down Expand Up @@ -54,9 +54,8 @@ const getItemStyle = (draggableStyle: DraggingStyle | NotDraggingStyle | undefin
});

const DashSchedule: React.FC = () => {
const [teamPresetsRep] = useReplicant<TeamsPreset>('teamPlayerPreset', DummyTeamsPreset);
const [teamPresetsRep] = useReplicant<TeamsPreset>('teamPlayerPreset', teamPlayerPreset);
const [matchesRep] = useReplicant<Matches>('matches', []);
console.log(matchesRep)
const [currentMatchRep] = useReplicant<Match | undefined>('currentMatch', undefined);

const [teamA, setTeamA] = useState('');
Expand Down
4 changes: 2 additions & 2 deletions src/dashboard/setup/server/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ThemeProvider } from '@material-ui/styles';
// Import { Tooltip, YAxis, AreaChart, Area } from 'recharts';

// Interfaces
import { bundleStatus as DummyBundle } from '../../../extension/dummyData';
import { bundleStatus as ExampleBundle } from '../../../extension/example-data';
import { BundleStatus } from '../../../types/bundle-status';
import { Button } from '@material-ui/core';

Expand Down Expand Up @@ -44,7 +44,7 @@ interface ActiveProps {
// ];

export const Server: React.FunctionComponent = () => {
const [bundleStatus] = useReplicant<BundleStatus>('bundleStatus', DummyBundle);
const [bundleStatus] = useReplicant<BundleStatus>('bundleStatus', ExampleBundle);
const [serverRateRep] = useReplicant<number>('serverRate', 0);
const [hlaeActiveRep] = useReplicant<boolean>('hlaeActive', false);
const serverBtn = useRef<StyledToggleButton>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ThemeProvider } from '@material-ui/styles';
import { flagList } from '../../atoms/flag-list';
import { theme } from '../../theme';
import { TeamsPreset } from '../../../types/team-preset';
import { DummyTeamsPreset } from '../../../extension/dummyData';
import { teamPlayerPreset } from '../../../extension/example-data';
import { FullTeam } from 'hltv/lib/models/FullTeam';
import { Asset } from '../../../types/nodecg';

Expand All @@ -46,7 +46,7 @@ const TwemojiMenuItem = styled(Twemoji)`
export const TeamPresetCreator: React.FC = () => {
const [profilePicturesRep] = useReplicant<Asset[]>('assets:playerIcons', []);
const [teamImagesRep] = useReplicant<Asset[]>('assets:teamimages', []);
const [teamPresetsRep] = useReplicant<TeamsPreset>('teamPlayerPreset', DummyTeamsPreset);
const [teamPresetsRep] = useReplicant<TeamsPreset>('teamPlayerPreset', teamPlayerPreset);
const [steamId, setSteamId] = useState('');
const [localName, setLocalName] = useState('');
const [localPfp, setLocalPfp] = useState('');
Expand Down
23 changes: 2 additions & 21 deletions src/dashboard/setup/teams/player-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DialogTitle from '@material-ui/core/DialogTitle';

import { CSGOAllplayer } from '../../../types/csgo-gsi';
import { PlayerData } from '../../../types/extra-data';
import { Asset } from '../../../types/nodecg';
import { useReplicant } from 'use-nodecg';
import { flagList } from '../../atoms/flag-list';

Expand Down Expand Up @@ -85,28 +86,8 @@ interface Props {
extraPlayer: PlayerData;
}

interface Asset {
base: string;
bundleName: string;
category: string;
ext: string;
name: string;
sum: string;
url: string;
}

const DummyAsset: Asset = {
base: '',
bundleName: 'csgo-layouts',
category: '',
ext: '',
name: '',
sum: '',
url: '',
};

export const PlayerBox: React.FC<Props> = (props: Props) => {
const [profilePicturesRep] = useReplicant<Asset[]>('assets:playerIcons', [DummyAsset]);
const [profilePicturesRep] = useReplicant<Asset[]>('assets:playerIcons', []);
const [dialogOpen, setDialogOpen] = useState(false);
const [localPfp, setLocalPfp] = useState('');
const [localCountry, setLocalCountry] = useState('');
Expand Down
14 changes: 7 additions & 7 deletions src/dashboard/setup/teams/teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Team } from './team';
import { Map, CSGOAllplayer } from '../../../types/csgo-gsi';
import { TeamData, PlayerDataAll } from '../../../types/extra-data';
import { TeamsPreset } from '../../../types/team-preset';
import * as DummyData from '../../../extension/dummyData';
import ExampleData from '../../../extension/example-data';
import { Match } from '../../../types/matches';

const Divider = styled.div`
Expand All @@ -24,12 +24,12 @@ const Divider = styled.div`
`;

export const Teams: React.FunctionComponent = () => {
const [matchRep] = useReplicant<Map>('matchStats', DummyData.match);
const [teamOneRep] = useReplicant<TeamData>('teamOne', DummyData.TeamData);
const [teamTwoRep] = useReplicant<TeamData>('teamTwo', DummyData.TeamData);
const [allPlayersRep] = useReplicant<CSGOAllplayer[]>('allPlayers', DummyData.player);
const [playerDataRep] = useReplicant<PlayerDataAll>('playerData', DummyData.ExtraData);
const [teamPresetsRep] = useReplicant<TeamsPreset>('teamPlayerPreset', DummyData.DummyTeamsPreset);
const [matchRep] = useReplicant<Map>('matchStats', ExampleData.match);
const [teamOneRep] = useReplicant<TeamData>('teamOne', ExampleData.teamData);
const [teamTwoRep] = useReplicant<TeamData>('teamTwo', ExampleData.teamData);
const [allPlayersRep] = useReplicant<CSGOAllplayer[]>('allPlayers', ExampleData.player);
const [playerDataRep] = useReplicant<PlayerDataAll>('playerData', ExampleData.extraData);
const [teamPresetsRep] = useReplicant<TeamsPreset>('teamPlayerPreset', ExampleData.teamPlayerPreset);
const [currentMatchRep] = useReplicant<Match | undefined>('currentMatch', undefined);
const [swapTeamsRep, setSwapTeamsRep] = useReplicant('swapTeams', false);

Expand Down
118 changes: 118 additions & 0 deletions src/dashboard/setup/test/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React from 'react';
import { render } from 'react-dom';
import styled from 'styled-components';

import { PlayerDeath } from '../../../types/hlae';

import { theme } from '../../theme';
import { Button } from '@material-ui/core';
import { ThemeProvider } from '@material-ui/styles';

import { RedButton } from '../../atoms/styled-ui';

const ExamplePlayerDeath: PlayerDeath = {
name: 'player_death',
clientTime: 168.671875,
keys: {
userid: {
value: 4,
xuid: '0',
eyeOrigin: [-373.6505126953125, 1573.7967529296875, -62.60200500488281],
eyeAngles: [355.6109619140625, 260.3814697265625, 0],
},
attacker: {
value: 5,
xuid: '0',
eyeOrigin: [-407.38153076171875, 122.61137390136719, 65.26649475097656],
eyeAngles: [6.102906227111816, 88.37369537353516, -2.1465999111569545e-7],
},
assister: {
value: 0,
xuid: '0',
eyeOrigin: [0, 0, 0],
eyeAngles: [0, 0, 0],
},
assistedflash: false,
weapon: 'ak47',
weaponItemid: '0',
weaponFauxitemid: '17293822569102704647',
weaponOriginalownerXuid: '0',
headshot: false,
dominated: 0,
revenge: 0,
wipe: 0,
penetrated: 0,
noreplay: true,
noscope: false,
thrusmoke: false,
attackerblind: false,
distance: 36.895103454589844,
},
round: 1,
};

const LargePlayerDeath: PlayerDeath = {
...ExamplePlayerDeath,
keys: {
...ExamplePlayerDeath.keys,
assister: {
...ExamplePlayerDeath.keys.assister,
value: 0
},
weapon: 'awp',
headshot: true,
penetrated: 1,
noscope: true,
thrusmoke: true,
attackerblind: true
}
}

const ButtonContainer = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
`;

export const Test: React.FC = () => {
return (
<ThemeProvider theme={theme}>
<ButtonContainer>
<RedButton
variant="contained"
fullWidth
onClick={() => {
nodecg.sendMessage('test:stop');
}}>
Stop
</RedButton>
<Button
variant="contained"
fullWidth
onClick={() => {
nodecg.sendMessage('test:standard');
}}>
Standard
</Button>
<Button
variant="contained"
fullWidth
onClick={() => {
nodecg.sendMessage('hlae:playerDeath', ExamplePlayerDeath);
}}>
Kill Basic
</Button>
<Button
variant="contained"
fullWidth
onClick={() => {
nodecg.sendMessage('hlae:playerDeath', LargePlayerDeath);
}}>
Kill Large
</Button>
</ButtonContainer>
</ThemeProvider>
);
};

render(<Test />, document.getElementById('test'));
13 changes: 13 additions & 0 deletions src/dashboard/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
</head>
<body>
<div id="test"></div>
<script src="setup/test/test.tsx"></script>
</body>
</html>
38 changes: 28 additions & 10 deletions src/extension/dummyData.ts → src/extension/example-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ export const bundleStatus: BundleStatus = {
export const gameSettings: GameSettings = {
bombPlantTime: 3,
bombTime: 40,
kitDefusedTime: 5,
kitDefuseTime: 5,
noKitDefuseTime: 10
};

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

export const TeamData: ITeamData = {
export const teamData: ITeamData = {
equipmentValue: 10000,
totalMoney: 10000,
grenades: {
Expand All @@ -139,25 +139,25 @@ export const TeamData: ITeamData = {
fire: 0,
decoy: 0
},
players: ['-1'],
players: [],
score: 0,
consecutiveRoundLosses: 0,
matchesWonThisSeries: 0
};

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

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

export const DummyTeamsPreset: TeamsPreset = {
export const teamPlayerPreset: TeamsPreset = {
teams: {},
players: {}
};
Expand All @@ -172,9 +172,9 @@ export const game: CSGO = {
},
allplayers: {},
bomb: bomb,
grenades: DummyGrenadesAll,
grenades: grenadesAll,
map: match,
phaseCountdowns: phase,
phase_countdowns: phase,
player: observingPlayer,
round: {
phase: "live"
Expand All @@ -194,3 +194,21 @@ export const game: CSGO = {
}
}
}

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

export default ExampleData;
7 changes: 2 additions & 5 deletions src/extension/extraData.ts → src/extension/extra-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from 'lodash';
import { CSGOAllplayer, CSGOPhaseCountdowns, Map } from '../types/csgo-gsi';
import { PlayerDataAll, TeamData } from '../types/extra-data';
import { MapInfo, Matches } from '../types/matches';
import { ExtraData as DummyExtraData } from './dummyData';
import { extraData as exampleExtraData } from './example-data';
import { TeamsPreset } from '../types/team-preset';

const nodecg = nodecgApiContext.get();
Expand All @@ -20,9 +20,6 @@ const teamPresetsRep = nodecg.Replicant<TeamsPreset>('teamPlayerPreset');
const currentMatchRep = nodecg.Replicant<string>('currentMatch');
const matchScoresRep = nodecg.Replicant<Matches>('matches');

teamOneRep.value.players = [];
teamTwoRep.value.players = [];

function getCurrentMatch() {
return matchScoresRep.value.find(match => match.id === currentMatchRep.value);
}
Expand Down Expand Up @@ -121,7 +118,7 @@ allPlayersRep.on('change', newVal => {

// Clear all data if round 0
if (matchRep.value.round === 0) {
playerDataRep.value = DummyExtraData;
playerDataRep.value = exampleExtraData;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async function init(): Promise<void> {
require('./map-interp');
require('./hlae');
require('./extraData');
require('./testing');
}

module.exports = (nodecg: NodeCG): void => {
Expand Down
Loading

0 comments on commit 7f3d215

Please sign in to comment.