Changes

Add missing date template, add missing ipairs, fix buildable
Line 38: Line 38:  
     _node_formation_template = "-${formation}",
 
     _node_formation_template = "-${formation}",
 
     _event_node_name_template = "${year} ${quarter} E-${map}-${node}",
 
     _event_node_name_template = "${year} ${quarter} E-${map}-${node}",
 +
    _date_template = "${year}-${month}-${day}",
 
     _quarters = {
 
     _quarters = {
 
     [1] = "Winter",
 
     [1] = "Winter",
Line 89: Line 90:  
     local availability = self._ship:availability()
 
     local availability = self._ship:availability()
 
     local result = {}
 
     local result = {}
 +
    local buildable = false
 +
    if self._ship:buildable() then
 +
        buildable = {self._normal_construction_label}
 +
    end
 +
    if self._ship:buildable_lsc() then
 +
    buildable = buildable or {}
 +
    table.insert(buildable, self._large_ship_construction_label)
 +
    end
 +
    if buildable then
 +
        table.insert(result, self._buildable_label .. format{self._details_template, details = table.concat(buildable, ", ")})
 +
    end
 
     for _, method in ipairs(availability) do
 
     for _, method in ipairs(availability) do
         if method == "buildable" then
+
         if method == "drop" then
            local details = {}
  −
            if availability.buildable.normal then
  −
                table.insert(details, self._normal_construction_label)
  −
            end
  −
            if availability.buildable.lsc then
  −
                table.insert(details, self._large_ship_construction_label)
  −
            end
  −
            if #details > 0 then
  −
            details = format{self._details_template, details = table.concat(details, ", ")}
  −
            else
  −
            details = ""
  −
            end
  −
            table.insert(result, self._buildable_label .. details)
  −
        elseif method == "drop" then
   
         local details = {}
 
         local details = {}
 
         if availability.drop then
 
         if availability.drop then
         for _, node in availability.drop do
+
         for _, node in ipairs(availability.drop) do
 
         local node_name = format{self._node_name_template, world = node[1], map = node[2], node = node[3]}
 
         local node_name = format{self._node_name_template, world = node[1], map = node[2], node = node[3]}
 
if #node == 4 then
 
if #node == 4 then
Line 124: Line 122:  
         local details = {}
 
         local details = {}
 
         if availability.event_reward then
 
         if availability.event_reward then
         for _, map in availability.event_reward do
+
         for _, map in ipairs(availability.event_reward) do
 
         local map_name = format{self._map_name_template, year = map[1], quarter = self._quarters[node[2]], map = map[3]}
 
         local map_name = format{self._map_name_template, year = map[1], quarter = self._quarters[node[2]], map = map[3]}
 
         if #map == 4 then
 
         if #map == 4 then
Line 141: Line 139:  
         local details = {}
 
         local details = {}
 
         if availability.event_drop then
 
         if availability.event_drop then
         for _, node in availability.drop do
+
         for _, node in ipairs(availability.drop) do
 
         local node_name = format{self._event_node_name_template, year = node[1], quarter = self._quarters[node[2]], map = node[3], node = node[4]}
 
         local node_name = format{self._event_node_name_template, year = node[1], quarter = self._quarters[node[2]], map = node[3], node = node[4]}
 
if #node == 5 then
 
if #node == 5 then
Line 162: Line 160:  
function ShipMetaKai:implementation_date()
 
function ShipMetaKai:implementation_date()
 
     local implementation_date = self._ship:implementation_date()
 
     local implementation_date = self._ship:implementation_date()
     self._vars.implementation_date = format{self._date_template, year = implementation_date[1], month = implementation_date[2], day = implementation_date[3]}
+
     if implementation_date then
 +
    self._vars.implementation_date = format{self._date_template, year = implementation_date[1], month = implementation_date[2], day = implementation_date[3]}
 +
    else
 +
    self._vars.implementation_date = "??"
 +
    end
 
end
 
end
  
Anonymous user