|
1 | 1 | import React from 'react';
|
2 | 2 | import PropTypes from 'prop-types';
|
3 | 3 | import styled from 'styled-components';
|
| 4 | +import items from 'dotaconstants/build/items.json'; |
4 | 5 | import { threshold, formatSeconds } from 'utility';
|
5 | 6 | import Table from 'components/Table';
|
6 | 7 | import strings from 'lang';
|
@@ -76,16 +77,19 @@ function logWard(log) {
|
76 | 77 |
|
77 | 78 | const generateData = match => (log) => {
|
78 | 79 | const wardKiller = (log.left && log.left.player1) ? heroTd(match.players[log.left.player1]) : '';
|
79 |
| - const duration = log.left ? log.left.time - log.entered.time : ''; |
| 80 | + const duration = (log.left && log.left.time - log.entered.time) || (match && match.duration - log.entered.time); |
| 81 | + |
| 82 | + // necessary until https://github.com/odota/parser/pull/3 is implemented |
| 83 | + const discrepancy = duration - Math.min(items[`ward_${log.type}`].attrib.find(x => x.key === 'lifetime').value, duration); |
80 | 84 |
|
81 | 85 | const durationColor = log.type === 'observer' ? durationObserverColor(duration) : durationSentryColor(duration);
|
82 | 86 |
|
83 | 87 | return {
|
84 | 88 | ...match.players[log.player],
|
85 | 89 | type: <img height="29" src={`${process.env.REACT_APP_API_HOST}/apps/dota2/images/items/ward_${log.type}_lg.png`} alt="" />,
|
86 | 90 | enter_time: formatSeconds(log.entered.time),
|
87 |
| - left_time: formatSeconds(log.left && log.left.time) || '-', |
88 |
| - duration: <span style={{ color: durationColor }}>{formatSeconds(duration)}</span>, |
| 91 | + left_time: formatSeconds(((log.left && log.left.time) || (match && match.duration)) - discrepancy) || '-', |
| 92 | + duration: <span style={{ color: durationColor }}>{formatSeconds(duration - discrepancy)}</span>, |
89 | 93 | killer: wardKiller,
|
90 | 94 | placement: logWard(log),
|
91 | 95 | };
|
|
0 commit comments