Skip to content

Commit

Permalink
refactor(ri): use int32 instead of uint32 in all components
Browse files Browse the repository at this point in the history
feat(ri): combat MVP (#58)

fix: use int32 everywhere

fix(ri): do not heal defenders when attacking with negative hp (lol)

fix(ri): fail stamina reduction if not enough is present

feat(ri): death MVP (#61)

Blueprints (#64)

* feat(ri): prototype MVP

* fix(ri): set current stamina to 0 when spawning a soldier

* refactor(ri): prototype -> blueprint

feat(ri): adding path movement, moveSpeed and aStar pathfinding, remo… (#62)

* feat(ri): adding path movement, moveSpeed and aStar pathfinding, removed keyboard movement

* fix(ri): delete destination system, use position system for local path logic

* feat(ri): change MoveSpeed from uint32 to int32

* fix(ri): delete old TODO commend

* refactor(ri): remove timestamps from right click stream

* fix(ri): filter right click stream correctly, remove unecessary checks in path viz

* refactor(ri): clean up rightclick stream

BlueprintComponents (#66)

* feat(ri/contracts): add BlueprintComponentsComponent to allow dynamic construction of blueprints

* fix(ri): fix BlueprintComponents getEntitiesWithValue

feat: merge main to get new systems pattern (#69)

* feat: merge main to get new systems pattern

* refactor: move PrototypeSystem back to LibPrototype

* feat: new forge test infrastructure

* fix(ri/contracts): fix stamina update to allow stamina to go to 0

* fix(ri/contracts): allow combat between attackers with no health or defenders with no attack

* fix(ri-contracts): fix dev dependencies and increase local gas limit

* feat: use dev mode to disable cache in sync worker

* fix(ri/client): pass devMode param to createSystemExecutors

* fix(ri-contracts): use existing variable

Co-authored-by: Andy Cernera <kooshaba@gmail.com>

Co-authored-by: Andy Cernera <kooshaba@gmail.com>
Co-authored-by: Big Nuge <davidkolop@gmail.com>
  • Loading branch information
2 people authored and alvrs committed Jul 11, 2022
1 parent ee381e1 commit 89a0307
Show file tree
Hide file tree
Showing 167 changed files with 3,436 additions and 3,366 deletions.
1 change: 1 addition & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
15 changes: 0 additions & 15 deletions packages/cli/build/cli.js

This file was deleted.

47 changes: 0 additions & 47 deletions packages/cli/build/commands/create.js

This file was deleted.

413 changes: 0 additions & 413 deletions packages/cli/build/commands/deploy.js

This file was deleted.

56 changes: 0 additions & 56 deletions packages/cli/build/commands/diamond-abi.js

This file was deleted.

18 changes: 0 additions & 18 deletions packages/cli/build/commands/hello.js

This file was deleted.

48 changes: 0 additions & 48 deletions packages/cli/build/utils.js

This file was deleted.

11 changes: 5 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
"directory": "packages/cli"
},
"scripts": {
"prepare": "chmod u+x build/cli.js",
"globalinstall": "yarn build && yarn prepare && yarn link && yarn global add @latticexyz/cli@link:./",
"build": "rimraf build && tsc -p . && yarn prepare",
"start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/cli.ts",
"link:bin": "export PATH=\"$(yarn global bin):$PATH\""
"prepare": "yarn build",
"globalinstall": "yarn build && yarn prepare && npm link",
"build": "rimraf build && tsc -p . && chmod u+x build/cli.js"
},
"devDependencies": {
"@types/clear": "^0.1.2",
Expand Down Expand Up @@ -50,7 +48,8 @@
"openurl": "^1.1.1",
"path": "^0.12.7",
"uuid": "^8.3.2",
"yargs": "^17.5.1"
"yargs": "^17.5.1",
"typechain": "^8.1.0"
},
"pkg": {
"scripts": "build/**/*.js"
Expand Down
97 changes: 20 additions & 77 deletions packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ interface Options {
chainSpec?: string;
chainId?: number;
rpc?: string;
personaMirror?: string;
personaAllMinter?: string;
persona?: string;
wsRpc?: string;
world?: string;
diamond?: string;
reuseComponents?: boolean;
deployerPrivateKey?: string;
deployClient?: boolean;
Expand All @@ -45,11 +42,8 @@ export const builder: CommandBuilder<Options, Options> = (yargs) =>
chainSpec: { type: "string" },
chainId: { type: "number" },
rpc: { type: "string" },
personaMirror: { type: "string" },
persona: { type: "string" },
personaAllMinter: { type: "string" },
wsRpc: { type: "string" },
world: { type: "string" },
diamond: { type: "string" },
reuseComponents: { type: "boolean" },
deployerPrivateKey: { type: "string" },
deployClient: { type: "boolean" },
Expand Down Expand Up @@ -107,6 +101,7 @@ const getDeployInfo: (args: Arguments<Options>) => Promise<Options> = async (arg
chainSpec: "chainSpec.json",
chainId: 31337,
rpc: "http://localhost:8545",
wsRpc: "ws://localhost:8545",
reuseComponents: false,
deployClient: false,
clientUrl: "http://localhost:3000",
Expand All @@ -128,6 +123,13 @@ const getDeployInfo: (args: Arguments<Options>) => Promise<Options> = async (arg
message: "Provide a chainId for the deployment",
when: (answers) => answers.chainSpec == null && args.chainId == null && config.chainSpec == null,
},
{
type: "input",
name: "wsRpc",
default: defaultOptions.wsRpc,
message: "Provide a WebSocket RPC endpoint for your deployment",
when: (answers) => answers.chainSpec == null && args.wsRpc == null && config.wsRpc == null,
},
{
type: "input",
name: "rpc",
Expand All @@ -139,49 +141,6 @@ const getDeployInfo: (args: Arguments<Options>) => Promise<Options> = async (arg
return "Invalid URL";
},
},
{
type: "input",
name: "personaMirror",
message:
"Provide the address of an existing PersonaMirror contract. (If none is given, PersonaMirror will be deployed.)",
when: (answers) => answers.chainSpec == null && args.personaMirror == null && config.personaMirror == null,
validate: (i) => {
if (!i || (i[0] == "0" && i[1] == "x" && i.length === 42)) return true;
return "Invalid address";
},
},
{
type: "input",
name: "persona",
message: "Provide the address of an existing Persona contract. (If none is given, Persona will be deployed.)",
when: (answers) => answers.chainSpec == null && args.persona == null && config.persona == null,
validate: (i) => {
if (!i || (i[0] == "0" && i[1] == "x" && i.length === 42)) return true;
return "Invalid address";
},
},
{
type: "input",
name: "personaAllMinter",
message:
"Provide the address of an existing PersonaAllMinter contract. (If none is given, PersonaAllMinter will be deployed.)",
when: (answers) => answers.chainSpec == null && args.persona == null && config.persona == null,
validate: (i) => {
if (!i || (i[0] == "0" && i[1] == "x" && i.length === 42)) return true;
return "Invalid address";
},
},
{
type: "input",
name: "diamond",
message:
"Provide the address of an existing Diamond contract that should be updated. (If none is given, a new Diamond will be deployed.)",
when: () => args.diamond == null && config.diamond == null,
validate: (i) => {
if (!i || (i[0] == "0" && i[1] == "x" && i.length === 42)) return true;
return "Invalid address";
},
},
{
type: "input",
name: "world",
Expand Down Expand Up @@ -277,16 +236,8 @@ const getDeployInfo: (args: Arguments<Options>) => Promise<Options> = async (arg
chainSpec: args.chainSpec ?? config.chainSpec ?? answers.chainSpec ?? defaultOptions.chainSpec,
chainId: args.chainId ?? chainSpec?.chainId ?? config.chainId ?? answers.chainId ?? defaultOptions.chainId,
rpc: args.rpc ?? chainSpec?.rpc ?? config.rpc ?? answers.rpc ?? defaultOptions.rpc,
personaMirror:
args.personaMirror ?? chainSpec?.personaMirrorAddress ?? config.personaMirror ?? answers.personaMirror,
personaAllMinter:
args.personaAllMinter ??
chainSpec?.personaAllMinterAddress ??
config.personaAllMinter ??
answers.personaAllMinter,
persona: args.persona ?? chainSpec?.personaAddress ?? config.persona ?? answers.persona,
wsRpc: args.wsRpc ?? chainSpec?.wsRpc ?? config.wsRpc ?? answers.wsRpc ?? defaultOptions.wsRpc,
world: args.world ?? chainSpec?.world ?? config.world ?? answers.world,
diamond: args.diamond ?? config.diamond ?? answers.diamond,
reuseComponents:
args.reuseComponents ?? config.reuseComponents ?? answers.reuseComponents ?? defaultOptions.reuseComponents,
deployerPrivateKey: args.deployerPrivateKey ?? config.deployerPrivateKey ?? answers.deployerPrivateKey,
Expand Down Expand Up @@ -318,7 +269,7 @@ export const deploy = async (options: Options) => {
const id = v4().substring(0, 6);

let launcherUrl;
let gameContractAddress;
let worldAddress;

try {
const tasks = new Listr([
Expand All @@ -337,10 +288,8 @@ export const deploy = async (options: Options) => {
"--private-keys",
wallet.privateKey,
"--sig",
"deployEmber(address,address,address,address,bool)",
"deploy(address,address,bool)",
wallet.address,
options.personaMirror || constants.AddressZero,
options.diamond || constants.AddressZero,
options.world || constants.AddressZero,
options.reuseComponents ? "true" : "false",
"--fork-url",
Expand All @@ -350,12 +299,8 @@ export const deploy = async (options: Options) => {
const { stdout } = await child;
const lines = stdout.split("\n");

ctx.gameContractAddress = gameContractAddress = findLog(lines, "diamond: address");
ctx.personaAddress = findLog(lines, "persona: address");
ctx.personaMirrorAddress = findLog(lines, "personaMirror: address");
ctx.personaAllMinterAddress = findLog(lines, "personaAllMinter: address");

task.output = chalk.yellow(`Game deployed at: ${chalk.bgYellow.black(gameContractAddress)}`);
ctx.worldAddress = worldAddress = findLog(lines, "world: address");
task.output = chalk.yellow(`World deployed at: ${chalk.bgYellow.black(ctx.worldAddress)}`);
},
options: { bottomBar: 3 },
},
Expand Down Expand Up @@ -420,13 +365,11 @@ export const deploy = async (options: Options) => {
title: "Open Launcher",
task: async (ctx) => {
const clientUrl = options.deployClient ? ctx.clientUrl : options.clientUrl;
launcherUrl = `https://play.lattice.xyz?address=${
ctx.gameContractAddress || ""
}&personaMirrorAddress=${ctx.personaMirrorAddress || ""}&personaAddress=${
options.persona || ctx.personaAddress || ""
}&personaAllMinterAddress=${options.personaAllMinter || ctx.personaAllMinterAddress || ""}&client=${
launcherUrl = `https://play.lattice.xyz?worldAddress=${ctx.worldAddress || ""}&client=${
clientUrl || ""
}&rpc=${options.rpc || ""}&chainId=${options.chainId || ""}&dev=${options.chainId === 31337 || ""}`;
}&rpc=${options.rpc || ""}&wsRpc=${options.wsRpc || ""}&chainId=${options.chainId || ""}&dev=${
options.chainId === 31337 || ""
}`;
openurl.open(launcherUrl);
},
options: { bottomBar: 3 },
Expand All @@ -440,7 +383,7 @@ export const deploy = async (options: Options) => {
await tasks.run();
console.log(chalk.bgGreen.black.bold(" Congratulations! Deployment successful"));
console.log();
console.log(chalk.green(`Contract deployed to ${gameContractAddress}`));
console.log(chalk.green(`World address ${worldAddress}`));
console.log(chalk.green(`Open launcher at ${launcherUrl}`));
console.log();
} catch (e) {
Expand Down
Loading

0 comments on commit 89a0307

Please sign in to comment.