Skip to content

Commit

Permalink
check if lobby is fullfilled after await
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul committed Jan 20, 2024
1 parent 1e8452a commit 94565c9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions contracts/arena/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@ impl Arena {
}

pub async fn register(&mut self, lobby_id: u128, owner_id: ActorId) {
let lobby = self.lobbys.get_mut(&lobby_id).expect("lobby isn't found");

if lobby.characters.len() == lobby.capacity.size.into() {
panic!("max number of players is already registered");
}

let payload = MintAction::CharacterInfo { owner_id };
let character_info: CharacterInfo = msg::send_for_reply_as(self.mint, payload, 0, 0)
.expect("unable to send message")
.await
.expect("unable to receive reply");

let lobby = self.lobbys.get_mut(&lobby_id).expect("lobby isn't found");

if lobby.characters.len() == lobby.capacity.size.into() {
panic!("max number of players is already registered");
}

let character = Character {
owner: owner_id,
id: character_info.id,
Expand Down

0 comments on commit 94565c9

Please sign in to comment.