From d5af20a2cfafcf3367091dd2386dc2541dca2de2 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Fri, 20 Sep 2019 18:54:35 +0300 Subject: [PATCH] Add tarraformation --- src/command.cr | 30 ++++++++++++++++++++++++++++++ src/expansion.cr | 4 ++-- src/tile.cr | 11 +++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/command.cr b/src/command.cr index 9ddc219..5de9720 100644 --- a/src/command.cr +++ b/src/command.cr @@ -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 diff --git a/src/expansion.cr b/src/expansion.cr index 99adf8e..026dc73 100644 --- a/src/expansion.cr +++ b/src/expansion.cr @@ -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 diff --git a/src/tile.cr b/src/tile.cr index e7b9e95..a301cf1 100644 --- a/src/tile.cr +++ b/src/tile.cr @@ -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