Add small world test
This commit is contained in:
parent
2df6b2f3ee
commit
6404a6e519
2
Makefile
2
Makefile
@ -24,5 +24,5 @@ format:
|
||||
|
||||
.PHONY: spec
|
||||
spec: format
|
||||
./crystal spec --warnings all --error-on-warnings
|
||||
./crystal spec --no-debug --warnings all --error-on-warnings
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require "spec"
|
||||
require "./spec_helper"
|
||||
require "./../src/map"
|
||||
require "./../src/queue"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require "spec"
|
||||
require "./spec_helper"
|
||||
require "./../src/queue"
|
||||
require "./../src/command"
|
||||
|
||||
|
13
spec/world_spec.cr
Normal file
13
spec/world_spec.cr
Normal file
@ -0,0 +1,13 @@
|
||||
require "./spec_helper"
|
||||
require "../src/world"
|
||||
|
||||
describe "World" do
|
||||
it "should build crystal harvester" do
|
||||
world = World.new
|
||||
point = Point.new(2, 3)
|
||||
cmd = BuildCrystalHarvesterCommand.new(point)
|
||||
world.push(cmd)
|
||||
world.run(100)
|
||||
world.map.get(point).has_role(TileRole::CrystalHarvester)
|
||||
end
|
||||
end
|
@ -1,3 +1,5 @@
|
||||
require "./resources"
|
||||
|
||||
class World
|
||||
property ts : Int32
|
||||
|
||||
@ -15,7 +17,6 @@ class World
|
||||
def push(command : Command)
|
||||
dur = command.start(self)
|
||||
done_at = @ts + dur
|
||||
printf "world : %d : plan `%s` at %d\n", @ts, typeof(command), done_at
|
||||
@tasks.push(done_at, command)
|
||||
end
|
||||
|
||||
@ -28,7 +29,6 @@ class World
|
||||
command = item.command
|
||||
@ts = item.ts
|
||||
command.finish(self)
|
||||
printf "world : %d : finish `%s`\n", @ts, typeof(command)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user