Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ClanCo committed Mar 29, 2024
1 parent 454fe15 commit fdef566
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/events.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ struct Emote {
#[key]
game_id: u32,
player_index: u32,
emote: felt252
emote: u32
}

#[derive(Drop, starknet::Event)]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ mod tests {
}
}

use zconqueror::data::v00 as config;
use zconqueror::data::v01 as config;
33 changes: 11 additions & 22 deletions src/systems/play.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ use dojo::world::IWorldDispatcher;
#[starknet::interface]
trait IPlay<TContractState> {
fn emote(
self: @TContractState,
world: IWorldDispatcher,
game_id: u32,
player_index: u32,
emote: felt252
);
self: @TContractState, world: IWorldDispatcher, game_id: u32, player_index: u32, emote: u32
);
fn attack(
self: @TContractState,
world: IWorldDispatcher,
Expand Down Expand Up @@ -123,6 +119,7 @@ mod play {
const BANISH_INVALID_PLAYER: felt252 = 'Banish: invalid player';
const BANISH_INVALID_CONDITION: felt252 = 'Banish: invalid condition';
const SURRENDER_INVALID_PLAYER: felt252 = 'Surrender: invalid player';
const EMOTE_INVALID_PLAYER: felt252 = 'Emote invalid player';
}

#[event]
Expand Down Expand Up @@ -158,13 +155,12 @@ mod play {

#[abi(embed_v0)]
impl Play of IPlay<ContractState> {

fn emote(
self: @ContractState,
world: IWorldDispatcher,
self: @ContractState,
world: IWorldDispatcher,
game_id: u32,
player_index: u32,
emote: felt252
player_index: u32,
emote: u32
) {
// Initialisation du datastore
let mut store: Store = StoreTrait::new(world);
Expand All @@ -178,19 +174,12 @@ mod play {

// [Check] Caller is player
let caller = get_caller_address();
let player = store.player(game,player_index);
assert(player.address == caller.into(), errors::ATTACK_INVALID_PLAYER);
let player = store.player(game, player_index);
assert(player.address == caller.into(), errors::EMOTE_INVALID_PLAYER);

// Une fois les vérifications passées, vous pouvez émettre un événement avec les détails de l'émoticône envoyée
// [Event] Supply
emit!(
world,
Emote {
game_id: game_id,
player_index: player_index,
emote: emote,
}
);
// [Event] Emote
emit!(world, Emote { game_id: game_id, player_index: player_index, emote: emote, });
}

fn attack(
Expand Down

0 comments on commit fdef566

Please sign in to comment.