From 685b0fe2a9853eb50851f5c8bf039cbbd6312c36 Mon Sep 17 00:00:00 2001 From: RolandoDrRobot Date: Tue, 20 Aug 2024 23:40:26 -0400 Subject: [PATCH] Added events emits --- .../models/bytebeasts-Status-6595af0f.json | 407 +++++++++ .../bytebeasts-StatusBattle-161fdb64.json | 407 +++++++++ .../bytebeasts-battle_system-461868ac.toml | 4 +- .../models/bytebeasts-Status-6595af0f.toml | 16 + .../bytebeasts-StatusBattle-161fdb64.toml | 16 + .../bytebeasts-battle_system-461868ac.json | 226 +++++ .../models/bytebeasts-Battle-55b5860b.json | 427 +++++++++ .../models/bytebeasts-Beast-27809d20.json | 4 +- manifests/dev/deployment/manifest.json | 821 ++++++++++++++++-- manifests/dev/deployment/manifest.toml | 59 +- src/systems/battle.cairo | 34 +- 11 files changed, 2345 insertions(+), 76 deletions(-) create mode 100644 manifests/dev/base/abis/models/bytebeasts-Status-6595af0f.json create mode 100644 manifests/dev/base/abis/models/bytebeasts-StatusBattle-161fdb64.json create mode 100644 manifests/dev/base/models/bytebeasts-Status-6595af0f.toml create mode 100644 manifests/dev/base/models/bytebeasts-StatusBattle-161fdb64.toml create mode 100644 manifests/dev/deployment/abis/models/bytebeasts-Battle-55b5860b.json diff --git a/manifests/dev/base/abis/models/bytebeasts-Status-6595af0f.json b/manifests/dev/base/abis/models/bytebeasts-Status-6595af0f.json new file mode 100644 index 0000000..439cd90 --- /dev/null +++ b/manifests/dev/base/abis/models/bytebeasts-Status-6595af0f.json @@ -0,0 +1,407 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "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": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "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": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "statusImpl", + "interface_name": "bytebeasts::systems::battle::battle_system::Istatus" + }, + { + "type": "struct", + "name": "bytebeasts::systems::battle::battle_system::Status", + "members": [ + { + "name": "player_id", + "type": "core::integer::u32" + }, + { + "name": "message", + "type": "core::felt252" + } + ] + }, + { + "type": "interface", + "name": "bytebeasts::systems::battle::battle_system::Istatus", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bytebeasts::systems::battle::battle_system::Status" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bytebeasts::systems::battle::battle_system::status::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/models/bytebeasts-StatusBattle-161fdb64.json b/manifests/dev/base/abis/models/bytebeasts-StatusBattle-161fdb64.json new file mode 100644 index 0000000..e387582 --- /dev/null +++ b/manifests/dev/base/abis/models/bytebeasts-StatusBattle-161fdb64.json @@ -0,0 +1,407 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "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": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "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": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "status_battleImpl", + "interface_name": "bytebeasts::systems::battle::battle_system::Istatus_battle" + }, + { + "type": "struct", + "name": "bytebeasts::systems::battle::battle_system::StatusBattle", + "members": [ + { + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "message", + "type": "core::felt252" + } + ] + }, + { + "type": "interface", + "name": "bytebeasts::systems::battle::battle_system::Istatus_battle", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bytebeasts::systems::battle::battle_system::StatusBattle" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bytebeasts::systems::battle::battle_system::status_battle::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/contracts/bytebeasts-battle_system-461868ac.toml b/manifests/dev/base/contracts/bytebeasts-battle_system-461868ac.toml index 8238517..90e5905 100644 --- a/manifests/dev/base/contracts/bytebeasts-battle_system-461868ac.toml +++ b/manifests/dev/base/contracts/bytebeasts-battle_system-461868ac.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x42e8d9b08e8c71fee2c025922e8bcd10b9277fb688e97701f2169ca03ad91c0" -original_class_hash = "0x42e8d9b08e8c71fee2c025922e8bcd10b9277fb688e97701f2169ca03ad91c0" +class_hash = "0x5efdb80629807631b0bb916ce067881084b4aca4aaf22da3794172290bbd232" +original_class_hash = "0x5efdb80629807631b0bb916ce067881084b4aca4aaf22da3794172290bbd232" base_class_hash = "0x0" abi = "manifests/dev/base/abis/contracts/bytebeasts-battle_system-461868ac.json" reads = [] diff --git a/manifests/dev/base/models/bytebeasts-Status-6595af0f.toml b/manifests/dev/base/models/bytebeasts-Status-6595af0f.toml new file mode 100644 index 0000000..7c1c791 --- /dev/null +++ b/manifests/dev/base/models/bytebeasts-Status-6595af0f.toml @@ -0,0 +1,16 @@ +kind = "DojoModel" +class_hash = "0xe446a8c3773fbfae6e2e0e87a6d1db12143224cf47e217e12bf9cfc76428ef" +original_class_hash = "0xe446a8c3773fbfae6e2e0e87a6d1db12143224cf47e217e12bf9cfc76428ef" +abi = "manifests/dev/base/abis/models/bytebeasts-Status-6595af0f.json" +tag = "bytebeasts-Status" +manifest_name = "bytebeasts-Status-6595af0f" + +[[members]] +name = "player_id" +type = "u32" +key = true + +[[members]] +name = "message" +type = "felt252" +key = false diff --git a/manifests/dev/base/models/bytebeasts-StatusBattle-161fdb64.toml b/manifests/dev/base/models/bytebeasts-StatusBattle-161fdb64.toml new file mode 100644 index 0000000..9d5cc6d --- /dev/null +++ b/manifests/dev/base/models/bytebeasts-StatusBattle-161fdb64.toml @@ -0,0 +1,16 @@ +kind = "DojoModel" +class_hash = "0x5ba495f80b653be6df964eb97ac2e7b3f7f72508d17b54b1d51595231db8fae" +original_class_hash = "0x5ba495f80b653be6df964eb97ac2e7b3f7f72508d17b54b1d51595231db8fae" +abi = "manifests/dev/base/abis/models/bytebeasts-StatusBattle-161fdb64.json" +tag = "bytebeasts-StatusBattle" +manifest_name = "bytebeasts-StatusBattle-161fdb64" + +[[members]] +name = "battle_id" +type = "u32" +key = true + +[[members]] +name = "message" +type = "felt252" +key = false diff --git a/manifests/dev/deployment/abis/contracts/bytebeasts-battle_system-461868ac.json b/manifests/dev/deployment/abis/contracts/bytebeasts-battle_system-461868ac.json index 5f6fb4e..ef36b6a 100644 --- a/manifests/dev/deployment/abis/contracts/bytebeasts-battle_system-461868ac.json +++ b/manifests/dev/deployment/abis/contracts/bytebeasts-battle_system-461868ac.json @@ -131,10 +131,192 @@ "name": "BattleActionsImpl", "interface_name": "bytebeasts::systems::battle::IBattleActions" }, + { + "type": "struct", + "name": "bytebeasts::models::Beast", + "members": [ + { + "name": "beast_id", + "type": "core::integer::u32" + }, + { + "name": "beast_name", + "type": "core::felt252" + }, + { + "name": "beast_type", + "type": "core::integer::u32" + }, + { + "name": "beast_description", + "type": "core::felt252" + }, + { + "name": "player_id", + "type": "core::integer::u32" + }, + { + "name": "hp", + "type": "core::integer::u32" + }, + { + "name": "current_hp", + "type": "core::integer::u32" + }, + { + "name": "attack", + "type": "core::integer::u32" + }, + { + "name": "defense", + "type": "core::integer::u32" + }, + { + "name": "mt1", + "type": "core::integer::u32" + }, + { + "name": "mt2", + "type": "core::integer::u32" + }, + { + "name": "mt3", + "type": "core::integer::u32" + }, + { + "name": "mt4", + "type": "core::integer::u32" + }, + { + "name": "level", + "type": "core::integer::u32" + }, + { + "name": "experience_to_next_level", + "type": "core::integer::u64" + } + ] + }, + { + "type": "struct", + "name": "bytebeasts::models::Potion", + "members": [ + { + "name": "potion_id", + "type": "core::integer::u32" + }, + { + "name": "potion_name", + "type": "core::felt252" + }, + { + "name": "potion_effect", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "bytebeasts::models::Mt", + "members": [ + { + "name": "mt_id", + "type": "core::integer::u32" + }, + { + "name": "mt_name", + "type": "core::felt252" + }, + { + "name": "mt_type", + "type": "core::integer::u32" + }, + { + "name": "mt_power", + "type": "core::integer::u32" + }, + { + "name": "mt_accuracy", + "type": "core::integer::u32" + } + ] + }, { "type": "interface", "name": "bytebeasts::systems::battle::IBattleActions", "items": [ + { + "type": "function", + "name": "check_flee_success", + "inputs": [ + { + "name": "player_beast", + "type": "bytebeasts::models::Beast" + }, + { + "name": "opponent_beast", + "type": "bytebeasts::models::Beast" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "apply_item_effect", + "inputs": [ + { + "name": "potion", + "type": "bytebeasts::models::Potion" + }, + { + "name": "target", + "type": "bytebeasts::models::Beast" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "calculate_damage", + "inputs": [ + { + "name": "mt", + "type": "bytebeasts::models::Mt" + }, + { + "name": "attacker", + "type": "bytebeasts::models::Beast" + }, + { + "name": "defender", + "type": "bytebeasts::models::Beast" + } + ], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "opponent_turn", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, { "type": "function", "name": "init_battle", @@ -150,6 +332,50 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "attack", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "mt_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "use_potion", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "potion_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "flee", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" } ] }, diff --git a/manifests/dev/deployment/abis/models/bytebeasts-Battle-55b5860b.json b/manifests/dev/deployment/abis/models/bytebeasts-Battle-55b5860b.json new file mode 100644 index 0000000..3e997e9 --- /dev/null +++ b/manifests/dev/deployment/abis/models/bytebeasts-Battle-55b5860b.json @@ -0,0 +1,427 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "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": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "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": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "battleImpl", + "interface_name": "bytebeasts::models::Ibattle" + }, + { + "type": "struct", + "name": "bytebeasts::models::Battle", + "members": [ + { + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "player_id", + "type": "core::integer::u32" + }, + { + "name": "opponent_id", + "type": "core::integer::u32" + }, + { + "name": "active_beast_player", + "type": "core::integer::u32" + }, + { + "name": "active_beast_opponent", + "type": "core::integer::u32" + }, + { + "name": "battle_active", + "type": "core::integer::u32" + }, + { + "name": "turn", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "bytebeasts::models::Ibattle", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bytebeasts::models::Battle" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bytebeasts::models::battle::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/deployment/abis/models/bytebeasts-Beast-27809d20.json b/manifests/dev/deployment/abis/models/bytebeasts-Beast-27809d20.json index 956eecf..f43176e 100644 --- a/manifests/dev/deployment/abis/models/bytebeasts-Beast-27809d20.json +++ b/manifests/dev/deployment/abis/models/bytebeasts-Beast-27809d20.json @@ -400,11 +400,11 @@ }, { "name": "attack", - "type": "core::integer::u64" + "type": "core::integer::u32" }, { "name": "defense", - "type": "core::integer::u64" + "type": "core::integer::u32" }, { "name": "mt1", diff --git a/manifests/dev/deployment/manifest.json b/manifests/dev/deployment/manifest.json index 151b0c5..d74dfb4 100644 --- a/manifests/dev/deployment/manifest.json +++ b/manifests/dev/deployment/manifest.json @@ -1251,8 +1251,8 @@ { "kind": "DojoContract", "address": "0x4854bb6cc04b51e5adaed76afc0664091182fe44a9e5e68dc4f8f5f59ffd464", - "class_hash": "0x4b192794775dc6ff0267fd1a9ed531908e7a661e73fe596707af46c8719b587", - "original_class_hash": "0x4b192794775dc6ff0267fd1a9ed531908e7a661e73fe596707af46c8719b587", + "class_hash": "0x194fab2764a0d823cb5aa7ef9810113952c3579700e114d409c33f954f0caf9", + "original_class_hash": "0x194fab2764a0d823cb5aa7ef9810113952c3579700e114d409c33f954f0caf9", "base_class_hash": "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2", "abi": [ { @@ -1492,8 +1492,8 @@ { "kind": "DojoContract", "address": "0x612b684f6b34356ad9a07ac3e1924f9dfa54235d0a513095b0d12695ace8b68", - "class_hash": "0x56093b60a0b0aa8902f1dd09a888754a910967e4029bb70d8983ee846d4f488", - "original_class_hash": "0x56093b60a0b0aa8902f1dd09a888754a910967e4029bb70d8983ee846d4f488", + "class_hash": "0x42e8d9b08e8c71fee2c025922e8bcd10b9277fb688e97701f2169ca03ad91c0", + "original_class_hash": "0x42e8d9b08e8c71fee2c025922e8bcd10b9277fb688e97701f2169ca03ad91c0", "base_class_hash": "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2", "abi": [ { @@ -1628,10 +1628,192 @@ "name": "BattleActionsImpl", "interface_name": "bytebeasts::systems::battle::IBattleActions" }, + { + "type": "struct", + "name": "bytebeasts::models::Beast", + "members": [ + { + "name": "beast_id", + "type": "core::integer::u32" + }, + { + "name": "beast_name", + "type": "core::felt252" + }, + { + "name": "beast_type", + "type": "core::integer::u32" + }, + { + "name": "beast_description", + "type": "core::felt252" + }, + { + "name": "player_id", + "type": "core::integer::u32" + }, + { + "name": "hp", + "type": "core::integer::u32" + }, + { + "name": "current_hp", + "type": "core::integer::u32" + }, + { + "name": "attack", + "type": "core::integer::u32" + }, + { + "name": "defense", + "type": "core::integer::u32" + }, + { + "name": "mt1", + "type": "core::integer::u32" + }, + { + "name": "mt2", + "type": "core::integer::u32" + }, + { + "name": "mt3", + "type": "core::integer::u32" + }, + { + "name": "mt4", + "type": "core::integer::u32" + }, + { + "name": "level", + "type": "core::integer::u32" + }, + { + "name": "experience_to_next_level", + "type": "core::integer::u64" + } + ] + }, + { + "type": "struct", + "name": "bytebeasts::models::Potion", + "members": [ + { + "name": "potion_id", + "type": "core::integer::u32" + }, + { + "name": "potion_name", + "type": "core::felt252" + }, + { + "name": "potion_effect", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "bytebeasts::models::Mt", + "members": [ + { + "name": "mt_id", + "type": "core::integer::u32" + }, + { + "name": "mt_name", + "type": "core::felt252" + }, + { + "name": "mt_type", + "type": "core::integer::u32" + }, + { + "name": "mt_power", + "type": "core::integer::u32" + }, + { + "name": "mt_accuracy", + "type": "core::integer::u32" + } + ] + }, { "type": "interface", "name": "bytebeasts::systems::battle::IBattleActions", "items": [ + { + "type": "function", + "name": "check_flee_success", + "inputs": [ + { + "name": "player_beast", + "type": "bytebeasts::models::Beast" + }, + { + "name": "opponent_beast", + "type": "bytebeasts::models::Beast" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "apply_item_effect", + "inputs": [ + { + "name": "potion", + "type": "bytebeasts::models::Potion" + }, + { + "name": "target", + "type": "bytebeasts::models::Beast" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "calculate_damage", + "inputs": [ + { + "name": "mt", + "type": "bytebeasts::models::Mt" + }, + { + "name": "attacker", + "type": "bytebeasts::models::Beast" + }, + { + "name": "defender", + "type": "bytebeasts::models::Beast" + } + ], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "opponent_turn", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, { "type": "function", "name": "init_battle", @@ -1647,95 +1829,610 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "attack", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "mt_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "use_potion", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "potion_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "flee", + "inputs": [ + { + "name": "battle_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "bytebeasts::systems::battle::battle_system::IDojoInit" + }, + { + "type": "interface", + "name": "bytebeasts::systems::battle::battle_system::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::battle::battle_system::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } + ], + "reads": [], + "writes": [], + "init_calldata": [], + "tag": "bytebeasts-battle_system", + "manifest_name": "bytebeasts-battle_system-461868ac" + } + ], + "models": [ + { + "kind": "DojoModel", + "members": [ + { + "name": "battle_id", + "type": "u32", + "key": true + }, + { + "name": "player_id", + "type": "u32", + "key": false + }, + { + "name": "opponent_id", + "type": "u32", + "key": false + }, + { + "name": "active_beast_player", + "type": "u32", + "key": false + }, + { + "name": "active_beast_opponent", + "type": "u32", + "key": false + }, + { + "name": "battle_active", + "type": "u32", + "key": false + }, + { + "name": "turn", + "type": "u32", + "key": false + } + ], + "class_hash": "0x1279ba311b8f42dceefdfc2f10b1e8d524a9df7f08a0716eccc3bedf6e235da", + "original_class_hash": "0x1279ba311b8f42dceefdfc2f10b1e8d524a9df7f08a0716eccc3bedf6e235da", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" } ] }, { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "bytebeasts::systems::battle::battle_system::IDojoInit" - }, - { - "type": "interface", - "name": "bytebeasts::systems::battle::battle_system::IDojoInit", - "items": [ + "type": "struct", + "name": "core::array::Span::", + "members": [ { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" + "name": "snapshot", + "type": "@core::array::Array::" } ] }, { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::contract::upgradeable::IUpgradeable" + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] }, { "type": "interface", - "name": "dojo::contract::upgradeable::IUpgradeable", + "name": "dojo::model::model::IModel", "items": [ { "type": "function", - "name": "upgrade", - "inputs": [ + "name": "name", + "inputs": [], + "outputs": [ { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" + "type": "core::byte_array::ByteArray" } ], - "outputs": [], - "state_mutability": "external" + "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": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "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": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" } ] }, { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "struct", + "type": "impl", + "name": "battleImpl", + "interface_name": "bytebeasts::models::Ibattle" + }, + { + "type": "struct", + "name": "bytebeasts::models::Battle", "members": [ { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" + "name": "battle_id", + "type": "core::integer::u32" + }, + { + "name": "player_id", + "type": "core::integer::u32" + }, + { + "name": "opponent_id", + "type": "core::integer::u32" + }, + { + "name": "active_beast_player", + "type": "core::integer::u32" + }, + { + "name": "active_beast_opponent", + "type": "core::integer::u32" + }, + { + "name": "battle_active", + "type": "core::integer::u32" + }, + { + "name": "turn", + "type": "core::integer::u32" } ] }, { - "type": "event", - "name": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ + "type": "interface", + "name": "bytebeasts::models::Ibattle", + "items": [ { - "name": "Upgraded", - "type": "dojo::contract::upgradeable::upgradeable::Upgraded", - "kind": "nested" + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bytebeasts::models::Battle" + } + ], + "outputs": [], + "state_mutability": "view" } ] }, { "type": "event", - "name": "bytebeasts::systems::battle::battle_system::Event", + "name": "bytebeasts::models::battle::Event", "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] + "variants": [] } ], - "reads": [], - "writes": [], - "init_calldata": [], - "tag": "bytebeasts-battle_system", - "manifest_name": "bytebeasts-battle_system-461868ac" - } - ], - "models": [ + "tag": "bytebeasts-Battle", + "manifest_name": "bytebeasts-Battle-55b5860b" + }, { "kind": "DojoModel", "members": [ @@ -1776,12 +2473,12 @@ }, { "name": "attack", - "type": "u64", + "type": "u32", "key": false }, { "name": "defense", - "type": "u64", + "type": "u32", "key": false }, { @@ -1815,8 +2512,8 @@ "key": false } ], - "class_hash": "0x1ae435e73e2ccb909d2fc7ea7ac0def65e0e2df5cb9496caa4e08d54f2c428c", - "original_class_hash": "0x1ae435e73e2ccb909d2fc7ea7ac0def65e0e2df5cb9496caa4e08d54f2c428c", + "class_hash": "0x7fe3d50195b0f91ee8bcbc17710f62df6f2d31732540b74b8b7dd7fc2157d9f", + "original_class_hash": "0x7fe3d50195b0f91ee8bcbc17710f62df6f2d31732540b74b8b7dd7fc2157d9f", "abi": [ { "type": "impl", @@ -2219,11 +2916,11 @@ }, { "name": "attack", - "type": "core::integer::u64" + "type": "core::integer::u32" }, { "name": "defense", - "type": "core::integer::u64" + "type": "core::integer::u32" }, { "name": "mt1", diff --git a/manifests/dev/deployment/manifest.toml b/manifests/dev/deployment/manifest.toml index f7b54c7..4017e19 100644 --- a/manifests/dev/deployment/manifest.toml +++ b/manifests/dev/deployment/manifest.toml @@ -24,8 +24,8 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" address = "0x4854bb6cc04b51e5adaed76afc0664091182fe44a9e5e68dc4f8f5f59ffd464" -class_hash = "0x4b192794775dc6ff0267fd1a9ed531908e7a661e73fe596707af46c8719b587" -original_class_hash = "0x4b192794775dc6ff0267fd1a9ed531908e7a661e73fe596707af46c8719b587" +class_hash = "0x194fab2764a0d823cb5aa7ef9810113952c3579700e114d409c33f954f0caf9" +original_class_hash = "0x194fab2764a0d823cb5aa7ef9810113952c3579700e114d409c33f954f0caf9" base_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" abi = "manifests/dev/deployment/abis/contracts/bytebeasts-actions-648ac931.json" reads = [] @@ -42,8 +42,8 @@ manifest_name = "bytebeasts-actions-648ac931" [[contracts]] kind = "DojoContract" address = "0x612b684f6b34356ad9a07ac3e1924f9dfa54235d0a513095b0d12695ace8b68" -class_hash = "0x56093b60a0b0aa8902f1dd09a888754a910967e4029bb70d8983ee846d4f488" -original_class_hash = "0x56093b60a0b0aa8902f1dd09a888754a910967e4029bb70d8983ee846d4f488" +class_hash = "0x42e8d9b08e8c71fee2c025922e8bcd10b9277fb688e97701f2169ca03ad91c0" +original_class_hash = "0x42e8d9b08e8c71fee2c025922e8bcd10b9277fb688e97701f2169ca03ad91c0" base_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" abi = "manifests/dev/deployment/abis/contracts/bytebeasts-battle_system-461868ac.json" reads = [] @@ -54,8 +54,51 @@ manifest_name = "bytebeasts-battle_system-461868ac" [[models]] kind = "DojoModel" -class_hash = "0x1ae435e73e2ccb909d2fc7ea7ac0def65e0e2df5cb9496caa4e08d54f2c428c" -original_class_hash = "0x1ae435e73e2ccb909d2fc7ea7ac0def65e0e2df5cb9496caa4e08d54f2c428c" +class_hash = "0x1279ba311b8f42dceefdfc2f10b1e8d524a9df7f08a0716eccc3bedf6e235da" +original_class_hash = "0x1279ba311b8f42dceefdfc2f10b1e8d524a9df7f08a0716eccc3bedf6e235da" +abi = "manifests/dev/deployment/abis/models/bytebeasts-Battle-55b5860b.json" +tag = "bytebeasts-Battle" +manifest_name = "bytebeasts-Battle-55b5860b" + +[[models.members]] +name = "battle_id" +type = "u32" +key = true + +[[models.members]] +name = "player_id" +type = "u32" +key = false + +[[models.members]] +name = "opponent_id" +type = "u32" +key = false + +[[models.members]] +name = "active_beast_player" +type = "u32" +key = false + +[[models.members]] +name = "active_beast_opponent" +type = "u32" +key = false + +[[models.members]] +name = "battle_active" +type = "u32" +key = false + +[[models.members]] +name = "turn" +type = "u32" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x7fe3d50195b0f91ee8bcbc17710f62df6f2d31732540b74b8b7dd7fc2157d9f" +original_class_hash = "0x7fe3d50195b0f91ee8bcbc17710f62df6f2d31732540b74b8b7dd7fc2157d9f" abi = "manifests/dev/deployment/abis/models/bytebeasts-Beast-27809d20.json" tag = "bytebeasts-Beast" manifest_name = "bytebeasts-Beast-27809d20" @@ -97,12 +140,12 @@ key = false [[models.members]] name = "attack" -type = "u64" +type = "u32" key = false [[models.members]] name = "defense" -type = "u64" +type = "u32" key = false [[models.members]] diff --git a/src/systems/battle.cairo b/src/systems/battle.cairo index 75ad1fd..bd5b740 100644 --- a/src/systems/battle.cairo +++ b/src/systems/battle.cairo @@ -24,6 +24,24 @@ mod battle_system { use starknet::{ContractAddress, get_caller_address}; use bytebeasts::models::{Beast, Mt, Player, Potion, Battle}; + #[derive(Copy, Drop, Serde)] + #[dojo::model] + #[dojo::event] + struct StatusBattle { + #[key] + battle_id: u32, + message: felt252, + } + + #[derive(Copy, Drop, Serde)] + #[dojo::model] + #[dojo::event] + struct Status { + #[key] + player_id: u32, + message: felt252, + } + #[abi(embed_v0)] impl BattleActionsImpl of IBattleActions { // Función para comprobar si se ha conseguido huir @@ -99,7 +117,8 @@ mod battle_system { turn: 0, }) ); - // Try to send a message to the player (emit) + let message = 'Battle started'; + emit!(world, (Status { player_id, message })); } // Función para realizar una acción @@ -114,8 +133,12 @@ mod battle_system { opponent_beast.current_hp -= damage; if opponent_beast.current_hp <= 0_u32 { + let message = 'Opponent\'s Beast Knocked Out!'; + emit!(world, (StatusBattle { battle_id, message })); battle.battle_active = 0; } else { + let message = 'Attack Performed!'; + emit!(world, (StatusBattle { battle_id, message })); self.opponent_turn(battle_id); } } @@ -129,9 +152,13 @@ mod battle_system { self.apply_item_effect(potion, player_beast); + let message = 'Item Used!'; + emit!(world, (StatusBattle { battle_id, message })); + // Turno del oponente self.opponent_turn(battle_id); } + // Función para huir fn flee(ref world: IWorldDispatcher, battle_id: u32) { let mut battle = get!(world, battle_id, (Battle)); @@ -142,8 +169,11 @@ mod battle_system { let flee_success = self.check_flee_success(player_beast, opponent_beast); if flee_success == 1 { battle.battle_active = 0; + let message = 'Player Fled!'; + emit!(world, (StatusBattle { battle_id, message })); } else { - // Turno del oponente + let message = 'Flee failed!'; + emit!(world, (StatusBattle { battle_id, message })); self.opponent_turn(battle_id); } }