跳转到内容

模組:VG NFC category handle

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Lopullinen留言 | 贡献2021年8月27日 (五) 14:47编辑。这可能和当前版本存在着巨大的差异。

require('Module:No globals')

local platformAlias = {
	-- Nintendo consoles
	['红白机游戏'] = {'红白机', '紅白機', 'FC', 'Famicom', 'NES', 'Nintendo Entertainment System', 'FC磁碟机', 'FC磁碟機'},
	['超级任天堂游戏'] = {'超级任天堂',  '超級任天堂', '超任', 'SFC', 'Super Famicom', 'SNES'},
	['任天堂64游戏'] = {'任天堂64', 'N64'},
	['任天堂GameCube游戏'] = {'任天堂GameCube', 'GameCube', 'NGC'},
	['Wii游戏'] = {'Wii'},
	['Wii U游戏'] = {'Wii ?U'},
	['任天堂Switch游戏'] = {'任天堂Switch', 'Nintendo Switch', 'NS'},
	['Game Boy游戏'] = {'Game ?Boy', 'GB'},
	['Game Boy Color游戏'] = {'Game Boy Color', 'GBC'},
	['Game Boy Advance游戏'] = {'Game Boy Advance', 'GBA'},
	['任天堂DS游戏'] = {'任天堂DS', 'Nintendo DS', 'NDS'},
	['任天堂3DS游戏'] = {'任天堂3DS', 'Nintendo 3DS', 'N3DS', '3DS'},
	
	-- Sony consoles 
	['PlayStation (游戏机)游戏'] = {'PlayStation %(游戏机%)', 'PlayStation %(遊戲機%)', 'PlayStation', 'PS1'},
	['PlayStation 2游戏'] = {'PlayStation 2', 'PS2'},
	['PlayStation 3游戏'] = {'PlayStation 3', 'PS3'},
	['PlayStation 4游戏'] = {'PlayStation 4', 'PS4'},
	['PlayStation 5游戏'] = {'PlayStation 5', 'PS5'},
	['PlayStation Portable游戏'] = {'PlayStation Portable', 'PSP'},
	['PlayStation Vita游戏'] = {'PlayStation Vita', 'PSV', 'PS ?Vita'},
	
	-- Microsoft consoles
	['Xbox游戏'] = {'Xbox %(游戏机%)', 'Xbox %(遊戲機%)', 'Xbox'},
	['Xbox 360游戏'] = {'Xbox? 360', 'X360'},
	['Xbox One游戏'] = {'Xbox? One', 'XOne'},
	['Xbox Series X/S游戏'] = {'Xbox? X/?S', 'Xbox?X', 'Xbox?S', 'XSX', 'XS'},

	-- Sega consoles
	['世嘉Master System游戏'] = {'世嘉Master System', 'Sega Master System', 'Master System', 'SMS'},
	['Mega Drive游戏'] = {'Mega ?Drive', 'MD', 'Sega Genesis'},
	['世嘉土星游戏'] = {'世嘉土星', 'Sega Saturn', 'SS'},
	['Dreamcast游戏'] = {'Dreamcast'},
	
	-- Computer platforms
	['Windows游戏'] = {'Windows', 'Microsoft Windows', 'Win'},
	['MacOS游戏'] = {'macOS', 'Mac OS X', 'OS?X'},
	['Linux游戏'] = {'Linux'},

	-- Mobile devices
	['Android游戏'] = {'Android', '安卓'},
	['iOS游戏'] = {'iOS', 'iPadOS' },

	-- Others
	['街机'] = {'街机', '街機', '大型電玩', 'Arcade'},
	['日本成人游戏'] = {'日本成人游戏', '日本成人遊戲', '十八禁'},

}


local getArgs = require('Module:Arguments').getArgs
local p = {}

local function returnCategory(input, property)
	for categoryName, aliases in pairs(platformAlias) do
		for _, k in ipairs(aliases) do
			if string.find(input, '^' .. k .. '$') then
				return '[[Category:' .. categoryName .. property .. ']]'
			end
		end
	end

	return '[[Category:' .. input .. property .. ']]'
	
end

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	-- Main module code goes here.
	local tab = {}
	for i = 1, 10 do
		if args[i] then
			table.insert(tab, returnCategory(args[i], args.property))
		end
	end
	if table.maxn(tab) == 0 then
		return returnCategory('电子', args.property)
	end
	return table.concat(tab)
end

return p