fix: Infinity and NaN values in GenericAllStats now render as --

This commit is contained in:
TresAbhi committed 2023-06-18 01:59:32 +00:00
1 parent e0c1db2a0b
commit 0cf0e63fda
1 file changed
+6 -5
+6 -5
View File
@@ -11,6 +11,10 @@ export default function GenericAllStats({
stats,
supplementaryStats,
}: GenericAllStatsProps) {
const damageRatio = stats.damage_dealt / stats.damage_received;
const killsToDeathRatio =
stats.frags / (stats.battles - stats.survived_battles);
return (
<GenericStats
stats={[
@@ -41,13 +45,10 @@ export default function GenericAllStats({
['Average hits', (stats.hits / stats.battles).toFixed(2)],
['Average kills', (stats.frags / stats.battles).toFixed(2)],
['Average spots', (stats.spotted / stats.battles).toFixed(2)],
[
'Damage ratio',
(stats.damage_dealt / stats.damage_received).toFixed(2),
],
['Damage ratio', isFinite(damageRatio) ? damageRatio.toFixed(2) : '--'],
[
'Kills to death ratio',
(stats.frags / (stats.battles - stats.survived_battles)).toFixed(2),
isFinite(killsToDeathRatio) ? killsToDeathRatio.toFixed(2) : '--',
],
]}
/>