Add oxygen collector
This commit is contained in:
parent
9b057bdc9f
commit
7802836fe7
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
- [x] Терраформация, 0 - 100%
|
- [x] Терраформация, 0 - 100%
|
||||||
- [x] Кристаллы (базовый ресурс)
|
- [x] Кристаллы (базовый ресурс)
|
||||||
- [ ] Кислород
|
- [x] Кислород
|
||||||
- [ ] Минералы
|
- [ ] Минералы
|
||||||
- [ ] Металлы
|
- [ ] Металлы
|
||||||
|
|
||||||
|
@ -131,8 +131,9 @@ class App
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render_resources(world)
|
def render_resources(world)
|
||||||
printf "Resources:\n Crystals: %5d\n Terraformation: %5d\n",
|
printf "Resources:\n Crystals: %5d\n Oxygen: %5d\n Terraformation: %5d\n",
|
||||||
world.resources[Game::Resource::Type::Crystals],
|
world.resources[Game::Resource::Type::Crystals],
|
||||||
|
world.resources[Game::Resource::Type::Oxygen],
|
||||||
world.resources[Game::Resource::Type::Terraformation]
|
world.resources[Game::Resource::Type::Terraformation]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,12 +9,13 @@ module Game
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Mining
|
class Mining
|
||||||
def initialize(@ts : TimeSpan, @resource : Resource, @input : ResourceBag)
|
def initialize(@ts : TimeSpan, @resource : Resource, @input : ResourceBag, @deposit : Bool = true)
|
||||||
end
|
end
|
||||||
|
|
||||||
getter ts
|
getter ts
|
||||||
getter resource
|
getter resource
|
||||||
getter input
|
getter input
|
||||||
|
getter deposit
|
||||||
end
|
end
|
||||||
|
|
||||||
class Construction
|
class Construction
|
||||||
@ -47,6 +48,7 @@ module Game
|
|||||||
StartPoint
|
StartPoint
|
||||||
CrystalMiner
|
CrystalMiner
|
||||||
CrystalRestorer
|
CrystalRestorer
|
||||||
|
OxygenCollector
|
||||||
Terraformer
|
Terraformer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,6 +45,23 @@ module Game
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add(
|
||||||
|
Building.new Building::Type::OxygenCollector, **{
|
||||||
|
shortcut: "oxygen",
|
||||||
|
construction: Construction.new(
|
||||||
|
ts: 60,
|
||||||
|
cost: ResourceBag.new({Resource::Type::Crystals => 200}),
|
||||||
|
requirements: [] of Game::Building::Type
|
||||||
|
),
|
||||||
|
mining: Mining.new(
|
||||||
|
ts: 30,
|
||||||
|
resource: Resource.new(Resource::Type::Oxygen, 10),
|
||||||
|
input: ResourceBag.new({Resource::Type::Crystals => 5}),
|
||||||
|
deposit: false
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
add(
|
add(
|
||||||
Building.new Building::Type::Terraformer, **{
|
Building.new Building::Type::Terraformer, **{
|
||||||
shortcut: "terr",
|
shortcut: "terr",
|
||||||
@ -59,6 +76,7 @@ module Game
|
|||||||
ts: 60,
|
ts: 60,
|
||||||
input: ResourceBag.new({
|
input: ResourceBag.new({
|
||||||
Resource::Type::Crystals => 50,
|
Resource::Type::Crystals => 50,
|
||||||
|
Resource::Type::Oxygen => 20,
|
||||||
}),
|
}),
|
||||||
output: ResourceBag.new({
|
output: ResourceBag.new({
|
||||||
Resource::Type::Terraformation => 5,
|
Resource::Type::Terraformation => 5,
|
||||||
|
@ -74,6 +74,15 @@ module Game
|
|||||||
if !world.resources.has(mining.input)
|
if !world.resources.has(mining.input)
|
||||||
return mining.ts
|
return mining.ts
|
||||||
end
|
end
|
||||||
|
need_deposit = mining.deposit
|
||||||
|
if need_deposit
|
||||||
|
calc_for_deposit world, mining
|
||||||
|
else
|
||||||
|
calc_for_non_deposit world, mining
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private def calc_for_deposit(world : World, mining : Mining) : TimeSpan
|
||||||
resource = mining.resource
|
resource = mining.resource
|
||||||
deposit_tile = nearest_deposit(world, resource.type)
|
deposit_tile = nearest_deposit(world, resource.type)
|
||||||
stock_tile = nearest_stock(world)
|
stock_tile = nearest_stock(world)
|
||||||
@ -81,8 +90,18 @@ module Game
|
|||||||
mined_amount = deposit_tile.dep.dec(resource.amount)
|
mined_amount = deposit_tile.dep.dec(resource.amount)
|
||||||
@holded = resource.type.to_res mined_amount
|
@holded = resource.type.to_res mined_amount
|
||||||
mining.ts +
|
mining.ts +
|
||||||
2 * tile.point.distance(stock_tile.point) +
|
2 * @point.distance(stock_tile.point) +
|
||||||
2 * tile.point.distance(deposit_tile.point)
|
2 * @point.distance(deposit_tile.point)
|
||||||
|
else
|
||||||
|
mining.ts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private def calc_for_non_deposit(world : World, mining : Mining) : TimeSpan
|
||||||
|
stock_tile = nearest_stock(world)
|
||||||
|
if stock_tile
|
||||||
|
@holded = mining.resource
|
||||||
|
mining.ts + 2 * @point.distance(stock_tile.point)
|
||||||
else
|
else
|
||||||
mining.ts
|
mining.ts
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,7 @@ require "./types"
|
|||||||
struct Game::Resource
|
struct Game::Resource
|
||||||
enum Type
|
enum Type
|
||||||
Crystals
|
Crystals
|
||||||
|
Oxygen
|
||||||
Terraformation
|
Terraformation
|
||||||
|
|
||||||
def to_res(amount : Capacity)
|
def to_res(amount : Capacity)
|
||||||
|
Loading…
Reference in New Issue
Block a user