Skip to content

Commit

Permalink
redeploy the contract
Browse files Browse the repository at this point in the history
  • Loading branch information
LidamaoHub committed Nov 3, 2023
1 parent 62ddbb6 commit 72464c1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
11 changes: 11 additions & 0 deletions packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,19 @@ export default mudConfig({
maxHp: "uint256",
name: "string",
url: "string",

}
},
// PlayerAddon:{
// keySchema: {
// addr: "address",
// },
// schema: {
// lootId: "uint256",
// userId: "uint256"
// }

// },
Ownable: {
schema: {
owner: "address",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/out/IWorld.sol/IWorld.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"name": "_tokenId",
"type": "uint256"
}
],
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts/out/IWorld.sol/IWorld.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions packages/contracts/src/systems/PlayerSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.0;

import { System } from "@latticexyz/world/src/System.sol";
import { Player, GlobalConfig, LootList1,LootList2 } from "@codegen/Tables.sol";
import {PlayerState } from "@codegen/Types.sol";
import { PlayerState } from "@codegen/Types.sol";

import { GLOBAL_CONFIG_KEY, PLAYER_KEY } from "../Constants.sol";
import { User, Loot } from "./library/Interface.sol";
Expand Down Expand Up @@ -37,20 +37,23 @@ contract PlayerSystem is System {
return(x, y);
}

function selectUserNft(uint256 tokenId) public {
function selectUserNft(uint256 _tokenId) public {
address sender = _msgSender();
// Player.selectNft(_msgSender(), tokenId);
address userAddress = GlobalConfig.getUserContract(GLOBAL_CONFIG_KEY);
User user = User(userAddress);
require(user.ownerOf(tokenId) == sender, "You are not the owner of this NFT");
(uint256 hp, uint256 attack ,uint256 attackRange, uint256 speed, uint256 strength,uint256 space) = user.getStructInfo(tokenId);
require(user.ownerOf(_tokenId) == sender, "You are not the owner of this NFT");
(uint256 hp, uint256 attack ,uint256 attackRange, uint256 speed, uint256 strength,uint256 space) = user.getStructInfo(_tokenId);
Player.setMaxHp(sender, hp);
Player.setHp(sender, hp);
Player.setAttack(sender, attack);
Player.setAttackRange(sender, attackRange);
Player.setSpeed(sender, speed);
Player.setStrength(sender, strength);
Player.setSpace(sender, space);

// PlayerAddon.setUserId(_tokenId);

}
function selectLootNFT(uint256 _tokenId) public {
address lootAddress = GlobalConfig.getLootContract(GLOBAL_CONFIG_KEY);
Expand All @@ -66,6 +69,7 @@ contract PlayerSystem is System {
LootList2.setHand(_sender,Hand);
LootList2.setNeck(_sender,Neck);
LootList2.setRing(_sender,Ring);
// Player.setLootId(_tokenId);
}

function selectBothNFT(uint256 _userTokenId,uint256 _lootTokenId) external {
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/worlds.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"4242": {
"address": "0x19A59F226A831fc663543228024A0136384a94D8",
"blockNumber": 29122003
"address": "0x62470f134F390a1f596727dADC8F2bf3c57F7bC0",
"blockNumber": 29327327
},
"31337": {
"address": "0x044EE13de544e192149549539C14dc3B376bB08D"
"address": "0xedDe0053512ef0d320fF782687c28BA8ACD6f386"
},
"421613": {
"address": "0x2Bc1034975c3df48D6f3026802f372677844b85d",
Expand Down

0 comments on commit 72464c1

Please sign in to comment.