Skip to content

Commit

Permalink
Merge branch 'main' into challenge-replay-logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzn authored Nov 3, 2024
2 parents 20eaafa + 96a31a0 commit c0bf4e5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
36 changes: 16 additions & 20 deletions src/constants/specials.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ fn specials_ids_all() -> Array<u32> {
SPECIAL_MULTI_FOR_CLUB_ID,
SPECIAL_MULTI_FOR_DIAMOND_ID,
SPECIAL_MULTI_FOR_SPADE_ID,
SPECIAL_INCREASE_LEVEL_PAIR_ID,
SPECIAL_INCREASE_LEVEL_DOUBLE_PAIR_ID,
SPECIAL_INCREASE_LEVEL_STRAIGHT_ID,
SPECIAL_INCREASE_LEVEL_FLUSH_ID,
// SPECIAL_INCREASE_LEVEL_PAIR_ID,
// SPECIAL_INCREASE_LEVEL_DOUBLE_PAIR_ID,
// SPECIAL_INCREASE_LEVEL_STRAIGHT_ID,
// SPECIAL_INCREASE_LEVEL_FLUSH_ID,
SPECIAL_STRAIGHT_WITH_FOUR_CARDS_ID,
SPECIAL_FLUSH_WITH_FOUR_CARDS_ID,
SPECIAL_JOKER_BOOSTER_ID,
Expand All @@ -269,33 +269,28 @@ fn specials_ids_all() -> Array<u32> {
SPECIAL_HAND_THIEF_ID,
SPECIAL_EXTRA_HELP_ID,
SPECIAL_LUCKY_SEVEN_ID,
SPECIAL_NEON_BONUS_ID,
SPECIAL_DEADLINE_ID,
// SPECIAL_NEON_BONUS_ID,
// SPECIAL_DEADLINE_ID,
SPECIAL_INITIAL_ADVANTAGE_ID,
SPECIAL_LUCKY_HAND_ID,
// SPECIAL_LUCKY_HAND_ID,
]
}

fn common_specials_ids() -> Array<u32> {
array![
SPECIAL_MULTI_FOR_HEART_ID,
SPECIAL_MULTI_FOR_CLUB_ID,
SPECIAL_MULTI_FOR_DIAMOND_ID,
SPECIAL_MULTI_FOR_SPADE_ID,
SPECIAL_INCREASE_LEVEL_PAIR_ID,
SPECIAL_INCREASE_LEVEL_DOUBLE_PAIR_ID,
SPECIAL_LUCKY_HAND_ID,
SPECIAL_MULTI_FOR_HEART_ID, SPECIAL_MULTI_FOR_CLUB_ID, SPECIAL_MULTI_FOR_DIAMOND_ID, SPECIAL_MULTI_FOR_SPADE_ID,
// SPECIAL_INCREASE_LEVEL_PAIR_ID,
// SPECIAL_INCREASE_LEVEL_DOUBLE_PAIR_ID,
// SPECIAL_LUCKY_HAND_ID,
]
}

fn uncommon_specials_ids() -> Array<u32> {
array![
SPECIAL_INCREASE_LEVEL_STRAIGHT_ID,
SPECIAL_INCREASE_LEVEL_FLUSH_ID,
array![ // SPECIAL_INCREASE_LEVEL_STRAIGHT_ID,
// SPECIAL_INCREASE_LEVEL_FLUSH_ID,
SPECIAL_STRAIGHT_WITH_FOUR_CARDS_ID,
SPECIAL_FLUSH_WITH_FOUR_CARDS_ID,
SPECIAL_MULTI_ACES_ID,
SPECIAL_NEON_BONUS_ID
SPECIAL_MULTI_ACES_ID, // SPECIAL_NEON_BONUS_ID
]
}

Expand All @@ -304,7 +299,8 @@ fn rare_specials_ids() -> Array<u32> {
}

fn epic_specials_ids() -> Array<u32> {
array![SPECIAL_EXTRA_HELP_ID, SPECIAL_JOKER_BOOSTER_ID, SPECIAL_DEADLINE_ID]
array![SPECIAL_EXTRA_HELP_ID, SPECIAL_JOKER_BOOSTER_ID, // SPECIAL_DEADLINE_ID
]
}

fn legendary_specials_ids() -> Array<u32> {
Expand Down
50 changes: 35 additions & 15 deletions src/models/status/round/beast.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,15 @@ fn _attack_beast(
ref beast: Beast,
ref game_mode_beast: GameModeBeast
) {
emit!(world, (BeastAttack { player: get_caller_address(), attack: beast.attack }));
game
.current_player_hp =
if beast.attack > game.current_player_hp {
0
} else {
game.current_player_hp - beast.attack
};
let mut randomizer = RandomImpl::new(world);
let beast_dmg = randomizer.between::<u32>(0, 5 * game.level) + beast.attack;

game.current_player_hp = if beast_dmg > game.current_player_hp {
0
} else {
game.current_player_hp - beast_dmg
};
emit!(world, (BeastAttack { player: get_caller_address(), attack: beast_dmg }));

if game.current_player_hp.is_zero() {
let play_game_over_event = PlayGameOverEvent { player: get_caller_address(), game_id: game.id };
Expand Down Expand Up @@ -286,12 +287,31 @@ fn _create_beast(world: IWorldDispatcher, game_id: u32, level: u8) {
}

fn _generate_stats(level: u8) -> (u8, u32, u32) { // tier, health, attack
match level {
0 => (0, 0, 0),
1 => (1, 300, 15),
2 => (1, 600, 25),
3 => (1, 900, 35),
4 => (1, 1200, 45),
_ => (2, 2000, 50),
if level <= 4 {
(0, _calculate_beast_hp(level), 10)
} else if level <= 8 {
(2, _calculate_beast_hp(level), 20)
} else if level <= 12 {
(3, _calculate_beast_hp(level), 30)
} else if level <= 16 {
(4, _calculate_beast_hp(level), 40)
} else {
(5, _calculate_beast_hp(level), 50)
}
}

fn _calculate_beast_hp(level: u8) -> u32 {
if level <= 2 {
300 * level
} else if level <= 10 {
600 * level - 600
} else if level <= 20 {
1200 * level - 6600
} else if level <= 25 {
3000 * level - 42600
} else if level <= 30 {
7000 * level - 142600
} else {
20000 * level - 532600
}
}
12 changes: 7 additions & 5 deletions src/models/status/round/challenge.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ impl ChallengeImpl of ChallengeTrait {
challenge_player.plays -= 1;
emit!(world, (challenge_player));
if challenge_player.plays.is_zero() {
game.current_player_hp = if game.current_player_hp <= 5 * game.level {
0
} else {
game.current_player_hp - 5 * game.level
};
game
.current_player_hp =
if game.current_player_hp <= 5 * game.level {
0
} else {
game.current_player_hp - 5 * game.level
};

if game.current_player_hp.is_zero() {
let play_game_over_event = PlayGameOverEvent { player: get_caller_address(), game_id: game.id };
Expand Down

0 comments on commit c0bf4e5

Please sign in to comment.