Skip to content

Commit

Permalink
fix dungeon and bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Aug 26, 2024
1 parent ba67877 commit 23af833
Show file tree
Hide file tree
Showing 19 changed files with 19,105 additions and 23,782 deletions.
222 changes: 113 additions & 109 deletions clients/react-client/src/typescript/models.gen.ts
Original file line number Diff line number Diff line change
@@ -1,145 +1,149 @@

// Generated by dojo-bindgen on Wed, 21 Aug 2024 14:15:09 +0000. Do not modify this file manually.
// Import the necessary types from the recs SDK
// generate again with `sozo build --typescript`
// generate again with `sozo build --typescript`
import { defineComponent, Type as RecsType, World } from "@dojoengine/recs";

export type ContractComponents = Awaited<ReturnType<typeof defineContractComponents>>;


export type ContractComponents = Awaited<
ReturnType<typeof defineContractComponents>
>;

// Type definition for `dojo::model::layout::Layout` enum
export type Layout = { type: 'Fixed'; value: RecsType.NumberArray; } | { type: 'Struct'; value: RecsType.StringArray; } | { type: 'Tuple'; value: RecsType.StringArray; } | { type: 'Array'; value: RecsType.StringArray; } | { type: 'ByteArray'; } | { type: 'Enum'; value: RecsType.StringArray; };
export type Layout =
| { type: "Fixed"; value: RecsType.NumberArray }
| { type: "Struct"; value: RecsType.StringArray }
| { type: "Tuple"; value: RecsType.StringArray }
| { type: "Array"; value: RecsType.StringArray }
| { type: "ByteArray" }
| { type: "Enum"; value: RecsType.StringArray };

export const LayoutDefinition = {
type: RecsType.String,
value: RecsType.String
type: RecsType.String,
value: RecsType.String,
};

// Type definition for `rpg::models::index::Player` struct
export interface Player {
id: BigInt;
mode: Number;
role: Number;
damage: Number;
health: Number;
gold: Number;
score: Number;
seed: BigInt;
name: BigInt;

id: BigInt;
mode: Number;
role: Number;
damage: Number;
health: Number;
gold: Number;
score: Number;
seed: BigInt;
name: BigInt;
}
export const PlayerDefinition = {
id: RecsType.BigInt,
mode: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
gold: RecsType.Number,
score: RecsType.Number,
seed: RecsType.BigInt,
name: RecsType.BigInt,

id: RecsType.BigInt,
mode: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
gold: RecsType.Number,
score: RecsType.Number,
seed: RecsType.BigInt,
name: RecsType.BigInt,
};

// Type definition for `dojo::model::layout::FieldLayout` struct
export interface FieldLayout {
selector: BigInt;
layout: Layout;

selector: BigInt;
layout: Layout;
}
export const FieldLayoutDefinition = {
selector: RecsType.BigInt,
layout: LayoutDefinition,

selector: RecsType.BigInt,
layout: LayoutDefinition,
};

// Type definition for `core::byte_array::ByteArray` struct
export interface ByteArray {
data: String[];
pending_word: BigInt;
pending_word_len: Number;

data: String[];
pending_word: BigInt;
pending_word_len: Number;
}
export const ByteArrayDefinition = {
data: RecsType.StringArray,
pending_word: RecsType.BigInt,
pending_word_len: RecsType.Number,

data: RecsType.StringArray,
pending_word: RecsType.BigInt,
pending_word_len: RecsType.Number,
};


// Type definition for `rpg::models::index::Dungeon` struct
export interface Dungeon {
id: BigInt;
monster: Number;
role: Number;
damage: Number;
health: Number;
reward: Number;

id: BigInt;
monster: Number;
role: Number;
damage: Number;
health: Number;
reward: Number;
}
export const DungeonDefinition = {
id: RecsType.BigInt,
monster: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
reward: RecsType.Number,

id: RecsType.BigInt,
monster: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
reward: RecsType.Number,
};


