diff --git a/Makefile b/Makefile index 4629822..c1bbf1c 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ build-docker: docker pull alpine:edge docker build -t $(APP_NAME)-crystal . +.PHONY: install +install: build-docker + .PHONY: build build: mkdir -p build diff --git a/WORLD.md b/WORLD.md index ad78dc1..6e3eecd 100644 --- a/WORLD.md +++ b/WORLD.md @@ -9,7 +9,7 @@ ## Терраформация: -- Терраформация, 0 - 100% +- [x] Терраформация, 0 - 100% ## Ресурсы: @@ -22,7 +22,7 @@ - [x] Главная база (склад) - [x] Добыча кристаллов - [x] Выращивание кристаллов -- [ ] Терраформатор +- [x] Терраформатор ## Карта diff --git a/src/command.cr b/src/command.cr index 5de9720..6a80ba8 100644 --- a/src/command.cr +++ b/src/command.cr @@ -128,15 +128,18 @@ class BuildTerraformerCommand < Command end class TerraformCommand < Command + PRODUCTION_TIME = 60 + PRODUCTION_VALUE = 5 + def initialize(@point : Point) end def start(world : World) : Int32 - 10 + PRODUCTION_TIME end def finish(world : World) - world.resources.inc(ResourceType::Terraformation, 5) + world.resources.inc(ResourceType::Terraformation, PRODUCTION_VALUE) world.push(TerraformCommand.new(@point)) end end diff --git a/src/expansion.cr b/src/expansion.cr index 026dc73..7aa0c1b 100644 --- a/src/expansion.cr +++ b/src/expansion.cr @@ -26,15 +26,13 @@ class Resources end class World + property ts : Int32 + def initialize @ts = 0 - @resources = Resources.new @map = Map.new - @queue = App::Queue.new - end - - private def ts - @ts + @resources = Resources.new + @tasks = App::Queue.new end def resources @@ -49,12 +47,12 @@ class World dur = command.start(self) done_at = @ts + dur printf "world : %d : plan `%s` at %d\n", @ts, typeof(command), done_at - @queue.push(done_at, command) + @tasks.push(done_at, command) end def run(ts : Int32) loop do - item = @queue.pop(ts) + item = @tasks.pop(ts) if item.nil? break end @@ -71,6 +69,6 @@ w.map.print w.push(BuildCrystalHarvesterCommand.new(Point.new(2, 3))) w.push(BuildCrystalRestorerCommand.new(Point.new(1, 2))) w.push(BuildTerraformerCommand.new(Point.new(3, 2))) -w.run(240) +w.run(2000) w.map.print pp w.resources