Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JON-494: Balance beast stats #25

Merged
merged 3 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
26 changes: 20 additions & 6 deletions src/models/status/round/challenge.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ChallengeImpl of ChallengeTrait {
ChallengeStore::set(@challenge, world);
emit!(world, (challenge));

let challenge_player = ChallengePlayer { game_id, discards: 5, plays: 5 };
let challenge_player = ChallengePlayer { game_id, discards: game.max_discard, plays: game.max_hands };
ChallengePlayerStore::set(@challenge_player, world);
emit!(world, (challenge_player));

Expand Down Expand Up @@ -93,13 +93,27 @@ impl ChallengeImpl of ChallengeTrait {
} else {
challenge_player.plays -= 1;
emit!(world, (challenge_player));
ChallengePlayerStore::set(@challenge_player, world);
if challenge_player.plays.is_zero() {
let play_game_over_event = PlayGameOverEvent { player: get_caller_address(), game_id: game.id };
emit!(world, (play_game_over_event));
game.state = GameState::FINISHED;
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 };
emit!(world, (play_game_over_event));
game.state = GameState::FINISHED;
return;
}
challenge_player.discards = game.max_discard;
challenge_player.plays = game.max_hands;

ChallengePlayerStore::set(@challenge_player, world);
emit!(world, (challenge_player));
GameStore::set(@game, world);
return;
}

let mut cards = array![];
Expand Down
Loading