export function defineContractComponents(world: World) {
return {

// Model definition for `rpg::models::index::Player` model
Player: (() => {
return defineComponent(
world,
{
id: RecsType.BigInt,
mode: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
gold: RecsType.Number,
score: RecsType.Number,
seed: RecsType.BigInt,
name: RecsType.BigInt,
},
{
metadata: {
namespace: "dojo_starter_rpg",
name: "Player",
types: ["felt252", "u8", "u8", "u8", "u8", "u16", "u16", "felt252", "felt252"],
customTypes: [],
},
}
);
})(),
return {
// Model definition for `rpg::models::index::Player` model
Player: (() => {
return defineComponent(
world,
{
id: RecsType.BigInt,
mode: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
gold: RecsType.Number,
score: RecsType.Number,
seed: RecsType.BigInt,
name: RecsType.BigInt,
},
{
metadata: {
namespace: "dojo_starter_rpg",
name: "Player",
types: [
"felt252",
"u8",
"u8",
"u8",
"u8",
"u16",
"u16",
"felt252",
"felt252",
],
customTypes: [],
},
}
);
})(),

// Model definition for `rpg::models::index::Dungeon` model
Dungeon: (() => {
return defineComponent(
world,
{
id: RecsType.BigInt,
monster: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
reward: RecsType.Number,
},
{
metadata: {
namespace: "dojo_starter_rpg",
name: "Dungeon",
types: ["felt252", "u8", "u8", "u8", "u8", "u16"],
customTypes: [],
},
}
);
})(),
};
// Model definition for `rpg::models::index::Dungeon` model
Dungeon: (() => {
return defineComponent(
world,
{
id: RecsType.BigInt,
monster: RecsType.Number,
role: RecsType.Number,
damage: RecsType.Number,
health: RecsType.Number,
reward: RecsType.Number,
},
{
metadata: {
namespace: "dojo_starter_rpg",
name: "Dungeon",
types: ["felt252", "u8", "u8", "u8", "u8", "u16"],
customTypes: [],
},
}
);
})(),
};
}
11 changes: 7 additions & 4 deletions clients/react-recs-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function App() {
const player = useComponentValue(Player, entityId);
const dungeon = useComponentValue(Dungeon, entityId);

console.log("dungeon", dungeon);
console.log("player", player);

return (
<>
<div className="bg-black text-green-600 h-screen w-screen p-10">
Expand All @@ -42,7 +45,7 @@ function App() {

<div className="grid grid-cols-2 gap-1">
<Button
disabled={dungeon?.health !== 0}
disabled={dungeon && dungeon?.health !== 0}
onClick={async () => {
await client.actions.move({
account,
Expand All @@ -54,7 +57,7 @@ function App() {
North
</Button>
<Button
disabled={dungeon?.health !== 0}
disabled={dungeon && dungeon?.health !== 0}
onClick={async () => {
await client.actions.move({
account,
Expand All @@ -66,7 +69,7 @@ function App() {
South
</Button>
<Button
disabled={dungeon?.health !== 0}
disabled={dungeon && dungeon?.health !== 0}
onClick={async () => {
await client.actions.move({
account,
Expand All @@ -78,7 +81,7 @@ function App() {
East
</Button>
<Button
disabled={dungeon?.health !== 0}
disabled={dungeon && dungeon?.health !== 0}
onClick={async () => {
await client.actions.move({
account,
Expand Down
14 changes: 2 additions & 12 deletions clients/react-recs-app/src/dojo/createSystemCalls.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { AccountInterface } from "starknet";
import {
Entity,
Has,
HasValue,
World,
defineSystem,
getComponentValue,
} from "@dojoengine/recs";
import { uuid } from "@latticexyz/utils";
import { World } from "@dojoengine/recs";

import { ClientComponents } from "./createClientComponents";
import { Direction, updatePositionWithDirection } from "../utils";
import { getEntityIdFromKeys } from "@dojoengine/utils";
import type { IWorld } from "./typescript/contracts.gen";

export type SystemCalls = ReturnType<typeof createSystemCalls>;
Expand Down
4 changes: 2 additions & 2 deletions clients/react-recs-app/src/dojo/typescript/models.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function defineContractComponents(world: World) {
{
metadata: {
namespace: "dojo_starter_rpg",
name: "dojo_starter_rpg-Dungeon",
name: "Dungeon",
types: ["felt252", "u8", "u8", "u8", "u8", "u16"],
customTypes: [],
},
Expand All @@ -128,7 +128,7 @@ export function defineContractComponents(world: World) {
{
metadata: {
namespace: "dojo_starter_rpg",
name: "dojo_starter_rpg-Player",
name: "Player",
types: [
"felt252",
"u8",
Expand Down
2 changes: 1 addition & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sozo build
sozo migrate apply

# Start Torii
torii --world 0x64ba78fe3ab8aedf19206180187d77a8b20b2a1f94877e18b86cb92dca82334 --allowed-origins "*"
torii --world 0x128bda34ac94a34dc53ea0ee024649f80ace13312a7dacdc9d541e6d4165ac1 --allowed-origins "*"
```

---
Expand Down
Loading

0 comments on commit 23af833

Please sign in to comment.