From 73f5f45c583095e6cbc3bbc6a5b4d67696e9cadc Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Tue, 5 Mar 2024 11:02:13 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20Battle=20events=20for=20remai?= =?UTF-8?q?ning=20dices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/tile.cairo | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/models/tile.cairo b/src/models/tile.cairo index 6e13c52..e48f227 100644 --- a/src/models/tile.cairo +++ b/src/models/tile.cairo @@ -339,6 +339,42 @@ fn _duel( duel_id += 1; }; + loop { + if offensive.is_empty() { + break; + }; + let offensive_value = *offensive.pop_front().unwrap(); + let battle = Battle { + game_id: 0, + nonce: 0, + battle_id: battle_id, + duel_id: duel_id, + attacker_index: 0, + defender_index: 0, + attacker_value: offensive_value, + defender_value: 0, + }; + battles.append(battle); + }; + + loop { + if defensive.is_empty() { + break; + }; + let defensive_value = *defensive.pop_front().unwrap(); + let battle = Battle { + game_id: 0, + nonce: 0, + battle_id: battle_id, + duel_id: duel_id, + attacker_index: 0, + defender_index: 0, + attacker_value: 0, + defender_value: defensive_value, + }; + battles.append(battle); + }; + (defensive_losses, offensive_losses) } @@ -657,7 +693,7 @@ mod tests { } #[test] - #[available_gas(1_200_000)] + #[available_gas(2_000_000)] fn test_tile_attack_and_defend_win() { let mut battles: Array = array![]; let mut attacker = TileTrait::new(GAME_ID, 1, 10, PLAYER_1);