mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: remove reward section
This commit is contained in:
1 parent
21bafa1b7b
commit
91d48eeadd
2 files changed
+10
-55
No files matched your search
@@ -5,7 +5,6 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { range } from 'lodash';
|
import { range } from 'lodash';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard';
|
|
||||||
import CommandWrapper from '../components/CommandWrapper';
|
import CommandWrapper from '../components/CommandWrapper';
|
||||||
import * as Leaderboard from '../components/Leaderboard';
|
import * as Leaderboard from '../components/Leaderboard';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
@@ -29,6 +28,7 @@ import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
|||||||
import { localizationObject } from '../core/discord/localizationObject';
|
import { localizationObject } from '../core/discord/localizationObject';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { translator } from '../core/localization/translator';
|
import { translator } from '../core/localization/translator';
|
||||||
|
import { BkrlDiscriminatedEntries } from '../core/streams/bkrl';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { UserError } from '../hooks/userError';
|
import { UserError } from '../hooks/userError';
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
let titleDescription: string;
|
let titleDescription: string;
|
||||||
let playersAfter: number;
|
let playersAfter: number;
|
||||||
let players: SimplifiedPlayer[] | undefined;
|
let players: SimplifiedPlayer[] | undefined;
|
||||||
let midnightLeaderboard: BlitzkriegRatingsLeaderboard | undefined;
|
let midnightLeaderboard: BkrlDiscriminatedEntries | null;
|
||||||
let playerId: number | undefined;
|
let playerId: number | undefined;
|
||||||
let regionRatingsInfo: RatingsInfo;
|
let regionRatingsInfo: RatingsInfo;
|
||||||
|
|
||||||
@@ -308,12 +308,12 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
const firstPlayerIndex =
|
const firstPlayerIndex =
|
||||||
leagueIndex === 0
|
leagueIndex === 0
|
||||||
? 0
|
? 0
|
||||||
: players.findIndex(
|
: players.entries.findIndex(
|
||||||
(player) =>
|
(player) =>
|
||||||
player.score < LEAGUES[leagueIndex - 1].minScore,
|
player.score < LEAGUES[leagueIndex - 1].minScore,
|
||||||
);
|
);
|
||||||
const lastPlayerIndex = firstPlayerIndex + limit - 1;
|
const lastPlayerIndex = firstPlayerIndex + limit - 1;
|
||||||
const trimmed = players.slice(
|
const trimmed = players.entries.slice(
|
||||||
firstPlayerIndex,
|
firstPlayerIndex,
|
||||||
lastPlayerIndex + 1,
|
lastPlayerIndex + 1,
|
||||||
);
|
);
|
||||||
@@ -388,7 +388,7 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
)
|
)
|
||||||
: await getArchivedRatingsLeaderboard(region, season!).then(
|
: await getArchivedRatingsLeaderboard(region, season!).then(
|
||||||
async (players) => {
|
async (players) => {
|
||||||
const playerIndex = players.findIndex(
|
const playerIndex = players.entries.findIndex(
|
||||||
(player) => player.id === id,
|
(player) => player.id === id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const halfRange = Math.round(limit / 2);
|
const halfRange = Math.round(limit / 2);
|
||||||
const trimmed = players.slice(
|
const trimmed = players.entries.slice(
|
||||||
playerIndex - halfRange,
|
playerIndex - halfRange,
|
||||||
playerIndex + halfRange + 1,
|
playerIndex + halfRange + 1,
|
||||||
);
|
);
|
||||||
@@ -441,23 +441,14 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
playerId = id;
|
playerId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolvedRegionRatingsInfo: typeof regionRatingsInfo & {
|
|
||||||
detail: undefined;
|
|
||||||
} = regionRatingsInfo;
|
|
||||||
|
|
||||||
const items = players.map((player) => {
|
const items = players.map((player) => {
|
||||||
const reward = resolvedRegionRatingsInfo.rewards.find(
|
const midnightIndex = midnightLeaderboard?.entries.findIndex(
|
||||||
(reward) =>
|
|
||||||
player.position >= reward.from_position &&
|
|
||||||
player.position <= reward.to_position,
|
|
||||||
);
|
|
||||||
const midnightIndex = midnightLeaderboard?.findIndex(
|
|
||||||
(item) => item.id === player.id,
|
(item) => item.id === player.id,
|
||||||
);
|
);
|
||||||
const midnightScore =
|
const midnightScore =
|
||||||
midnightIndex === undefined
|
midnightIndex === undefined
|
||||||
? player.score
|
? player.score
|
||||||
: midnightLeaderboard![midnightIndex].score;
|
: midnightLeaderboard!.entries[midnightIndex].score;
|
||||||
const midnightPosition =
|
const midnightPosition =
|
||||||
midnightIndex === undefined ? player.position : midnightIndex + 1;
|
midnightIndex === undefined ? player.position : midnightIndex + 1;
|
||||||
|
|
||||||
@@ -467,7 +458,6 @@ export const ratingsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
score={player.score}
|
score={player.score}
|
||||||
position={player.position}
|
position={player.position}
|
||||||
clan={player.clan}
|
clan={player.clan}
|
||||||
reward={reward}
|
|
||||||
deltaScore={player.score - midnightScore}
|
deltaScore={player.score - midnightScore}
|
||||||
deltaPosition={midnightPosition - player.position}
|
deltaPosition={midnightPosition - player.position}
|
||||||
key={player.id}
|
key={player.id}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { ComponentProps } from 'react';
|
import { ComponentProps } from 'react';
|
||||||
import { RatingsReward } from '../../../commands/ratings';
|
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
interface ItemProps extends ComponentProps<'div'> {
|
interface ItemProps extends ComponentProps<'div'> {
|
||||||
@@ -7,7 +6,6 @@ interface ItemProps extends ComponentProps<'div'> {
|
|||||||
deltaPosition?: number;
|
deltaPosition?: number;
|
||||||
score?: number;
|
score?: number;
|
||||||
deltaScore?: number;
|
deltaScore?: number;
|
||||||
reward?: RatingsReward;
|
|
||||||
nickname: string;
|
nickname: string;
|
||||||
clan?: string;
|
clan?: string;
|
||||||
highlight?: boolean;
|
highlight?: boolean;
|
||||||
@@ -22,7 +20,6 @@ export function Item({
|
|||||||
deltaPosition,
|
deltaPosition,
|
||||||
score,
|
score,
|
||||||
deltaScore,
|
deltaScore,
|
||||||
reward,
|
|
||||||
nickname,
|
nickname,
|
||||||
clan,
|
clan,
|
||||||
highlight,
|
highlight,
|
||||||
@@ -120,40 +117,8 @@ export function Item({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div
|
{/* TODO: lol remove this spacer div for a better solution */}
|
||||||
style={{
|
<div style={{ flex: 1 }} />
|
||||||
flex: 1,
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
gap: 4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{reward && (
|
|
||||||
<img
|
|
||||||
style={{ width: 16, height: 16, objectFit: 'cover' }}
|
|
||||||
src={normalizeImage(
|
|
||||||
reward.type === 'vehicle'
|
|
||||||
? reward.vehicle.image_url
|
|
||||||
: reward.stuff.image_url,
|
|
||||||
)}
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{reward && reward.count > 1 && (
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
color: highlight
|
|
||||||
? theme.colors.textLowContrast_blue
|
|
||||||
: theme.colors.textLowContrast,
|
|
||||||
fontSize: 16,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
x {reward.count.toLocaleString()}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
Reference in new issue
Block a user