Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

feat: battle show score of match #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions src/components/BattleTV/BattleTV.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,23 @@ html {
text-align: right;
}

.score {
width: 12%;
text-align: center;
font-size: 2vw;
line-height: 22px;
}
.coinused {
width: 7%;
text-align: center;
font-size: 1vw;
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;
Expand Down
22 changes: 22 additions & 0 deletions src/components/BattleTV/BattleTV.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ function PaginatedItems() {
setItemOffset(newOffset);
};

function calculateScore(coinsUsed: number, destruction: number) {
return (1500 - coinsUsed) / 15 + 2 * destruction;
}

return (
<>
<>
Expand Down Expand Up @@ -99,6 +103,12 @@ function PaginatedItems() {
<div className={styles.destruction}>
{[...match.games.values()][0].destruction.toFixed(2)}
</div>
<div className={styles.score}>
{calculateScore(
[...match.games.values()][0].coinsUsed,
[...match.games.values()][0].destruction,
)}
</div>
<div
className={styles.watchButton}
onClick={() => {
Expand All @@ -114,6 +124,16 @@ function PaginatedItems() {
>
Watch
</div>
<div className={styles.score}>
{calculateScore(
[...match.games.values()][
[...match.games.values()].length === 1 ? 0 : 1
].coinsUsed,
[...match.games.values()][
[...match.games.values()].length === 1 ? 0 : 1
].destruction,
)}
</div>
<div className={styles.destruction}>
{[...match.games.values()][
[...match.games.values()].length === 1 ? 0 : 1
Expand Down Expand Up @@ -177,7 +197,9 @@ export default function BattleTV(): JSX.Element {
<div className={styles.username}></div>
<div className={styles.coinused}>Coins Used</div>
<div className={styles.destruction}>Destruction %</div>
<div className={styles.score}>Score</div>
<div className={styles.vs}>VS</div>
<div className={styles.score}>Score</div>
<div className={styles.destruction}>Destruction %</div>
<div className={styles.coinused}>Coins Used</div>
<div className={styles.username}></div>
Expand Down