From 09ec46dd82cd22b5bb4e2cafa29e477598f228ec Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Fri, 13 Sep 2019 20:34:30 +0300 Subject: [PATCH] Add forester command --- src/village.cr | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/village.cr b/src/village.cr index a0fb62f..4174003 100644 --- a/src/village.cr +++ b/src/village.cr @@ -37,6 +37,18 @@ class BuildMillCommand < Command end end +class BuildForesterHouseCommand < Command + def supports?(world : World) : Bool + return true + end + + def run(world : World) + puts "build forester house" + c = GrowWoodCommand.new(@ts + 10) + world.push(c) + end +end + class GetWoodCommand < Command def supports?(world : World) : Bool return true @@ -51,6 +63,19 @@ class GetWoodCommand < Command end end +class GrowWoodCommand < Command + def supports?(world : World) : Bool + return true + end + + def run(world : World) + res = world.resources + puts "grow wood" + c = GetWoodCommand.new(@ts + 5) + world.push(c) + end +end + abstract class Tile abstract def letter : Char end @@ -159,5 +184,6 @@ end w = World.new w.map.print -w.push(BuildMillCommand.new(2)) -w.run(10) +w.push(BuildMillCommand.new(0)) +w.push(BuildForesterHouseCommand.new(0)) +w.run(100)