Add construction site tile
This commit is contained in:
parent
cf2d81cbb1
commit
9dad61f7a2
@ -13,6 +13,7 @@ module Game
|
|||||||
end
|
end
|
||||||
|
|
||||||
def start(world : World) : Int32
|
def start(world : World) : Int32
|
||||||
|
world.map.set(ConstructionSiteTile.new(@point))
|
||||||
BUILD_TIME
|
BUILD_TIME
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ module Game
|
|||||||
|
|
||||||
def start(world : World) : Int32
|
def start(world : World) : Int32
|
||||||
world.resources.dec(ResourceType::Crystal, CRYSTALS_COST)
|
world.resources.dec(ResourceType::Crystal, CRYSTALS_COST)
|
||||||
|
world.map.set(ConstructionSiteTile.new(@point))
|
||||||
BUILD_TIME
|
BUILD_TIME
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -122,6 +124,7 @@ module Game
|
|||||||
end
|
end
|
||||||
|
|
||||||
def start(world : World) : Int32
|
def start(world : World) : Int32
|
||||||
|
world.map.set(ConstructionSiteTile.new(@point))
|
||||||
world.resources.dec(ResourceType::Crystal, CRYSTALS_COST)
|
world.resources.dec(ResourceType::Crystal, CRYSTALS_COST)
|
||||||
BUILD_TIME
|
BUILD_TIME
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ module Game
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get(x : Int32, y : Int32) : Tile
|
def get(x : Int32, y : Int32) : Tile
|
||||||
@data[key(Point.new(x, y))]
|
get(Point.new(x, y))
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(tile : Tile)
|
def set(tile : Tile)
|
||||||
@ -75,15 +75,6 @@ module Game
|
|||||||
seek_tile
|
seek_tile
|
||||||
end
|
end
|
||||||
|
|
||||||
def print
|
|
||||||
(0...SIZE).each do |x|
|
|
||||||
(0...SIZE).each do |y|
|
|
||||||
printf "%c", @data[key(Point.new(x, y))].letter
|
|
||||||
end
|
|
||||||
printf "\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private def key(p : Point) : String
|
private def key(p : Point) : String
|
||||||
return sprintf "%d:%d", p.x, p.y
|
return sprintf "%d:%d", p.x, p.y
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module Game
|
module Game
|
||||||
enum TileRole
|
enum TileRole
|
||||||
|
ConstructionSite
|
||||||
CrystalDeposits
|
CrystalDeposits
|
||||||
CrystalHarvester
|
CrystalHarvester
|
||||||
CrystalRestorer
|
CrystalRestorer
|
||||||
@ -37,6 +38,10 @@ module Game
|
|||||||
charged = @cur + value
|
charged = @cur + value
|
||||||
@cur = charged <= @cap ? charged : @cap
|
@cur = charged <= @cap ? charged : @cap
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_build?
|
||||||
|
@role == TileRole::Plateau
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class PlateauTile < Tile
|
class PlateauTile < Tile
|
||||||
@ -49,6 +54,16 @@ module Game
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ConstructionSiteTile < Tile
|
||||||
|
def letter : Char
|
||||||
|
'_'
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_role(role : TileRole) : Bool
|
||||||
|
role == TileRole::ConstructionSite
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class MainBaseTile < Tile
|
class MainBaseTile < Tile
|
||||||
def letter : Char
|
def letter : Char
|
||||||
'H'
|
'H'
|
||||||
|
Loading…
Reference in New Issue
Block a user