Skip to content

Commit

Permalink
impermanent win indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Jun 24, 2024
1 parent aa1fc06 commit fd2ad53
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
13 changes: 11 additions & 2 deletions web/src/components/pages/home/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import { useAccount } from "@starknet-react/core";
import { observer } from "mobx-react-lite";
import { useEffect, useRef, useState } from "react";
import Countdown from "react-countdown";
import { Arrow, InfosIcon, PaperIcon, Skull } from "../../icons";
import { Arrow, InfosIcon, PaperIcon, Skull, Trophy } from "../../icons";
import { SeasonDetailsModal } from "./SeasonDetailsModal";
import { Game } from "@/generated/graphql";
import { shortString } from "starknet";
import { Config, ConfigStoreClass } from "@/dojo/stores/config";
import { getPayedCount } from "@/dojo/helpers";

const renderer = ({
days,
Expand Down Expand Up @@ -72,6 +73,8 @@ export const Leaderboard = observer(({ config }: { config?: Config }) => {
refetch: refetchRegisteredGames,
} = useRegisteredGamesBySeason(selectedVersion);

const payedCount = getPayedCount(registeredGames.length);

useEffect(() => {
if (!config) return;

Expand Down Expand Up @@ -207,7 +210,13 @@ export const Leaderboard = observer(({ config }: { config?: Config }) => {

{game.claimable > 0 && (
<Text flexShrink={0} fontSize={["12px", "16px"]}>
<PaperIcon /> {game.claimable} ...
<PaperIcon /> {game.claimable} ..
</Text>
)}

{game.season_version === config.ryo.season_version && index + 1 < payedCount && (
<Text flexShrink={0} fontSize={["12px", "16px"]} >
<Trophy opacity={0.5}/>
</Text>
)}

Expand Down
36 changes: 36 additions & 0 deletions web/src/dojo/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,39 @@ export const wantedModeColor = {
[WantedMode.KoolAndTheGang]: colors.neon["400"],
};
export type wantedModeColorKeys = keyof typeof wantedModeColor;

export function getPayedCount(entrants: number): number {
if (entrants <= 2) {
return 1; // payout_0_2(rank)
} else if (entrants <= 10) {
return 2; // payout_3_10(rank)
} else if (entrants <= 30) {
return 3; // payout_11_30(rank)
} else if (entrants <= 50) {
return 5; // payout_31_50(rank)
} else if (entrants <= 75) {
return 8; //payout_51_75(rank)
} else if (entrants <= 100) {
return 10; // payout_76_100(rank)
} else if (entrants <= 150) {
return 15; // payout_101_150(rank)
} else if (entrants <= 200) {
return 20; // payout_151_200(rank)
} else if (entrants <= 250) {
return 25; // payout_201_250(rank)
} else if (entrants <= 300) {
return 30; // payout_251_300(rank)
} else if (entrants <= 350) {
return 35; // payout_301_350(rank)
} else if (entrants <= 400) {
return 40; // payout_351_400(rank)
} else if (entrants <= 500) {
return 50; // payout_401_500(rank)
} else {
return 60; // payout_501_700(rank)
}
}

//
// payout count
//

0 comments on commit fd2ad53

Please sign in to comment.