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 9f1e238 commit f9b473d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 656 deletions.
5 changes: 4 additions & 1 deletion packages/hardhat/contracts/Game.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract Game is IOptionalSystemHook {
mapping(uint256 => VoxelCoord[]) locations;
mapping(address => uint256) earned;

event GameNotif(string message);
event GameNotif(address player, string message);

ResourceId BuildSystemId = WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "", name: "BuildSystem" });

Expand Down Expand Up @@ -106,6 +106,8 @@ contract Game is IOptionalSystemHook {

submissionPrices[buildCount] = submissionPrice;
names[buildCount] = name;

emit GameNotif(address(0), "A new build has been added to the game.");
}

function submitBuilding(uint256 buildingId, VoxelCoord memory baseWorldCoord) external payable {
Expand Down Expand Up @@ -162,6 +164,7 @@ contract Game is IOptionalSystemHook {
earned[buildersAtId[i]] += splitAmount;
(bool sent, ) = buildersAtId[i].call{ value: splitAmount }("");
require(sent, "Failed to send submission price to builder");
emit GameNotif(buildersAtId[i], "You've earned some ether for your contribution to a build.");
}

if (remainder > 0) {
Expand Down
Loading

0 comments on commit f9b473d

Please sign in to comment.