2022-07-23 20:32:10 +00:00
|
|
|
import { segment } from 'oicq'
|
|
|
|
import lodash from 'lodash'
|
2022-10-06 22:20:46 +00:00
|
|
|
import Calendar from './wiki/Calendar.js'
|
2022-09-16 20:37:09 +00:00
|
|
|
import { Format, Cfg, Common, App } from '../components/index.js'
|
2022-09-07 19:48:03 +00:00
|
|
|
import { Character } from '../models/index.js'
|
|
|
|
import CharWiki from './wiki/CharWiki.js'
|
2022-07-23 20:32:10 +00:00
|
|
|
|
2022-09-21 19:28:33 +00:00
|
|
|
let wikiReg = /^(?:#|喵喵)?(.*)(天赋|技能|命座|命之座|资料|图鉴|照片|写真|图片|图像)$/
|
2022-04-03 22:06:03 +00:00
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
let app = App.init({
|
|
|
|
id: 'wiki',
|
2022-09-16 22:01:31 +00:00
|
|
|
name: '角色资料'
|
2022-09-16 20:37:09 +00:00
|
|
|
})
|
|
|
|
app.reg('wiki', wiki, {
|
2022-10-21 11:11:20 +00:00
|
|
|
rule: '^#喵喵WIKI$',
|
|
|
|
check: checkCharacter,
|
2022-09-16 20:37:09 +00:00
|
|
|
desc: '【#资料】 #神里天赋 #夜兰命座'
|
|
|
|
})
|
|
|
|
app.reg('calendar', calendar, {
|
|
|
|
rule: /^(#|喵喵)+(日历|日历列表)$/,
|
|
|
|
desc: '【#日历】 活动日历'
|
|
|
|
})
|
|
|
|
|
|
|
|
export default app
|
|
|
|
|
2022-10-21 11:11:20 +00:00
|
|
|
function checkCharacter (e) {
|
|
|
|
let msg = e.original_msg || e.msg
|
2022-04-05 19:49:37 +00:00
|
|
|
if (!e.msg) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return false
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|
2022-09-21 19:28:33 +00:00
|
|
|
let ret = wikiReg.exec(msg)
|
2022-04-08 21:52:05 +00:00
|
|
|
if (!ret || !ret[1] || !ret[2]) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return false
|
2022-04-05 19:49:37 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
let mode = 'talent'
|
2022-04-07 19:39:43 +00:00
|
|
|
if (/命/.test(ret[2])) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'cons'
|
2022-09-04 21:03:23 +00:00
|
|
|
} else if (/(图鉴|资料)/.test(ret[2])) {
|
|
|
|
mode = 'wiki'
|
2022-11-12 21:35:46 +00:00
|
|
|
if (!Common.cfg('charWiki')) {
|
|
|
|
return false
|
|
|
|
}
|
2022-04-08 21:52:05 +00:00
|
|
|
} else if (/图|画|写真|照片/.test(ret[2])) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'pic'
|
2022-11-12 21:35:46 +00:00
|
|
|
if (!Common.cfg('charPic')) {
|
|
|
|
return false
|
|
|
|
}
|
2022-09-21 19:28:33 +00:00
|
|
|
} else if (/(材料|养成|成长)/.test(ret[2])) {
|
|
|
|
mode = 'material'
|
2022-04-07 19:39:43 +00:00
|
|
|
}
|
2022-11-12 21:35:46 +00:00
|
|
|
if (['cons', 'talent'].includes(mode) && !Common.cfg('charWikiTalent')) {
|
2022-09-19 19:16:00 +00:00
|
|
|
return false
|
2022-04-09 21:33:21 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
let char = Character.get(ret[1])
|
2022-04-11 20:26:28 +00:00
|
|
|
if (!char) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return false
|
2022-04-11 20:26:28 +00:00
|
|
|
}
|
2022-10-21 11:11:20 +00:00
|
|
|
e.wikiMode = mode
|
|
|
|
e.msg = '#喵喵WIKI'
|
|
|
|
e.char = char
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
async function wiki (e) {
|
|
|
|
let mode = e.wikiMode
|
|
|
|
let char = e.char
|
2022-04-08 21:52:05 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode === 'pic') {
|
2022-11-12 21:35:46 +00:00
|
|
|
let img = char.getCardImg(Cfg.get('charPicSe', false), false)
|
2022-04-08 21:52:05 +00:00
|
|
|
if (img && img.img) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + img.img))
|
2022-04-08 21:52:05 +00:00
|
|
|
} else {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply('暂无图片')
|
2022-04-08 21:52:05 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
2022-04-08 21:52:05 +00:00
|
|
|
}
|
2022-06-29 23:05:31 +00:00
|
|
|
if (char.isCustom) {
|
2022-09-05 17:05:06 +00:00
|
|
|
if (mode === 'wiki') {
|
|
|
|
return false
|
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply('暂不支持自定义角色')
|
|
|
|
return true
|
2022-06-29 23:05:31 +00:00
|
|
|
}
|
2023-02-06 18:08:12 +00:00
|
|
|
if (!char.isRelease && Cfg.get('notReleasedData') === false) {
|
|
|
|
e.reply('未实装角色资料已禁用...')
|
|
|
|
return true
|
|
|
|
}
|
2022-09-03 21:08:57 +00:00
|
|
|
let lvs = []
|
|
|
|
for (let i = 1; i <= 15; i++) {
|
|
|
|
lvs.push('Lv' + i)
|
|
|
|
}
|
2022-09-04 21:03:23 +00:00
|
|
|
if (mode === 'wiki') {
|
2022-09-29 13:21:52 +00:00
|
|
|
if (char.source === 'amber') {
|
|
|
|
e.reply('暂不支持该角色图鉴展示')
|
|
|
|
return true
|
|
|
|
}
|
2022-09-04 21:03:23 +00:00
|
|
|
return await renderWiki({ e, char })
|
2022-09-21 19:28:33 +00:00
|
|
|
} else if (mode === 'material') {
|
|
|
|
return await renderCharMaterial({ e, char })
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
return await Common.render('wiki/character-talent', {
|
2022-09-21 19:28:33 +00:00
|
|
|
saveId: `${mode}-${char.id}`,
|
2022-09-03 21:08:57 +00:00
|
|
|
...char.getData(),
|
|
|
|
detail: char.getDetail(),
|
2022-09-01 20:09:59 +00:00
|
|
|
imgs: char.getImgs(),
|
2022-04-07 19:39:43 +00:00
|
|
|
mode,
|
2022-09-03 21:08:57 +00:00
|
|
|
lvs,
|
2022-09-04 21:03:23 +00:00
|
|
|
line: getLineData(char)
|
2022-09-03 21:08:57 +00:00
|
|
|
}, { e, scale: 1.1 })
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-04 21:03:23 +00:00
|
|
|
async function renderWiki ({ e, char }) {
|
|
|
|
let data = char.getData()
|
2022-11-26 08:12:32 +00:00
|
|
|
lodash.extend(data, char.getData('weaponTypeName,elemName'))
|
2022-09-05 19:02:06 +00:00
|
|
|
// 命座持有
|
2022-09-07 19:48:03 +00:00
|
|
|
let holding = await CharWiki.getHolding(char.id)
|
2022-11-23 20:26:07 +00:00
|
|
|
let usage = await CharWiki.getUsage(char.id)
|
2022-09-04 21:03:23 +00:00
|
|
|
return await Common.render('wiki/character-wiki', {
|
|
|
|
data,
|
|
|
|
attr: char.getAttrList(),
|
|
|
|
detail: char.getDetail(),
|
|
|
|
imgs: char.getImgs(),
|
2022-09-05 19:02:06 +00:00
|
|
|
holding,
|
2022-10-22 19:45:28 +00:00
|
|
|
usage,
|
2022-09-04 21:03:23 +00:00
|
|
|
materials: char.getMaterials(),
|
|
|
|
elem: char.elem
|
|
|
|
}, { e, scale: 1.4 })
|
|
|
|
}
|
|
|
|
|
2022-09-21 19:28:33 +00:00
|
|
|
async function renderCharMaterial ({ e, char }) {
|
|
|
|
let data = char.getData()
|
|
|
|
return await Common.render('wiki/character-material', {
|
|
|
|
// saveId: `info-${char.id}`,
|
|
|
|
data,
|
|
|
|
attr: char.getAttrList(),
|
|
|
|
detail: char.getDetail(),
|
|
|
|
imgs: char.getImgs(),
|
|
|
|
materials: char.getMaterials(),
|
|
|
|
elem: char.elem
|
|
|
|
}, { e, scale: 1.4 })
|
|
|
|
}
|
|
|
|
|
2022-09-03 21:08:57 +00:00
|
|
|
const getLineData = function (char) {
|
2022-07-23 20:32:10 +00:00
|
|
|
let ret = []
|
2022-09-01 20:09:59 +00:00
|
|
|
const attrMap = {
|
2022-09-03 21:08:57 +00:00
|
|
|
atkPct: '大攻击',
|
|
|
|
hpPct: '大生命',
|
|
|
|
defPct: '大防御',
|
|
|
|
cpct: '暴击',
|
|
|
|
cdmg: '爆伤',
|
|
|
|
recharge: '充能',
|
|
|
|
mastery: '精通',
|
|
|
|
heal: '治疗',
|
|
|
|
dmg: char.elemName + '伤',
|
|
|
|
phy: '物伤'
|
2022-09-01 20:09:59 +00:00
|
|
|
}
|
2022-09-03 21:08:57 +00:00
|
|
|
lodash.forEach({ hp: '基础生命', atk: '基础攻击', def: '基础防御' }, (label, key) => {
|
|
|
|
ret.push({
|
|
|
|
num: Format.comma(char.baseAttr[key], 1),
|
|
|
|
label
|
|
|
|
})
|
|
|
|
})
|
|
|
|
let ga = char.growAttr
|
|
|
|
ret.push({
|
2022-09-30 12:20:04 +00:00
|
|
|
num: ga.key === 'mastery' ? Format.comma(ga.value, 1) : ga.value,
|
2022-09-03 21:08:57 +00:00
|
|
|
label: `成长·${attrMap[ga.key]}`
|
2022-04-05 19:49:37 +00:00
|
|
|
})
|
2022-04-03 22:06:03 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
return ret
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
async function calendar (e) {
|
2022-07-23 20:32:10 +00:00
|
|
|
let calData = await Calendar.get()
|
|
|
|
let mode = 'calendar'
|
2022-05-16 21:32:31 +00:00
|
|
|
if (/(日历列表|活动)$/.test(e.msg)) {
|
2022-07-23 20:32:10 +00:00
|
|
|
mode = 'list'
|
2022-05-16 21:32:31 +00:00
|
|
|
}
|
2022-05-06 21:20:14 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
return await Common.render('wiki/calendar', {
|
2022-05-07 21:01:18 +00:00
|
|
|
...calData,
|
2022-07-23 20:32:10 +00:00
|
|
|
displayMode: mode
|
2022-08-24 01:07:06 +00:00
|
|
|
}, { e, scale: 1.1 })
|
2022-07-23 20:32:10 +00:00
|
|
|
}
|