Line 8: |
Line 8: |
| !style="background-color:#3baef5;color:white;width:40%%"|Ship | | !style="background-color:#3baef5;color:white;width:40%%"|Ship |
| |colspan="4" style="background-color:#eef2f7"|%s<br>[[%s]]]=], | | |colspan="4" style="background-color:#eef2f7"|%s<br>[[%s]]]=], |
− | item_header = [[{|style="text-align:center;width:100%" class="sortable" | + | choice = [=[|- |
| + | !colspan="5" style="background-color:#3baef5;color:red"|OR]=], |
| + | -- TODO: class="sortable" |
| + | item_header = [[{|style="text-align:center;width:100%" |
| !style="background-color:#3baef5;color:white;width:40%"|Item/Equipment | | !style="background-color:#3baef5;color:white;width:40%"|Item/Equipment |
| !class="unsortable" style="background-color:#3baef5;color:white;width:15%"|丁<br>Casual | | !class="unsortable" style="background-color:#3baef5;color:white;width:15%"|丁<br>Casual |
Line 36: |
Line 39: |
| local tbl = {} | | local tbl = {} |
| local types = {} | | local types = {} |
| + | local choices = {} |
| -- TODO: assuming 0-1 single ship reward on all difficulties | | -- TODO: assuming 0-1 single ship reward on all difficulties |
| local ship = false | | local ship = false |
− | local function setData(diff) | + | local function setDataItem(diff, v, choice, last) |
− | for _, v in ipairs(data[diff] or {}) do
| + | local name = v.item or v.equipment or v.ship or '??' |
− | local name = v.item or v.equipment or v.ship or '??'
| + | types[name] = v.item and 'item' or v.equipment and 'equipment' or v.ship and 'ship' or '??' |
− | types[name] = v.item and 'item' or v.equipment and 'equipment' or v.ship and 'ship' or '??'
| + | if choice then |
| + | if not U.ifind(index, name) then table.insert(index, name) end |
| + | tbl[name] = tbl[name] or {} |
| + | tbl[name][diff] = { count = v.count or 1, level = v.level } |
| + | if not last then |
| + | choices[name] = true |
| + | end |
| + | else |
| if v.ship then | | if v.ship then |
| ship = v.ship | | ship = v.ship |
Line 48: |
Line 59: |
| tbl[name] = tbl[name] or {} | | tbl[name] = tbl[name] or {} |
| tbl[name][diff] = { count = v.count or 1, level = v.level } | | tbl[name][diff] = { count = v.count or 1, level = v.level } |
| + | end |
| + | end |
| + | end |
| + | local function setData(diff) |
| + | for _, v in ipairs(data[diff] or {}) do |
| + | if v.choice then |
| + | for i, v in ipairs(v.choice) do |
| + | setDataItem(diff, v, true, i == #v.choice) |
| + | end |
| + | else |
| + | setDataItem(diff, v) |
| end | | end |
| end | | end |
Line 89: |
Line 111: |
| table.insert(result, string.format(template.item_row, sortValues[name], getAsset(name), name, | | table.insert(result, string.format(template.item_row, sortValues[name], getAsset(name), name, |
| getCell(name, 'Casual'), getCell(name, 'Easy'), getCell(name, 'Medium'), getCell(name, 'Hard'))) | | getCell(name, 'Casual'), getCell(name, 'Easy'), getCell(name, 'Medium'), getCell(name, 'Hard'))) |
| + | if choices[name] then |
| + | table.insert(result, template.choice) |
| + | end |
| end | | end |
| table.insert(result, template.footer) | | table.insert(result, template.footer) |