Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions contracts/battle/app/src/services/game/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub async fn create_new_battle(
dodge,
player_id,
msg_value,
msg_src,
)
.await;
if reply.is_err() {
Expand All @@ -100,6 +101,7 @@ async fn create(
dodge: u16,
player_id: ActorId,
msg_value: u128,
msg_src: ActorId,
) -> Result<Event, BattleError> {
let time_creation = exec::block_timestamp();
check_player_settings(attack, defence, dodge, &storage.config)?;
Expand Down Expand Up @@ -149,6 +151,8 @@ async fn create(
Ok(Event::NewBattleCreated {
battle_id: player_id,
bid: msg_value,
user_id: msg_src,
user_name,
})
}

Expand Down Expand Up @@ -176,7 +180,7 @@ pub async fn battle_registration(

let reply = register(
storage, admin_id, warrior_id, appearance, user_name, attack, defence, dodge, player_id,
msg_value,
msg_value, msg_src
)
.await;
if reply.is_err() {
Expand All @@ -196,6 +200,7 @@ async fn register(
dodge: u16,
player_id: ActorId,
msg_value: u128,
msg_src: ActorId,
) -> Result<Event, BattleError> {
check_player_settings(attack, defence, dodge, &storage.config)?;

Expand All @@ -219,7 +224,7 @@ async fn register(
if battle.state != State::Registration {
return Err(BattleError::WrongState);
}
if battle.participants.len() >= storage.config.max_participants.into() {
if battle.participants.len() >= storage.config.max_participants as usize {
return Err(BattleError::BattleFull);
}
if battle.bid != msg_value {
Expand Down Expand Up @@ -255,6 +260,7 @@ async fn register(
Ok(Event::PlayerRegistered {
admin_id,
user_name,
user_id: msg_src,
bid: msg_value,
})
}
Expand Down
3 changes: 3 additions & 0 deletions contracts/battle/app/src/services/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ pub enum Event {
NewBattleCreated {
battle_id: ActorId,
bid: u128,
user_id: ActorId,
user_name: String,
},
PlayerRegistered {
admin_id: ActorId,
user_id: ActorId,
user_name: String,
bid: u128,
},
Expand Down
Loading