diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..342a21f --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +dojo 1.0.0-alpha.5 +scarb 2.7.0 diff --git a/src/models/evolution.cairo b/src/models/evolution.cairo index 8ac091f..f9fc761 100644 --- a/src/models/evolution.cairo +++ b/src/models/evolution.cairo @@ -14,11 +14,17 @@ struct Evolution { } mod rules { - // Minimum rule to envolve - const ENVOLVED_BEAST_ID: u32 = 2; + /// Minimum rules for beast evolution + + /// The ID assigned to the evolved beast form + const EVOLVED_BEAST_ID: u32 = 2; + /// Minimum level required before evolution is possible const LEVEL_REQUIREMENT: u32 = 10; + /// Minimum number of battles required before evolution const REQUIRED_BATTLES: u32 = 5; + /// Item ID required for evolution (special evolution stone) const REQUIRED_ITEM: u32 = 1001; + } #[generate_trait] @@ -29,16 +35,17 @@ impl EvolutionImpl of EvolutionTrait { Option::None => true, }; - is_valid_item && self.level_requirement >= rules::LEVEL_REQUIREMENT && self.required_battles >= rules::REQUIRED_BATTLES + is_valid_item && + self.level_requirement > rules::LEVEL_REQUIREMENT && + self.required_battles > rules::REQUIRED_BATTLES } - fn envolve(ref self: Evolution) -> Result { + fn evolve(self: Evolution) -> Result { + assert(self.base_beast_id != 0, 'Invalid base beast'); + match self.can_evolve() { - true => { - self.evolved_beast_id = rules::ENVOLVED_BEAST_ID; - Result::Ok(self.evolved_beast_id) - }, - false => Result::Err('Invalid Evolution'), + true => Result::Ok(rules::EVOLVED_BEAST_ID), + false => Result::Err('Evolution requirements not met'), } } } \ No newline at end of file