• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
no edit summary
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]]]=],
 +
choice_header = [=[|-
 +
!style="background-color:#3baef5;color:white;width:40%"|Choice
 +
!class="unsortable" style="background-color:#3baef5;color:white;width:15%"|丁<br>Casual
 +
!class="unsortable" style="background-color:#3baef5;color:white;width:15%"|丙<br>Easy
 +
!class="unsortable" style="background-color:#3baef5;color:white;width:15%"|乙<br>Medium
 +
!class="unsortable" style="background-color:#3baef5;color:white;width:15%"|甲<br>Hard]=],
 
choice = [=[|-
 
choice = [=[|-
 
!style="background-color:#eef2f7;color:red"|OR
 
!style="background-color:#eef2f7;color:red"|OR
 
|colspan="4" style="background-color:#eef2f7"|]=],
 
|colspan="4" style="background-color:#eef2f7"|]=],
-- TODO: class="sortable"
+
item_header = [[{|style="text-align:center;width:100%" class="sortable"
item_header = [[{|style="text-align:center;width:100%"
+
!style="background-color:#3baef5;color:white;width:40%"|Reward
!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
 
!class="unsortable" style="background-color:#3baef5;color:white;width:15%"|丙<br>Easy
 
!class="unsortable" style="background-color:#3baef5;color:white;width:15%"|丙<br>Easy
Line 24: Line 29:  
|style="background-color:#eef2f7;font-size:18px"|%s
 
|style="background-color:#eef2f7;font-size:18px"|%s
 
|style="background-color:#eef2f7;font-size:18px"|%s]=],
 
|style="background-color:#eef2f7;font-size:18px"|%s]=],
item_row_choice_top = [=[|-
  −
|data-sort-value="%s" style="background-color:#eef2f7;font-size:12px;line-height:14px;border-top:4px solid grey"|%s<br>[[%s]]]=],
  −
item_row_choice_middle = [=[|-
  −
|data-sort-value="%s" style="background-color:#eef2f7;font-size:12px;line-height:14px;"|%s<br>[[%s]]]=],
  −
item_row_choice_bottom = [=[|-
  −
|data-sort-value="%s" style="background-color:#eef2f7;font-size:12px;line-height:14px;border-bottom:4px solid grey"|%s<br>[[%s]]]=],
  −
item_row_amount_top    = [=[|style="background-color:#eef2f7;font-size:18px;border-top:4px solid grey"|%s]=],
  −
item_row_amount_middle = [=[|style="background-color:#eef2f7;font-size:18px;"|%s]=],
  −
item_row_amount_bottom = [=[|style="background-color:#eef2f7;font-size:18px;border-bottom:4px solid grey"|%s]=],
  −
item_style_top    = [=[|data-sort-value="%s" style="background-color:#eef2f7;color:red;font-size:12px;line-height:14px;width:auto;border-top:4px solid grey"|]=],
  −
item_style_bottom = [=[|data-sort-value="%s" style="background-color:#eef2f7;color:red;font-size:12px;line-height:14px;width:auto;border-bottom:4px solid grey"|]=],
   
}
 
}
   Line 51: Line 45:  
local tbl = {}
 
local tbl = {}
 
local types = {}
 
local types = {}
-- TODO: assuming 0-1 single ship reward on all difficulties
+
-- TODO: assuming 0-1 ship
 +
-- TODO: assuming 0-1 choice
 
local ship = false
 
local ship = false
 +
local choice = false
 +
local choiceFirstIndex = {}
 +
local choiceSecondIndex = {}
 
local function setData(diff)
 
local function setData(diff)
 
for _, v in ipairs(data[diff] or {}) do
 
for _, v in ipairs(data[diff] or {}) do
Line 62: Line 60:  
types[name1] = v1.item and 'item' or v1.equipment and 'equipment' or v1.ship and 'ship' or '??'
 
types[name1] = v1.item and 'item' or v1.equipment and 'equipment' or v1.ship and 'ship' or '??'
 
types[name2] = v2.item and 'item' or v2.equipment and 'equipment' or v2.ship and 'ship' or '??'
 
types[name2] = v2.item and 'item' or v2.equipment and 'equipment' or v2.ship and 'ship' or '??'
local names = {name1 .. '1', name2 .. '2'}
+
choice = true
local name = names[1] .. '||' .. names[2]
+
tbl['choice1' .. name1] = tbl['choice1' .. name1] or {}
types[name] = 'choice'
+
tbl['choice1' .. name1][diff] = { count = v1.count or 1, level = v1.level }
if not U.ifind(index, name) then table.insert(index, name) end
+
tbl['choice2' .. name2] = tbl['choice2' .. name2] or {}
tbl[name] = tbl[name] or {}
+
tbl['choice2' .. name2][diff] = { count = v2.count or 1, level = v2.level }
tbl[name][diff] = {
+
if not U.ifind(choiceFirstIndex, name1) then table.insert(choiceFirstIndex, name1) end
{ name = name1, count = v1.count or 1, level = v1.level },
+
if not U.ifind(choiceSecondIndex, name2) then table.insert(choiceSecondIndex, name2) end
{ name = name2, count = v2.count or 1, level = v2.level },
  −
}
   
