Skip to content

Commit

Permalink
add events
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvanipa committed May 14, 2024
1 parent 3575d69 commit 80269c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/hardhat/contracts/Game.sol
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ contract Game is IOptionalSystemHook {

isGameStarted = true;
gameEndBlock = block.number + numBlocksToEnd;

emit GameNotif("Game has started!");
}

function setMatchArea(VoxelCoord memory lowerSouthwestCorner, VoxelCoord memory size) external {
Expand Down Expand Up @@ -244,6 +246,8 @@ contract Game is IOptionalSystemHook {
}

alivePlayers.push(player);

emit GameNotif(string.concat("Player ", Strings.toHexString(player), " has joined the game"));
}

function updateAlivePlayers(address msgSender) internal returns (uint256, bool) {
Expand All @@ -265,6 +269,7 @@ contract Game is IOptionalSystemHook {
}
}
if (!markedDead) {
emit GameNotif(string.concat("Player ", Strings.toHexString(alivePlayers[i]), " has died"));
deadPlayers.push(alivePlayers[i]);
}
} else {
Expand Down Expand Up @@ -364,6 +369,8 @@ contract Game is IOptionalSystemHook {
require(sent, "Failed to send Ether");
}

emit GameNotif("Game has ended. Reward pool has been distributed.");

// reset the game state
resetGame();
}
Expand Down
15 changes: 14 additions & 1 deletion packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
const deployedContracts = {
31337: {
Game: {
address: "0xaC9fCBA56E42d5960f813B9D0387F3D3bC003338",
address: "0x71089Ba41e478702e1904692385Be3972B2cBf9e",
abi: [
{
inputs: [
Expand Down Expand Up @@ -90,6 +90,19 @@ const deployedContracts = {
name: "Slice_OutOfBounds",
type: "error",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "string",
name: "message",
type: "string",
},
],
name: "GameNotif",
type: "event",
},
{
inputs: [],
name: "biomeWorldAddress",
Expand Down

0 comments on commit 80269c0

Please sign in to comment.