mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-22 11:05:09 -05:00
Add Triton-Cup badge
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import { Button } from "@chakra-ui/button";
|
||||
import { Image } from "@chakra-ui/image";
|
||||
import { Divider, Flex, Text } from "@chakra-ui/layout";
|
||||
import { useState } from "react";
|
||||
import { wonITZCount } from "utils/constants";
|
||||
import { Fragment, useState } from "react";
|
||||
import { wonITZCount, wonTournamentCount } from "utils/constants";
|
||||
|
||||
const Badges = ({
|
||||
userId,
|
||||
userDiscordId,
|
||||
patreonTier,
|
||||
peakXP = -1,
|
||||
}: {
|
||||
userId: number;
|
||||
userDiscordId: string;
|
||||
patreonTier: number | null;
|
||||
peakXP?: number;
|
||||
}) => {
|
||||
@@ -97,6 +99,21 @@ const Badges = ({
|
||||
});
|
||||
}
|
||||
|
||||
// Triton-Cup
|
||||
|
||||
if (
|
||||
wonTournamentCount({ tournament: "TRITON", discordId: userDiscordId }) > 0
|
||||
) {
|
||||
badges.push({
|
||||
src: "triton.gif",
|
||||
description: "Awarded for winning Triton-Cup",
|
||||
count: wonTournamentCount({
|
||||
tournament: "TRITON",
|
||||
discordId: userDiscordId,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
if (badges.length === 0) return null;
|
||||
|
||||
return (
|
||||
@@ -116,12 +133,12 @@ const Badges = ({
|
||||
{badges.flatMap((badge) => {
|
||||
if (showInfo)
|
||||
return (
|
||||
<>
|
||||
<Flex key={badge.src} justify="center" align="center" my={2}>
|
||||
<Fragment key={badge.src}>
|
||||
<Flex justify="center" align="center" my={2}>
|
||||
<Image w={10} h={10} m={4} src={`/badges/${badge.src}`} />{" "}
|
||||
<Text fontSize="sm">{badge.description}</Text>
|
||||
</Flex>
|
||||
</>
|
||||
</Fragment>
|
||||
);
|
||||
return new Array(badge.count).fill(null).map((_, i) => {
|
||||
return (
|
||||
|
||||
@@ -110,6 +110,7 @@ const ProfilePage = (props: Props) => {
|
||||
/>
|
||||
<Badges
|
||||
userId={props.user.id}
|
||||
userDiscordId={props.user.discordId}
|
||||
patreonTier={user.patreonTier}
|
||||
peakXP={
|
||||
Object.values(props.peakXPowers).sort(
|
||||
|
||||
BIN
public/badges/triton.gif
Normal file
BIN
public/badges/triton.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 212 KiB |
@@ -341,3 +341,30 @@ export const wonITZCount = (
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const TRITON_CUP_WINNERS =
|
||||
"277760673436401664,317021572470669312,347127232839417856,149504203654430720,207150814735761408,304337232808902668,403962004739588096,381129695980290050";
|
||||
|
||||
export const wonTournamentCount = ({
|
||||
tournament,
|
||||
discordId,
|
||||
}: {
|
||||
tournament: "TRITON";
|
||||
discordId: string;
|
||||
}) => {
|
||||
let winnersString = "";
|
||||
switch (tournament) {
|
||||
case "TRITON":
|
||||
winnersString = TRITON_CUP_WINNERS;
|
||||
break;
|
||||
default:
|
||||
console.error(`Invalid tournament: ${tournament}`);
|
||||
}
|
||||
|
||||
return winnersString
|
||||
.split(",")
|
||||
.reduce(
|
||||
(count, winnersId) => (winnersId === discordId ? count + 1 : count),
|
||||
0
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user