Skip to content

Commit

Permalink
feat: GameSystem.sol spilt three system
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis committed Oct 8, 2023
1 parent ed40efc commit 39df443
Show file tree
Hide file tree
Showing 19 changed files with 743 additions and 943 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
packages/contracts/src/codegen/*
17 changes: 17 additions & 0 deletions packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ extra_output_files = [
"evm.bytecode"
]
fs_permissions = [{ access = "read", path = "./"}]
gas_reports = ["*"]

[profile.lattice-testnet]
eth_rpc_url = "https://follower.testnet-chain.linfra.xyz"


[profile.arb-testnet]
eth_rpc_url = "https://goerli-rollup.arbitrum.io/rpc"
optimizer = true
optimizer_runs = 3000

[profile.linea-testnet]
eth_rpc_url = "https://linea-goerli.infura.io/v3/5ca372516740427e97512d4dfefd9c47"
optimizer = true
optimizer_runs = 3000

[profile.sepolia-testnet]
eth_rpc_url = "https://sepolia.infura.io/v3/5ca372516740427e97512d4dfefd9c47"
optimizer = true
optimizer_runs = 3000
22 changes: 14 additions & 8 deletions packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,42 @@ export default mudConfig({
addr: "address",
},
schema: {
name: "string",
url: "string",
suitId : "uint256",
equipmentId : "uint256",
x : "uint16",
y : "uint16",
state : "PlayerState",
hP : "uint256",
oreBalance: "uint16",
treasureBalance: "uint16",
state : "PlayerState",
name: "string",
url: "string",
}
},
Ownable: {
schema: {
owner: "address",
}
},
Game: {
GameConfig: {
dataStruct: false,
schema: {
merkleRoot: "bytes32",
maxAttackzDistance: "uint256",
maxMoveDistance: "uint256",
battleId: "uint256",
randomId: "uint256",
maxTimeLimit: "uint256",
maxUserLocationLockTime: "uint256",
originX: "uint16",
originY: "uint16",
roomId: "uint256",
boxId : "uint256",
}
},
BattleConfig: {
dataStruct: false,
schema: {
maxAttackzDistance: "uint256",
maxMoveDistance: "uint256",
maxTimeLimit: "uint256",
maxUserLocationLockTime: "uint256",
maxBoxBindTime : "uint256",
battlefieldPlayers: "address[]",
}
Expand Down
23 changes: 23 additions & 0 deletions packages/contracts/script/BattleConfigInit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {console} from "forge-std/console.sol";
import {IWorld} from "../src/codegen/world/IWorld.sol";
import {BattleConfig} from "../src/codegen/Tables.sol";
import { BATTLE_CONFIG_KEY } from "../src/Constants.sol";

library BattleConfigInit {
function initGameConfig(IWorld _world) internal {
address[] memory players;
BattleConfig.set(
_world,
BATTLE_CONFIG_KEY, //key
10, //maxAttackzDistance
15, //maxMoveDistance,
120, //maxTimeLimit,
120, //maxUserLocationLockTime,
120, //maxBoxBindTime,
players
);
}
}
24 changes: 24 additions & 0 deletions packages/contracts/script/GameConfigInit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {console} from "forge-std/console.sol";
import {IWorld} from "../src/codegen/world/IWorld.sol";
import {GameConfig} from "../src/codegen/Tables.sol";
import { GAME_CONFIG_KEY } from "../src/Constants.sol";

library GameConfigInit {
function initGameConfig(IWorld _world) internal {
bytes32 merkleRoot = "";
GameConfig.set(
_world,
GAME_CONFIG_KEY, //key
merkleRoot, //merkleRoot
0, //battleId,
0, //randomId,
100, //originX,
100, //originY,
0, //roomId,
0 //boxId,
);
}
}
10 changes: 6 additions & 4 deletions packages/contracts/script/PostDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity >=0.8.0;
import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/console.sol";
import { IWorld } from "../src/codegen/world/IWorld.sol";
import { GameConfigInit } from "./GameConfigInit.sol";
import { BattleConfigInit } from "./BattleConfigInit.sol";

contract PostDeploy is Script {
function run(address worldAddress) external {
Expand All @@ -13,11 +15,11 @@ contract PostDeploy is Script {
// Start broadcasting transactions from the deployer account
vm.startBroadcast(deployerPrivateKey);

// ------------------ EXAMPLES ------------------

// uint32 newValue = IWorld(worldAddress).getPos(10,10);
// console.log("Increment via IWorld:", newValue);
// ------------------ INIT ------------------
GameConfigInit.initGameConfig(IWorld(worldAddress));
BattleConfigInit.initGameConfig(IWorld(worldAddress));

vm.stopBroadcast();

}
}
67 changes: 0 additions & 67 deletions packages/contracts/script/mapParser.ts

This file was deleted.

5 changes: 5 additions & 0 deletions packages/contracts/src/Constants.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

bytes32 constant GAME_CONFIG_KEY = keccak256("Game-Key");
bytes32 constant BATTLE_CONFIG_KEY = keccak256("Battle-Key");
15 changes: 0 additions & 15 deletions packages/contracts/src/codegen/Tables.sol

This file was deleted.

19 changes: 0 additions & 19 deletions packages/contracts/src/codegen/world/IWorld.sol

This file was deleted.

Loading

0 comments on commit 39df443

Please sign in to comment.