Skip to content

Commit

Permalink
make increase_day_index public
Browse files Browse the repository at this point in the history
  • Loading branch information
TAdev0 committed Apr 10, 2024
1 parent 1611a38 commit 66a31f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
25 changes: 11 additions & 14 deletions onchain/src/art_peace.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ pub mod ArtPeace {
}
}

fn increase_day_index(ref self: ContractState) {
let block_timestamp = starknet::get_block_timestamp();
let start_day_time = self.start_day_time.read();

assert(block_timestamp > start_day_time + day_time, 'day has not passed');

self.day_index.write(self.day_index.read() + 1);
self.start_day_time.write(block_timestamp);
self.emit(NewDay { day_index: self.day_index.read() });
}

fn get_user_pixels_placed(self: @ContractState, user: ContractAddress) -> u32 {
let mut i = 0;
let mut total = 0;
Expand Down Expand Up @@ -435,19 +446,5 @@ pub mod ArtPeace {
}
}
}

#[generate_trait]
impl InternatImpl of InternalTrait {
fn increase_day_index(ref self: ContractState) {
let block_timestamp = starknet::get_block_timestamp();
let start_day_time = self.start_day_time.read();

assert(block_timestamp > start_day_time + day_time, 'day has not passed');

self.day_index.write(self.day_index.read() + 1);
self.start_day_time.write(block_timestamp);
self.emit(NewDay { day_index: self.day_index.read() });
}
}
}

3 changes: 3 additions & 0 deletions onchain/src/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub trait IArtPeace<TContractState> {
fn claim_today_quest(ref self: TContractState, quest_id: u32);
fn claim_main_quest(ref self: TContractState, quest_id: u32);

// Start a new day
fn increase_day_index(ref self: TContractState);

// Stats
fn get_user_pixels_placed(self: @TContractState, user: starknet::ContractAddress) -> u32;
fn get_user_pixels_placed_day(
Expand Down

0 comments on commit 66a31f0

Please sign in to comment.