2023-03-07 17:52:11 +00:00
|
|
|
import lodash from 'lodash'
|
2023-02-13 19:47:22 +00:00
|
|
|
import CharTalent from './CharTalent.js'
|
|
|
|
import CharWikiData from './CharWikiData.js'
|
|
|
|
import CharMaterial from './CharMaterial.js'
|
2023-03-07 17:52:11 +00:00
|
|
|
import { Cfg, Common } from '#miao'
|
|
|
|
import { Character } from '#miao.models'
|
2024-05-21 18:05:37 +00:00
|
|
|
import { miaoPath } from '#miao.path'
|
2022-09-07 19:48:03 +00:00
|
|
|
|
2024-01-04 23:14:23 +00:00
|
|
|
const wikiReg = /^(?:#|喵喵)?(?:星铁)?(.*)(天赋|技能|行迹|命座|命之座|星魂|资料|图鉴|照片|写真|图片|图像)$/
|
2022-09-07 19:48:03 +00:00
|
|
|
|
2023-02-13 19:47:22 +00:00
|
|
|
const CharWiki = {
|
|
|
|
check (e) {
|
|
|
|
let msg = e.original_msg || e.msg
|
|
|
|
if (!e.msg) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let ret = wikiReg.exec(msg)
|
|
|
|
if (!ret || !ret[1] || !ret[2]) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let mode = 'talent'
|
2024-01-04 23:14:23 +00:00
|
|
|
if (/(命|星魂)/.test(ret[2])) {
|
2023-02-13 19:47:22 +00:00
|
|
|
mode = 'cons'
|
|
|
|
} else if (/(图鉴|资料)/.test(ret[2])) {
|
|
|
|
mode = 'wiki'
|
|
|
|
if (!Common.cfg('charWiki')) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
} else if (/图|画|写真|照片/.test(ret[2])) {
|
|
|
|
mode = 'pic'
|
|
|
|
if (!Common.cfg('charPic')) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
} else if (/(材料|养成|成长)/.test(ret[2])) {
|
|
|
|
mode = 'material'
|
2022-10-22 19:45:28 +00:00
|
|
|
}
|
2023-02-13 19:47:22 +00:00
|
|
|
if (['cons', 'talent'].includes(mode) && !Common.cfg('charWikiTalent')) {
|
|
|
|
return false
|
2022-10-22 19:45:28 +00:00
|
|
|
}
|
2023-12-06 20:58:41 +00:00
|
|
|
let char = Character.get(ret[1], e.game)
|
2023-03-27 20:02:49 +00:00
|
|
|
if (!char || (char.isCustom && mode !== 'pic')) {
|
2023-02-13 19:47:22 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
e.wikiMode = mode
|
|
|
|
e.msg = '#喵喵WIKI'
|
|
|
|
e.char = char
|
|
|
|
return true
|
2022-10-22 19:45:28 +00:00
|
|
|
},
|
2022-11-23 20:26:07 +00:00
|
|
|
|
2023-02-13 19:47:22 +00:00
|
|
|
async wiki (e) {
|
|
|
|
let mode = e.wikiMode
|
|
|
|
let char = e.char
|
2022-11-23 20:26:07 +00:00
|
|
|
|
2023-02-13 19:47:22 +00:00
|
|
|
if (mode === 'pic') {
|
|
|
|
let img = char.getCardImg(Cfg.get('charPicSe', false), false)
|
|
|
|
if (img && img.img) {
|
2024-05-21 18:05:37 +00:00
|
|
|
e.reply(segment.image(`file://${miaoPath}/resources/${img.img}`))
|
2023-02-13 19:47:22 +00:00
|
|
|
} else {
|
|
|
|
e.reply('暂无图片')
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (char.isCustom) {
|
|
|
|
if (mode === 'wiki') {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
e.reply('暂不支持自定义角色')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (!char.isRelease && Cfg.get('notReleasedData') === false) {
|
|
|
|
e.reply('未实装角色资料已禁用...')
|
|
|
|
return true
|
|
|
|
}
|
2022-10-22 19:45:28 +00:00
|
|
|
|
2023-02-13 19:47:22 +00:00
|
|
|
if (mode === 'wiki') {
|
|
|
|
if (char.source === 'amber') {
|
|
|
|
e.reply('暂不支持该角色图鉴展示')
|
|
|
|
return true
|
|
|
|
}
|
2023-10-31 20:07:47 +00:00
|
|
|
if (char.isSr) {
|
|
|
|
e.reply('暂不支持星铁角色')
|
|
|
|
return true
|
|
|
|
}
|
2023-02-13 19:47:22 +00:00
|
|
|
return await CharWiki.render({ e, char })
|
|
|
|
} else if (mode === 'material') {
|
|
|
|
return CharMaterial.render({ e, char })
|
|
|
|
}
|
|
|
|
return await CharTalent.render(e, mode, char)
|
|
|
|
},
|
2022-10-22 19:45:28 +00:00
|
|
|
|
2023-02-13 19:47:22 +00:00
|
|
|
async render ({ e, char }) {
|
|
|
|
let data = char.getData()
|
|
|
|
lodash.extend(data, char.getData('weaponTypeName,elemName'))
|
|
|
|
// 命座持有
|
|
|
|
let holding = await CharWikiData.getHolding(char.id)
|
|
|
|
let usage = await CharWikiData.getUsage(char.id)
|
|
|
|
return await Common.render('wiki/character-wiki', {
|
|
|
|
data,
|
|
|
|
attr: char.getAttrList(),
|
|
|
|
detail: char.getDetail(),
|
|
|
|
imgs: char.getImgs(),
|
|
|
|
holding,
|
|
|
|
usage,
|
|
|
|
materials: char.getMaterials(),
|
|
|
|
elem: char.elem
|
|
|
|
}, { e, scale: 1.4 })
|
2022-09-07 19:48:03 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-13 19:47:22 +00:00
|
|
|
|
2022-09-07 19:48:03 +00:00
|
|
|
export default CharWiki
|