Skip to content

Commit

Permalink
JON-467: Add JN beasts (#26)
Browse files Browse the repository at this point in the history
* wip beast jn

* power up jn beast

* fix challenge

* add GameStore

---------

Co-authored-by: dub_zn <[email protected]>
  • Loading branch information
dpinones and dubzn authored Nov 4, 2024
1 parent 957c914 commit fbb3be6
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 10 deletions.
99 changes: 98 additions & 1 deletion src/constants/beast.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ const WRAITH_BEAST_ID: u32 = 73;
const WYVERN_BEAST_ID: u32 = 74;
const YETI_BEAST_ID: u32 = 75;

fn all_beast() -> Array<u32> {
const JACK_BEAST_ID: u32 = 101;
const QUEEN_BEAST_ID: u32 = 102;
const KING_BEAST_ID: u32 = 103;
const JOKER_BEAST_ID: u32 = 104;
const NEON_JACK_BEAST_ID: u32 = 105;
const NEON_QUEEN_BEAST_ID: u32 = 106;
const NEON_KING_BEAST_ID: u32 = 107;
const NEON_JOKER_BEAST_ID: u32 = 108;

fn beast_loot_survivor() -> Array<u32> {
array![
AMMIT_BEAST_ID,
ANANSI_BEAST_ID,
Expand Down Expand Up @@ -154,6 +163,94 @@ fn all_beast() -> Array<u32> {
]
}

fn all_beast() -> Array<u32> {
array![
AMMIT_BEAST_ID,
ANANSI_BEAST_ID,
BALROG_BEAST_ID,
BANSHEE_BEAST_ID,
BASILISK_BEAST_ID,
BEAR_BEAST_ID,
BEHEMOTH_BEAST_ID,
BERSERKER_BEAST_ID,
BIGFOOT_BEAST_ID,
CHIMERA_BEAST_ID,
CHUPACABRA_BEAST_ID,
COLOSSUS_BEAST_ID,
CYCLOPS_BEAST_ID,
DIREWOLF_BEAST_ID,
DRAGON_BEAST_ID,
DRAUGR_BEAST_ID,
ENT_BEAST_ID,
ETTIN_BEAST_ID,
FAIRY_BEAST_ID,
FENRIR_BEAST_ID,
GHOUL_BEAST_ID,
GIANT_BEAST_ID,
GNOME_BEAST_ID,
GOBLIN_BEAST_ID,
GOLEM_BEAST_ID,
GORGON_BEAST_ID,
GRIFFIN_BEAST_ID,
HARPY_BEAST_ID,
HIPPOGRIFF_BEAST_ID,
HYDRA_BEAST_ID,
JAGUAR_BEAST_ID,
JIANGSHI_BEAST_ID,
JOTUNN_BEAST_ID,
JUGGERNAUT_BEAST_ID,
KAPPA_BEAST_ID,
KELPIE_BEAST_ID,
KITSUNE_BEAST_ID,
KRAKEN_BEAST_ID,
LEPRECHAUN_BEAST_ID,
LEVIATHAN_BEAST_ID,
LICH_BEAST_ID,
MANTICORE_BEAST_ID,
MANTIS_BEAST_ID,
MINOTAUR_BEAST_ID,
NEMEANLION_BEAST_ID,
NEPHILIM_BEAST_ID,
NUE_BEAST_ID,
OGRE_BEAST_ID,
ONI_BEAST_ID,
ORC_BEAST_ID,
PEGASUS_BEAST_ID,
PHOENIX_BEAST_ID,
PIXIE_BEAST_ID,
QILIN_BEAST_ID,
RAKSHASA_BEAST_ID,
RAT_BEAST_ID,
ROC_BEAST_ID,
SATORI_BEAST_ID,
SKELETON_BEAST_ID,
SKINWALKER_BEAST_ID,
SPIDER_BEAST_ID,
SPRITE_BEAST_ID,
TARRASQUE_BEAST_ID,
TITAN_BEAST_ID,
TROLL_BEAST_ID,
TYPHON_BEAST_ID,
VAMPIRE_BEAST_ID,
WARLOCK_BEAST_ID,
WENDIGO_BEAST_ID,
WERETIGER_BEAST_ID,
WEREWOLF_BEAST_ID,
WOLF_BEAST_ID,
WRAITH_BEAST_ID,
WYVERN_BEAST_ID,
YETI_BEAST_ID,
JACK_BEAST_ID,
QUEEN_BEAST_ID,
KING_BEAST_ID,
JOKER_BEAST_ID,
NEON_JACK_BEAST_ID,
NEON_QUEEN_BEAST_ID,
NEON_KING_BEAST_ID,
NEON_JOKER_BEAST_ID
]
}

fn is_loot_survivor_beast(beast_id: u32) -> bool {
beast_id <= YETI_BEAST_ID
}
32 changes: 23 additions & 9 deletions src/models/status/round/beast.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::nullable::NullableTrait;
use dojo::world::Resource::Contract;
use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait};
use jokers_of_neon::constants::beast::{all_beast, is_loot_survivor_beast};
use jokers_of_neon::constants::beast::{all_beast, beast_loot_survivor, is_loot_survivor_beast};
use jokers_of_neon::constants::card::INVALID_CARD;
use jokers_of_neon::models::data::beast::{
GameModeBeast, GameModeBeastStore, Beast, BeastStore, PlayerBeast, PlayerBeastStore, TypeBeast
Expand Down Expand Up @@ -274,8 +274,13 @@ fn _attack_beast(

fn _create_beast(world: IWorldDispatcher, game_id: u32, level: u8) {
let mut randomizer = RandomImpl::new(world);
let beast_id = randomizer.between::<u32>(0, all_beast().len() - 1);
let (tier, health, attack) = _generate_stats(level);

let beast_id = if level < 10 {
*beast_loot_survivor()[randomizer.between::<u32>(0, beast_loot_survivor().len() - 1)]
} else {
*all_beast()[randomizer.between::<u32>(0, all_beast().len() - 1)]
};
let (tier, health, attack) = _generate_stats(level, beast_id);
let type_beast = if is_loot_survivor_beast(beast_id) {
TypeBeast::LOOT_SURVIVOR
} else {
Expand All @@ -286,17 +291,26 @@ fn _create_beast(world: IWorldDispatcher, game_id: u32, level: u8) {
emit!(world, (beast));
}

fn _generate_stats(level: u8) -> (u8, u32, u32) { // tier, health, attack
// tier, health, attack
fn _generate_stats(level: u8, beast_id: u32) -> (u8, u32, u32) {
let mut stats = (0, 0, 0);
if level <= 4 {
(0, _calculate_beast_hp(level), 10)
stats = (0, _calculate_beast_hp(level), 10)
} else if level <= 8 {
(2, _calculate_beast_hp(level), 20)
stats = (2, _calculate_beast_hp(level), 20)
} else if level <= 12 {
(3, _calculate_beast_hp(level), 30)
stats = (3, _calculate_beast_hp(level), 30)
} else if level <= 16 {
(4, _calculate_beast_hp(level), 40)
stats = (4, _calculate_beast_hp(level), 40)
} else {
stats = (5, _calculate_beast_hp(level), 50)
}

if beast_id >= 101 && beast_id <= 108 {
let (tier, health, attack) = stats;
(tier, health + (health / 10), attack + 20)
} else {
(5, _calculate_beast_hp(level), 50)
stats
}
}

Expand Down
1 change: 1 addition & 0 deletions src/models/status/round/challenge.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl ChallengeImpl of ChallengeTrait {
challenge_player.plays -= 1;
ChallengePlayerStore::set(@challenge_player, world);
emit!(world, (challenge_player));
ChallengePlayerStore::set(@challenge_player, world);
if challenge_player.plays.is_zero() {
game
.current_player_hp =
Expand Down

0 comments on commit fbb3be6

Please sign in to comment.