Skip to content
This repository was archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
feat: add gold medal to tournament winner avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWbn committed Nov 5, 2022
1 parent c829d59 commit 4787306
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 131 deletions.
27 changes: 20 additions & 7 deletions components/player-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,26 @@ function PlayerItem({
) : (
<>
<p className="mr-2 w-4 text-slate-300 text-center">{rank || "-"}</p>
<Image
src={`/animals/${player.animal}.png`}
alt={player.animal}
width={24}
height={24}
onClick={() => setIsAnimalEdit(true)}
/>
{player.isTournamentWinner ? (
<div className="w-6 flex justify-center items-center flex-col relative">
<div className="absolute text-xs -right-1 -bottom-1">🥇</div>
<Image
src={`/animals/${player.animal}.png`}
alt={player.animal}
width={20}
height={20}
onClick={() => setIsAnimalEdit(true)}
/>
</div>
) : (
<Image
src={`/animals/${player.animal}.png`}
alt={player.animal}
width={24}
height={24}
onClick={() => setIsAnimalEdit(true)}
/>
)}
{isNameEdit ? (
<div className="flex grow">
<input
Expand Down
5 changes: 4 additions & 1 deletion domain/Leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Tournament } from "./Tournament";

export interface RatedPlayer extends Player {
rating: number;
isTournamentWinner: boolean;
}

export interface GameWithDelta extends Game {
Expand All @@ -26,6 +27,7 @@ export class Leaderboard {
getRankedPlayers(date = new Date()): RatedPlayer[] {
let ratedPlayers: RatedPlayer[] = this.players.map((player) => ({
...player,
isTournamentWinner: false,
rating: 1500,
}));

Expand All @@ -48,7 +50,7 @@ export class Leaderboard {

get events(): LeaderboardEvent[] {
const playersWithInitialRating: RatedPlayer[] = this.players.map(
(player) => ({ ...player, rating: 1500 })
(player) => ({ ...player, rating: 1500, isTournamentWinner: false })
);

const { events } = [...this.games, ...this.tournaments]
Expand Down Expand Up @@ -110,6 +112,7 @@ export class Leaderboard {
return {
...player,
rating: player.rating + Math.round(prizepool * 0.25),
isTournamentWinner: true,
};
}
if (tournament.second.includes(player.id)) {
Expand Down
Loading

0 comments on commit 4787306

Please sign in to comment.