From e6b38b7745243dabf570f136c946d6f30927bdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Pi=C3=B1ones?= Date: Thu, 31 Oct 2024 23:56:13 -0300 Subject: [PATCH 1/2] fix create challenge --- src/models/status/round/challenge.cairo | 8 +++++++- src/systems/game_system.cairo | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/models/status/round/challenge.cairo b/src/models/status/round/challenge.cairo index 848677f..2cf3e6b 100644 --- a/src/models/status/round/challenge.cairo +++ b/src/models/status/round/challenge.cairo @@ -40,11 +40,17 @@ mod errors { #[generate_trait] impl ChallengeImpl of ChallengeTrait { - fn create(world: IWorldDispatcher, game_id: u32) { + fn create(world: IWorldDispatcher, ref store: Store, game_id: u32) { + let mut game = store.get_game(game_id); + let mut challenge = ChallengeStore::get(world, game_id); challenge.active_ids = generate_unique_random_values(world, 3, challenges_all(), array![]).span(); ChallengeStore::set(@challenge, world); emit!(world, (challenge)); + + let mut game_deck = GameDeckStore::get(world, game_id); + game_deck.restore(world); + CurrentHandCardTrait::create(world, game); } fn play(world: IWorldDispatcher, game_id: u32, cards_index: Array, modifiers_index: Array) { diff --git a/src/systems/game_system.cairo b/src/systems/game_system.cairo index 3f8afba..31f4742 100644 --- a/src/systems/game_system.cairo +++ b/src/systems/game_system.cairo @@ -123,7 +123,7 @@ mod game_system { game.substate = LevelTrait::calculate(world, game_id); match game.substate { GameSubState::BEAST => { BeastTrait::create(world, ref store, game_id); }, - GameSubState::OBSTACLE => { ChallengeTrait::create(world, game_id); }, + GameSubState::OBSTACLE => { ChallengeTrait::create(world, ref store, game_id); }, GameSubState::CREATE_LEVEL => {}, } store.set_game(game); From 9640a840371eb005cc5cf05a8acf5412ee1e4464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Pi=C3=B1ones?= Date: Fri, 1 Nov 2024 08:47:19 -0300 Subject: [PATCH 2/2] add challenge player --- src/models/status/round/challenge.cairo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/models/status/round/challenge.cairo b/src/models/status/round/challenge.cairo index 2cf3e6b..dfa56cf 100644 --- a/src/models/status/round/challenge.cairo +++ b/src/models/status/round/challenge.cairo @@ -16,7 +16,7 @@ use jokers_of_neon::constants::{ use jokers_of_neon::{ models::{ data::{ - challenge::{Challenge, ChallengeStore, ChallengePlayerStore}, card::{Card, Suit, Value}, + challenge::{Challenge, ChallengeStore, ChallengePlayer, ChallengePlayerStore}, card::{Card, Suit, Value}, game_deck::{GameDeckStore, GameDeckImpl}, events::{ChallengeCompleted, PlayGameOverEvent, ModifierCardSuitEvent, SpecialModifierSuitEvent}, poker_hand::PokerHand @@ -48,6 +48,9 @@ impl ChallengeImpl of ChallengeTrait { ChallengeStore::set(@challenge, world); emit!(world, (challenge)); + let challenge_player = ChallengePlayer { game_id, discards: 5, plays: 5 }; + ChallengePlayerStore::set(@challenge_player, world); + let mut game_deck = GameDeckStore::get(world, game_id); game_deck.restore(world); CurrentHandCardTrait::create(world, game);