Skip to content

Commit

Permalink
test: Get cards of a year
Browse files Browse the repository at this point in the history
  • Loading branch information
Abeeujah committed Jan 30, 2025
1 parent ab6fa5c commit fcf4335
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 150 deletions.
6 changes: 3 additions & 3 deletions onchain/src/contracts/lyricsflip.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ pub mod LyricsFlip {
cards.span()
}

fn get_cards_of_a_year(self: @ContractState, year: u64) -> Span<Card> {
fn get_cards_of_a_year(self: @ContractState, year: u64, seed: u64) -> Span<Card> {
let year_cards = self.year_cards.entry(year).len();
assert(year_cards > 0, Errors::EMPTY_YEAR_CARDS);
let amount = self.cards_per_round.read();
let mut cards = ArrayTrait::new();
let random_indices = self
._get_random_numbers(get_block_timestamp(), year_cards, year_cards, true);
let random_indices = self._get_random_numbers(seed, amount.into(), year_cards, true);
for i in random_indices {
let card_id = self.year_cards.entry(year).at(*i).read();
let card = self.cards.entry(card_id).read();
Expand Down
2 changes: 1 addition & 1 deletion onchain/src/interfaces/lyricsflip.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ pub trait ILyricsFlip<TContractState> {
// TODO
fn get_cards_of_artist(self: @TContractState, artist: felt252, seed: u64) -> Span<Card>;
// //TODO
fn get_cards_of_a_year(self: @TContractState, year: u64) -> Span<Card>;
fn get_cards_of_a_year(self: @TContractState, year: u64, seed: u64) -> Span<Card>;
}
Loading

0 comments on commit fcf4335

Please sign in to comment.