From ed09603aef5ffce38d012d89769a50cd172d8f15 Mon Sep 17 00:00:00 2001 From: Strong Force <64266194+princeibs@users.noreply.github.com> Date: Sun, 6 Oct 2024 09:03:52 +0100 Subject: [PATCH] Update player_actions.cairo --- onchain/src/systems/player_actions.cairo | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/onchain/src/systems/player_actions.cairo b/onchain/src/systems/player_actions.cairo index 1cdecce..8e6b921 100644 --- a/onchain/src/systems/player_actions.cairo +++ b/onchain/src/systems/player_actions.cairo @@ -36,16 +36,13 @@ mod PlayerActions { let caller: ContractAddress = get_caller_address(); let zero_address: ContractAddress = contract_address_const::<0x0>(); - // assert(caller != zero_address, 'Cannot create from zero address'); assert(caller != zero_address, Errors::ADDRESS_ZERO); - let new_player: Player = PlayerTrait::new(username, caller); // Ensure player username is unique let mut existing_player = get!(world, username, (Player)); - // assert(existing_player.owner == 0.try_into().unwrap(), 'username already taken'); assert(existing_player.owner == 0.try_into().unwrap(), Errors::USERNAME_TAKEN); set!(world, (new_player)); @@ -57,7 +54,6 @@ mod PlayerActions { let mut player: Player = get!(world, username, (Player)); // Validate username - // assert(player.owner != 0.try_into().unwrap(), 'player with username not found'); assert(player.owner != 0.try_into().unwrap(), Errors::USERNAME_NOT_FOUND); player.owner @@ -86,12 +82,10 @@ mod PlayerActions { let mut player: Player = get!(world, old_username, (Player)); // Only allow the player to update their own username - // assert(player.owner == caller, 'only user can udpate username'); assert(player.owner == caller, Errors::ONLY_OWNER_USERNAME); // Check if the new username is already taken let mut existing_player = get!(world, new_username, (Player)); - // assert(existing_player.owner == 0.try_into().unwrap(), 'username already exist'); assert(existing_player.owner == 0.try_into().unwrap(), Errors::USERNAME_EXIST); // Update the player's username @@ -99,4 +93,4 @@ mod PlayerActions { set!(world, (player)); } } -} \ No newline at end of file +}