-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEgggrouplist-allgroups.lua
128 lines (106 loc) · 3.42 KB
/
Egggrouplist-allgroups.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
--[[
This module has the sole purpose of
creating the list of Pokémon by type
in the namesake page.
--]]
local g = {}
-- stylua: ignore start
local txt = require('Wikilib-strings')
local css = require('Css')
local resp = require('Resp')
local tl = require('Egggrouplist')
local data = require("Wikilib-data")
-- stylua: ignore end
--[[
Override of this method: prints
both egg groups in the full list
--]]
---@diagnostic disable-next-line: duplicate-set-field
tl.Entry.groupsString = function(this)
local otherGroup = this.group1 == this.group and this.group2 or this.group1
return "|"
.. resp.eggsTwoCellsLua(
this.group,
otherGroup,
tl.Entry.eggBox,
tl.Entry.eggCell
)
end
--[[
Sorting function for Entry:
Pokémon with two groups are sorted first for
second group order, then for ndex
--]]
tl.DoubleGroupEntry.__lt = function(a, b)
if a.type2 == b.type2 then
return tl.DoubleGroupEntry.super.__lt(a, b)
end
return a.type2 < b.type2
end
--[[
Wikicode for list header: it takes the group
name, for colors, and the number of groups,
to print the correct amount of group columns.
--]]
local makeHeader = function(group, groupsCount)
return txt.interp(
[=[{| class="roundy-corners sortable pull-center text-center white-rows" style="border-spacing: 0; padding: 0.3ex; ${bg};"
|- class="hidden-xs"
! style="padding-top: 0.5ex; padding-bottom: 0.5ex; padding-left: 0.5ex;" | [[Elenco Pokémon secondo il Pokédex Nazionale|<span style="color:#000">#</span>]]
! class="unsortable" | <span class="hidden-xs"> </span>
! [[Pokémon|<span style="color:#000">Pokémon</span>]]
! class="unsortable" | [[Tipo|<span style="color:#000">Tipo</span>]]
${groups}]=],
{
bg = css.horizGradLua({ type = group:gsub(" ", "_") .. "_uova" }),
groups = table.concat({
'! [[Gruppi uova|<span style="color:#000">Primo gruppo</span>]]\n',
groupsCount < 2 and ""
or '! [[Gruppi uova|<span style="color:#000">Altro gruppo</span>]]',
}),
}
)
end
--[[
Wikicode interface: takes no parameters
and returns the list of all Pokémon by
type, with relative headings for every
part. Indeed, they are divided, for each
type, into mono-typed and first-typed,
the latter being sorted by second type.
Example:
{{#invoke: Typelist/alltypes | typelist }}
--]]
g.grouplist = function(frame)
local tables = {}
for _, group in ipairs(data.allGroups) do
table.insert(
tables,
tl.makeGroupTable(
group,
tl.SingleGroupEntry,
table.concat({ "===Solo nel gruppo ", txt.fu(group), "===" }),
makeHeader
)
)
-- groups Ditto and Sconosciuto doesn't have the double entry
if group ~= "ditto" and group ~= "sconosciuto" then
table.insert(
tables,
tl.makeGroupTable(
group,
tl.DoubleGroupEntry,
table.concat({
"===Nel gruppo ",
txt.fu(group),
" e in un altro===",
}),
makeHeader
)
)
end
end
return table.concat(tables, "\n")
end
g.Grouplist, g.GroupList, g.groupList = g.grouplist, g.grouplist, g.grouplist
return g