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 3022cd1 commit 920750c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/models/data/reward.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum RewardType {
SPECIAL_CARDS,
NONE
}

#[generate_trait]
impl RewardImpl of RewardTrait {
fn challenge(world: IWorldDispatcher, game_id: u32) {
Expand Down
59 changes: 52 additions & 7 deletions src/systems/player_system.cairo
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
use jokers_of_neon::models::{
status::{game::game::{Game, GameStore}, round::current_hand_card::{CurrentHandCard, CurrentHandCardTrait}}
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}
}
};

#[dojo::interface]
trait IPlayerSystem {
fn get_player_current_hand(world: @IWorldDispatcher, game_id: u32) -> Array<CurrentHandCard>;
fn get_game(world: @IWorldDispatcher, game_id: u32) -> Game;
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;
fn get_player_beast(world: @IWorldDispatcher, game_id: u32) -> PlayerBeast;
fn get_challenge(world: @IWorldDispatcher, game_id: u32) -> Challenge;
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;
}

#[dojo::contract]
mod player_system {
use jokers_of_neon::{
store::StoreTrait,
models::{
status::{game::game::{Game, GameStore}, round::current_hand_card::{CurrentHandCard, CurrentHandCardStore}}
data::{
beast::{Beast, BeastStore, GameModeBeast, GameModeBeastStore, PlayerBeast, PlayerBeastStore},
challenge::{Challenge, ChallengeStore, ChallengePlayer, ChallengePlayerStore},
reward::{Reward, RewardStore},
},
status::{
game::game::{Game, GameStore}, shop::shop::{BlisterPackResult, BlisterPackResultStore},
round::current_hand_card::{CurrentHandCard, CurrentHandCardStore}
}
}
};

#[abi(embed_v0)]
impl PokerHandSystem of super::IPlayerSystem<ContractState> {
fn get_game(world: @IWorldDispatcher, game_id: u32) -> Game {
GameStore::get(world, game_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 All @@ -34,8 +55,32 @@ mod player_system {
current_hand
}

fn get_game(world: @IWorldDispatcher, game_id: u32) -> Game {
GameStore::get(world, game_id)
fn get_beast(world: @IWorldDispatcher, game_id: u32) -> Beast {
BeastStore::get(world, game_id)
}

fn get_player_beast(world: @IWorldDispatcher, game_id: u32) -> PlayerBeast {
PlayerBeastStore::get(world, game_id)
}

fn get_game_mode_beast(world: @IWorldDispatcher, game_id: u32) -> GameModeBeast {
GameModeBeastStore::get(world, game_id)
}

fn get_challenge(world: @IWorldDispatcher, game_id: u32) -> Challenge {
ChallengeStore::get(world, game_id)
}

fn get_challenge_player(world: @IWorldDispatcher, game_id: u32) -> ChallengePlayer {
ChallengePlayerStore::get(world, game_id)
}

fn get_reward(world: @IWorldDispatcher, game_id: u32) -> Reward {
RewardStore::get(world, game_id)
}

fn get_blister_pack_result(world: @IWorldDispatcher, game_id: u32) -> BlisterPackResult {
BlisterPackResultStore::get(world, game_id)
}
}
}

0 comments on commit 920750c

Please sign in to comment.