Fix ameba inspections
This commit is contained in:
parent
b63c00cea4
commit
ea5e7950de
@ -13,7 +13,6 @@ class App
|
|||||||
@router = CLI::CommandRouter.new
|
@router = CLI::CommandRouter.new
|
||||||
|
|
||||||
@buildings.items.each do |i|
|
@buildings.items.each do |i|
|
||||||
t = i[:t]
|
|
||||||
b = i[:b]
|
b = i[:b]
|
||||||
route = sprintf "%s {x} {y}", b.name.downcase
|
route = sprintf "%s {x} {y}", b.name.downcase
|
||||||
desc = sprintf "Build %s at x,y", b.name
|
desc = sprintf "Build %s at x,y", b.name
|
||||||
@ -26,7 +25,7 @@ class App
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@router.add "help", "Show all commands" do |p|
|
@router.add "help", "Show all commands" do
|
||||||
printf "Commands:\n"
|
printf "Commands:\n"
|
||||||
@router.routes.each do |r|
|
@router.routes.each do |r|
|
||||||
printf " %s - %s\n", r.route, r.desc
|
printf " %s - %s\n", r.route, r.desc
|
||||||
@ -47,7 +46,7 @@ class App
|
|||||||
(0...rows).each do |x|
|
(0...rows).each do |x|
|
||||||
if x == 0
|
if x == 0
|
||||||
printf "+"
|
printf "+"
|
||||||
(0...cols).each do |y|
|
(0...cols).each do
|
||||||
printf "------+"
|
printf "------+"
|
||||||
end
|
end
|
||||||
print "\n"
|
print "\n"
|
||||||
@ -59,7 +58,7 @@ class App
|
|||||||
end
|
end
|
||||||
print "\n"
|
print "\n"
|
||||||
printf "|"
|
printf "|"
|
||||||
(0...cols).each do |y|
|
(0...cols).each do
|
||||||
printf " |"
|
printf " |"
|
||||||
end
|
end
|
||||||
print "\n"
|
print "\n"
|
||||||
@ -74,7 +73,7 @@ class App
|
|||||||
end
|
end
|
||||||
print "\n"
|
print "\n"
|
||||||
printf "+"
|
printf "+"
|
||||||
(0...cols).each do |y|
|
(0...cols).each do
|
||||||
printf "------+"
|
printf "------+"
|
||||||
end
|
end
|
||||||
print "\n"
|
print "\n"
|
||||||
|
@ -39,7 +39,7 @@ class CLI::CommandRouter
|
|||||||
m = command.match(pattern)
|
m = command.match(pattern)
|
||||||
return false if m.nil?
|
return false if m.nil?
|
||||||
groups = m.named_captures
|
groups = m.named_captures
|
||||||
nil_groups = groups.select { |k, v| v.nil? }
|
nil_groups = groups.select { |_, v| v.nil? }
|
||||||
return false if nil_groups.size != 0
|
return false if nil_groups.size != 0
|
||||||
params = groups.transform_values { |v| v.to_s }
|
params = groups.transform_values { |v| v.to_s }
|
||||||
cb.call params
|
cb.call params
|
||||||
|
@ -80,15 +80,15 @@ module Game
|
|||||||
end
|
end
|
||||||
|
|
||||||
private def nearest_deposit(world : World, res_type : Resource::Type) : DepositTile?
|
private def nearest_deposit(world : World, res_type : Resource::Type) : DepositTile?
|
||||||
tile = world.map.nearest_tile @point do |tile|
|
tile = world.map.nearest_tile @point do |t|
|
||||||
tile.is_a?(DepositTile) && tile.dep.type == res_type && tile.dep.cur > 0
|
t.is_a?(DepositTile) && t.dep.type == res_type && t.dep.cur > 0
|
||||||
end
|
end
|
||||||
tile.as?(DepositTile)
|
tile.as?(DepositTile)
|
||||||
end
|
end
|
||||||
|
|
||||||
private def nearest_stock(world : World) : BuildingTile?
|
private def nearest_stock(world : World) : BuildingTile?
|
||||||
tile = world.map.nearest_tile @point do |tile|
|
tile = world.map.nearest_tile @point do |t|
|
||||||
tile.is_a?(BuildingTile) && tile.building.has_role Building::Role::Storehouse
|
t.is_a?(BuildingTile) && t.building.has_role Building::Role::Storehouse
|
||||||
end
|
end
|
||||||
tile.as?(BuildingTile)
|
tile.as?(BuildingTile)
|
||||||
end
|
end
|
||||||
@ -135,8 +135,8 @@ module Game
|
|||||||
end
|
end
|
||||||
|
|
||||||
private def nearest_deposit(world : World, res_type : Resource::Type) : DepositTile?
|
private def nearest_deposit(world : World, res_type : Resource::Type) : DepositTile?
|
||||||
tile = world.map.nearest_tile @point do |tile|
|
tile = world.map.nearest_tile @point do |t|
|
||||||
tile.is_a?(DepositTile) && tile.dep.type == res_type && tile.dep.cur == 0
|
t.is_a?(DepositTile) && t.dep.type == res_type && t.dep.cur == 0
|
||||||
end
|
end
|
||||||
tile.as?(DepositTile)
|
tile.as?(DepositTile)
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,6 @@ struct Game::Point
|
|||||||
getter y
|
getter y
|
||||||
|
|
||||||
def distance(other) : Int32
|
def distance(other) : Int32
|
||||||
return (other.x - @x).abs + (other.y - @y).abs
|
(other.x - @x).abs + (other.y - @y).abs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ class Game::ResourceBag
|
|||||||
|
|
||||||
def initialize(vals : ResourceHash | Nil = nil)
|
def initialize(vals : ResourceHash | Nil = nil)
|
||||||
@values = ResourceHash.new
|
@values = ResourceHash.new
|
||||||
Resource::Type.each { |t, v| @values[t] = 0 }
|
Resource::Type.each { |t, _| @values[t] = 0 }
|
||||||
if vals.is_a?(ResourceHash)
|
if vals.is_a?(ResourceHash)
|
||||||
add_amounts vals
|
add_amounts vals
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user