|
|
| Line 1: |
Line 1: |
| local p = {}
| |
| local data = {}
| |
|
| |
|
| -- Called by the data templates to register themselves
| |
| function p.register(frame)
| |
| local args = frame.args
| |
| local name = args.name or "Unknown"
| |
| data[name] = args
| |
| return "" -- don't output anything directly
| |
| end
| |
|
| |
| -- Get data for a monster
| |
| function p.get(monster)
| |
| return data[monster]
| |
| end
| |
|
| |
| -- Generate a table row for the monster list
| |
| function p.row(frame)
| |
| local monster = frame.args[1]
| |
| local m = data[monster]
| |
| if not m then return "Missing data for "..monster end
| |
|
| |
| local out = {}
| |
| table.insert(out, "|-")
| |
| table.insert(out, string.format("| [[File:%s|50px]]", m.image or ""))
| |
| table.insert(out, string.format("|| [[%s]]", m.name or ""))
| |
| table.insert(out, string.format("|| <span class=\"%s Neutral\">%s</span>", m.element or "Unknown", m.element or "Unknown"))
| |
| table.insert(out, string.format("|| %s || %s || %s || %s || %s || %s || %s",
| |
| m.level or "?", m.exp or "?", m.hp or "?", m.atk or "?", m.def or "?",
| |
| m.mp or "?", m.spd or "?"))
| |
| table.insert(out, string.format("|| %s", m.drops or ""))
| |
| return table.concat(out, "\n")
| |
| end
| |
|
| |
| -- Generate a portable infobox for a monster
| |
| function p.infobox(frame)
| |
| local monster = frame.args[1]
| |
| local m = data[monster]
| |
| if not m then return "Missing data for "..monster end
| |
|
| |
| local out = {}
| |
| table.insert(out, string.format("{{Portable infobox\n|title = %s", m.name))
| |
| table.insert(out, string.format("|image = [[File:%s|150px]]", m.image or ""))
| |
| table.insert(out, string.format("|label1 = Element\n|data1 = %s", m.element or "Unknown"))
| |
| table.insert(out, string.format("|label2 = Level\n|data2 = %s", m.level or "Unknown"))
| |
| table.insert(out, string.format("|label3 = EXP\n|data3 = %s", m.exp or "Unknown"))
| |
| table.insert(out, string.format("|label4 = HP\n|data4 = %s", m.hp or "Unknown"))
| |
| table.insert(out, string.format("|label5 = ATK\n|data5 = %s", m.atk or "Unknown"))
| |
| table.insert(out, string.format("|label6 = DEF\n|data6 = %s", m.def or "Unknown"))
| |
| table.insert(out, string.format("|label7 = MP\n|data7 = %s", m.mp or "Unknown"))
| |
| table.insert(out, string.format("|label8 = SPD\n|data8 = %s", m.spd or "Unknown"))
| |
| table.insert(out, string.format("|label9 = Drops\n|data9 = %s", m.drops or "Unknown/None"))
| |
| table.insert(out, "}}")
| |
| return table.concat(out, "\n")
| |
| end
| |
|
| |
| return p
| |