Small fix

This commit is contained in:
Anton Vakhrushev 2019-09-16 21:59:58 +03:00
parent f0ec7833d7
commit 9c8fdb89ac

View File

@ -15,9 +15,9 @@ end
abstract class Tile abstract class Tile
property cap : Int32 = 0 property cap : Int32 = 0
property cur : Int32 = 0
def initialize(@point : Point) def initialize(@point : Point)
@cur = 0
end end
getter point getter point
@ -36,17 +36,14 @@ abstract class Tile
end end
def charge(value) def charge(value)
if (value + @cur) > @cap charged = @cur + value
@cur = @cap @cur = charged <= @cap ? charged : @cap
else
@cur += value
end
end end
abstract def letter : Char abstract def letter : Char
end end
class GrassTile < Tile class StoneTile < Tile
def letter : Char def letter : Char
'.' '.'
end end
@ -82,7 +79,7 @@ class Map
@data = {} of String => Tile @data = {} of String => Tile
(0...SIZE).each do |x| (0...SIZE).each do |x|
(0...SIZE).each do |y| (0...SIZE).each do |y|
self.set(GrassTile.new(Point.new(x, y))) self.set(StoneTile.new(Point.new(x, y)))
end end
end end
self.set(WoodTile.new(Point.new(1, 1), 100)) self.set(WoodTile.new(Point.new(1, 1), 100))