Line 2: |
Line 2: |
| local EquipmentListKai = require('Module:EquipmentListKai') | | local EquipmentListKai = require('Module:EquipmentListKai') |
| local Formatting = require('Module:Formatting') | | local Formatting = require('Module:Formatting') |
− | local StatIcons = require('Module:StatIcons') | + | local ResourceIcons = require('Module:Data/Asset') |
| + | local StatIcons = require('Module:Data/Asset') |
| | | |
− | local format = require('Module:StringInterpolation').format | + | local format = require('Module:Core').format |
| | | |
| local EquipmentComparisonKai = EquipmentListKai{ | | local EquipmentComparisonKai = EquipmentListKai{ |
| _columns = { | | _columns = { |
| "id", | | "id", |
− | "stars", | + | "rarity", |
| "name", | | "name", |
| "equipment_type", | | "equipment_type", |
Line 22: |
Line 23: |
| "shelling_accuracy", | | "shelling_accuracy", |
| "evasion", | | "evasion", |
| + | "anti_bomber", |
| + | "interception", |
| "speed", | | "speed", |
| "range", | | "range", |
| + | "combat_radius", |
| + | "deployment_cost", |
| "compatibility", | | "compatibility", |
| "buildable", | | "buildable", |
| + | "improvable", |
| "notes", | | "notes", |
| }, | | }, |
Line 39: |
Line 45: |
| "shelling_accuracy", | | "shelling_accuracy", |
| "evasion", | | "evasion", |
| + | "anti_bomber", |
| + | "interception", |
| "speed", | | "speed", |
| "range", | | "range", |
| + | "combat_radius", |
| + | "deployment_cost", |
| }, | | }, |
| _stat_colors = { | | _stat_colors = { |
Line 53: |
Line 63: |
| shelling_accuracy = "darkseagreen", | | shelling_accuracy = "darkseagreen", |
| evasion = "violet", | | evasion = "violet", |
| + | anti_bomber = "darkseagreen", |
| + | interception = "violet", |
| + | combat_radius = "lightseagreen", |
| + | deployment_cost = "#D4B390", |
| speed = "#72E6E6", | | speed = "#72E6E6", |
| range = "lightseagreen", | | range = "lightseagreen", |
Line 67: |
Line 81: |
| firepower = 0 | | firepower = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(firepower)}, bg_color = self:get_bg_color(self._cell_color.firepower, firepower, self._args.firepower_operator, self._args.firepower_outstanding, self._args.firepower_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(firepower)}, bg_color = self:get_bg_color(self._cell_color.firepower, firepower, self._args.firepower_operator, self._args.firepower_outstanding, self._args.firepower_good, self._args.firepower_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 77: |
Line 91: |
| torpedo = 0 | | torpedo = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(torpedo)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(torpedo)}, bg_color = self:get_bg_color(self._cell_color.torpedo, torpedo, self._args.torpedo_operator, self._args.torpedo_outstanding, self._args.torpedo_good, self._args.torpedo_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 87: |
Line 101: |
| bombing = 0 | | bombing = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(bombing)}, bg_color = self:get_bg_color(self._cell_color.bombing, bombing, self._args.bombing_operator, self._args.bombing_outstanding, self._args.bombing_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(bombing)}, bg_color = self:get_bg_color(self._cell_color.bombing, bombing, self._args.bombing_operator, self._args.bombing_outstanding, self._args.bombing_good, self._args.bombing_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 97: |
Line 111: |
| aa = 0 | | aa = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(aa)}, bg_color = self:get_bg_color(self._cell_color.aa, aa, self._args.aa_operator, self._args.aa_outstanding, self._args.aa_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(aa)}, bg_color = self:get_bg_color(self._cell_color.aa, aa, self._args.aa_operator, self._args.aa_outstanding, self._args.aa_good, self._args.aa_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 107: |
Line 121: |
| asw = 0 | | asw = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(asw)}, bg_color = self:get_bg_color(self._cell_color.asw, asw, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(asw)}, bg_color = self:get_bg_color(self._cell_color.asw, asw, self._args.asw_operator, self._args.asw_outstanding, self._args.asw_good, self._args.asw_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 117: |
Line 131: |
| los = 0 | | los = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(los)}, bg_color = self:get_bg_color(self._cell_color.los, los, self._args.los_operator, self._args.los_outstanding, self._args.los_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(los)}, bg_color = self:get_bg_color(self._cell_color.los, los, self._args.los_operator, self._args.los_outstanding, self._args.los_good, self._args.los_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 127: |
Line 141: |
| luck = 0 | | luck = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(luck)}, bg_color = self:get_bg_color(self._cell_color.luck, luck, self._args.luck_operator, self._args.luck_outstanding, self._args.luck_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(luck)}, bg_color = self:get_bg_color(self._cell_color.luck, luck, self._args.luck_operator, self._args.luck_outstanding, self._args.luck_good, self._args.luck_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 137: |
Line 151: |
| armor = 0 | | armor = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(armor)}, bg_color = self:get_bg_color(self._cell_color.armor, armor, self._args.armor_operator, self._args.armor_outstanding, self._args.armor_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(armor)}, bg_color = self:get_bg_color(self._cell_color.armor, armor, self._args.armor_operator, self._args.armor_outstanding, self._args.armor_good, self._args.armor_bad), text_align = self._center_align} |
| end | | end |
| | | |
| function EquipmentComparisonKai:shelling_accuracy(equipment) | | function EquipmentComparisonKai:shelling_accuracy(equipment) |
| local shelling_accuracy = equipment:shelling_accuracy() | | local shelling_accuracy = equipment:shelling_accuracy() |
| + | if equipment:type() == 48 then |
| + | shelling_accuracy = false |
| + | end |
| if shelling_accuracy ~= false then | | if shelling_accuracy ~= false then |
| self._shown_stats.shelling_accuracy = true | | self._shown_stats.shelling_accuracy = true |
Line 147: |
Line 164: |
| shelling_accuracy = 0 | | shelling_accuracy = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(shelling_accuracy)}, bg_color = self:get_bg_color(self._cell_color.shelling_accuracy, shelling_accuracy, self._args.shelling_accuracy_operator, self._args.shelling_accuracy_outstanding, self._args.shelling_accuracy_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(shelling_accuracy)}, bg_color = self:get_bg_color(self._cell_color.shelling_accuracy, shelling_accuracy, self._args.shelling_accuracy_operator, self._args.shelling_accuracy_outstanding, self._args.shelling_accuracy_good, self._args.shelling_accuracy_bad), text_align = self._center_align} |
| + | end |
| + | |
| + | function EquipmentComparisonKai:anti_bomber(equipment) |
| + | local anti_bomber = equipment:shelling_accuracy() |
| + | if equipment:type() ~= 48 then |
| + | anti_bomber = false |
| + | end |
| + | if anti_bomber ~= false then |
| + | self._shown_stats.anti_bomber = true |
| + | else |
| + | anti_bomber = 0 |
| + | end |
| + | return {values = {value = Formatting:format_stat(anti_bomber)}, bg_color = self:get_bg_color(self._cell_color.anti_bomber, anti_bomber, self._args.anti_bomber_operator, self._args.anti_bomber_outstanding, self._args.anti_bomber_good, self._args.anti_bomber_bad), text_align = self._center_align} |
| end | | end |
| | | |
| function EquipmentComparisonKai:evasion(equipment) | | function EquipmentComparisonKai:evasion(equipment) |
| local evasion = equipment:evasion() | | local evasion = equipment:evasion() |
| + | if equipment:type() == 48 then |
| + | evasion = false |
| + | end |
| if evasion ~= false then | | if evasion ~= false then |
| self._shown_stats.evasion = true | | self._shown_stats.evasion = true |
Line 157: |
Line 190: |
| evasion = 0 | | evasion = 0 |
| end | | end |
− | return {values = {value = Formatting:format_stat(evasion)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_stat(evasion)}, bg_color = self:get_bg_color(self._cell_color.evasion, evasion, self._args.evasion_operator, self._args.evasion_outstanding, self._args.evasion_good, self._args.evasion_bad), text_align = self._center_align} |
| + | end |
| + | |
| + | function EquipmentComparisonKai:interception(equipment) |
| + | local interception = equipment:evasion() |
| + | if equipment:type() ~= 48 then |
| + | interception = false |
| + | end |
| + | if interception ~= false then |
| + | self._shown_stats.interception = true |
| + | else |
| + | interception = 0 |
| + | end |
| + | return {values = {value = Formatting:format_stat(interception)}, bg_color = self:get_bg_color(self._cell_color.interception, interception, self._args.interception_operator, self._args.interception_outstanding, self._args.interception_good, self._args.interception_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 167: |
Line 213: |
| speed = 0 | | speed = 0 |
| end | | end |
− | return {values = {value = Formatting:format_speed(speed)}, bg_color = self:get_bg_color(self._cell_color.speed, speed, self._args.speed_operator, self._args.speed_outstanding, self._args.speed_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_speed(speed)}, bg_color = self:get_bg_color(self._cell_color.speed, speed, self._args.speed_operator, self._args.speed_outstanding, self._args.speed_good, self._args.speed_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 177: |
Line 223: |
| range = 0 | | range = 0 |
| end | | end |
− | return {values = {value = Formatting:format_range(range)}, bg_color = self:get_bg_color(self._cell_color.range, range, self._args.range_operator, self._args.range_outstanding, self._args.range_good), text_align = self._center_align} | + | return {values = {value = Formatting:format_range(range)}, bg_color = self:get_bg_color(self._cell_color.range, range, self._args.range_operator, self._args.range_outstanding, self._args.range_good, self._args.range_bad), text_align = self._center_align} |
| + | end |
| + | |
| + | function EquipmentComparisonKai:combat_radius(equipment) |
| + | local combat_radius = equipment:combat_radius() |
| + | if combat_radius then |
| + | self._shown_stats.combat_radius = true |
| + | else |
| + | combat_radius = "-" |
| + | end |
| + | return {values = {value = Formatting:format_stat(combat_radius)}, bg_color = self:get_bg_color(self._cell_color.combat_radius, combat_radius, self._args.combat_radius_operator, self._args.combat_radius_outstanding, self._args.combat_radius_good, self._args.combat_radius_bad), text_align = self._center_align} |
| + | end |
| + | |
| + | function EquipmentComparisonKai:deployment_cost(equipment) |
| + | local deployment_cost = equipment:deployment_cost().bauxite |
| + | if deployment_cost then |
| + | self._shown_stats.deployment_cost = true |
| + | else |
| + | deployment_cost = "-" |
| + | end |
| + | return {values = {value = Formatting:format_stat(deployment_cost)}, bg_color = self:get_bg_color(self._cell_color.deployment_cost, deployment_cost, self._args.deployment_cost_operator, self._args.deployment_cost_outstanding, self._args.deployment_cost_good, self._args.deployment_cost_bad), text_align = self._center_align} |
| end | | end |
| | | |
Line 183: |
Line 249: |
| local note = self._notes[equipment] | | local note = self._notes[equipment] |
| if note then | | if note then |
− | local bg_color | + | local bg_color = self._transparent |
− | if note.highlight == "outstanding" then | + | if note.highlight then |
− | bg_color = self._outstanding_stat_color
| + | if note.highlight == "outstanding" then |
− | elseif note.highlight == "good" then
| + | bg_color = self._outstanding_stat_color |
− | bg_color = self._good_stat_color
| + | elseif note.highlight == "good" then |
− | else
| + | bg_color = self._good_stat_color |
− | bg_color = self._transparent
| + | elseif note.highlight == "bad" then |
| + | bg_color = self._bad_stat_color |
| + | end |
| end | | end |
| return {values = {value = note.note or ""}, bg_color = bg_color} | | return {values = {value = note.note or ""}, bg_color = bg_color} |
Line 206: |
Line 274: |
| for _, column in ipairs(self._stat_columns) do | | for _, column in ipairs(self._stat_columns) do |
| if self._shown_stats[column] then | | if self._shown_stats[column] then |
− | table.insert(stat_columns, format{self._column_header_cell_template, value = Formatting:format_image{StatIcons[column], caption = Formatting:format_stat_name(column)}, bg_color = self._stat_colors[column]}) | + | table.insert(stat_columns, format{self._column_header_cell_template, value = Formatting:format_image{StatIcons[column] or (column == "deployment_cost" and ResourceIcons.bauxite or nil), caption = Formatting:format_stat_name(column)}, bg_color = self._stat_colors[column]}) |
| else | | else |
| for _, row_values in ipairs(self._data_rows) do | | for _, row_values in ipairs(self._data_rows) do |
− | row_values[column] = nil | + | if type(row_values) == "table" then |
| + | row_values[column] = nil |
| + | end |
| end | | end |
| end | | end |