Skip to content

Commit

Permalink
Fix some small bugs in warcraft infobox building and infobox unit (#3325
Browse files Browse the repository at this point in the history
)

* Fix some small bugs in warcraft infobox building

* Update infobox_unit_custom.lua
  • Loading branch information
hjpalpha authored Sep 27, 2023
1 parent acf1c36 commit e68cdac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions components/infobox/wikis/warcraft/infobox_building_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ local EXPERIENCE = mw.loadData('Module:Experience')
local DEFAULT_BUILDING_TYPE_RACE = 'Neutral'
local ICON_HP = '[[File:Icon_Hitpoints.png|link=Hit Points]]'
local ICON_FOOD = '[[File:Food_WC3_Icon.gif|15px|link=Food]]'
local ADDITIONAL_BUILDING_RACES = {
creeps = 'Creeps',
neutral = 'Creeps',
c = 'Creeps',
}

local _args

Expand Down Expand Up @@ -64,20 +69,21 @@ function CustomInjector:addCustomCells(widgets)
local mana = Shared.manaValues(_args)
local acquisitionRange = tonumber(_args.acq_range) or 0
local level = tonumber(_args.level) or 0
local race = Faction.toName(Faction.read(_args.race)) or ADDITIONAL_BUILDING_RACES[string.lower(_args.race or '')]

Array.appendWith(widgets,
Cell{name = '[[Food supplied|Food]]', content = {
_args.foodproduced and (ICON_FOOD .. ' ' .. _args.foodproduced) or nil,
}},
Cell{name = '[[Race|Race]]', content = {'[['.. Faction.toName(Faction.read(_args.race)) ..']]'}},
Cell{name = '[[Race]]', content = {race and ('[[' .. race .. ']]') or _args.race}},
Cell{name = '[[Targeting#Target_Classifications|Classification]]', content = {
_args.class and String.convertWikiListToHtmlList(_args.class) or nil}},
Cell{name = 'Sleeps', content = {_args.sleeps}},
Cell{name = 'Cargo Capacity', content = {_args.cargo_capacity}},
Cell{name = 'Morphs into', content = {_args.morphs}},
Cell{name = 'Duration', content = {_args.duration}},
Cell{name = 'Formation Rank', content = {_args.formationrank}},
Cell{name = '[[Sight_Range|Sight]]', content = {_args.daysight .. ' / ' .. _args.nightsight}},
Cell{name = '[[Sight_Range|Sight]]', content = {race and (_args.daysight .. ' / ' .. _args.nightsight) or nil}},
Cell{name = 'Acquisition Range', content = {acquisitionRange > 0 and acquisitionRange or nil}},
Cell{name = '[[Experience#Determining_Experience_Gained|Level]]', content = {
level > 0 and ('[[Experience|'.._args.level..']]') or nil}},
Expand Down Expand Up @@ -190,7 +196,7 @@ function CustomBuilding:_defenseDisplay()
end

local display = ICON_HP .. ' ' .. (_args.hp or 0)
if tonumber(_args.hitpoint_bonus) > 0 then
if (tonumber(_args.hitpoint_bonus) or 0) > 0 then
return display .. ' (' .. _args.hp + _args.hitpoint_bonus .. ')'
end
return display
Expand Down
8 changes: 7 additions & 1 deletion components/infobox/wikis/warcraft/infobox_unit_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ local EXPERIENCE = mw.loadData('Module:Experience')
local CRITTERS = 'critters'
local ICON_HP = '[[File:Icon_Hitpoints.png|link=Hit Points]]'
local GOLD = '[[File:Gold WC3 Icon.gif|15px|link=Gold]]'
local ADDITIONAL_UNIT_RACES = {
creeps = 'Creeps',
neutral = 'Creeps',
c = 'Creeps',
}

local _args

Expand Down Expand Up @@ -63,9 +68,10 @@ function CustomInjector:addCustomCells(widgets)
local mana = Shared.manaValues(_args)
local acquisitionRange = tonumber(_args.acq_range) or 0
local level = tonumber(_args.level) or 0
local race = Faction.toName(Faction.read(_args.race)) or ADDITIONAL_UNIT_RACES[string.lower(_args.race or '')]

Array.appendWith(widgets,
Cell{name = '[[Race|Race]]', content = {'[['.. Faction.toName(Faction.read(_args.race)) ..']]'}},
Cell{name = '[[Race]]', content = {race and ('[[' .. race .. ']]') or _args.race}},
Cell{name = '[[Targeting#Target_Classifications|Classification]]', content = {
_args.class and String.convertWikiListToHtmlList(_args.class) or nil}},
Cell{name = 'Bounty Awarded', content = {CustomUnit._bounty(_args)}},
Expand Down

0 comments on commit e68cdac

Please sign in to comment.