Skip to content

Commit

Permalink
🐛 Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Aug 20, 2024
1 parent 654226d commit ef00b1b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
2 changes: 1 addition & 1 deletion contracts/src/components/playable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
23 changes: 3 additions & 20 deletions contracts/src/models/dungeon.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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]
Expand All @@ -69,20 +69,3 @@ impl DungeonAssert of AssertTrait {
}
}

impl ZeroableDungeonImpl of core::Zeroable<Dungeon> {
#[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()
}
}

23 changes: 2 additions & 21 deletions contracts/src/models/player.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -128,22 +128,3 @@ impl PlayerAssert of AssertTrait {
}
}

impl ZeroablePlayerImpl of core::Zeroable<Player> {
#[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()
}
}

0 comments on commit ef00b1b

Please sign in to comment.