diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2017-06-22 20:08:54 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2017-06-22 20:08:54 +0200 |
commit | 29719e34889f14377c0865e320eb4c1571f60a42 (patch) | |
tree | 14124c40ce5a2d77c14517d65850a29cc123fe1e /src/ships.rs | |
parent | 862897ea1d183810c2783eaeeaf40f648ef3dc2d (diff) |
Added turns to weapon being available to knowledge
Diffstat (limited to 'src/ships.rs')
-rw-r--r-- | src/ships.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ships.rs b/src/ships.rs index e37fe33..104e986 100644 --- a/src/ships.rs +++ b/src/ships.rs @@ -54,6 +54,13 @@ impl Weapon { &SeekerMissle => 10*epr } } + pub fn single_shot_rounds_to_ready(&self, current_energy: u16, map_size: u16) -> u16 { + let single_shot_cost = Weapon::SingleShot.energy_cost(map_size); + let energy_per_round = Weapon::energy_per_round(map_size) - single_shot_cost; + let required_energy = self.energy_cost(map_size) - current_energy; + //weird plus is to make the integer rounding up instead of down + (required_energy + energy_per_round - 1) / energy_per_round + } } |