mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: added collector tanks to /ownedtanks
This commit is contained in:
1 parent
80ffff322c
commit
feeb850ca9
5 files changed
+65
-21
No files matched your search
@@ -6,6 +6,7 @@ import TitleBar from '../components/TitleBar.js';
|
|||||||
import Wrapper from '../components/Wrapper.js';
|
import Wrapper from '../components/Wrapper.js';
|
||||||
import { BLITZ_SERVERS } from '../constants/servers.js';
|
import { BLITZ_SERVERS } from '../constants/servers.js';
|
||||||
import getTankStats from '../core/blitz/getTankStats.js';
|
import getTankStats from '../core/blitz/getTankStats.js';
|
||||||
|
import getTreeType from '../core/blitz/getTreeType.js';
|
||||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
import resolveTankName from '../core/blitz/resolveTankName.js';
|
import resolveTankName from '../core/blitz/resolveTankName.js';
|
||||||
import {
|
import {
|
||||||
@@ -44,7 +45,7 @@ const COMP_TANKS = [
|
|||||||
|
|
||||||
export const ownedTanksCommand: CommandRegistry = {
|
export const ownedTanksCommand: CommandRegistry = {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -95,7 +96,6 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{/* TODO: integrate some of these into title bar */}
|
|
||||||
<TitleBar
|
<TitleBar
|
||||||
name={accountInfo[id].nickname}
|
name={accountInfo[id].nickname}
|
||||||
nameDiscriminator={`(Tier ${TIER_ROMAN_NUMERALS[tier as Tier]})`}
|
nameDiscriminator={`(Tier ${TIER_ROMAN_NUMERALS[tier as Tier]})`}
|
||||||
@@ -119,9 +119,9 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
<Tanks.Item
|
<Tanks.Item
|
||||||
key={tank.tank_id}
|
key={tank.tank_id}
|
||||||
name={await resolveTankName(tank.tank_id)}
|
name={await resolveTankName(tank.tank_id)}
|
||||||
type={tank.type}
|
tankType={tank.type}
|
||||||
image={tank.images?.normal}
|
image={tank.images?.normal}
|
||||||
isPremium={tank.is_premium}
|
treeType={await getTreeType(tank.tank_id)}
|
||||||
/>
|
/>
|
||||||
)),
|
)),
|
||||||
)}
|
)}
|
||||||
@@ -132,9 +132,9 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
<Tanks.Item
|
<Tanks.Item
|
||||||
key={tank.tank_id}
|
key={tank.tank_id}
|
||||||
name={await resolveTankName(tank.tank_id)}
|
name={await resolveTankName(tank.tank_id)}
|
||||||
type={tank.type}
|
tankType={tank.type}
|
||||||
image={tank.images?.normal}
|
image={tank.images?.normal}
|
||||||
isPremium={tank.is_premium}
|
treeType={await getTreeType(tank.tank_id)}
|
||||||
/>
|
/>
|
||||||
)),
|
)),
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,17 +1,36 @@
|
|||||||
import {
|
import {
|
||||||
TANK_ICONS,
|
TANK_ICONS,
|
||||||
|
TANK_ICONS_COLLECTOR,
|
||||||
TANK_ICONS_PREMIUM,
|
TANK_ICONS_PREMIUM,
|
||||||
} from '../../../core/blitz/tankopedia.js';
|
} from '../../../core/blitz/tankopedia.js';
|
||||||
import { theme } from '../../../stitches.config.js';
|
import { theme } from '../../../stitches.config.js';
|
||||||
|
|
||||||
export interface ItemProps {
|
export enum TreeType {
|
||||||
image?: string;
|
TechTree,
|
||||||
type?: string;
|
Premium,
|
||||||
name: string;
|
Collector,
|
||||||
isPremium?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Item({ image, type, name, isPremium }: ItemProps) {
|
export interface ItemProps {
|
||||||
|
image?: string;
|
||||||
|
tankType?: string;
|
||||||
|
name: string;
|
||||||
|
treeType: TreeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TREE_TYPE_COLOR = {
|
||||||
|
[TreeType.TechTree]: '',
|
||||||
|
[TreeType.Premium]: '_amber',
|
||||||
|
[TreeType.Collector]: '_blue',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const TREE_TYPE_ICONS = {
|
||||||
|
[TreeType.TechTree]: TANK_ICONS,
|
||||||
|
[TreeType.Premium]: TANK_ICONS_PREMIUM,
|
||||||
|
[TreeType.Collector]: TANK_ICONS_COLLECTOR,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Item({ image, tankType, name, treeType }: ItemProps) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -22,9 +41,8 @@ export function Item({ image, type, name, isPremium }: ItemProps) {
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
backgroundColor: isPremium
|
backgroundColor:
|
||||||
? theme.colors.componentInteractive_amber
|
theme.colors[`componentInteractive${TREE_TYPE_COLOR[treeType]}`],
|
||||||
: theme.colors.componentInteractive,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -37,9 +55,9 @@ export function Item({ image, type, name, isPremium }: ItemProps) {
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{type && (
|
{tankType && (
|
||||||
<img
|
<img
|
||||||
src={isPremium ? TANK_ICONS_PREMIUM[type] : TANK_ICONS[type]}
|
src={TREE_TYPE_ICONS[treeType][tankType]}
|
||||||
style={{ width: 14, height: 14 }}
|
style={{ width: 14, height: 14 }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -47,9 +65,7 @@ export function Item({ image, type, name, isPremium }: ItemProps) {
|
|||||||
style={{
|
style={{
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
color: isPremium
|
color: theme.colors[`textLowContrast${TREE_TYPE_COLOR[treeType]}`],
|
||||||
? theme.colors.textLowContrast_amber
|
|
||||||
: theme.colors.textHighContrast,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { TreeType } from '../../components/Tanks/index.js';
|
||||||
|
import { tankopedia } from './tankopedia.js';
|
||||||
|
|
||||||
|
export default async function getTreeType(id: number) {
|
||||||
|
const entry = (await tankopedia)[id];
|
||||||
|
|
||||||
|
if (entry?.is_collectible) return TreeType.Collector;
|
||||||
|
if (entry?.is_premium) return TreeType.Premium;
|
||||||
|
|
||||||
|
return TreeType.TechTree;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ export interface TankopediaEntry {
|
|||||||
name: string;
|
name: string;
|
||||||
nation: string;
|
nation: string;
|
||||||
is_premium: boolean;
|
is_premium: boolean;
|
||||||
|
is_collectible: boolean;
|
||||||
tier: number;
|
tier: number;
|
||||||
cost: { price_credit: number; price_gold: number };
|
cost: { price_credit: number; price_gold: number };
|
||||||
images: { preview: string; normal: string };
|
images: { preview: string; normal: string };
|
||||||
@@ -45,6 +46,13 @@ export const TANK_ICONS_PREMIUM: Record<string, string> = {
|
|||||||
heavyTank: 'https://i.imgur.com/P3vbmyA.png',
|
heavyTank: 'https://i.imgur.com/P3vbmyA.png',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const TANK_ICONS_COLLECTOR: Record<string, string> = {
|
||||||
|
'AT-SPG': 'https://i.imgur.com/WTjeirB.png',
|
||||||
|
lightTank: 'https://i.imgur.com/EwhtKkU.png',
|
||||||
|
mediumTank: 'https://i.imgur.com/u8YDMBh.png',
|
||||||
|
heavyTank: 'https://i.imgur.com/8xRf3nc.png',
|
||||||
|
};
|
||||||
|
|
||||||
export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
||||||
|
|
||||||
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
||||||
|
|||||||
+10
-1
@@ -1,4 +1,10 @@
|
|||||||
import { amberDark, slate, slateDark, slateDarkA } from '@radix-ui/colors';
|
import {
|
||||||
|
amberDark,
|
||||||
|
blueDark,
|
||||||
|
slate,
|
||||||
|
slateDark,
|
||||||
|
slateDarkA,
|
||||||
|
} from '@radix-ui/colors';
|
||||||
import { createBorderStyles, createColors } from 'bepaint';
|
import { createBorderStyles, createColors } from 'bepaint';
|
||||||
|
|
||||||
// this isn't really a stitches config, but the object is compliant
|
// this isn't really a stitches config, but the object is compliant
|
||||||
@@ -6,8 +12,11 @@ export const theme = {
|
|||||||
colors: {
|
colors: {
|
||||||
...createColors(slateDark),
|
...createColors(slateDark),
|
||||||
...createColors(slate, 'light'),
|
...createColors(slate, 'light'),
|
||||||
|
|
||||||
...createColors(slateDarkA, 'transparent'),
|
...createColors(slateDarkA, 'transparent'),
|
||||||
|
|
||||||
...createColors(amberDark, 'amber'),
|
...createColors(amberDark, 'amber'),
|
||||||
|
...createColors(blueDark, 'blue'),
|
||||||
},
|
},
|
||||||
|
|
||||||
borderStyles: createBorderStyles(slateDark),
|
borderStyles: createBorderStyles(slateDark),
|
||||||
|
|||||||
Reference in new issue
Block a user