Skip to content

Commit

Permalink
check_flee_success compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandoDrRobot committed Aug 20, 2024
1 parent 86479e5 commit 82e35ff
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = []
Expand Down
10 changes: 10 additions & 0 deletions src/systems/battle.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
}
}
}

0 comments on commit 82e35ff

Please sign in to comment.