Skip to content

Commit

Permalink
add assert owner
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinones committed Nov 4, 2024
1 parent 95690f7 commit 7b35ad3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/systems/game_system.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ mod game_system {
let mut game = store.get_game(game_id);

assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(game.state == GameState::IN_GAME, errors::GAME_NOT_IN_GAME);
assert(game.substate == GameSubState::CREATE_LEVEL, errors::WRONG_SUBSTATE_CREATE_LEVEL);

Expand All @@ -177,6 +178,7 @@ mod game_system {

let game = store.get_game(game_id);
assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(game.state == GameState::IN_GAME, errors::GAME_NOT_IN_GAME);

match game.substate {
Expand All @@ -191,6 +193,7 @@ mod game_system {

let game = store.get_game(game_id);
assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(game.state == GameState::IN_GAME, errors::GAME_NOT_IN_GAME);

match game.substate {
Expand All @@ -205,6 +208,7 @@ mod game_system {

let game = store.get_game(game_id);
assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(game.substate == GameSubState::BEAST, errors::WRONG_SUBSTATE_BEAST);

BeastTrait::end_turn(world, game_id);
Expand All @@ -213,6 +217,7 @@ mod game_system {
fn create_reward(ref world: IWorldDispatcher, game_id: u32, reward_index: u8) {
let mut game = GameStore::get(world, game_id);
assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(game.substate == GameSubState::CREATE_REWARD, errors::WRONG_SUBSTATE_REWARD);

let reward: RewardType = (*RewardStore::get(world, game_id).rewards_ids.at(reward_index.into())).into();
Expand Down Expand Up @@ -257,6 +262,7 @@ mod game_system {
fn select_reward(ref world: IWorldDispatcher, game_id: u32, cards_index: Array<u32>) {
let mut game = GameStore::get(world, game_id);
assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(
game.substate == GameSubState::REWARD_SPECIALS || game.substate == GameSubState::REWARD_CARDS_PACK,
errors::WRONG_SUBSTATE_SELECT_REWARD
Expand Down Expand Up @@ -419,6 +425,7 @@ mod game_system {
fn skip_unpassed_obstacle(ref world: IWorldDispatcher, game_id: u32) {
let mut game = GameStore::get(world, game_id);
assert(game.owner.is_non_zero(), errors::GAME_NOT_FOUND);
assert(game.owner == get_caller_address(), errors::CALLER_NOT_OWNER);
assert(
game.substate == GameSubState::UNPASSED_OBSTACLE,
errors::WRONG_SUBSTATE_UNPASSED_OBSTABLE
Expand Down

0 comments on commit 7b35ad3

Please sign in to comment.