Add smelter

This commit is contained in:
Anton Vakhrushev 2019-10-18 14:58:02 +03:00
parent 7802836fe7
commit 5a0cc4cb10
4 changed files with 34 additions and 8 deletions

View File

@ -88,10 +88,12 @@ class App
def render_building_letter(building_type : Game::Building::Type)
case building_type
when Game::Building::Type::StartPoint then 'S'.colorize(:yellow)
when Game::Building::Type::StartPoint then 'S'.colorize(:yellow).underline
when Game::Building::Type::CrystalMiner then 'M'.colorize(:yellow)
when Game::Building::Type::CrystalRestorer then 'R'.colorize(:yellow)
when Game::Building::Type::Terraformer then 'T'.colorize(:yellow)
when Game::Building::Type::CrystalRestorer then 'R'.colorize(:green)
when Game::Building::Type::OxygenCollector then 'O'.colorize(:yellow)
when Game::Building::Type::Smelter then 'E'.colorize(:magenta)
when Game::Building::Type::Terraformer then 'T'.colorize(:cyan)
else
' '
end
@ -131,10 +133,10 @@ class App
end
def render_resources(world)
printf "Resources:\n Crystals: %5d\n Oxygen: %5d\n Terraformation: %5d\n",
world.resources[Game::Resource::Type::Crystals],
world.resources[Game::Resource::Type::Oxygen],
world.resources[Game::Resource::Type::Terraformation]
printf "Resources:\n"
Game::Resource::Type.each do |t|
printf " %-15s %5d\n", t.to_s + ':', world.resources[t]
end
end
def render_world(world)

View File

@ -49,6 +49,7 @@ module Game
CrystalMiner
CrystalRestorer
OxygenCollector
Smelter
Terraformer
end

View File

@ -62,11 +62,32 @@ module Game
}
)
add(
Building.new Building::Type::Smelter, **{
shortcut: "iron",
construction: Construction.new(
ts: 120,
cost: ResourceBag.new({Resource::Type::Crystals => 300}),
requirements: [] of Game::Building::Type
),
production: Production.new(
ts: 60,
input: ResourceBag.new({
Resource::Type::Crystals => 20,
Resource::Type::Oxygen => 10,
}),
output: ResourceBag.new({
Resource::Type::Iron => 10,
})
),
}
)
add(
Building.new Building::Type::Terraformer, **{
shortcut: "terr",
construction: Construction.new(
ts: 120,
ts: 180,
cost: ResourceBag.new({
Resource::Type::Crystals => 300,
}),
@ -77,6 +98,7 @@ module Game
input: ResourceBag.new({
Resource::Type::Crystals => 50,
Resource::Type::Oxygen => 20,
Resource::Type::Iron => 5,
}),
output: ResourceBag.new({
Resource::Type::Terraformation => 5,

View File

@ -4,6 +4,7 @@ struct Game::Resource
enum Type
Crystals
Oxygen
Iron
Terraformation
def to_res(amount : Capacity)