From 723bbf05009287915a67398f4091ea29a4dd4184 Mon Sep 17 00:00:00 2001 From: Akash Jaiswal Date: Thu, 3 Mar 2022 15:40:43 +0530 Subject: [PATCH 1/2] feat: battle show score of match --- src/components/BattleTV/BattleTV.module.css | 12 ++++++++--- src/components/BattleTV/BattleTV.tsx | 22 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/BattleTV/BattleTV.module.css b/src/components/BattleTV/BattleTV.module.css index 41b1af3a..0a546818 100644 --- a/src/components/BattleTV/BattleTV.module.css +++ b/src/components/BattleTV/BattleTV.module.css @@ -94,6 +94,12 @@ html { text-align: right; } +.score { + width: 12%; + text-align: center; + font-size: 2vw; + line-height: 22px; +} .coinused { width: 7%; text-align: center; @@ -101,10 +107,10 @@ html { line-height: 22px; } .destruction { - width: 12%; + width: 7%; text-align: center; - font-size: 2vw; - line-height: 25px; + font-size: 1vw; + line-height: 22px; } .vs { text-align: center; diff --git a/src/components/BattleTV/BattleTV.tsx b/src/components/BattleTV/BattleTV.tsx index f2df26dd..9baa3bda 100644 --- a/src/components/BattleTV/BattleTV.tsx +++ b/src/components/BattleTV/BattleTV.tsx @@ -68,6 +68,10 @@ function PaginatedItems() { setItemOffset(newOffset); }; + function calculateScore(coinsUsed: number, destruction: number) { + return coinsUsed / 15 + 2 * destruction; + } + return ( <> <> @@ -99,6 +103,12 @@ function PaginatedItems() {
{[...match.games.values()][0].destruction.toFixed(2)}
+
+ {calculateScore( + [...match.games.values()][0].coinsUsed, + [...match.games.values()][0].destruction, + )} +
{ @@ -114,6 +124,16 @@ function PaginatedItems() { > Watch
+
+ {calculateScore( + [...match.games.values()][ + [...match.games.values()].length === 1 ? 0 : 1 + ].coinsUsed, + [...match.games.values()][ + [...match.games.values()].length === 1 ? 0 : 1 + ].destruction, + )} +
{[...match.games.values()][ [...match.games.values()].length === 1 ? 0 : 1 @@ -177,7 +197,9 @@ export default function BattleTV(): JSX.Element {
Coins Used
Destruction %
+
Score
VS
+
Score
Destruction %
Coins Used
From 718afafbd241eb0349afac9892e45fa4eb63e1a4 Mon Sep 17 00:00:00 2001 From: Akash Jaiswal Date: Thu, 3 Mar 2022 15:43:34 +0530 Subject: [PATCH 2/2] typo: score formula --- src/components/BattleTV/BattleTV.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BattleTV/BattleTV.tsx b/src/components/BattleTV/BattleTV.tsx index 9baa3bda..027d96e6 100644 --- a/src/components/BattleTV/BattleTV.tsx +++ b/src/components/BattleTV/BattleTV.tsx @@ -69,7 +69,7 @@ function PaginatedItems() { }; function calculateScore(coinsUsed: number, destruction: number) { - return coinsUsed / 15 + 2 * destruction; + return (1500 - coinsUsed) / 15 + 2 * destruction; } return (