Skip to content

Commit

Permalink
added exocraft tech
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed Jan 20, 2024
1 parent 0aad492 commit 1cf3cd3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/game/main.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
}

Expand Down Expand Up @@ -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;
},
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/libraries/research.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 },
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/libraries/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ struct TechLevels {
combustion: u8,
thrust: u8,
warp: u8,
exocraft: u8,
}

impl TechLevelsPrint of PrintTrait<TechLevels> {
Expand Down Expand Up @@ -182,6 +183,7 @@ struct TechsCost {
combustion: ERC20s,
thrust: ERC20s,
warp: ERC20s,
exocraft: ERC20s,
}

#[derive(Copy, Drop, Serde)]
Expand Down Expand Up @@ -475,7 +477,8 @@ enum UpgradeType {
Spacetime,
Combustion,
Thrust,
Warp
Warp,
Exocraft,
}


Expand Down Expand Up @@ -526,6 +529,7 @@ mod Names {
const BEAM: felt252 = 26;
const ASTRAL: felt252 = 27;
const PLASMA: felt252 = 28;
const EXOCRAFT: felt252 = 29;
}


Expand Down

0 comments on commit 1cf3cd3

Please sign in to comment.