-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTypelist-alltypes.lua
More file actions
64 lines (47 loc) · 1.46 KB
/
Typelist-alltypes.lua
File metadata and controls
64 lines (47 loc) · 1.46 KB
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
--[[
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 data = require("Wikilib-data")
local tl = require('Typelist')
-- stylua: ignore end
--[[
Sorting function for Entry:
Pokémon with two types are sorted first for
second type order, then for ndex
--]]
tl.FirstTypeEntry.__lt = function(a, b)
if a.type2 == b.type2 then
return tl.FirstTypeEntry.super.__lt(a, b)
end
return a.type2 < b.type2
end
-- Needs a different heading level than Typelist
---@diagnostic disable-next-line: duplicate-set-field
tl.FirstTypeEntry.makeHeader = function(type)
return tl.FirstTypeEntry.super.makeHeader(type, 3, "come tipo primario")
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.typelist = function(_)
local tables = {}
for _, type in ipairs(data.allTypes) do
local typeName = type == "coleot" and "coleottero" or type
table.insert(tables, tl.makeTypeTable(typeName, tl.MonoTypeEntry))
table.insert(tables, tl.makeTypeTable(type, tl.FirstTypeEntry))
end
return table.concat(tables, "\n")
end
g.Typelist, g.TypeList, g.typeList = g.typelist, g.typelist, g.typelist
return g