Skip to content

Commit cfaf2b7

Browse files
committed
Added player alive and adr reference
1 parent 6f80387 commit cfaf2b7

File tree

6 files changed

+100
-20
lines changed

6 files changed

+100
-20
lines changed

src/HUD/Layout/Layout.tsx

+32-14
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface State {
2828
}
2929

3030
export default class Layout extends React.Component<Props, State> {
31-
constructor(props: Props){
31+
constructor(props: Props) {
3232
super(props);
3333
this.state = {
3434
winner: null,
@@ -37,23 +37,33 @@ export default class Layout extends React.Component<Props, State> {
3737
}
3838
}
3939

40-
componentDidMount(){
40+
componentDidMount() {
4141
GSI.on('roundEnd', score => {
4242
this.setState({ winner: score.winner, showWin: true }, () => {
4343
setTimeout(() => {
44-
this.setState({showWin: false})
44+
this.setState({ showWin: false })
4545
}, 4000)
4646
});
4747
});
4848
actions.on("boxesState", (state: string) => {
49-
if(state === "show"){
50-
this.setState({forceHide: false});
51-
} else if(state === "hide"){
52-
this.setState({forceHide:true});
49+
if (state === "show") {
50+
this.setState({ forceHide: false });
51+
} else if (state === "hide") {
52+
this.setState({ forceHide: true });
5353
}
5454
});
5555
}
5656

57+
getVeto = () => {
58+
const { game, match } = this.props;
59+
const { map } = game;
60+
if (!match) return null;
61+
const mapName = map.name.substring(map.name.lastIndexOf('/') + 1);
62+
const veto = match.vetos.find(veto => veto.mapName === mapName);
63+
if (!veto) return null;
64+
return veto;
65+
}
66+
5767
render() {
5868
const { game, match } = this.props;
5969
const left = game.map.team_ct.orientation === "left" ? game.map.team_ct : game.map.team_t;
@@ -66,26 +76,34 @@ export default class Layout extends React.Component<Props, State> {
6676

6777
return (
6878
<div className="layout">
79+
<div className={`players_alive`}>
80+
<div className="title_container">Players alive</div>
81+
<div className="counter_container">
82+
<div className={`team_counter ${left.side}`}>{leftPlayers.filter(player => player.state.health > 0).length}</div>
83+
<div className={`vs_counter`}>VS</div>
84+
<div className={`team_counter ${right.side}`}>{rightPlayers.filter(player => player.state.health > 0).length}</div>
85+
</div>
86+
</div>
6987
<Killfeed />
7088
<Overview match={match} map={game.map} players={game.players || []} />
71-
<RadarMaps match={match} map={game.map} game={game}/>
72-
<MatchBar map={game.map} phase={game.phase_countdowns} bomb={game.bomb}/>
89+
<RadarMaps match={match} map={game.map} game={game} />
90+
<MatchBar map={game.map} phase={game.phase_countdowns} bomb={game.bomb} />
7391

7492
<SeriesBox map={game.map} phase={game.phase_countdowns} match={match} />
7593

7694
<Tournament />
7795

78-
<Observed player={game.player} />
96+
<Observed player={game.player} veto={this.getVeto()} round={game.map.round+1}/>
7997

80-
<TeamBox team={left} players={leftPlayers} side="left" current={game.player} isFreezetime={isFreezetime}/>
98+
<TeamBox team={left} players={leftPlayers} side="left" current={game.player} isFreezetime={isFreezetime} />
8199
<TeamBox team={right} players={rightPlayers} side="right" current={game.player} isFreezetime={isFreezetime} />
82100

83101
<Trivia />
84-
85-
<MapSeries teams={[left, right]} match={match} isFreezetime={isFreezetime} map={game.map}/>
102+
103+
<MapSeries teams={[left, right]} match={match} isFreezetime={isFreezetime} map={game.map} />
86104
<div className={"boxes left"}>
87105
<UtilityLevel side={left.side} players={game.players} show={isFreezetime && !forceHide} />
88-
<SideBox side="left" hide={forceHide}/>
106+
<SideBox side="left" hide={forceHide} />
89107
<MoneyBox
90108
team={left.side}
91109
side="left"

src/HUD/Overview/Overview.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class Overview extends React.Component<IProps, IState> {
9090
renderPlayer = () => {
9191
const { player } = this.state;
9292
if(!player.data) return null;
93-
return <PlayerOverview player={player.data} players={this.props.players} show={player.show} veto={this.getVeto()} />
93+
return <PlayerOverview round={this.props.map.round + 1} player={player.data} players={this.props.players} show={player.show} veto={this.getVeto()} />
9494
}
9595
renderMatch = () => {
9696
const { match } = this.state;

src/HUD/PlayerOverview/PlayerOverview.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ interface IProps {
1010
show: boolean,
1111
veto: I.Veto | null
1212
players: Player[],
13+
round: number
1314
}
1415

1516
export default class PlayerOverview extends React.Component<IProps> {
1617
sum = (data: number[]) => data.reduce((a, b) => a + b, 0);
1718

1819
getData = () => {
19-
const { veto, player } = this.props;
20+
const { veto, player, round } = this.props;
2021
if(!player || !veto || !veto.rounds) return null;
2122
const stats = veto.rounds.map(round => round.players[player.steamid]).filter(data => !!data);
2223
const overall = {
@@ -25,7 +26,7 @@ export default class PlayerOverview extends React.Component<IProps> {
2526
killshs: this.sum(stats.map(round => round.killshs)),
2627
};
2728
const data = {
28-
adr: stats.length !== 0 ? (overall.damage/stats.length).toFixed(0) : '0',
29+
adr: stats.length !== 0 ? (overall.damage/(round-1)).toFixed(0) : '0',
2930
kills: overall.kills,
3031
killshs: overall.kills,
3132
kpr: stats.length !== 0 ? (overall.kills/stats.length).toFixed(2) : 0,

src/HUD/Players/Observed.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "./../Styles/observed.css";
77
import {apiUrl} from './../../api/api';
88
import { getCountry } from "./../countries";
99
import { ArmorHelmetCT, ArmorHelmetT, ArmorFullCT, ArmorFullT, HealthFullCT, HealthFullT, BulletsCT, BulletsT } from './../../assets/Icons';
10+
import { Veto } from "../../api/interfaces";
1011

1112

1213
const armor = {
@@ -20,7 +21,7 @@ const armor = {
2021
}
2122
};
2223

23-
class Statistic extends React.PureComponent<{ label: string; value: string | number }> {
24+
class Statistic extends React.PureComponent<{ label: string; value: string | number, }> {
2425
render() {
2526
return (
2627
<div className="stat">
@@ -31,7 +32,14 @@ class Statistic extends React.PureComponent<{ label: string; value: string | num
3132
}
3233
}
3334

34-
export default class Observed extends React.Component<{ player: Player | null }> {
35+
export default class Observed extends React.Component<{ player: Player | null, veto: Veto | null, round: number }> {
36+
getAdr = () => {
37+
const { veto, player } = this.props;
38+
if(!player || !veto || !veto.rounds) return null;
39+
const damageInRounds = veto.rounds.map(round => round.players[player.steamid]).filter(data => !!data).map(roundData => roundData.damage);
40+
//console.log(damageInRounds)
41+
return damageInRounds.reduce((a, b) => a + b, 0)/(this.props.round-1);
42+
}
3543
render() {
3644
if (!this.props.player) return '';
3745
const { player } = this.props;
@@ -42,6 +50,10 @@ export default class Observed extends React.Component<{ player: Player | null }>
4250
const { stats } = player;
4351
const ratio = stats.deaths === 0 ? stats.kills : stats.kills/stats.deaths;
4452
const countryName = country ? getCountry(country) : null;
53+
54+
55+
const adr = this.getAdr() !== null ? this.getAdr() : "-";
56+
4557
return (
4658
<div className={`observed ${player.team.side}`}>
4759
<div className="main_row">

src/HUD/Styles/maps.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
font-size: 10pt;
3434
}
3535
.veto_entry .team_logo img {
36-
max-height: 75%;
36+
max-height: 23px;
3737
padding-right: 3px;
38+
max-width: 23px;
3839
}
3940
.veto_entry .map_name.active {
4041
text-shadow: 0 0 15px white;

src/HUD/Styles/players.css

+48
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,52 @@ img.weapon.active {
476476
}
477477
.teambox.T .player_side_stats .side_stat_row:first-child {
478478
color: var(--mainT);
479+
}
480+
481+
.players_alive {
482+
display: flex;
483+
flex-direction: column;
484+
width: 180px;
485+
background-color: rgba(0,0,0,0.5);
486+
position: fixed;
487+
right: 10px;
488+
top: 10px;
489+
opacity: 1;
490+
transition: opacity 1s;
491+
}
492+
.players_alive.hide {
493+
opacity: 0;
494+
}
495+
.players_alive .counter_container {
496+
display: flex;
497+
height: 45px;
498+
}
499+
.players_alive .counter_container > div {
500+
flex: 1;
501+
display: flex;
502+
align-items: center;
503+
justify-content: center;
504+
font-size:30px;
505+
color: white;
506+
background-color: rgba(0,0,0,0.5);
507+
}
508+
.players_alive .counter_container .team_counter {
509+
background-color: rgba(0,0,0,0.75);
510+
}
511+
.players_alive .title_container {
512+
color: white;
513+
text-transform: uppercase;
514+
text-align: center;
515+
height:20px;
516+
font-size:14px;
517+
display: flex;
518+
align-items: center;
519+
justify-content: center;
520+
background-color: rgba(0,0,0,0.75);
521+
}
522+
.players_alive .counter_container .CT {
523+
color: var(--color-new-ct);
524+
}
525+
.players_alive .counter_container .T {
526+
color: var(--color-new-t);
479527
}

0 commit comments

Comments
 (0)