Add tarraformation
This commit is contained in:
parent
97030f7c5b
commit
d5af20a2cf
@ -110,3 +110,33 @@ class RestoreCrystalCommand < Command
|
|||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
@ -70,7 +70,7 @@ w = World.new
|
|||||||
w.map.print
|
w.map.print
|
||||||
w.push(BuildCrystalHarvesterCommand.new(Point.new(2, 3)))
|
w.push(BuildCrystalHarvesterCommand.new(Point.new(2, 3)))
|
||||||
w.push(BuildCrystalRestorerCommand.new(Point.new(1, 2)))
|
w.push(BuildCrystalRestorerCommand.new(Point.new(1, 2)))
|
||||||
w.push(BuildCrystalRestorerCommand.new(Point.new(3, 2)))
|
w.push(BuildTerraformerCommand.new(Point.new(3, 2)))
|
||||||
w.run(60)
|
w.run(240)
|
||||||
w.map.print
|
w.map.print
|
||||||
pp w.resources
|
pp w.resources
|
||||||
|
11
src/tile.cr
11
src/tile.cr
@ -3,6 +3,7 @@ enum TileRole
|
|||||||
CrystalHarvester
|
CrystalHarvester
|
||||||
CrystalRestorer
|
CrystalRestorer
|
||||||
Plateau
|
Plateau
|
||||||
|
Terraformer
|
||||||
Warehouse
|
Warehouse
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -91,3 +92,13 @@ class CrystalRestorerTile < Tile
|
|||||||
role == TileRole::CrystalRestorer
|
role == TileRole::CrystalRestorer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TerraformerTile < Tile
|
||||||
|
def letter : Char
|
||||||
|
'T'
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_role(role : TileRole) : Bool
|
||||||
|
role == TileRole::Terraformer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user