Changes

no edit summary
Line 1: Line 1: −
local BaseData = require('Module:BaseData')
+
local BaseTable = require('Module:BaseTable')
 
local Equipment = require('Module:Equipment')
 
local Equipment = require('Module:Equipment')
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
Line 6: Line 6:  
local format = require('Module:StringInterpolation').format
 
local format = require('Module:StringInterpolation').format
   −
local EquipmentListKai = BaseData{
+
local EquipmentListKai = BaseTable{
 
_table_start = [[{| class="wikitable"]],
 
_table_start = [[{| class="wikitable"]],
 
_row_starter = "|-",
 
_row_starter = "|-",
Line 17: Line 17:  
! Craftable
 
! Craftable
 
! style="white-space:nowrap;width:130px;" | Notes]],
 
! style="white-space:nowrap;width:130px;" | Notes]],
_column_header_cell_template = "! ${value}",
   
_column_cell_templates = {
 
_column_cell_templates = {
 
name = [[| colspan="1" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.name}<br />${values.icon} ${values.japanese_name}]]
 
name = [[| colspan="1" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.name}<br />${values.icon} ${values.japanese_name}]]
},
  −
_icons = {
  −
firepower = "${stat_icons.firepower}",
  −
torpedo = "${stat_icons.torpedo}",
  −
bombing = "${stat_icons.bombing}",
  −
aa = "${stat_icons.aa}",
  −
asw = "${stat_icons.asw}",
  −
los = "${stat_icons.los}",
  −
armor = "${stat_icons.armor}",
  −
accuracy = "${stat_icons.accuracy}",
  −
evasion = "${stat_icons.evasion}",
  −
range = "${stat_icons.range}",
   
},
 
},
 
_comparison_columns = {
 
_comparison_columns = {
Line 78: Line 65:  
"notes",
 
"notes",
 
},
 
},
_cell_color = {
  −
},
  −
_cell = [[| colspan="1" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.value}]],
  −
_good_stat_color = "#ffff40",
  −
_outstanding_stat_color = "#73ff4d",
  −
_transparent = "transparent",
  −
_start_align = "start",
  −
_center_align = "center",
  −
_notes_suffix = "_notes",
  −
_highlight_suffix = "_highlight",
   
_stats_column_label = "Stats",
 
_stats_column_label = "Stats",
_table_end = [[|}]],
  −
_operators = {
  −
["<"] = function(x,y) return x < y end,
  −
[">"] = function(x,y) return x > y end,
  −
},
   
}
 
}
  −
function EquipmentListKai:Table(args)
  −
return self{
  −
_args = args,
  −
}:create_table()
  −
end
      
function EquipmentListKai:id(equipment)
 
function EquipmentListKai:id(equipment)
Line 289: Line 255:  
end
 
end
 
return {values = {value = ""}, bg_color = self._transparent}
 
return {values = {value = ""}, bg_color = self._transparent}
end
  −
  −
function EquipmentListKai:get_bg_color(default, value, operator, outstanding, good)
  −
if not value then
  −
return default or self._transparent
  −
end
  −
local comparison = self._operators[operator or ">"]
  −
if outstanding and comparison(value, tonumber(outstanding)) then
  −
return self._outstanding_stat_color
  −
elseif good and comparison(value, tonumber(good)) then
  −
return self._good_stat_color
  −
else
  −
return default or self._transparent
  −
end
  −
end
  −
  −
function EquipmentListKai.compare_values(val1, val2)
  −
if #val1 == #val2 then
  −
for value_type, value in pairs(val1) do
  −
if value ~= val2[value_type] then
  −
return false
  −
end
  −
end
  −
else
  −
return false
  −
end
  −
return true
   
end
 
end
   Line 435: Line 374:  
table.insert(rows, self._table_end)
 
table.insert(rows, self._table_end)
 
return table.concat(rows, "\n")
 
return table.concat(rows, "\n")
end
  −
  −
function EquipmentListKai.test(frame)
  −
local getArgs = require('Module:GetArgs')
  −
local args = getArgs{frame = frame}
  −
return EquipmentListKai:Table(args)
   
end
 
end
    
return EquipmentListKai
 
return EquipmentListKai
Anonymous user