Skip to content

Commit

Permalink
add extra functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzn committed Nov 7, 2024
1 parent 920750c commit da3ad70
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/systems/player_system.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
use jokers_of_neon::{
models::{
data::{beast::{GameModeBeast, Beast, PlayerBeast}, challenge::{Challenge, ChallengePlayer}, reward::Reward,},
status::{game::game::Game, shop::shop::BlisterPackResult, round::current_hand_card::CurrentHandCard}
data::{
adventurer::AdventurerConsumed, beast::{GameModeBeast, Beast, PlayerBeast},
challenge::{Challenge, ChallengePlayer}, reward::Reward,
},
status::{
game::game::{Game, CurrentSpecialCards}, shop::shop::BlisterPackResult,
round::current_hand_card::CurrentHandCard
}
}
};

#[dojo::interface]
trait IPlayerSystem {
fn get_game(world: @IWorldDispatcher, game_id: u32) -> Game;
fn get_adventurer(world: @IWorldDispatcher, adventurer_id: u32) -> AdventurerConsumed;
fn get_player_current_hand(world: @IWorldDispatcher, game_id: u32) -> Array<CurrentHandCard>;
fn get_game_mode_beast(world: @IWorldDispatcher, game_id: u32) -> GameModeBeast;
fn get_beast(world: @IWorldDispatcher, game_id: u32) -> Beast;
Expand All @@ -16,19 +23,21 @@ trait IPlayerSystem {
fn get_challenge_player(world: @IWorldDispatcher, game_id: u32) -> ChallengePlayer;
fn get_reward(world: @IWorldDispatcher, game_id: u32) -> Reward;
fn get_blister_pack_result(world: @IWorldDispatcher, game_id: u32) -> BlisterPackResult;
fn get_current_special_cards(world: @IWorldDispatcher, game_id: u32) -> Array<CurrentSpecialCards>;
}

#[dojo::contract]
mod player_system {
use jokers_of_neon::{
models::{
data::{
adventurer::{AdventurerConsumed, AdventurerConsumedStore},
beast::{Beast, BeastStore, GameModeBeast, GameModeBeastStore, PlayerBeast, PlayerBeastStore},
challenge::{Challenge, ChallengeStore, ChallengePlayer, ChallengePlayerStore},
reward::{Reward, RewardStore},
},
status::{
game::game::{Game, GameStore}, shop::shop::{BlisterPackResult, BlisterPackResultStore},
game::game::{Game, GameStore, CurrentSpecialCards, CurrentSpecialCardsStore}, shop::shop::{BlisterPackResult, BlisterPackResultStore},
round::current_hand_card::{CurrentHandCard, CurrentHandCardStore}
}
}
Expand All @@ -40,6 +49,10 @@ mod player_system {
GameStore::get(world, game_id)
}

fn get_adventurer(world: @IWorldDispatcher, adventurer_id: u32) -> AdventurerConsumed {
AdventurerConsumedStore::get(world, adventurer_id)
}

fn get_player_current_hand(world: @IWorldDispatcher, game_id: u32) -> Array<CurrentHandCard> {
let mut current_hand = array![];
let game = GameStore::get(world, game_id);
Expand Down Expand Up @@ -82,5 +95,20 @@ mod player_system {
fn get_blister_pack_result(world: @IWorldDispatcher, game_id: u32) -> BlisterPackResult {
BlisterPackResultStore::get(world, game_id)
}

fn get_current_special_cards(world: @IWorldDispatcher, game_id: u32) -> Array<CurrentSpecialCards> {
let mut special_cards = array![];
let game = GameStore::get(world, game_id);

let mut i = 0;
loop {
if i == game.len_current_special_cards {
break;
}
special_cards.append(CurrentSpecialCardsStore::get(world, game_id, i));
i += 1;
};
special_cards
}
}
}

0 comments on commit da3ad70

Please sign in to comment.