打开/关闭搜索
搜索
打开/关闭菜单
1K
5.2K
4
8.2K
星砂岛百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
本站正在进行早期测试,目前仍存在许多内容的缺失。
查看“︁模块:Character”︁的源代码
来自星砂岛百科
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:Character
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:已验证邮箱用户
您没有权限编辑
模块
命名空间内的页面。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local common = require('Module:Common') local character_common = require('Module:CharacterCommon') local p = {} local data_cache local mapping local gender_map = { male = '男', female = '女', } local season_map = { ['1'] = 'Spring', ['2'] = 'Summer', ['3'] = 'Autumn', ['4'] = 'Winter', } local function pick_first(...) local values = { ... } for _, value in ipairs(values) do value = common.trim(value) if value ~= '' then return value end end return '' end local function format_birthday(record) if type(record) ~= 'table' then return '' end local month = common.trim(record.birthday_month) local day = common.trim(record.birthday_day) local season = season_map[month] if season ~= nil and day ~= '' then return mw.getCurrentFrame():expandTemplate{ title = 'Season', args = { season, day }, } end return '' end local function localize_gender(value) local normalized = character_common.normalizeKey(value) return gender_map[normalized] or common.trim(value) end local function display_image(record) if type(record) ~= 'table' then return '' end local image_key = common.trim(record.image_key) if image_key ~= '' then return 'Head ' .. image_key .. '.png' end return pick_first(record.default_image, record.upgrade_icon, record.map_image) end local function load_data() if data_cache then return end data_cache, mapping = character_common.loadDomainData('数据:Character/character_index.json') end local function find_record(key) load_data() return character_common.findRecord(data_cache, mapping, key) end local function get_display_field(record, field) if type(record) ~= 'table' then return '' end if field == 'birthday_display' or field == 'birthday' then return format_birthday(record) end if field == 'gender_display' or field == 'gender_zh' then return localize_gender(record.gender) end if field == 'image' or field == 'image_fallback' then return display_image(record) end if field == 'display_name' then return pick_first(record.name, record.title, record.id) end if field == 'display_title' then return pick_first(record.title, record.name) end return record[field] end function p.getField(frame) local key = common.getArg(frame, 1, '') local field = common.getArg(frame, 2, '') if field == '' then return '' end local record = find_record(key) if not record then return '' end return common.toText(get_display_field(record, field)) end function p.getId(frame) local key = common.getArg(frame, 1, '') local record = find_record(key) if not record then return '' end return common.toText(record.id) end function p.getImage(frame) local key = common.getArg(frame, 1, '') local record = find_record(key) if not record then return '' end return common.toText(display_image(record)) end function p.getBirthday(frame) local key = common.getArg(frame, 1, '') local record = find_record(key) if not record then return '' end return format_birthday(record) end function p.getGender(frame) local key = common.getArg(frame, 1, '') local record = find_record(key) if not record then return '' end return localize_gender(record.gender) end return p
该页面嵌入的页面:
模板:Tl
(
查看源代码
)
模块:ArgsUtil
(
查看源代码
)
模块:Character/doc
(
查看源代码
)
模块:Template link
(
查看源代码
)
返回
模块:Character
。
查看“︁模块:Character”︁的源代码
来自星砂岛百科