Skip to content

Commit

Permalink
fix create challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinones committed Nov 1, 2024
1 parent 16ccc87 commit e6b38b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/models/status/round/challenge.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>, modifiers_index: Array<u32>) {
Expand Down
2 changes: 1 addition & 1 deletion src/systems/game_system.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e6b38b7

Please sign in to comment.