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