Skip to content

Commit

Permalink
getters
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvanipa committed May 14, 2024
1 parent 765bf40 commit 08ee5ec
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 1,651 deletions.
24 changes: 24 additions & 0 deletions packages/hardhat/contracts/Game.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";
import { Hook } from "@latticexyz/store/src/Hook.sol";
Expand All @@ -15,6 +16,7 @@ import { IWorld } from "@biomesaw/world/src/codegen/world/IWorld.sol";
import { VoxelCoord } from "@biomesaw/utils/src/Types.sol";
import { Area, insideArea } from "../utils/AreaUtils.sol";
import { getEntityFromPlayer, getPosition } from "../utils/EntityUtils.sol";
import { NamedArea } from "../utils/GameUtils.sol";

contract Game is IOptionalSystemHook {
address public immutable biomeWorldAddress;
Expand Down Expand Up @@ -99,4 +101,26 @@ contract Game is IOptionalSystemHook {
ResourceId systemId,
bytes memory callData
) external override onlyBiomeWorld {}

function getDisplayName() external view returns (string memory) {
return "Race To the Sky";
}

function getAreas() external view returns (NamedArea[] memory) {
NamedArea[] memory areas = new NamedArea[](1);
areas[0] = NamedArea({ name: "SkyBox", area: prizeArea });
return areas;
}

function getStatus() external view returns (string memory) {
if (isGameOver) {
if (winner == msg.sender) {
return "Game over. You won!";
} else {
return string.concat("Game over. Winner: ", Strings.toHexString(winner));
}
} else {
return "Game in progress. Move your avatar inside the SkyBox to win!";
}
}
}
3 changes: 2 additions & 1 deletion packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const Home: NextPage = () => {
const isBiomesRegistered = useGlobalState(({ isBiomesRegistered }) => isBiomesRegistered);
// const isGameRegistered = useGlobalState(({ isGameRegistered }) => isGameRegistered);
const isGameRegistered = true;
const isBiomesClientSetup = useGlobalState(({ isBiomesClientSetup }) => isBiomesClientSetup);
// const isBiomesClientSetup = useGlobalState(({ isBiomesClientSetup }) => isBiomesClientSetup);
const isBiomesClientSetup = true;

useEffect(() => {
if (connectedAddress) {
Expand Down
Loading

0 comments on commit 08ee5ec

Please sign in to comment.