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-447: Challenge #1

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ move = "./scripts/move.sh"
deploy-sepolia = "rm -rf ./manifest/sepolia && sozo --profile sepolia clean && sozo --profile sepolia build && sozo --profile sepolia migrate plan && sozo --profile sepolia migrate apply"

[dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.19" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.16" }
alexandria_sorting = { git = "https://github.com/dubzn/quaireaux.git", branch = "main" }

[profile.prod]
Expand Down
69 changes: 69 additions & 0 deletions src/constants/challenge.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const CHALLENGE_ROYAL_FLUSH: u32 = 1;
const CHALLENGE_STRAIGHT_FLUSH: u32 = 2;
const CHALLENGE_FIVE_OF_A_KIND: u32 = 3;
const CHALLENGE_FOUR_OF_A_KIND: u32 = 4;
const CHALLENGE_FULL_HOUSE: u32 = 5;
const CHALLENGE_FLUSH: u32 = 6;
const CHALLENGE_STRAIGHT: u32 = 7;
const CHALLENGE_THREE_OF_A_KIND: u32 = 8;
const CHALLENGE_DOUBLE_PAIR: u32 = 9;
const CHALLENGE_PAIR: u32 = 10;
const CHALLENGE_HIGH_CARD: u32 = 11;

const CHALLENGE_HEARTS: u32 = 12;
const CHALLENGE_CLUBS: u32 = 13;
const CHALLENGE_DIAMONDS: u32 = 14;
const CHALLENGE_SPADES: u32 = 15;

const CHALLENGE_ONE: u32 = 16;
const CHALLENGE_TWO: u32 = 17;
const CHALLENGE_THREE: u32 = 18;
const CHALLENGE_FOUR: u32 = 19;
const CHALLENGE_FIVE: u32 = 20;
const CHALLENGE_SIX: u32 = 21;
const CHALLENGE_SEVEN: u32 = 22;
const CHALLENGE_EIGHT: u32 = 23;
const CHALLENGE_NINE: u32 = 24;
const CHALLENGE_TEN: u32 = 25;
const CHALLENGE_JACK: u32 = 26;
const CHALLENGE_QUEEN: u32 = 27;
const CHALLENGE_KING: u32 = 28;
const CHALLENGE_ACE: u32 = 29;

const CHALLENGE_JOKER: u32 = 30;


fn challenges_all() -> Array<u32> {
array![
CHALLENGE_ROYAL_FLUSH,
CHALLENGE_STRAIGHT_FLUSH,
CHALLENGE_FIVE_OF_A_KIND,
CHALLENGE_FOUR_OF_A_KIND,
CHALLENGE_FULL_HOUSE,
CHALLENGE_FLUSH,
CHALLENGE_STRAIGHT,
CHALLENGE_THREE_OF_A_KIND,
CHALLENGE_DOUBLE_PAIR,
CHALLENGE_PAIR,
CHALLENGE_HIGH_CARD,
CHALLENGE_HEARTS,
CHALLENGE_CLUBS,
CHALLENGE_DIAMONDS,
CHALLENGE_SPADES,
CHALLENGE_ONE,
CHALLENGE_TWO,
CHALLENGE_THREE,
CHALLENGE_FOUR,
CHALLENGE_FIVE,
CHALLENGE_SIX,
CHALLENGE_SEVEN,
CHALLENGE_EIGHT,
CHALLENGE_NINE,
CHALLENGE_TEN,
CHALLENGE_JACK,
CHALLENGE_QUEEN,
CHALLENGE_KING,
CHALLENGE_ACE,
CHALLENGE_JOKER
]
}
5 changes: 4 additions & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod traits;

mod constants {
mod card;
mod challenge;
mod effect;
mod modifiers;
mod packs;
Expand All @@ -16,6 +17,7 @@ mod models {
mod data {
mod blister_pack;
mod card;
mod challenge;
mod effect_card;
mod events;
mod game_deck;
Expand All @@ -27,9 +29,9 @@ mod models {
mod rage;
}
mod round {
mod challenge;
mod current_hand_card;
mod deck_card;
mod round;
}
mod shop {
mod shop;
Expand All @@ -48,6 +50,7 @@ mod tests {
mod setup;
mod test_calculate_hand;
mod test_calculate_level_score;
mod test_challenge;
mod test_game_discard_effect_card;
mod test_game_discard_special_card;
mod test_game_play;
Expand Down
16 changes: 16 additions & 0 deletions src/models/data/challenge.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[derive(Copy, Drop, Serde)]
#[dojo::model]
struct Challenge {
#[key]
game_id: u32,
active_ids: Span<u32>,
}

#[derive(Copy, Drop, IntrospectPacked, Serde)]
#[dojo::model]
struct ChallengePlayer {
#[key]
game_id: u32,
discards: u8,
plays: u8
}
10 changes: 10 additions & 0 deletions src/models/data/events.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,13 @@ struct SpecialCashEvent {
card_idx: u32,
special_idx: u32
}

#[derive(Copy, Drop, Serde)]
#[dojo::event]
#[dojo::model]
struct ChallengeCompleted {
#[key]
player: ContractAddress,
player_name: felt252,
game_id: u32
}
9 changes: 9 additions & 0 deletions src/models/status/game/game.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ enum GameState {
OPEN_BLISTER_PACK
}

#[derive(Serde, Copy, Drop, IntrospectPacked, PartialEq)]
enum GameSubState {
NONE,
OBSTACLE,
BEAST
}

#[derive(Copy, Drop, IntrospectPacked, Serde)]
#[dojo::model]
#[dojo::event]
Expand All @@ -30,6 +37,7 @@ struct Game {
len_current_special_cards: u32,
current_jokers: u8,
state: GameState,
substate: GameSubState,
cash: u32
}

Expand Down Expand Up @@ -62,6 +70,7 @@ impl DefaultGame of Default<Game> {
len_current_special_cards: 0,
current_jokers: 0,
state: GameState::IN_GAME,
substate: GameSubState::NONE,
cash: 0
}
}
Expand Down
Loading