Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/domains/player/components/Leader/CompactLeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SmoothPopover } from "@/shared/ui/SmoothPopover";
import { LeaderDetailsCard } from "../LeaderDetailsCard";
import styles from "./CompactLeader.module.css";
import { useDisclosure } from "@/hooks/useDisclosure";
import { getLeaderImageId } from "@/entities/data/leaders";

type Props = {
id: string;
Expand Down Expand Up @@ -31,7 +32,7 @@ export function CompactLeader({ id, exhausted, locked }: Props) {
}}
>
<div className={styles.imageFrame}>
<Image src={`/leaders/${id}.webp`} className={styles.image} />
<Image src={`/leaders/${getLeaderImageId(id)}.webp`} className={styles.image} />
</div>
</div>
</SmoothPopover.Target>
Expand Down
4 changes: 2 additions & 2 deletions src/domains/player/components/Leader/LeaderChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDisclosure } from "@/hooks/useDisclosure";
import { Chip } from "@/shared/ui/primitives/Chip";
import { SmoothPopover } from "@/shared/ui/SmoothPopover";
import { LeaderDetailsCard } from "../LeaderDetailsCard";
import { leaders } from "@/entities/data/leaders";
import { leaders, getLeaderImageId } from "@/entities/data/leaders";
import { showLeader } from "./showLeader";
import styles from "./Leader.module.css";

Expand Down Expand Up @@ -51,7 +51,7 @@ export function LeaderChip({ variant = "default", ...props }: LeaderChipProps) {
<Group gap={variant === "mobile" ? 8 : 6} className={styles.leaderGroup}>
{showLeaderImage && (
<div className={styles.leaderImageContainer}>
<Image src={`/leaders/${id}.webp`} className={styles.leaderImage} />
<Image src={`/leaders/${getLeaderImageId(id)}.webp`} className={styles.leaderImage} />
</div>
Comment on lines 53 to 55

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LeaderChip already calls getLeaderData(id) which does leaders.find(...). Using getLeaderImageId(id) in the image src adds a second linear search over the same array during render. Prefer using leaderData.imageID ?? id (or have getLeaderData return the resolved image id) to avoid the extra lookup.

Copilot uses AI. Check for mistakes.
)}

Expand Down
4 changes: 2 additions & 2 deletions src/domains/player/components/LeaderDetailsCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Stack, Image, Divider } from "@mantine/core";
import { leaders } from "@/entities/data/leaders";
import { leaders, getLeaderImageId } from "@/entities/data/leaders";
import { DetailsCard } from "@/shared/ui/DetailsCard";
import { showLeader } from "./Leader/showLeader";
import { useIsTwilightsFallMode } from "@/hooks/useIsTwilightsFallMode";
Expand Down Expand Up @@ -27,7 +27,7 @@ export function LeaderDetailsCard({ leaderId }: Props) {
const renderLeaderIcon = () => {
if (showLeader(leaderData.source)) {
return (
<Image src={`/leaders/${leaderId}.webp`} w={60} h={80} radius="50%" />
<Image src={`/leaders/${getLeaderImageId(leaderId)}.webp`} w={60} h={80} radius="50%" />
);
Comment on lines 29 to 31

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LeaderDetailsCard already looks up leaderData via leaders.find(...), but the image src now calls getLeaderImageId(leaderId) which performs another leaders.find(...). To avoid duplicate work per render, use leaderData.imageID ?? leaderId (or pass leaderData into a helper) when constructing the image URL.

Copilot uses AI. Check for mistakes.
}
return <></>;
Expand Down
6 changes: 6 additions & 0 deletions src/entities/data/leaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const leaders: LeaderData[] = [
"Place any combination of up to 4 PDS or mechs onto planets you control; ready each planet that you place a unit on. Then, purge this card.",
unlockCondition: "Have 3 scored objectives.",
homebrewReplacesID: "xxchahero",
imageID: "xxchahero",
source: "thunders_edge",
},
Comment on lines 181 to 186

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is marked as auto-generated ("Do not edit manually"). Adding imageID directly in the generated leaders array will likely be overwritten the next time the data is regenerated. Prefer updating the upstream JSON/generator that produces leaders.ts, or move overrides into a separate non-generated layer (e.g., a small map of image redirects keyed by leader id).

Copilot uses AI. Check for mistakes.
{
Expand Down Expand Up @@ -5243,3 +5244,8 @@ export const leaders: LeaderData[] = [
source: "twilights_fall",
},
];

export function getLeaderImageId(id: string): string {
const leader = leaders.find((l) => l.id === id);
Comment on lines +5248 to +5249

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLeaderImageId does a linear leaders.find(...) over a ~5k-entry array on every call. Since this will be invoked during rendering (and some callers already do their own leaders.find), consider switching to an O(1) lookup (e.g., build/export a leadersById map once) or accept a LeaderData object so callers can use leaderData.imageID ?? leaderData.id without an extra search.

Suggested change
export function getLeaderImageId(id: string): string {
const leader = leaders.find((l) => l.id === id);
const leadersById: Record<string, LeaderData> = leaders.reduce(
(acc, leader) => {
acc[leader.id] = leader;
return acc;
},
{} as Record<string, LeaderData>,
);
export function getLeaderImageId(id: string): string {
const leader = leadersById[id];

Copilot uses AI. Check for mistakes.
return leader?.imageID ?? id;
}
1 change: 1 addition & 0 deletions src/entities/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export type LeaderData = {
shrinkName?: boolean;
searchTags?: string[];
homebrewReplacesID?: string;
imageID?: string;
tfName?: string;
tfTitle?: string;
tfAbilityWindow?: string;
Expand Down
3 changes: 1 addition & 2 deletions src/styles/fonts.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@font-face {
font-family: 'Slider';
src: url('/font/Slider.woff2') format('woff2'),
url('/font/Slider.woff') format('woff');
src: url('/font/Slider.woff') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
Expand Down
Loading