Add map for tests
This commit is contained in:
parent
6fa9a7cf8e
commit
354bbfcf32
@ -1 +1,10 @@
|
|||||||
require "spec"
|
require "spec"
|
||||||
|
require "../src/game/**"
|
||||||
|
require "../src/cli/**"
|
||||||
|
|
||||||
|
def create_map_2x2 : Game::Map
|
||||||
|
map = Game::Map.new 2, 2
|
||||||
|
map.set(Game::MainBaseTile.new(Game::Point.new(0, 0)))
|
||||||
|
map.set(Game::CrystalTile.new(Game::Point.new(1, 1), 100))
|
||||||
|
map
|
||||||
|
end
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
require "../src/game/world"
|
|
||||||
|
|
||||||
describe "World" do
|
describe "World" do
|
||||||
it "should build crystal harvester" do
|
it "should build crystal harvester" do
|
||||||
map = Game::Generator.make 5, 5
|
world = Game::World.new create_map_2x2
|
||||||
world = Game::World.new map
|
point = Game::Point.new 1, 0
|
||||||
point = Game::Point.new 2, 3
|
|
||||||
cmd = Game::BuildCrystalHarvesterCommand.new(point)
|
cmd = Game::BuildCrystalHarvesterCommand.new(point)
|
||||||
world.push(cmd)
|
world.push(cmd)
|
||||||
world.run(100)
|
world.run(100)
|
||||||
@ -13,9 +11,8 @@ describe "World" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "should fail when not enought resources" do
|
it "should fail when not enought resources" do
|
||||||
map = Game::Generator.make 5, 5
|
world = Game::World.new create_map_2x2
|
||||||
world = Game::World.new map
|
point = Game::Point.new 1, 0
|
||||||
point = Game::Point.new 2, 3
|
|
||||||
cmd = Game::BuildCrystalRestorerCommand.new(point)
|
cmd = Game::BuildCrystalRestorerCommand.new(point)
|
||||||
expect_raises(Game::NotEnoughtResources) do
|
expect_raises(Game::NotEnoughtResources) do
|
||||||
world.push(cmd)
|
world.push(cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user