Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix battle contract #499

Merged
merged 6 commits into from
Nov 1, 2024
Merged
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
19 changes: 1 addition & 18 deletions contracts/battle/app/src/services/game/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,6 @@ impl Battle {
}
}

pub fn delete_players(&mut self, loser_1: &ActorId, loser_2: &ActorId, pair_id: u16) {
let player_loser_1 = self
.participants
.remove(loser_1)
.expect("The player must exist");
let player_loser_2 = self
.participants
.remove(loser_2)
.expect("The player must exist");

self.defeated_participants.insert(*loser_1, player_loser_1);
self.defeated_participants.insert(*loser_2, player_loser_2);

self.pairs.remove(&pair_id);
self.players_to_pairs.remove(loser_1);
self.players_to_pairs.remove(loser_2);
}

pub fn check_min_player_amount(&self) -> Result<(), BattleError> {
if self.participants.len() <= 1 {
return Err(BattleError::NotEnoughPlayers);
Expand Down Expand Up @@ -183,6 +165,7 @@ impl Battle {
self.pairs.insert(self.pair_id, pair);
self.players_to_pairs.insert(player.owner, self.pair_id);
self.waiting_player = Some((player.owner, self.pair_id));
self.pair_id += 1;
}
}
pub fn send_delayed_message_make_move_from_reservation(&mut self, time_for_move: u32) {
Expand Down