Skip to content

Commit

Permalink
feat: show the podium above treaties
Browse files Browse the repository at this point in the history
  • Loading branch information
rsproule committed Jan 5, 2024
1 parent d209cf0 commit d01f40e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
26 changes: 9 additions & 17 deletions frontend/src/components/tankGame/EventsStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export async function getTankNameFromJoinIndex(
address: Address,
tankId: bigint
) {
// HACK: jonah forgot to set his name so we are mapping it here :eyeroll:
if (tankId === BigInt(2)) {
return "jonah-forgot-to-set-his-name";
}
let logs = await getLogs(address);
let joinLogs = logs.filter((log) => log.eventName == "PlayerJoined");
// @ts-ignore
Expand Down Expand Up @@ -41,13 +37,6 @@ export async function getTankNameFromAddress(
address: Address,
player: Address
) {
// HACK: jonah forgot to set his name so we are mapping it here :eyeroll:
if (
player.toLowerCase() ===
"0xc6d109eFf13844c1AE490Ed7e1dD46F56b337928".toLowerCase()
) {
return "jonah-forgot-to-set-his-name";
}
let logs = await getLogs(address);
let joinLogs = logs.filter((log) => log.eventName === "PlayerJoined");
// @ts-ignore
Expand Down Expand Up @@ -280,8 +269,9 @@ const giveString = async (address: Address, event: any) => {
return `🤝 ${await getTankNameFromJoinIndex(
address,
event.args.fromId
)} gave ${event.args.hearts || event.args.aps} ${event.args.hearts ? "hearts" : "aps"
} to ${await getTankNameFromJoinIndex(address, event.args.toId)}`;
)} gave ${event.args.hearts || event.args.aps} ${
event.args.hearts ? "hearts" : "aps"
} to ${await getTankNameFromJoinIndex(address, event.args.toId)}`;
};

const upgradeString = async (address: Address, event: any) => {
Expand Down Expand Up @@ -321,15 +311,17 @@ const claimString = async (address: Address, event: any) => {
};

const joinString = async (address: Address, event: any) => {
return `🆕 ${(await getTankNameFromAddress(address, event.args.player)) ||
return `🆕 ${
(await getTankNameFromAddress(address, event.args.player)) ||
event.args.player
} has joined the game.`;
} has joined the game.`;
};

const donateString = async (address: Address, event: any) => {
return `🎁 ${(await getTankNameFromAddress(address, event.args.donator)) ||
return `🎁 ${
(await getTankNameFromAddress(address, event.args.donator)) ||
event.args.donator
} has added ${formatEther(event.args.amount!)} ether to the prize pool.`;
} has added ${formatEther(event.args.amount!)} ether to the prize pool.`;
};

const startString = async () => {
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/components/tankGame/TankGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ export function TankGame({ address }: { address: `0x${string}` }) {
gameAddress={address}
/>
<div className="block justify-evenly py-5 md:flex">
<Timer address={address} />
{gameState.data !== 2 && <Timer address={address} />}
{gameState.data === 2 && <GameOver gameAddress={address} />}
{gameState.data !== 2 && <Donate gameAddress={address} />}
</div>
<Treaties gameAddress={address} />
<div className="block justify-evenly py-5 md:flex">
{/* {gameState.data === 1 && <Timer address={address} />} */}
{gameState.data === 2 && <GameOver gameAddress={address} />}
{gameState.data !== 2 && <Donate gameAddress={address} />}
</div>
<LeaderBoard gameAddress={address} />
</div>
Expand Down

0 comments on commit d01f40e

Please sign in to comment.