Building name is optional
This commit is contained in:
parent
d3fe2ff23b
commit
a13969ce43
@ -2,12 +2,12 @@ require "./spec_helper"
|
||||
|
||||
describe Game::Building do
|
||||
it "should create storehouse" do
|
||||
bg = Game::Building.new Game::Building::Type::Storehouse, "Storehouse", storage: 100
|
||||
bg = Game::Building.new Game::Building::Type::Storehouse, storage: 100
|
||||
bg.storage.should eq 100
|
||||
end
|
||||
|
||||
it "should create crystal miner" do
|
||||
bg = Game::Building.new Game::Building::Type::CrystalMiner, "Cryslal Miner", **{
|
||||
bg = Game::Building.new Game::Building::Type::CrystalMiner, **{
|
||||
production: Game::Production.new(
|
||||
ts: 20,
|
||||
input: Game::Resources.new,
|
||||
|
@ -4,7 +4,7 @@ describe Game::Command do
|
||||
it "should complete build command" do
|
||||
world = Game::World.new create_map_2x2
|
||||
point = Game::Point.new 1, 0
|
||||
building = Game::Building.new Game::Building::Type::StartPoint, "Dummy", **{
|
||||
building = Game::Building.new Game::Building::Type::StartPoint, **{
|
||||
construction: Game::Construction.free 10,
|
||||
}
|
||||
command = Game::BuildCommand.new point, building
|
||||
@ -19,7 +19,7 @@ describe Game::Command do
|
||||
it "should restrict build if not enought resources" do
|
||||
world = Game::World.new create_map_2x2
|
||||
point = Game::Point.new 1, 0
|
||||
building = Game::Building.new Game::Building::Type::StartPoint, "Dummy", **{
|
||||
building = Game::Building.new Game::Building::Type::StartPoint, **{
|
||||
construction: Game::Construction.new(
|
||||
ts: 10,
|
||||
cost: Game::Resources.new({
|
||||
|
@ -50,8 +50,8 @@ module Game
|
||||
|
||||
def initialize(
|
||||
@type : Type,
|
||||
@name : String,
|
||||
*,
|
||||
name : String = "",
|
||||
roles : Array(Role) | Nil = nil,
|
||||
construction : Construction | Nil = nil,
|
||||
production : Production | Nil = nil,
|
||||
@ -59,6 +59,7 @@ module Game
|
||||
restoration : Mining | Nil = nil,
|
||||
storage : Capacity | Nil = nil
|
||||
)
|
||||
@name = name != "" ? name : @type.to_s
|
||||
@roles = roles.nil? ? Array(Role).new : roles
|
||||
@construction = construction.nil? ? Construction.immediatly : construction.as(Construction)
|
||||
@production = production
|
||||
|
Loading…
Reference in New Issue
Block a user