diff --git a/manifests/dev/base/abis/contracts/bytebeasts-move_action-62decdb8.json b/manifests/dev/base/abis/contracts/bytebeasts-move_action-62decdb8.json new file mode 100644 index 0000000..ed34d1f --- /dev/null +++ b/manifests/dev/base/abis/contracts/bytebeasts-move_action-62decdb8.json @@ -0,0 +1,237 @@ +[ + { + "type": "impl", + "name": "ContractImpl", + "interface_name": "dojo::contract::contract::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::contract::IContract", + "items": [ + { + "type": "function", + "name": "contract_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::world_contract::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::world_contract::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::world_contract::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::world_contract::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "MoveActionImpl", + "interface_name": "bytebeasts::systems::move::IMoveAction" + }, + { + "type": "interface", + "name": "bytebeasts::systems::move::IMoveAction", + "items": [ + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "player_id", + "type": "core::integer::u32" + }, + { + "name": "new_x", + "type": "core::integer::u32" + }, + { + "name": "new_y", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "bytebeasts::systems::move::move_action::IDojoInit" + }, + { + "type": "interface", + "name": "bytebeasts::systems::move::move_action::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::contract::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "bytebeasts::systems::move::move_action::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/contracts/bytebeasts-spawn_action-5176c1e8.json b/manifests/dev/base/abis/contracts/bytebeasts-spawn_action-5176c1e8.json new file mode 100644 index 0000000..da498df --- /dev/null +++ b/manifests/dev/base/abis/contracts/bytebeasts-spawn_action-5176c1e8.json @@ -0,0 +1,229 @@ +[ + { + "type": "impl", + "name": "ContractImpl", + "interface_name": "dojo::contract::contract::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::contract::IContract", + "items": [ + { + "type": "function", + "name": "contract_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::world_contract::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::world_contract::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::world_contract::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::world_contract::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "SpawnActionImpl", + "interface_name": "bytebeasts::systems::spawn::ISpawnAction" + }, + { + "type": "interface", + "name": "bytebeasts::systems::spawn::ISpawnAction", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [ + { + "name": "player_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "bytebeasts::systems::spawn::spawn_action::IDojoInit" + }, + { + "type": "interface", + "name": "bytebeasts::systems::spawn::spawn_action::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::contract::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "bytebeasts::systems::spawn::spawn_action::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/contracts/bytebeasts-world_setup-674b640b.json b/manifests/dev/base/abis/contracts/bytebeasts-world_setup-674b640b.json new file mode 100644 index 0000000..edd696c --- /dev/null +++ b/manifests/dev/base/abis/contracts/bytebeasts-world_setup-674b640b.json @@ -0,0 +1,224 @@ +[ + { + "type": "impl", + "name": "ContractImpl", + "interface_name": "dojo::contract::contract::IContract" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::contract::IContract", + "items": [ + { + "type": "function", + "name": "contract_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::world_contract::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::world_contract::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::world_contract::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::world_contract::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldSetupImpl", + "interface_name": "bytebeasts::systems::world_setup::IWorldSetup" + }, + { + "type": "interface", + "name": "bytebeasts::systems::world_setup::IWorldSetup", + "items": [ + { + "type": "function", + "name": "setWorld", + "inputs": [], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "bytebeasts::systems::world_setup::world_setup::IDojoInit" + }, + { + "type": "interface", + "name": "bytebeasts::systems::world_setup::world_setup::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::contract::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "bytebeasts::systems::world_setup::world_setup::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/manifests/dev/base/contracts/bytebeasts-move_action-62decdb8.toml b/manifests/dev/base/contracts/bytebeasts-move_action-62decdb8.toml new file mode 100644 index 0000000..aea78af --- /dev/null +++ b/manifests/dev/base/contracts/bytebeasts-move_action-62decdb8.toml @@ -0,0 +1,10 @@ +kind = "DojoContract" +class_hash = "0x6ab57932e6f1d360557867a6775d89180d623a481695d4349f6d356c8cd31ee" +original_class_hash = "0x6ab57932e6f1d360557867a6775d89180d623a481695d4349f6d356c8cd31ee" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/bytebeasts-move_action-62decdb8.json" +reads = [] +writes = [] +init_calldata = [] +tag = "bytebeasts-move_action" +manifest_name = "bytebeasts-move_action-62decdb8" diff --git a/manifests/dev/base/contracts/bytebeasts-spawn_action-5176c1e8.toml b/manifests/dev/base/contracts/bytebeasts-spawn_action-5176c1e8.toml new file mode 100644 index 0000000..2d56eaf --- /dev/null +++ b/manifests/dev/base/contracts/bytebeasts-spawn_action-5176c1e8.toml @@ -0,0 +1,10 @@ +kind = "DojoContract" +class_hash = "0x394b6a9219ec1e5e1e3afdec390794e017870eb56b58ad18252d3c1eaf2a0f0" +original_class_hash = "0x394b6a9219ec1e5e1e3afdec390794e017870eb56b58ad18252d3c1eaf2a0f0" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/bytebeasts-spawn_action-5176c1e8.json" +reads = [] +writes = [] +init_calldata = [] +tag = "bytebeasts-spawn_action" +manifest_name = "bytebeasts-spawn_action-5176c1e8" diff --git a/manifests/dev/base/contracts/bytebeasts-world_setup-674b640b.toml b/manifests/dev/base/contracts/bytebeasts-world_setup-674b640b.toml new file mode 100644 index 0000000..37f98ba --- /dev/null +++ b/manifests/dev/base/contracts/bytebeasts-world_setup-674b640b.toml @@ -0,0 +1,10 @@ +kind = "DojoContract" +class_hash = "0xad9d2da0783e3a31f6198d7c355bd293e496019e0e335449377a2c0146880" +original_class_hash = "0xad9d2da0783e3a31f6198d7c355bd293e496019e0e335449377a2c0146880" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/bytebeasts-world_setup-674b640b.json" +reads = [] +writes = [] +init_calldata = [] +tag = "bytebeasts-world_setup" +manifest_name = "bytebeasts-world_setup-674b640b" diff --git a/src/lib.cairo b/src/lib.cairo index 2dcec7b..6738c1a 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -1,7 +1,9 @@ mod systems { - mod actions; mod battle; mod realms; + mod move; + mod spawn; + mod world_setup; } mod models { diff --git a/src/systems/move.cairo b/src/systems/move.cairo new file mode 100644 index 0000000..3439537 --- /dev/null +++ b/src/systems/move.cairo @@ -0,0 +1,33 @@ +use bytebeasts::{ + models::{player::Player, coordinates::Coordinates, position::Position}, +}; + +#[dojo::interface] +trait IMoveAction { + fn move(ref world: IWorldDispatcher, player_id: u32, new_x: u32, new_y: u32); +} + +#[dojo::contract] +mod move_action { + use super::IMoveAction; + use starknet::{ContractAddress, get_caller_address}; + use bytebeasts::{ + models::{player::Player, coordinates::Coordinates, position::Position}, + }; + + #[abi(embed_v0)] + impl MoveActionImpl of IMoveAction { + fn move(ref world: IWorldDispatcher, player_id: u32, new_x: u32, new_y: u32) { + let player_from_world = get!(world, player_id, (Player)); + + set!( + world, + ( + Position { + player: player_from_world, coordinates: Coordinates { x: new_x, y: new_y } + }, + ) + ); + } + } +} \ No newline at end of file diff --git a/src/systems/spawn.cairo b/src/systems/spawn.cairo new file mode 100644 index 0000000..352d334 --- /dev/null +++ b/src/systems/spawn.cairo @@ -0,0 +1,29 @@ +use bytebeasts::{ + models::{player::Player, coordinates::Coordinates, position::Position}, +}; + +#[dojo::interface] +trait ISpawnAction { + fn spawn(ref world: IWorldDispatcher, player_id: u32); +} + +#[dojo::contract] +mod spawn_action { + use super::ISpawnAction; + use starknet::{ContractAddress, get_caller_address}; + use bytebeasts::{ + models::{player::Player, coordinates::Coordinates, position::Position}, + }; + + #[abi(embed_v0)] + impl SpawnActionImpl of ISpawnAction { + fn spawn(ref world: IWorldDispatcher, player_id: u32) { + let player_from_world = get!(world, player_id, (Player)); + + set!( + world, + (Position { player: player_from_world, coordinates: Coordinates { x: 10, y: 10 } },) + ); + } + } +} \ No newline at end of file diff --git a/src/systems/actions.cairo b/src/systems/world_setup.cairo similarity index 84% rename from src/systems/actions.cairo rename to src/systems/world_setup.cairo index abc5b33..1b8d5b4 100644 --- a/src/systems/actions.cairo +++ b/src/systems/world_setup.cairo @@ -5,20 +5,14 @@ use bytebeasts::{ }, }; - -// define the interface #[dojo::interface] -trait IActions { +trait IWorldSetup { fn setWorld(ref world: IWorldDispatcher); - fn spawn(ref world: IWorldDispatcher, player_id: u32); - fn move(ref world: IWorldDispatcher, player_id: u32, new_x: u32, new_y: u32); } -// dojo decorator #[dojo::contract] -mod actions { - use super::{IActions}; - +mod world_setup { + use super::IWorldSetup; use starknet::{ContractAddress, get_caller_address}; use bytebeasts::{ models::{ @@ -27,9 +21,8 @@ mod actions { }, }; - #[abi(embed_v0)] - impl ActionsImpl of IActions { + impl WorldSetupImpl of IWorldSetup { fn setWorld(ref world: IWorldDispatcher) { // Set Beasts set!( @@ -103,7 +96,6 @@ mod actions { // Set Potions set!(world, (Potion { potion_id: 1, potion_name: 'Health Potion', potion_effect: 50 })); - set!(world, (Potion { potion_id: 2, potion_name: 'Super Potion', potion_effect: 100 })); // Set Mts @@ -195,27 +187,5 @@ mod actions { }) ); } - - fn spawn(ref world: IWorldDispatcher, player_id: u32) { - let player_from_world = get!(world, player_id, (Player)); - - set!( - world, - (Position { player: player_from_world, coordinates: Coordinates { x: 10, y: 10 } },) - ); - } - - fn move(ref world: IWorldDispatcher, player_id: u32, new_x: u32, new_y: u32) { - let player_from_world = get!(world, player_id, (Player)); - - set!( - world, - ( - Position { - player: player_from_world, coordinates: Coordinates { x: new_x, y: new_y } - }, - ) - ); - } } -} +} \ No newline at end of file