Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show result of the laning stage #3107

Merged
merged 5 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/actions/transformMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function generateExpandedUnitNames(strings) {
Object.keys(strings)
.filter(str => str.indexOf('npc_dota_') === 0)
.forEach((key) => {
// Currently, no unit goes up higher than 4
// Currently, no unit goes up higher than 4
for (let i = 1; i < 5; i += 1) {
expanded[key.replace('#', i)] = strings[key];
}
Expand Down Expand Up @@ -145,6 +145,16 @@ function generateVisionLog(match) {

function transformMatch(m) {
const { abilityIds, strings } = store.getState().app;

// lane winning
const lineResults = m.players.reduce((res, pl) => {
res[pl.isRadiant] = res[pl.isRadiant] || [];
res[pl.isRadiant][pl.lane] = res[pl.isRadiant][pl.lane] || 0;

res[pl.isRadiant][pl.lane] += pl.gold_t[10]
return res;
}, {});

const newPlayers = m.players.map((player) => {
const newPlayer = {
...player,
Expand All @@ -153,6 +163,7 @@ function transformMatch(m) {
kill_streaks_max: getMaxKeyOfObject(player.kill_streaks),
lh_ten: (player.lh_t || [])[10],
dn_ten: (player.dn_t || [])[10],
line_win: lineResults[player.isRadiant][player.lane] > lineResults[!player.isRadiant][player.lane],
analysis: analyzeMatch(m, player),
};

Expand Down
12 changes: 11 additions & 1 deletion src/components/Match/Laning/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,28 @@ class Laning extends React.Component {
this.setState({ ...this.state, selectedPlayer: playerSlot });
};

defaultSort = (r1, r2) => {
if (r1.isRadiant !== r2.isRadiant) {
return 1;
}

return r1.lane - r2.lane;
}

render() {
const {
match, strings, sponsorURL, sponsorIcon,
} = this.props;
const { laningColumns } = mcs(strings);

const tableData = [...match.players].sort(this.defaultSort);

return (
<StyledFlexContainer>
<StyledFlexElementFullWidth>
<Heading title={strings.heading_laning} />
<Table
data={match.players}
data={tableData}
columns={laningColumns(this.state, this.setSelectedPlayer)}
/>
</StyledFlexElementFullWidth>
Expand Down
8 changes: 8 additions & 0 deletions src/components/Match/StyledMatch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,11 @@ export const StyledDmgTargetRow = styled.div`
}
}
`;

export const StyledLineWinnerSpan = styled.span`
& svg {
width: 20px !important;
height: 20px !important;
fill: ${constants.colorGolden};
}
`;
Loading