Add tarraformation

This commit is contained in:
Anton Vakhrushev 2019-09-20 18:54:35 +03:00
parent 97030f7c5b
commit d5af20a2cf
3 changed files with 43 additions and 2 deletions

View File

@ -110,3 +110,33 @@ class RestoreCrystalCommand < Command
end
end
end
class BuildTerraformerCommand < Command
BUILD_TIME = 120
def initialize(@point : Point)
end
def start(world : World) : Int32
BUILD_TIME
end
def finish(world : World)
world.map.set(TerraformerTile.new(@point))
world.push(TerraformCommand.new(@point))
end
end
class TerraformCommand < Command
def initialize(@point : Point)
end
def start(world : World) : Int32
10
end
def finish(world : World)
world.resources.inc(ResourceType::Terraformation, 5)
world.push(TerraformCommand.new(@point))
end
end

View File

@ -70,7 +70,7 @@ w = World.new
w.map.print
w.push(BuildCrystalHarvesterCommand.new(Point.new(2, 3)))
w.push(BuildCrystalRestorerCommand.new(Point.new(1, 2)))
w.push(BuildCrystalRestorerCommand.new(Point.new(3, 2)))
w.run(60)
w.push(BuildTerraformerCommand.new(Point.new(3, 2)))
w.run(240)
w.map.print
pp w.resources

View File

@ -3,6 +3,7 @@ enum TileRole
CrystalHarvester
CrystalRestorer
Plateau
Terraformer
Warehouse
end
@ -91,3 +92,13 @@ class CrystalRestorerTile < Tile
role == TileRole::CrystalRestorer
end
end
class TerraformerTile < Tile
def letter : Char
'T'
end
def has_role(role : TileRole) : Bool
role == TileRole::Terraformer
end
end