diff --git a/manifests/dev/base/abis/contracts/bytebeasts-battle_system-461868ac.json b/manifests/dev/base/abis/contracts/bytebeasts-battle_system-461868ac.json index 5f6fb4e..2b4a2e8 100644 --- a/manifests/dev/base/abis/contracts/bytebeasts-battle_system-461868ac.json +++ b/manifests/dev/base/abis/contracts/bytebeasts-battle_system-461868ac.json @@ -131,6 +131,72 @@ "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::u64" + }, + { + "name": "defense", + "type": "core::integer::u64" + }, + { + "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": "interface", "name": "bytebeasts::systems::battle::IBattleActions", @@ -150,6 +216,26 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "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" } ] }, diff --git a/manifests/dev/base/contracts/bytebeasts-battle_system-461868ac.toml b/manifests/dev/base/contracts/bytebeasts-battle_system-461868ac.toml index 2570f2d..42903d7 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 = "0x26ce110d44d925e05ce62603ad698824266db3199eb9a549e996cd94b94dd73" -original_class_hash = "0x26ce110d44d925e05ce62603ad698824266db3199eb9a549e996cd94b94dd73" +class_hash = "0x43222893b3ed91744967f9971ca278b217e57668303c343fc9b9abbaead14c1" +original_class_hash = "0x43222893b3ed91744967f9971ca278b217e57668303c343fc9b9abbaead14c1" base_class_hash = "0x0" abi = "manifests/dev/base/abis/contracts/bytebeasts-battle_system-461868ac.json" reads = [] diff --git a/src/systems/battle.cairo b/src/systems/battle.cairo index b572025..4f22b42 100644 --- a/src/systems/battle.cairo +++ b/src/systems/battle.cairo @@ -9,6 +9,7 @@ use bytebeasts::models::Battle; #[dojo::interface] trait IBattleActions { fn init_battle(ref world: IWorldDispatcher, player_id: u32, opponent_id: u32); + fn check_flee_success(player_beast: Beast, opponent_beast: Beast) -> felt252; } #[dojo::contract] @@ -37,6 +38,15 @@ mod battle_system { turn: 0, }) ); + // Try to send a message to the player (emit) } + + fn check_flee_success(player_beast: Beast, opponent_beast: Beast) -> felt252 { + if player_beast.level > opponent_beast.level { + 1 // Success + } else { + 0 // Fail + } + } } }