Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update mud to next14 #195

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]
},
"devDependencies": {
"@latticexyz/cli": "2.0.0-next.11",
"@latticexyz/cli": "2.0.0-next.14",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"concurrently": "^8.0.1",
Expand All @@ -45,4 +45,4 @@
"dependencies": {
"eslint-plugin-react": "7.31.11"
}
}
}
20 changes: 10 additions & 10 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"test": "tsc --noEmit"
},
"dependencies": {
"@latticexyz/common": "2.0.0-next.11",
"@latticexyz/dev-tools": "2.0.0-next.11",
"@latticexyz/react": "2.0.0-next.11",
"@latticexyz/recs": "2.0.0-next.11",
"@latticexyz/schema-type": "2.0.0-next.11",
"@latticexyz/services": "2.0.0-next.11",
"@latticexyz/store-sync": "2.0.0-next.11",
"@latticexyz/utils": "2.0.0-next.11",
"@latticexyz/world": "2.0.0-next.11",
"@latticexyz/common": "2.0.0-next.14",
"@latticexyz/dev-tools": "2.0.0-next.14",
"@latticexyz/react": "2.0.0-next.14",
"@latticexyz/recs": "2.0.0-next.14",
"@latticexyz/schema-type": "2.0.0-next.14",
"@latticexyz/services": "2.0.0-next.14",
"@latticexyz/store-sync": "2.0.0-next.14",
"@latticexyz/utils": "2.0.0-next.14",
"@latticexyz/world": "2.0.0-next.14",
"ahooks": "^3.7.8",
"antd": "^5.8.4",
"autoprefixer": "^10.4.15",
Expand All @@ -45,4 +45,4 @@
"vite": "^4.2.1",
"wait-port": "^1.0.4"
}
}
}
16 changes: 8 additions & 8 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"test": "tsc --noEmit && mud test"
},
"dependencies": {
"@latticexyz/cli": "2.0.0-next.11",
"@latticexyz/schema-type": "2.0.0-next.11",
"@latticexyz/store": "2.0.0-next.11",
"@latticexyz/world": "2.0.0-next.11",
"@latticexyz/world-modules": "2.0.0-next.11"
"@latticexyz/cli": "2.0.0-next.14",
"@latticexyz/schema-type": "2.0.0-next.14",
"@latticexyz/store": "2.0.0-next.14",
"@latticexyz/world": "2.0.0-next.14",
"@latticexyz/world-modules": "2.0.0-next.14"
},
"devDependencies": {
"@types/node": "^18.15.11",
Expand All @@ -35,7 +35,7 @@
"prettier": "^2.6.2",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"solhint": "^3.3.7",
"solhint-config-mud": "2.0.0-next.11",
"solhint-plugin-mud": "2.0.0-next.11"
"solhint-config-mud": "2.0.0-next.14",
"solhint-plugin-mud": "2.0.0-next.14"
}
}
}
4 changes: 2 additions & 2 deletions packages/contracts/script/ConfigInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ pragma solidity >=0.8.0;
import {console} from "forge-std/console.sol";
import {IWorld} from "../src/codegen/world/IWorld.sol";
import {GameConfig, ShopConfig} from "../src/codegen/index.sol";
import {StoreSwitch} from "@latticexyz/store/src/StoreSwitch.sol";

