diff --git a/src/app.cr b/src/app.cr index 376fed2..2543753 100644 --- a/src/app.cr +++ b/src/app.cr @@ -13,7 +13,6 @@ class App @router = CLI::CommandRouter.new @buildings.items.each do |i| - t = i[:t] b = i[:b] route = sprintf "%s {x} {y}", b.name.downcase desc = sprintf "Build %s at x,y", b.name @@ -26,7 +25,7 @@ class App end end - @router.add "help", "Show all commands" do |p| + @router.add "help", "Show all commands" do printf "Commands:\n" @router.routes.each do |r| printf " %s - %s\n", r.route, r.desc @@ -47,7 +46,7 @@ class App (0...rows).each do |x| if x == 0 printf "+" - (0...cols).each do |y| + (0...cols).each do printf "------+" end print "\n" @@ -59,7 +58,7 @@ class App end print "\n" printf "|" - (0...cols).each do |y| + (0...cols).each do printf " |" end print "\n" @@ -74,7 +73,7 @@ class App end print "\n" printf "+" - (0...cols).each do |y| + (0...cols).each do printf "------+" end print "\n" diff --git a/src/cli/command_router.cr b/src/cli/command_router.cr index 25983a0..91a1484 100644 --- a/src/cli/command_router.cr +++ b/src/cli/command_router.cr @@ -39,7 +39,7 @@ class CLI::CommandRouter m = command.match(pattern) return false if m.nil? 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 params = groups.transform_values { |v| v.to_s } cb.call params diff --git a/src/game/command.cr b/src/game/command.cr index 2c9cb53..49a88f5 100644 --- a/src/game/command.cr +++ b/src/game/command.cr @@ -80,15 +80,15 @@ module Game end private def nearest_deposit(world : World, res_type : Resource::Type) : DepositTile? - tile = world.map.nearest_tile @point do |tile| - tile.is_a?(DepositTile) && tile.dep.type == res_type && tile.dep.cur > 0 + tile = world.map.nearest_tile @point do |t| + t.is_a?(DepositTile) && t.dep.type == res_type && t.dep.cur > 0 end tile.as?(DepositTile) end private def nearest_stock(world : World) : BuildingTile? - tile = world.map.nearest_tile @point do |tile| - tile.is_a?(BuildingTile) && tile.building.has_role Building::Role::Storehouse + tile = world.map.nearest_tile @point do |t| + t.is_a?(BuildingTile) && t.building.has_role Building::Role::Storehouse end tile.as?(BuildingTile) end @@ -135,8 +135,8 @@ module Game end private def nearest_deposit(world : World, res_type : Resource::Type) : DepositTile? - tile = world.map.nearest_tile @point do |tile| - tile.is_a?(DepositTile) && tile.dep.type == res_type && tile.dep.cur == 0 + tile = world.map.nearest_tile @point do |t| + t.is_a?(DepositTile) && t.dep.type == res_type && t.dep.cur == 0 end tile.as?(DepositTile) end diff --git a/src/game/point.cr b/src/game/point.cr index d5ab1db..6caaf0a 100644 --- a/src/game/point.cr +++ b/src/game/point.cr @@ -9,6 +9,6 @@ struct Game::Point getter y def distance(other) : Int32 - return (other.x - @x).abs + (other.y - @y).abs + (other.x - @x).abs + (other.y - @y).abs end end diff --git a/src/game/resources.cr b/src/game/resources.cr index 3b5cfac..67c1db1 100644 --- a/src/game/resources.cr +++ b/src/game/resources.cr @@ -28,7 +28,7 @@ class Game::ResourceBag def initialize(vals : ResourceHash | Nil = nil) @values = ResourceHash.new - Resource::Type.each { |t, v| @values[t] = 0 } + Resource::Type.each { |t, _| @values[t] = 0 } if vals.is_a?(ResourceHash) add_amounts vals end