diff --git a/src/game/main.cairo b/src/game/main.cairo index c260a5a..26c6f28 100644 --- a/src/game/main.cairo +++ b/src/game/main.cairo @@ -695,7 +695,8 @@ mod NoGame { spacetime: self.techs_level.read((planet_id, Names::SPACETIME)), combustion: self.techs_level.read((planet_id, Names::COMBUSTION)), thrust: self.techs_level.read((planet_id, Names::THRUST)), - warp: self.techs_level.read((planet_id, Names::WARP)) + warp: self.techs_level.read((planet_id, Names::WARP)), + exocraft: self.techs_level.read((planet_id, Names::EXOCRAFT)), } } @@ -1694,6 +1695,22 @@ mod NoGame { ); return cost; }, + UpgradeType::Exocraft => { + let lab_level = self.compounds_level.read((planet_id, Names::LAB)); + let techs = self.get_tech_levels(planet_id); + Lab::exocraft_requirements_check(lab_level, techs); + let base_cost: ERC20s = Lab::base_tech_costs().exocraft; + let cost = Lab::get_tech_cost(techs.exocraft, quantity, base_cost); + self.check_enough_resources(caller, cost); + self.pay_resources_erc20(caller, cost); + self + .techs_level + .write( + (planet_id, Names::EXOCRAFT), + techs.exocraft + quantity.try_into().expect('u32 into u8 failed') + ); + return cost; + }, } } diff --git a/src/libraries/research.cairo b/src/libraries/research.cairo index b513409..0f5520d 100644 --- a/src/libraries/research.cairo +++ b/src/libraries/research.cairo @@ -104,6 +104,12 @@ impl Lab of LabTrait { assert(techs.spacetime >= 3, 'Spacetime Warp 3 required'); } + #[inline(always)] + fn exocraft_requirements_check(lab_level: u8, techs: TechLevels) { + assert(lab_level >= 3, 'Lab 3 required'); + assert(techs.thrust >= 3, 'Thrust prop 3 required') + } + #[inline(always)] fn base_tech_costs() -> TechsCost { TechsCost { @@ -119,6 +125,7 @@ impl Lab of LabTrait { combustion: ERC20s { steel: 400, quartz: 0, tritium: 600 }, thrust: ERC20s { steel: 2000, quartz: 4000, tritium: 600 }, warp: ERC20s { steel: 10000, quartz: 20000, tritium: 6000 }, + exocraft: ERC20s { steel: 4000, quartz: 8000, tritium: 4000 }, } } } diff --git a/src/libraries/types.cairo b/src/libraries/types.cairo index fd48288..d63ae77 100644 --- a/src/libraries/types.cairo +++ b/src/libraries/types.cairo @@ -149,6 +149,7 @@ struct TechLevels { combustion: u8, thrust: u8, warp: u8, + exocraft: u8, } impl TechLevelsPrint of PrintTrait { @@ -182,6 +183,7 @@ struct TechsCost { combustion: ERC20s, thrust: ERC20s, warp: ERC20s, + exocraft: ERC20s, } #[derive(Copy, Drop, Serde)] @@ -475,7 +477,8 @@ enum UpgradeType { Spacetime, Combustion, Thrust, - Warp + Warp, + Exocraft, } @@ -526,6 +529,7 @@ mod Names { const BEAM: felt252 = 26; const ASTRAL: felt252 = 27; const PLASMA: felt252 = 28; + const EXOCRAFT: felt252 = 29; }