From ef00b1b3d9011234324fc4a0f441e325c4a7a66f Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Tue, 20 Aug 2024 19:05:14 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Minor=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/src/components/playable.cairo | 2 +- contracts/src/models/dungeon.cairo | 23 +++-------------------- contracts/src/models/player.cairo | 23 ++--------------------- 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/contracts/src/components/playable.cairo b/contracts/src/components/playable.cairo index 4f91a9c..a6f9e89 100644 --- a/contracts/src/components/playable.cairo +++ b/contracts/src/components/playable.cairo @@ -102,7 +102,7 @@ mod PlayableComponent { // [Effect] Defend if dungeon.is_done() { - player.reward(dungeon.treasury()); + player.reward(dungeon.get_treasury()); } else { player.take_damage(dungeon.role.into(), dungeon.damage); } diff --git a/contracts/src/models/dungeon.cairo b/contracts/src/models/dungeon.cairo index cc174f6..daf557d 100644 --- a/contracts/src/models/dungeon.cairo +++ b/contracts/src/models/dungeon.cairo @@ -45,7 +45,7 @@ impl DungeonImpl of DungeonTrait { } #[inline] - fn treasury(self: Dungeon) -> u16 { + fn get_treasury(self: Dungeon) -> u16 { let monster: Monster = self.monster.into(); monster.reward() } @@ -55,12 +55,12 @@ impl DungeonImpl of DungeonTrait { impl DungeonAssert of AssertTrait { #[inline] fn assert_is_done(self: Dungeon) { - assert(self.is_zero(), errors::DUNGEON_NOT_DONE); + assert(self.is_done(), errors::DUNGEON_NOT_DONE); } #[inline] fn assert_not_done(self: Dungeon) { - assert(self.is_non_zero(), errors::DUNGEON_ALREADY_DONE); + assert(!self.is_done(), errors::DUNGEON_ALREADY_DONE); } #[inline] @@ -69,20 +69,3 @@ impl DungeonAssert of AssertTrait { } } -impl ZeroableDungeonImpl of core::Zeroable { - #[inline] - fn zero() -> Dungeon { - Dungeon { id: 0, monster: 0, role: 0, damage: 0, health: 0, reward: 0 } - } - - #[inline] - fn is_zero(self: Dungeon) -> bool { - self.monster == Monster::None.into() || self.health == 0 - } - - #[inline] - fn is_non_zero(self: Dungeon) -> bool { - !self.is_zero() - } -} - diff --git a/contracts/src/models/player.cairo b/contracts/src/models/player.cairo index c3af454..374108b 100644 --- a/contracts/src/models/player.cairo +++ b/contracts/src/models/player.cairo @@ -109,12 +109,12 @@ impl PlayerImpl of PlayerTrait { impl PlayerAssert of AssertTrait { #[inline] fn assert_exists(self: Player) { - assert(self.is_non_zero(), errors::PLAYER_NOT_EXIST); + assert(0 != self.name, errors::PLAYER_NOT_EXIST); } #[inline] fn assert_not_exists(self: Player) { - assert(self.is_zero(), errors::PLAYER_ALREADY_EXIST); + assert(0 == self.name, errors::PLAYER_ALREADY_EXIST); } #[inline] @@ -128,22 +128,3 @@ impl PlayerAssert of AssertTrait { } } -impl ZeroablePlayerImpl of core::Zeroable { - #[inline] - fn zero() -> Player { - Player { - id: 0, mode: 0, role: 0, damage: 0, health: 0, gold: 0, score: 0, seed: 0, name: 0 - } - } - - #[inline] - fn is_zero(self: Player) -> bool { - 0 == self.name - } - - #[inline] - fn is_non_zero(self: Player) -> bool { - !self.is_zero() - } -} -