-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from qlemaire22/winrates-by-match
Winrates by matchups
- Loading branch information
Showing
4 changed files
with
85 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
import { Race, type PlayerMatchupsStats } from "../../lib/api" | ||
import Widget from "../Widget.astro" | ||
import { classes, styles } from "../../lib/theme" | ||
import { Image } from "astro:assets" | ||
import infernals from "../../assets/game/factions/infernals-small.png" | ||
import vanguard from "../../assets/game/factions/vanguard-small.png" | ||
type Theme = keyof typeof styles.badges | ||
interface Props { | ||
playerMatchupStats: PlayerMatchupsStats | ||
} | ||
const { playerMatchupStats } = Astro.props | ||
const matchupsSortedByRace = playerMatchupStats.matchups.sort((a, b) => a.race.localeCompare(b.race)) | ||
--- | ||
|
||
<Widget title="Winrates by matchup"> | ||
<table class="mx-auto w-full table-auto whitespace-nowrap text-left text-sm transition-opacity"> | ||
<tbody> | ||
{ | ||
matchupsSortedByRace.map((matchup) => ( | ||
<tr class="border-b border-gray-700/50 last:border-b-0"> | ||
<td class="flex w-full gap-2 truncate p-2 font-semibold text-gray-50"> | ||
<Image src={matchup.race === "infernals" ? infernals : vanguard} alt={matchup.race} class="size-6" /> | ||
vs | ||
<Image | ||
src={matchup.opponent_race === "infernals" ? infernals : vanguard} | ||
alt={matchup.opponent_race} | ||
class="size-6" | ||
/> | ||
</td> | ||
<td class="pr-2 text-right text-sm text-gray-100"> | ||
{matchup.aggregated.wins_count} | ||
<span class="text-green-400"> W</span> | ||
</td> | ||
<td class="pr-2 text-right text-sm text-gray-100"> | ||
{matchup.aggregated.wins_count} | ||
<span class="text-red-400"> L</span> | ||
</td> | ||
<td class=" text-right text-sm text-gray-100">{Math.round(matchup.aggregated.win_rate)}%</td> | ||
</tr> | ||
)) | ||
} | ||
</tbody> | ||
</table> | ||
</Widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters