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

cap ward lifespans and exclude some wards from average #1379

Merged
merged 2 commits into from
Dec 9, 2017
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
10 changes: 7 additions & 3 deletions src/components/Match/Vision/VisionLog.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import items from 'dotaconstants/build/items.json';
import { threshold, formatSeconds } from 'utility';
import Table from 'components/Table';
import strings from 'lang';
Expand Down Expand Up @@ -76,16 +77,19 @@ function logWard(log) {

const generateData = match => (log) => {
const wardKiller = (log.left && log.left.player1) ? heroTd(match.players[log.left.player1]) : '';
const duration = log.left ? log.left.time - log.entered.time : '';
const duration = (log.left && log.left.time - log.entered.time) || (match && match.duration - log.entered.time);

// necessary until https://github.com/odota/parser/pull/3 is implemented
const discrepancy = duration - Math.min(items[`ward_${log.type}`].attrib.find(x => x.key === 'lifetime').value, duration);

const durationColor = log.type === 'observer' ? durationObserverColor(duration) : durationSentryColor(duration);

return {
...match.players[log.player],
type: <img height="29" src={`${process.env.REACT_APP_API_HOST}/apps/dota2/images/items/ward_${log.type}_lg.png`} alt="" />,
enter_time: formatSeconds(log.entered.time),
left_time: formatSeconds(log.left && log.left.time) || '-',
duration: <span style={{ color: durationColor }}>{formatSeconds(duration)}</span>,
left_time: formatSeconds(((log.left && log.left.time) || (match && match.duration)) - discrepancy) || '-',
duration: <span style={{ color: durationColor }}>{formatSeconds(duration - discrepancy)}</span>,
killer: wardKiller,
placement: logWard(log),
};
Expand Down
8 changes: 5 additions & 3 deletions src/components/Match/matchColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,11 @@ const computeAverage = (row, type) => {
const totalDuration = [];
row[`${type}_log`].forEach((ward) => {
const findTime = row[`${type}_left_log`].find(x => x.ehandle === ward.ehandle);
const leftTime = (findTime && findTime.time) || row.duration;
const duration = Math.min(Math.max(leftTime - ward.time, 0), maxDuration);
totalDuration.push(duration);
const leftTime = (findTime && findTime.time) || false;
if (leftTime !== false) { // exclude wards that did not expire before game ended from average time
const duration = Math.min(Math.max(leftTime - ward.time, 0), maxDuration);
totalDuration.push(duration);
}
});
let sum = 0;
for (let i = 0; i < totalDuration.length; i += 1) {
Expand Down