[LuaDoc] Fix some non-nullable warnings by adding explicit type annotations on local variables
This commit is contained in:
parent
b506010a8f
commit
94adca0fff
3 changed files with 8 additions and 0 deletions
|
@ -1489,6 +1489,7 @@ function ai_helper.can_reach(unit, x, y, cfg)
|
|||
local ignore_visibility = cfg and cfg.ignore_visibility
|
||||
|
||||
-- Is there a visible unit at the goal hex?
|
||||
---@type unit?
|
||||
local unit_in_way = wesnoth.units.get(x, y)
|
||||
if unit_in_way and (not ignore_visibility) and (not ai_helper.is_visible_unit(viewing_side, unit_in_way)) then
|
||||
unit_in_way = nil
|
||||
|
@ -1558,6 +1559,7 @@ function ai_helper.get_reachmap(unit, cfg)
|
|||
if cfg and cfg.avoid_map and cfg.avoid_map:get(loc[1], loc[2]) then
|
||||
is_available = false
|
||||
else
|
||||
---@type unit?
|
||||
local unit_in_way = wesnoth.units.get(loc[1], loc[2])
|
||||
if unit_in_way and (unit_in_way.id == unit.id) then
|
||||
unit_in_way = nil
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local LS = wesnoth.require "location_set"
|
||||
---@type ai_helper_lib
|
||||
local AH = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
|
||||
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"
|
||||
|
@ -26,6 +27,7 @@ local function bottleneck_is_my_territory(map, enemy_map)
|
|||
dummy_unit.x, dummy_unit.y = x, y
|
||||
|
||||
-- Find lowest movement cost to own front-line hexes
|
||||
---@type number, location[]?
|
||||
local min_cost, best_path = math.huge, nil
|
||||
map:iter(function(xm, ym, v)
|
||||
local path, cost = AH.find_path_with_shroud(dummy_unit, xm, ym, { ignore_units = true })
|
||||
|
@ -35,6 +37,7 @@ local function bottleneck_is_my_territory(map, enemy_map)
|
|||
end)
|
||||
|
||||
-- And the same to the enemy front line
|
||||
---@type number, location[]?
|
||||
local min_cost_enemy, best_path_enemy = math.huge, nil
|
||||
enemy_map:iter(function(xm, ym, v)
|
||||
local path, cost = AH.find_path_with_shroud(dummy_unit, xm, ym, { ignore_units = true })
|
||||
|
@ -321,6 +324,7 @@ function ca_bottleneck_move:evaluation(cfg, data)
|
|||
for _,enemy in ipairs(enemies) do
|
||||
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
|
||||
if BD_is_my_territory:get(xa, ya) then
|
||||
---@type unit?
|
||||
local unit_in_way = wesnoth.units.get(xa, ya)
|
||||
if (not AH.is_visible_unit(wesnoth.current.side, unit_in_way)) then
|
||||
unit_in_way = nil
|
||||
|
@ -439,6 +443,7 @@ function ca_bottleneck_move:evaluation(cfg, data)
|
|||
BD_bottleneck_moves_done = true
|
||||
else
|
||||
-- If there's another unit in the best location, moving it out of the way becomes the best move
|
||||
---@type unit?
|
||||
local unit_in_way = wesnoth.units.find_on_map { x = best_hex[1], y = best_hex[2],
|
||||
{ "not", { id = best_unit.id } }
|
||||
}[1]
|
||||
|
|
|
@ -32,6 +32,7 @@ function ca_forest_animals_tusker_attack:execution(cfg)
|
|||
local adjacent_enemies = get_adjacent_enemies(cfg)
|
||||
|
||||
-- Find the closest enemy to any tusker
|
||||
---@type number, unit?, unit?
|
||||
local min_dist, attacker, target = math.huge, nil, nil
|
||||
for _,tusker in ipairs(tuskers) do
|
||||
for _,enemy in ipairs(adjacent_enemies) do
|
||||
|
|
Loading…
Add table
Reference in a new issue