Progression
Getting Started
Emit events to track the progress of the player.
The package provides also a way to be used as a cairo package.
#[dojo::contract]
pub mod Actions {
use arcade_trophy::store::{Store, StoreTrait};
// ...
#[abi(embed_v0)]
impl ActionsImpl of IActions<ContractState> {
fn play(ref self: ContractState, do: felt252) {
let world = self.world(@"<YOUR-NAMESPACE>")
// If the player meets the task requirement, emit an event to track the progress
if do === 'something' {
let store = StoreTrait::new(world);
let player_id = starknet::get_caller_address();
let task_id = 'TASK_IDENTIFIER';
let count = 1;
let time = starknet::get_block_timestamp();
store.progress(player_id.into(), task_id, count, time);
}
}
}
}
API References
AchievableComponent.progress
AchievableComponent.create(
self: @ComponentState<TContractState>,
world: WorldStorage,
player_id: felt252,
task_id: felt252,
count: u32,
)
See also AchievableComponent
Parameters
self
: The component state.world
: The world storage.player_id
: The player identifier.task_id
: The task identifier.count
: The progression count to add.