Skip to content

Commit

Permalink
Merge pull request #64 from manlikeHB/main
Browse files Browse the repository at this point in the history
refac contract
  • Loading branch information
manlikeHB authored Jan 21, 2025
2 parents 142f7fa + 6643211 commit 13cd694
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions onchain/src/contracts/lyricsflip.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod LyricsFlip {
#[storage]
struct Storage {
round_count: u64,
card_count: u64,
cards_count: u64,
cards_per_round: u8,
cards: Map<u64, Card>,
genre_cards: Map<Genre, Vec<u64>>, // genre -> vec<card_ids>
Expand Down Expand Up @@ -129,7 +129,7 @@ pub mod LyricsFlip {
is_started: false,
is_completed: false,
end_time: 0, //TODO
current_card_index: 0,
next_card_index: 0,
};

let round_players_count = self.round_players_count.entry(round_id).read();
Expand Down Expand Up @@ -216,23 +216,28 @@ pub mod LyricsFlip {
// }

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

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

// //TODO
// fn get_cards_of_a_year(self: @ContractState, year: u64) -> Span<Card> {}
// fn get_cards_of_a_year(self: @ContractState, year: u64, amount: 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
// }
// fn _next_round_card(ref self: ContractState, round_id: u64) -> Card {
// // check round is started and is_completed is false
// }

fn _get_random_numbers(amount: u64, limit: u64, for_index: bool) -> Span<u64> {
array![].span()
}
}
}
4 changes: 2 additions & 2 deletions onchain/src/utils/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use starknet::ContractAddress;
#[derive(Drop, Serde, starknet::Store)]
pub struct Card {
pub card_id: u64,
pub genre: felt252,
pub genre: Genre,
pub artist: ByteArray,
pub title: ByteArray,
pub year: u64,
Expand Down Expand Up @@ -43,5 +43,5 @@ pub struct Round {
pub is_started: bool,
pub is_completed: bool,
pub end_time: u64,
pub current_card_index: u8,
pub next_card_index: u8,
}

0 comments on commit 13cd694

Please sign in to comment.