library ConfigInitializer {
function initGameConfig(IWorld _world) internal {
StoreSwitch.setStoreAddress(address(_world));
uint8[] memory expUpgrade = new uint8[](8);
expUpgrade[0] = 1;
expUpgrade[1] = 1;
Expand All @@ -18,7 +20,6 @@ library ConfigInitializer {
expUpgrade[7] = 56;

GameConfig.set(
_world,
0, // GameConfig key
0, // game index
0, // creature index
Expand Down Expand Up @@ -46,7 +47,6 @@ library ConfigInitializer {
rarityRate[9] = 0x071f19160f; // 7 31 25 22 15

ShopConfig.set(
_world,
0,
5, // slot num
2, // refresh price
Expand Down
13 changes: 5 additions & 8 deletions packages/contracts/script/CreatureInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {CreatureRace, CreatureClass} from "../src/codegen/common.sol";

library CreatureInitializer {
// creature internal index start from 1
function _increCreatureCounter(IWorld _world, uint256 _rarity) private returns (uint256 current) {
uint256 counter = GameConfig.getCreatureCounter(_world, 0);
function _increCreatureCounter(uint256 _rarity) private returns (uint256 current) {
uint256 counter = GameConfig.getCreatureCounter(0);
counter += 1 << ((_rarity - 1) * 8);
current = uint8(counter >> ((_rarity - 1) * 8));
GameConfig.setCreatureCounter(_world, 0, uint40(counter));
GameConfig.setCreatureCounter(0, uint40(counter));
}

function _genCreatureIndex(uint256 _tier, uint256 _rarity, uint256 _index) private pure returns (uint24 index) {
Expand All @@ -32,9 +32,8 @@ library CreatureInitializer {
uint32 _movement,
string memory _uri
) private {
uint256 internalIndex = _increCreatureCounter(_world, _rarity);
uint256 internalIndex = _increCreatureCounter(_rarity);
Creature.set(
_world,
_genCreatureIndex(0, _rarity, internalIndex),
_race,
_class,
Expand All @@ -46,7 +45,6 @@ library CreatureInitializer {
_movement
);
Creature.set(
_world,
_genCreatureIndex(1, _rarity, internalIndex),
_race,
_class,
Expand All @@ -58,7 +56,6 @@ library CreatureInitializer {
_movement
);
Creature.set(
_world,
_genCreatureIndex(2, _rarity, internalIndex),
_race,
_class,
Expand All @@ -69,7 +66,7 @@ library CreatureInitializer {
_speed,
_movement
);
CreatureUri.set(_world, uint16(_genCreatureIndex(0, _rarity, internalIndex)), _uri);
CreatureUri.set(uint16(_genCreatureIndex(0, _rarity, internalIndex)), _uri);
}

function init(IWorld _world) internal {
Expand Down
54 changes: 17 additions & 37 deletions packages/contracts/script/EffectInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,38 @@ library EffectInitializer {
function _initSynergy(IWorld _world) private {
// race synergy
// orc: + max health 100/300
RaceSynergyEffect.set(_world, 0x000200, 0, 0x8080_ff);
RaceSynergyEffect.set(_world, 0x000400, 0, 0x8081_ff);
RaceSynergyEffect.set(0x000200, 0, 0x8080_ff);
RaceSynergyEffect.set(0x000400, 0, 0x8081_ff);
// god: + attack 20%
RaceSynergyEffect.set(_world, 0x020000, 0, 0x8082_ff);
RaceSynergyEffect.set(0x020000, 0, 0x8082_ff);
// pandaren: + evasion 20/30
RaceSynergyEffect.set(_world, 0x000020, 0, 0x8083_ff);
RaceSynergyEffect.set(_world, 0x000040, 0, 0x8084_ff);
RaceSynergyEffect.set(0x000020, 0, 0x8083_ff);
RaceSynergyEffect.set(0x000040, 0, 0x8084_ff);
// human: + dmg_reduction 10/20 when at least one ally is around
RaceSynergyEffect.set(_world, 0x002000, 0, 0x0c80_ff);
RaceSynergyEffect.set(_world, 0x004000, 0, 0x0c81_ff);
RaceSynergyEffect.set(0x002000, 0, 0x0c80_ff);
RaceSynergyEffect.set(0x004000, 0, 0x0c81_ff);
// troll: + 10% attack the enemy twice
RaceSynergyEffect.set(_world, 0x000002, 0, 0x1c80_ff);
RaceSynergyEffect.set(0x000002, 0, 0x1c80_ff);

// class synergy
// mage: - enemy defense 20%/40%
ClassSynergyEffect.set(_world, 0x020000, 1, 0x8100_ff);
ClassSynergyEffect.set(_world, 0x040000, 1, 0x8101_ff);
ClassSynergyEffect.set(0x020000, 1, 0x8100_ff);
ClassSynergyEffect.set(0x040000, 1, 0x8101_ff);
// warrior: + defense 5/10
ClassSynergyEffect.set(_world, 0x002000, 0, 0x8102_ff);
ClassSynergyEffect.set(_world, 0x004000, 0, 0x8103_ff);
ClassSynergyEffect.set(0x002000, 0, 0x8102_ff);
ClassSynergyEffect.set(0x004000, 0, 0x8103_ff);
// knight: + immunity 10
ClassSynergyEffect.set(_world, 0x000002, 0, 0x8104_ff);
ClassSynergyEffect.set(0x000002, 0, 0x8104_ff);
// assassin: + crit 10/20
ClassSynergyEffect.set(_world, 0x000200, 0, 0x8105_ff);
ClassSynergyEffect.set(_world, 0x000400, 0, 0x8106_ff);
ClassSynergyEffect.set(0x000200, 0, 0x8105_ff);
ClassSynergyEffect.set(0x000400, 0, 0x8106_ff);
// warlock: + 10% stun enemy for 1 turn on attack
ClassSynergyEffect.set(_world, 0x000020, 0, 0x1d00_ff);
ClassSynergyEffect.set(0x000020, 0, 0x1d00_ff);
}

function _initEffects(IWorld _world) private {
// index = binary(1_0000_0_001000_0000) = 0x8080
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -60,7 +59,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_001000_0001) = 0x8081
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -71,7 +69,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_001000_0002) = 0x8082
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -82,7 +79,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_001000_0003) = 0x8083
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -93,7 +89,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_001000_0004) = 0x8084
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -104,7 +99,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0000) = 0x8100
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -115,7 +109,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0001) = 0x8101
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -126,7 +119,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0002) = 0x8102
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -137,7 +129,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0003) = 0x8103
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -148,7 +139,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0004) = 0x8104
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -159,7 +149,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0005) = 0x8105
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -170,7 +159,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_010000_0006) = 0x8106
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -181,7 +169,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_000100_0000) = 0x8040
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -192,7 +179,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_000100_0001) = 0x8041
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -203,7 +189,6 @@ library EffectInitializer {
);
// index = binary(1_0000_0_000100_0002) = 0x8042
_newEffect(
_world,
true,
EventType.NONE,
false,
Expand All @@ -217,7 +202,6 @@ library EffectInitializer {
// class synergy
// index = binary(0_0011_1_010000_0000) = 0x1d00
_newEffect(
_world,
false,
EventType.ON_ATTACK,
true,
Expand All @@ -231,7 +215,6 @@ library EffectInitializer {
// race synergy
// index = binary(0_0011_1_001000_0000) = 0x1c80
_newEffect(
_world,
false,
EventType.ON_ATTACK,
true,
Expand All @@ -247,7 +230,6 @@ library EffectInitializer {
// with event ON_START
// index = binary(0_0001_1_001000_0000) = 0x0c80
_newEffect(
_world,
false,
EventType.ON_START,
true,
Expand All @@ -260,7 +242,6 @@ library EffectInitializer {
);
// index = binary(0_0001_1_001000_0001) = 0x0c81
_newEffect(
_world,
false,
EventType.ON_START,
true,
Expand Down Expand Up @@ -311,7 +292,6 @@ library EffectInitializer {
}

function _newEffect(
IWorld _world,
bool _withModifier,
EventType _eventType,
bool _direct,
Expand All @@ -330,7 +310,7 @@ library EffectInitializer {
index <<= 4;
index += _internalIndex & 0x0f;

Effect.set(_world, index, EffectData(_modifier, _trigger));
Effect.set(index, EffectData(_modifier, _trigger));
}

function _newModifier(
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts/script/PostDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import {EffectInitializer} from "./EffectInitializer.sol";
import {ZkVerifier} from "../src/codegen/index.sol";
import {Groth16Verifier} from "../src/zkVerifier/Verifier.sol";

import {StoreSwitch} from "@latticexyz/store/src/StoreSwitch.sol";

contract PostDeploy is Script {
function run(address worldAddress) external {
StoreSwitch.setStoreAddress(worldAddress);
// Load the private key from the `PRIVATE_KEY` environment variable (in .env)
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

Expand All @@ -25,7 +28,7 @@ contract PostDeploy is Script {
// ------------------ EXAMPLES ------------------

Groth16Verifier verifier = new Groth16Verifier();
ZkVerifier.set(IWorld(worldAddress), address(verifier));
ZkVerifier.set(address(verifier));

ConfigInitializer.initGameConfig(IWorld(worldAddress));

Expand Down
Loading
Loading