Line 10: |
Line 10: |
| local ShipCategoriesKai = require("Module:ShipCategoriesKai") | | local ShipCategoriesKai = require("Module:ShipCategoriesKai") |
| | | |
− | function ship_remodel_forms(ship_name) | + | function ship_remodel_forms(ship_name, ship_suffix, j) |
| + | j = j or 1 |
| + | ship_suffix = ship_suffix or "" |
| + | local forms = { ship_name .. "/" .. ship_suffix } |
| local success, ship_data = Utils.requireModule(ship_name) | | local success, ship_data = Utils.requireModule(ship_name) |
− | local forms = { ship_name }
| |
| if not success then | | if not success then |
− | table.insert(forms, string.format("%s/Kai", ship_name))
| |
| return forms | | return forms |
| end | | end |
− | local form_data = ship_data[""] | + | local form_data = ship_data[ship_suffix] |
| local i = 0 | | local i = 0 |
− | while form_data and form_data._remodel_to and not Utils.find(forms, form_data._remodel_to) and i < 10 do | + | while form_data and form_data._remodel_to and not Utils.find(forms, form_data._remodel_to) and i < 10 and j <= 3 do |
− | table.insert(forms, form_data._remodel_to) | + | local ship_name_next, ship_suffix_next = Ship:process_ship_key(form_data._remodel_to) |
− | local ship_base_name, ship_suffix = Ship:process_ship_key(form_data._remodel_to) | + | if ship_name_next ~= ship_name then |
− | form_data = ship_data[ship_suffix]
| + | return Utils.concat(forms, ship_remodel_forms(ship_name_next, ship_suffix_next, j + 1)) |
| + | else |
| + | table.insert(forms, form_data._remodel_to) |
| + | form_data = ship_data[ship_suffix_next] |
| + | end |
| i = i + 1 | | i = i + 1 |
| end | | end |
Line 145: |
Line 150: |
| }) | | }) |
| -- print(p.t6) | | -- print(p.t6) |
| + | ]]-- |
| + | --[[ |
| + | function ShipPage.test() |
| + | function print_forms(ship_name) |
| + | for _, v in ipairs(ship_remodel_forms(ship_name)) do |
| + | mw.log(v) |
| + | end |
| + | end |
| + | print_forms("Ayanami") |
| + | print_forms("Hibiki") |
| + | print_forms("Zuikaku") |
| + | print_forms("Matsukaze") |
| + | print_forms("Bismarck") |
| + | print_forms("Taigei") |
| + | print_forms("U-511") |
| + | print_forms("Kasuga Maru") |
| + | print_forms("Gangut") |
| + | end |
| ]]-- | | ]]-- |
| | | |
| return ShipPage | | return ShipPage |