Add forester coords
This commit is contained in:
parent
40c8e0640f
commit
101c4179df
@ -39,6 +39,12 @@ class WoodMillTile < Tile
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ForesterHouseTile < Tile
|
||||||
|
def letter : Char
|
||||||
|
'h'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
struct Point
|
struct Point
|
||||||
def initialize(@x : Int32, @y : Int32)
|
def initialize(@x : Int32, @y : Int32)
|
||||||
end
|
end
|
||||||
|
@ -30,21 +30,23 @@ class BuildWoodMillCommand < Command
|
|||||||
|
|
||||||
def run(ts : Int32, world : World)
|
def run(ts : Int32, world : World)
|
||||||
printf "build mill at [%d,%d]\n", @point.x, @point.y
|
printf "build mill at [%d,%d]\n", @point.x, @point.y
|
||||||
c = GetWoodCommand.new
|
|
||||||
world.map.set(@point, WoodMillTile.new)
|
world.map.set(@point, WoodMillTile.new)
|
||||||
world.push(ts + 5, c)
|
world.push(ts + 5, GetWoodCommand.new)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class BuildForesterHouseCommand < Command
|
class BuildForesterHouseCommand < Command
|
||||||
|
def initialize(@point : Point)
|
||||||
|
end
|
||||||
|
|
||||||
def supports?(world : World) : Bool
|
def supports?(world : World) : Bool
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(ts : Int32, world : World)
|
def run(ts : Int32, world : World)
|
||||||
puts "build forester house"
|
printf "build forester house at [%d,%d]\n", @point.x, @point.y
|
||||||
c = GrowWoodCommand.new
|
world.map.set(@point, ForesterHouseTile.new)
|
||||||
world.push(ts + 10, c)
|
world.push(ts + 10, GrowWoodCommand.new)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -115,6 +117,6 @@ end
|
|||||||
w = World.new
|
w = World.new
|
||||||
w.map.print
|
w.map.print
|
||||||
w.push(0, BuildWoodMillCommand.new(Point.new(0, 0)))
|
w.push(0, BuildWoodMillCommand.new(Point.new(0, 0)))
|
||||||
w.push(1, BuildForesterHouseCommand.new)
|
w.push(0, BuildForesterHouseCommand.new(Point.new(2, 0)))
|
||||||
w.run(20)
|
w.run(20)
|
||||||
w.map.print
|
w.map.print
|
||||||
|
Loading…
Reference in New Issue
Block a user