Skip to content

Commit

Permalink
chore: add player position function
Browse files Browse the repository at this point in the history
  • Loading branch information
xingxinglian committed Oct 11, 2023
1 parent 0dd3a07 commit 77e0d7b
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 631 deletions.
17 changes: 15 additions & 2 deletions packages/contracts/script/GameConfigInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@ library GameConfigInit {
merkleRoot, //merkleRoot
0, //battleId,
0, //randomId,
100, //originX,
100, //originY,
4, //originX,
4, //originY,
0, //roomId,
0 //boxId,
);
}

function setInitPosition(IWorld _world) internal {
GameConfig.setOriginX(_world, GAME_CONFIG_KEY, 4);
GameConfig.setOriginY(_world, GAME_CONFIG_KEY, 4);
}

function getPosition(IWorld _world) internal view returns (uint256, uint256) {
uint256 x = GameConfig.getOriginX(_world, GAME_CONFIG_KEY);
uint256 y = GameConfig.getOriginY(_world, GAME_CONFIG_KEY);
return (x,y);
}


}
13 changes: 13 additions & 0 deletions packages/contracts/src/systems/PlayerSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ contract PlayerSystem is System {
Player.setName(addr, name);
Player.setUrl(addr, url);
}

function transfer(address addr, uint16 x, uint16 y) public {
Player.setX(addr, x);
Player.setY(addr, y);
}

function getPosition(address addr) public view returns (uint16, uint16) {
uint16 x = Player.getX(addr);
uint16 y = Player.getY(addr);
return(x, y);
}


}
2 changes: 1 addition & 1 deletion packages/contracts/worlds.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"31337": {
"address": "0xD5724171C2b7f0AA717a324626050BD05767e2C6"
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3"
},
"421613": {
"address": "0xfB532D8f51E07c3B157AB9752510D710cE0b61B0",
Expand Down
Loading

0 comments on commit 77e0d7b

Please sign in to comment.