Skip to content

Commit

Permalink
chore: add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis committed Oct 13, 2023
1 parent 1a30fd1 commit fc300df
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
31 changes: 23 additions & 8 deletions packages/contracts/src/systems/GMSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
pragma solidity >=0.8.0;

import { System } from "@latticexyz/world/src/System.sol";
import { Season, GameConfig } from "../codegen/Tables.sol";
import { Season, GameConfig, BoxList} from "../codegen/Tables.sol";
import { GAME_CONFIG_KEY } from "../Constants.sol";

contract GMSystem {
bytes32 constant MAP_KEY = keccak256("Season-Key");

// season
function GetSeasonInfo() public view returns (uint256, uint256, uint256) {
uint256 start = Season.getStart(MAP_KEY);
uint256 end = Season.getEnd(MAP_KEY);
Expand All @@ -16,20 +17,34 @@ contract GMSystem {
return (start, end, no);
}

function SetSeasonInfo(uint256 start, uint256 end) public {
require (start < end, "start must be less than end");
function SetSeasonInfo(uint256 _start, uint256 _end) public {
require (_start < _end, "start must be less than end");

uint256 now_end = Season.getEnd(MAP_KEY);
require (start > now_end, "start must be more than prev end");
require (_start > now_end, "start must be more than prev end");

Season.setStart(MAP_KEY, start);
Season.setEnd(MAP_KEY, end);
Season.setStart(MAP_KEY, _start);
Season.setEnd(MAP_KEY, _end);
uint256 no = Season.getNo(MAP_KEY);
Season.setNo(MAP_KEY, no+1);
}

function SetMapMerkleRoot(bytes32 root) public {
GameConfig.setMerkleRoot(GAME_CONFIG_KEY, root);
// merkle root
function SetMapMerkleRoot(bytes32 _root) public {
GameConfig.setMerkleRoot(GAME_CONFIG_KEY, _root);
}

// create box
function CreateBox(uint16 _x, uint16 _y) public {
uint256 roomId = GameConfig.getRoomId(GAME_CONFIG_KEY);
uint256 boxId = GameConfig.getBoxId(GAME_CONFIG_KEY);
BoxList.setX(roomId, boxId, _x);
BoxList.setY(roomId, boxId, _y);

uint256 randomId = GameConfig.getRandomId(GAME_CONFIG_KEY);
BoxList.setRandomId(roomId, boxId, randomId);
GameConfig.setRandomId(GAME_CONFIG_KEY, randomId + 1);
GameConfig.setBoxId(GAME_CONFIG_KEY, boxId + 1);
}


Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/systems/MoveSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ contract MoveSystem is System {

uint16 x2 = i > 0 ? moveList[i - 1].x : Player.getX(_msgSender());
uint16 y2 = i > 0 ? moveList[i - 1].y : Player.getY(_msgSender());
console.log(" step : ", i);
console.log(" step : ", i, x2, y2);
console.log(" move : ", moveList[i - 1].x, moveList[i - 1].y);
require(
CommonUtils.isNear(moveList[i].x, x2, moveList[i].y, y2),
"invalied move"
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/worlds.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"blockNumber": 27500999
},
"31337": {
"address": "0xCD8a1C3ba11CF5ECfa6267617243239504a98d90"
"address": "0x10e38eE9dd4C549b61400Fc19347D00eD3edAfC4"
},
"421613": {
"address": "0x2Bc1034975c3df48D6f3026802f372677844b85d",
Expand Down

0 comments on commit fc300df

Please sign in to comment.