Skip to content

Commit

Permalink
chore: add more functions to be impl
Browse files Browse the repository at this point in the history
  • Loading branch information
manlikeHB committed Jan 19, 2025
1 parent edc1a54 commit b87b483
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
33 changes: 32 additions & 1 deletion onchain/src/contracts/lyricsflip.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod LyricsFlip {
card_count: u64,
cards_per_round: u8,
cards: Map<u64, Card>,
genre_cards: Map<ByteArray, Vec<u64>>, // genre -> vec<card_ids>
genre_cards: Map<Genre, Vec<u64>>, // genre -> vec<card_ids>
artist_cards: Map<ByteArray, Vec<u64>>, // artist -> vec<card_ids>
year_cards: Map<u64, Vec<u64>>, // year -> vec<card_ids>
rounds: Map<u64, Round>, // round_id -> Round
Expand Down Expand Up @@ -129,6 +129,7 @@ pub mod LyricsFlip {
is_started: false,
is_completed: false,
end_time: 0, //TODO
current_card_index: 0,
};

let round_players_count = self.round_players_count.entry(round_id).read();
Expand Down Expand Up @@ -197,11 +198,41 @@ pub mod LyricsFlip {
}
}

// // TODO
// fn add_card(ref self: ContractState, card: Card) {}

// // TODO
// fn get_card(self: @ContractState, card_id: u64) -> Card {}

// // TODO
// fn set_cards_per_round(ref self: ContractState, value: u8) {}

// // TODO
// fn get_cards_per_round(self: @ContractState) -> u8 {}

// // TODO
// fn next_card(ref self: ContractState, round_id: u64) -> Card {
// self._next_round_card()
// }

// // TODO
// fn get_cards_of_genre(self: @ContractState, genre: Genre) -> Span<Card> {}

// // TODO
// fn get_cards_of_artist(self: @ContractState, artist: ByteArray) -> Span<Card> {}

// //TODO
// fn get_cards_of_a_year(self: @ContractState, year: u64) -> Span<Card> {}

#[generate_trait]
impl InternalFunctions of InternalFunctionsTrait {
//TODO
fn get_random_cards(ref self: ContractState) -> Span<u64> {
array![1, 2].span()
}
// // TODO
// fn _next_round_card(ref self: ContractState, round_id: u64) -> Card {
// // check round is started and is_completed is false
// }
}
}
23 changes: 23 additions & 0 deletions onchain/src/interfaces/lyricsflip.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,27 @@ pub trait ILyricsFlip<TContractState> {
fn create_round(ref self: TContractState, genre: Option<Genre>) -> u64;
fn start_round(ref self: TContractState, round_id: u64);
fn join_round(ref self: TContractState, round_id: u64);
// // TODO
// fn add_card(ref self: TContractState, card: Card);

// // TODO
// fn get_card(self: @TContractState, card_id: u64) -> Card;

// // TODO
// fn set_cards_per_round(ref self: TContractState, value: u8);

// //TODO
// fn get_cards_per_round(self: @TContractState) -> u8;

// // TODO
// fn next_card(ref self: TContractState, round_id: u64) -> Card;

// // TODO
// fn get_cards_of_genre(self: @TContractState, genre: Genre) -> Span<Card>;

// // TODO
// fn get_cards_of_artist(self: @TContractState, artist: ByteArray) -> Span<Card>;

// //TODO
// fn get_cards_of_a_year(self: @TContractState, year: u64) -> Span<Card>;
}
1 change: 1 addition & 0 deletions onchain/src/utils/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ pub struct Round {
pub is_started: bool,
pub is_completed: bool,
pub end_time: u64,
pub current_card_index: u8,
}

0 comments on commit b87b483

Please sign in to comment.