Skip to content

Commit

Permalink
fix redirect game beast
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinones committed Nov 1, 2024
1 parent 076e4ca commit c9052b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/configs/level.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct LevelConfig {
impl LevelConfigDefault of Default<LevelConfig> {
fn default() -> LevelConfig {
LevelConfig {
initial_probability: 35, increment_by_round: 15, min_round_level_before_activate: 3, level_cooldown: 2
initial_probability: 35, increment_by_round: 15, min_round_level_before_activate: 1, level_cooldown: 1
}
}
}
4 changes: 4 additions & 0 deletions src/models/status/round/level.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ impl LevelImpl of LevelTrait {
let mut last_active_level = LastBeastLevelStore::get(world, game_id);

if game.level <= level_config.min_round_level_before_activate.into() {
println!("dale 1");
return GameSubState::OBSTACLE;
}

if last_active_level.level != 0 && game.level
- last_active_level.level.into() <= level_config.level_cooldown.try_into().unwrap() {
println!("dale 2");
return GameSubState::OBSTACLE;
}

let mut randomizer = RandomImpl::new(world);
let random = randomizer.between::<u16>(0, 100);
if random <= last_active_level.current_probability {
println!("dale 3");
last_active_level.level = game.level.try_into().unwrap();
last_active_level.current_probability = level_config.initial_probability;
LastBeastLevelStore::set(@last_active_level, world);

GameSubState::BEAST
} else {
println!("dale 4");
if last_active_level.current_probability + level_config.increment_by_round <= 100 {
last_active_level.current_probability = last_active_level.current_probability
+ level_config.increment_by_round;
Expand Down
9 changes: 8 additions & 1 deletion src/systems/game_system.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mod game_system {
SpecialCashEvent
};
use jokers_of_neon::models::data::game_deck::{GameDeckStore, GameDeckImpl};
use jokers_of_neon::models::data::last_beast_level::{LastBeastLevel, LastBeastLevelStore};
use jokers_of_neon::models::data::poker_hand::{LevelPokerHand, PokerHand};
use jokers_of_neon::models::status::game::game::{Game, GameState, GameSubState};
use jokers_of_neon::models::status::game::rage::{RageRound, RageRoundStore};
Expand All @@ -63,7 +64,6 @@ mod game_system {
use jokers_of_neon::models::status::round::current_hand_card::{CurrentHandCard, CurrentHandCardTrait};
use jokers_of_neon::models::status::round::level::LevelTrait;
use jokers_of_neon::models::status::shop::shop::{BlisterPackResult};

use jokers_of_neon::store::{Store, StoreTrait};
use jokers_of_neon::systems::rage_system::{IRageSystemDispatcher, IRageSystemDispatcherTrait};
use jokers_of_neon::utils::calculate_hand::calculate_hand;
Expand Down Expand Up @@ -108,6 +108,12 @@ mod game_system {
store.set_game(game);
emit!(world, (game));

let level_config = store.get_level_config();
LastBeastLevelStore::set(
@LastBeastLevel { game_id: game_id, current_probability: level_config.initial_probability, level: 0 },
world
);

let create_game_event = CreateGameEvent { player: get_caller_address(), game_id };
emit!(world, (create_game_event));
game_id
Expand All @@ -127,6 +133,7 @@ mod game_system {
GameSubState::OBSTACLE => { ChallengeTrait::create(world, ref store, game_id); },
GameSubState::CREATE_LEVEL => {},
}
game.level += 1;
store.set_game(game);
}

Expand Down

0 comments on commit c9052b3

Please sign in to comment.