From 101c4179df66677e8d183a1eee615d5c0ba362d4 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sun, 15 Sep 2019 12:45:55 +0300 Subject: [PATCH] Add forester coords --- src/map.cr | 6 ++++++ src/village.cr | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/map.cr b/src/map.cr index 47a44b5..af5b6fe 100644 --- a/src/map.cr +++ b/src/map.cr @@ -39,6 +39,12 @@ class WoodMillTile < Tile end end +class ForesterHouseTile < Tile + def letter : Char + 'h' + end +end + struct Point def initialize(@x : Int32, @y : Int32) end diff --git a/src/village.cr b/src/village.cr index 11388c7..98a328e 100644 --- a/src/village.cr +++ b/src/village.cr @@ -30,21 +30,23 @@ class BuildWoodMillCommand < Command def run(ts : Int32, world : World) printf "build mill at [%d,%d]\n", @point.x, @point.y - c = GetWoodCommand.new world.map.set(@point, WoodMillTile.new) - world.push(ts + 5, c) + world.push(ts + 5, GetWoodCommand.new) end end class BuildForesterHouseCommand < Command + def initialize(@point : Point) + end + def supports?(world : World) : Bool return true end def run(ts : Int32, world : World) - puts "build forester house" - c = GrowWoodCommand.new - world.push(ts + 10, c) + printf "build forester house at [%d,%d]\n", @point.x, @point.y + world.map.set(@point, ForesterHouseTile.new) + world.push(ts + 10, GrowWoodCommand.new) end end @@ -115,6 +117,6 @@ end w = World.new w.map.print w.push(0, BuildWoodMillCommand.new(Point.new(0, 0))) -w.push(1, BuildForesterHouseCommand.new) +w.push(0, BuildForesterHouseCommand.new(Point.new(2, 0))) w.run(20) w.map.print