Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(overlay): add trinkets support #55

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
10 changes: 10 additions & 0 deletions src/twitch-hdt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ export interface BoardStatePlayer {
*/
weapon?: number;

/**
* The dbfId of the first trinket, if any.
*/
first_trinket?: number;

/**
* The dbfId of the second trinket, if any.
*/
second_trinket?: number;

/**
* The dbfIds of secrets.
*/
Expand Down
47 changes: 41 additions & 6 deletions src/viewer/overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@
clip-path: circle(50% at 50% 50%);
`;

const Trinket = styled(OverlayElement)`
top: ${(props) => props.top || "unset"};
left: ${(props) => props.left || "unset"};
bottom: ${(props) => props.bottom || "unset"};

height: 9.5vh;
width: 9.5vh;
clip-path: circle(50% at 50% 50%);
`;

const BattlegroundsAnomaly = styled(OverlayElement)`
top: ${(props) => props.top || "unset"};
right: ${(props) => props.right || "unset"};
Expand Down Expand Up @@ -324,7 +334,7 @@
};
}

public render(): React.ReactNode {

Check warning on line 337 in src/viewer/overlay/Overlay.tsx

View workflow job for this annotation

GitHub Actions / build

Method 'render' has too many lines (309). Maximum allowed is 200
const { boardState } = this.props;

const player = boardState && boardState.player ? boardState.player : {};
Expand Down Expand Up @@ -559,12 +569,37 @@
<HeroPower bottom={"16.9vh"} right={"65.6vh"}>
<Entity dbfId={player.hero_power || null} />
</HeroPower>
<Weapon top={"15.5vh"} left={"65.8vh"}>
<Entity dbfId={opponent.weapon || null} />
</Weapon>
<Weapon bottom={"16.8vh"} left={"64.25vh"}>
<Entity dbfId={player.weapon || null} />
</Weapon>

{opponent.first_trinket || opponent.second_trinket ? (
<>
<Trinket top={"10.7vh"} left={"72.7vh"}>
<Entity dbfId={opponent.first_trinket || null} />
</Trinket>
<Trinket top={"16.7vh"} left={"65.3vh"}>
<Entity dbfId={opponent.second_trinket || null} />
</Trinket>
</>
) : (
<Weapon top={"15.5vh"} left={"65.8vh"}>
<Entity dbfId={opponent.weapon || null} />
</Weapon>
)}

{player.first_trinket || player.second_trinket ? (
<>
<Trinket bottom={"14.3vh"} left={"71.6vh"}>
<Entity dbfId={player.first_trinket || null} />
</Trinket>
<Trinket bottom={"21vh"} left={"64.6vh"}>
<Entity dbfId={player.second_trinket || null} />
</Trinket>
</>
) : (
<Weapon bottom={"16.8vh"} left={"64.25vh"}>
<Entity dbfId={player.weapon || null} />
</Weapon>
)}

{!ignoreDeck ? (
<>
<Deck top={"24vh"} right={"24vh"}>
Expand Down
Loading