else
 
else
 
local name = v.item or v.equipment or v.ship or '??'
 
local name = v.item or v.equipment or v.ship or '??'
Line 84: Line 80:  
end
 
end
 
end
 
end
local function getCount(name, diff, i)
+
local function getCount(name, diff)
if i then
+
return ((tbl[name] or {})[diff] or {}).count or 0
return (((tbl[name] or {})[diff] or {})[i] or {}).count or 0
  −
else
  −
return ((tbl[name] or {})[diff] or {}).count or 0
  −
end
   
end
 
end
local function getLevel(name, diff, i)
+
local function getLevel(name, diff)
local level
+
local level = ((tbl[name] or {})[diff] or {}).level
if i then
  −
level = (((tbl[name] or {})[diff] or {})[i] or {}).level
  −
else
  −
level = ((tbl[name] or {})[diff] or {}).level
  −
end
   
return level and string.format(" (★%d)", level) or ''
 
return level and string.format(" (★%d)", level) or ''
 
end
 
end
local function getCell(name, diff, i)
+
local function getCell(name, diff)
local count = getCount(name, diff, i)
+
local count = getCount(name, diff)
return (count == 0 and '' or count) .. getLevel(name, diff, i)
+
return (count == 0 and '' or count) .. getLevel(name, diff)
 
end
 
end
 
local function getAsset(name)
 
local function getAsset(name)
Line 114: Line 101:  
if ship then
 
if ship then
 
table.insert(result, string.format(template.ship_row, getAsset(ship), ship))
 
table.insert(result, string.format(template.ship_row, getAsset(ship), ship))
 +
end
 +
if choice then
 +
table.insert(result, template.choice_header)
 +
for i, name in ipairs(choiceFirstIndex) do
 +
table.insert(result, string.format(template.item_row, 0, getAsset(name), name,
 +
getCell('choice1' .. name, 'Casual'), getCell('choice1' .. name, 'Easy'), getCell('choice1' .. name, 'Medium'), getCell('choice1' .. name, 'Hard')))
 +
end
 +
table.insert(result, template.choice)
 +
for i, name in ipairs(choiceSecondIndex) do
 +
table.insert(result, string.format(template.item_row, 0, getAsset(name), name,
 +
getCell('choice2' .. name, 'Casual'), getCell('choice2' .. name, 'Easy'), getCell('choice2' .. name, 'Medium'), getCell('choice2' .. name, 'Hard')))
 +
end
 
end
 
end
 
table.insert(result, template.footer)
 
table.insert(result, template.footer)
 
table.insert(result, template.item_header)
 
table.insert(result, template.item_header)
--[[
   
local sortedIndex = U.imap(index, function(name, i) return { name = name, i = i, typ = types[name] } end)
 
local sortedIndex = U.imap(index, function(name, i) return { name = name, i = i, typ = types[name] } end)
 
table.sort(sortedIndex, function (x, y)
 
table.sort(sortedIndex, function (x, y)
Line 129: Line 127:  
local sortValues = {}
 
local sortValues = {}
 
for i, e in ipairs(sortedIndex) do sortValues[e.name] = i end
 
for i, e in ipairs(sortedIndex) do sortValues[e.name] = i end
]]--
  −
-- sortValues[name]
   
for i, name in ipairs(index) do
 
for i, name in ipairs(index) do
if types[name] == 'choice' then
+
table.insert(result, string.format(template.item_row, sortValues[name], getAsset(name), name,
local names = U.split(name, '||')
+
getCell(name, 'Casual'), getCell(name, 'Easy'), getCell(name, 'Medium'), getCell(name, 'Hard')))
  −
local subNames = {}
  −
for j=1, #names do
  −
subNames[j] = names[j]:sub(1, -2)
  −
end
  −
  −
local difficulty = {'Casual', 'Easy', 'Medium', 'Hard'}
  −
  −
for c=1, #names do
  −
local str = ""
  −
  −
if      c==1      then str = template.item_row_choice_top
  −
elseif  c==#names then str = template.item_row_choice_bottom
  −
else            str = template.item_row_choice_middle end
  −
table.insert(result, string.format(str, 0, getAsset(subNames[c]), subNames[c]))
  −
  −
str = ""
  −
for d=1, #difficulty do
  −
if      c==1      then str = template.item_row_amount_top
  −
elseif  c==#names then str = template.item_row_amount_bottom
  −
else            str = template.item_row_amount_middle end
  −
table.insert(result, string.format(str, getCell(name, difficulty[d], c), c))
  −
end
  −
  −
if c~=#names then table.insert(result, template.choice) end
  −
end
  −
  −
else
  −
table.insert(result, string.format(template.item_row, 0, getAsset(name), name,
  −
getCell(name, 'Casual'), getCell(name, 'Easy'), getCell(name, 'Medium'), getCell(name, 'Hard')))
  −
end
   
end
 
end
 
table.insert(result, template.footer)
 
table.insert(result, template.footer)
Line 175: Line 140:     
return { render = render, test = test }
 
return { render = render, test = test }
 +
 +
-- TEST: p.test()
cssedit, gkautomate
6,928

edits

Navigation menu