初步支持星铁面板变换,待处理行迹变换

This commit is contained in:
Kokomi 2023-10-13 18:25:21 +08:00
parent c625d5ffd1
commit 4dbaf60558
6 changed files with 235 additions and 50 deletions

View File

@ -5,22 +5,6 @@ import lodash from 'lodash'
import { Data } from '#miao' import { Data } from '#miao'
import { Character, ArtifactSet, ProfileData, Weapon, Player } from '#miao.models' import { Character, ArtifactSet, ProfileData, Weapon, Player } from '#miao.models'
const keyMap = {
artis: '圣遗物',
arti1: '花',
arti2: '毛,羽,羽毛',
arti3: '沙,沙漏,表',
arti4: '杯,杯子',
arti5: '头,冠',
weapon: '武器'
}
let keyTitleMap = {}
lodash.forEach(keyMap, (val, key) => {
lodash.forEach(val.split(','), (v) => {
keyTitleMap[v] = key
})
})
const keyReg = new RegExp(`^(\\d{9})?\\s*(.+?)\\s*(\\d{9})?\\s*((?:${lodash.keys(keyTitleMap).join('|')}|\\+)+)$`)
// 默认武器 // 默认武器
let defWeapon = { let defWeapon = {
bow: '西风猎弓', bow: '西风猎弓',
@ -36,20 +20,46 @@ const ProfileChange = {
* @param msg * @param msg
* @returns {{}} * @returns {{}}
*/ */
matchMsg (msg) { matchMsg (msg, game = 'gs') {
if (!/(变|改|换)/.test(msg)) { if (!/(变|改|换)/.test(msg)) {
return false return false
} }
msg = msg.toLowerCase().replace(/uid ?:? ?/, '') msg = msg.toLowerCase().replace(/uid ?:? ?/, '')
let regRet = /^#*(\d{9})?(.+?)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)?\s*(\d{9})?[变换改](.+)/.exec(msg) let regRet = /^#*(?:原神|星铁)?(\d{9})?(.+?)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)?\s*(\d{9})?[变换改](.+)/.exec(msg)
if (!regRet || !regRet[2]) { if (!regRet || !regRet[2]) {
return false return false
} }
const isGs = game === 'gs'
const keyMap = isGs ? {
artis: '圣遗物',
arti1: '花',
arti2: '毛,羽,羽毛',
arti3: '沙,沙漏,表',
arti4: '杯,杯子',
arti5: '头,冠',
weapon: '武器'
} : {
artis: '圣遗物,遗器',
arti1: '头,帽子',
arti2: '手,手套',
arti3: '衣,衣服,甲,躯干',
arti4: '鞋,靴,鞋子,靴子',
arti5: '球',
artis6: '绳',
weapon: '武器,光锥'
}
let keyTitleMap = {}
lodash.forEach(keyMap, (val, key) => {
lodash.forEach(val.split(','), (v) => {
keyTitleMap[v] = key
})
})
const keyReg = new RegExp(`^(\\d{9})?\\s*(.+?)\\s*(\\d{9})?\\s*((?:${lodash.keys(keyTitleMap).join('|')}|\\+)+)$`)
let ret = {} let ret = {}
let change = {} let change = {}
let char = Character.get(lodash.trim(regRet[2])) let char = Character.get(lodash.trim(regRet[2]))
if (!char) { if (!char || char.game !== game) {
return false return false
} }
ret.char = char.id ret.char = char.id
@ -69,7 +79,7 @@ const ProfileChange = {
let keyRet = keyReg.exec(txt) let keyRet = keyReg.exec(txt)
if (keyRet && keyRet[4]) { if (keyRet && keyRet[4]) {
let char = Character.get(lodash.trim(keyRet[2])) let char = Character.get(lodash.trim(keyRet[2]))
if (char) { if (char && char.game === game) {
lodash.forEach(keyRet[4].split('+'), (key) => { lodash.forEach(keyRet[4].split('+'), (key) => {
key = lodash.trim(key) key = lodash.trim(key)
let type = keyTitleMap[key] let type = keyTitleMap[key]
@ -79,20 +89,32 @@ const ProfileChange = {
type type
} }
}) })
} else if (keyRet[4] !== '武器' && keyRet[4] !== '花') { } else if (!['武器', '光锥', '花'].includes(keyRet[4])) {
return true return true
} }
} }
// 匹配圣遗物套装 // 匹配圣遗物套装
let asMap = ArtifactSet.getAliasMap() let asMap = ArtifactSet.getAliasMap(game)
let asKey = lodash.keys(asMap).sort((a,b)=>b.length-a.length).join('|') let asKey = lodash.keys(asMap).sort((a, b) => b.length - a.length).join('|')
let asReg = new RegExp(`(${asKey})套?[2,4]?\\+?(${asKey})?套?[2,4]?`) let asReg = new RegExp(`(${asKey})套?[2,4]?\\+?(${asKey})?套?[2,4]?\\+?(${asKey})?套?[2,4]?`)
let asRet = asReg.exec(txt) let asRet = asReg.exec(txt)
if (asRet && asRet[1] && asMap[asRet[1]]) { if (asRet && asRet[1] && asMap[asRet[1]]) {
change.artisSet = [asMap[asRet[1]]] if (game === 'gs') {
if (asRet[2] && asMap[asRet[2]]) { change.artisSet = [asMap[asRet[1]], asMap?.[asRet[2]] || asMap[asRet[1]]]
change.artisSet.push(asMap[asRet[2]]) } else if (game === 'sr') {
for (let idx = 1; idx <= 3; idx++) {
let as = ArtifactSet.get(asMap?.[asRet[idx]])
if (as) { // 球&绳
change.artisSet = change.artisSet || []
let ca = change.artisSet
ca[as.sets?.[1] ? (ca[0] ? 1 : 0) : 2] = as.name
}
}
let ca = change.artisSet
if (ca && ca[0] && !ca[1]) {
ca[1] = ca[0]
}
} }
return true return true
} }
@ -101,7 +123,7 @@ const ProfileChange = {
let wRet = /^(?:等?级?([1-9][0-9])?级?)?\s*(?:([1-5一二三四五满])?精炼?([1-5一二三四五])?)?\s*(?:等?级?([1-9][0-9])?级?)?\s*(.*)$/.exec(txt) let wRet = /^(?:等?级?([1-9][0-9])?级?)?\s*(?:([1-5一二三四五满])?精炼?([1-5一二三四五])?)?\s*(?:等?级?([1-9][0-9])?级?)?\s*(.*)$/.exec(txt)
if (wRet && wRet[5]) { if (wRet && wRet[5]) {
let weaponName = lodash.trim(wRet[5]) let weaponName = lodash.trim(wRet[5])
let weapon = Weapon.get(weaponName, ret.char.game) let weapon = Weapon.get(weaponName, game, ret.char.game)
if (weapon || weaponName === '武器' || Weapon.isWeaponSet(weaponName)) { if (weapon || weaponName === '武器' || Weapon.isWeaponSet(weaponName)) {
let affix = wRet[2] || wRet[3] let affix = wRet[2] || wRet[3]
affix = { : 1, : 2, : 3, : 4, : 5, : 5 }[affix] || affix * 1 affix = { : 1, : 2, : 3, : 4, : 5, : 5 }[affix] || affix * 1
@ -118,7 +140,7 @@ const ProfileChange = {
} }
let char = change.char || {} let char = change.char || {}
// 命座匹配 // 命座匹配
let consRet = /([0-6零一二三四五六满])命/.exec(txt) let consRet = /([0-6零一二三四五六满])(|魂|星魂)/.exec(txt)
if (consRet && consRet[1]) { if (consRet && consRet[1]) {
let cons = consRet[1] let cons = consRet[1]
char.cons = Math.max(0, Math.min(6, lodash.isNaN(cons * 1) ? '零一二三四五六满'.split('').indexOf(cons) : cons * 1)) char.cons = Math.max(0, Math.min(6, lodash.isNaN(cons * 1) ? '零一二三四五六满'.split('').indexOf(cons) : cons * 1))
@ -126,15 +148,15 @@ const ProfileChange = {
} }
// 天赋匹配 // 天赋匹配
let talentRet = /(?:天赋|技能)((?:[1][0-5]|[1-9])[ ,]?)((?:[1][0-5]|[1-9])[ ,]?)([1][0-5]|[1-9])/.exec(txt)
let talentRet = (isGs ? /(?:天赋|技能|行迹)((?:[1][0-5]|[1-9])[ ,]?)((?:[1][0-5]|[1-9])[ ,]?)([1][0-5]|[1-9])/ :
/(?:天赋|技能|行迹)((?:[1][0-5]|[1-9])[ ,]?)((?:[1][0-5]|[1-9])[ ,]?)((?:[1][0-5]|[1-9])[ ,]?)([1][0-5]|[1-9])/).exec(txt)
if (talentRet) { if (talentRet) {
let [match, a, e, q] = talentRet char.talent = {}
char.talent = { lodash.forEach((isGs ? 'aeq' : 'aetq').split(''), (key, idx) => {
a: a * 1 || 1, char.talent[key] = talentRet[idx + 1] * 1 || 1
e: e * 1 || 1, })
q: q * 1 || 1 txt = txt.replace(talentRet[0], '')
}
txt = txt.replace(match, '')
} }
let lvRet = /等级([1-9][0-9]?)|([1-9][0-9]?)级/.exec(txt) let lvRet = /等级([1-9][0-9]?)|([1-9][0-9]?)级/.exec(txt)
@ -145,7 +167,7 @@ const ProfileChange = {
txt = lodash.trim(txt) txt = lodash.trim(txt)
if (txt) { if (txt) {
let chars = Character.get(txt) let chars = Character.get(txt)
if (chars) { if (chars && char.game === game) {
char.char = chars.id char.char = chars.id
} }
} }
@ -170,6 +192,8 @@ const ProfileChange = {
return false return false
} }
const isGs = game === 'gs'
let player = Player.create(uid, game) let player = Player.create(uid, game)
let source = player.getProfile(charid) let source = player.getProfile(charid)
@ -240,21 +264,21 @@ const ProfileChange = {
if (ds?.char?.talent) { if (ds?.char?.talent) {
ret.setTalent(ds?.char?.talent, 'level') ret.setTalent(ds?.char?.talent, 'level')
} else { } else {
ret.setTalent(source?.originalTalent || { a: 9, e: 9, q: 9 }, 'original') ret.setTalent(source?.originalTalent || (isGs ? { a: 9, e: 9, q: 9 } : { a: 6, e: 8, t: 8, q: 8 }), 'original')
} }
// 设置圣遗物 // 设置圣遗物
let artis = getSource(ds.artis)?.artis?.artis || {} let artis = getSource(ds.artis)?.artis?.artis || {}
for (let idx = 1; idx <= (isGs ? 5 : 6); idx++) {
for (let idx = 1; idx <= 5; idx++) {
if (ds['arti' + idx]) { if (ds['arti' + idx]) {
let source = getSource(ds['arti' + idx]) let source = getSource(ds['arti' + idx])
if (source && source.artis && source.artis[idx]) { if (source && source.artis && source.artis[idx]) {
artis[idx] = source.artis[idx] artis[idx] = source.artis[idx]
} }
} }
if (ds.artisSet) { let artisIdx = (isGs ? '00111' : '001122')[idx - 1]
let as = ArtifactSet.get(idx >= 3 && ds.artisSet[1] ? ds.artisSet[1] : ds.artisSet[0]) if (artis[idx] && ds.artisSet && ds.artisSet[artisIdx]) {
let as = ArtifactSet.get(ds.artisSet[artisIdx], game)
if (as) { if (as) {
artis[idx]._name = artis[idx].name = as.getArtiName(idx) artis[idx]._name = artis[idx].name = as.getArtiName(idx)
artis[idx]._set = artis[idx].set = as.name artis[idx]._set = artis[idx].set = as.name

View File

@ -28,10 +28,6 @@ let ProfileDetail = {
e.reply('面板替换功能已禁用...') e.reply('面板替换功能已禁用...')
return true return true
} }
if (pc.game === 'sr') {
e.reply('星铁面板暂不支持面板替换,请等待后续升级...')
return true
}
e.uid = pc.uid || e.runtime.uid e.uid = pc.uid || e.runtime.uid
profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change, pc.game) profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change, pc.game)
if (profileChange && profileChange.char) { if (profileChange && profileChange.char) {

View File

@ -4,7 +4,7 @@
import lodash from 'lodash' import lodash from 'lodash'
import Base from './Base.js' import Base from './Base.js'
import { abbr, aliasMap, artiMap, artiSetMap, calc as artisBuffs } from '../resources/meta/artifact/index.js' import { abbr, aliasMap, artiMap, artiSetMap, calc as artisBuffs } from '../resources/meta/artifact/index.js'
import { abbr as abbrSR, artiMap as artiMapSR, artisBuffs as artisBuffsSR, artiSetMap as artiSetMapSR } from '../resources/meta-sr/artifact/index.js' import { abbr as abbrSR, aliasMap as aliasMapSR, artiMap as artiMapSR, artisBuffs as artisBuffsSR, artiSetMap as artiSetMapSR } from '../resources/meta-sr/artifact/index.js'
import { Artifact } from './index.js' import { Artifact } from './index.js'
@ -83,7 +83,7 @@ class ArtifactSet extends Base {
} }
static getAliasMap (game = 'gs') { static getAliasMap (game = 'gs') {
return aliasMap return game === 'gs' ? aliasMap : aliasMapSR
} }
} }

View File

@ -106,3 +106,38 @@ export const abbr = {
宝命长存的莳者: '莳者', 宝命长存的莳者: '莳者',
骇域漫游的信使: '信使' 骇域漫游的信使: '信使'
} }
let aliasCfg = {
盗匪荒漠的废土客: '虚数套,废土',
繁星璀璨的天才: '繁星',
激奏雷电的乐队: '雷套,雷电',
熔岩锻铸的火匠: '火套',
晨昏交界的翔鹰: '风套',
野穗伴行的快枪手: '快枪手,快枪',
密林卧雪的猎人: '冰套',
流星追迹的怪盗: '怪盗',
街头出身的拳王: '拳王',
云无留迹的过客: '过客,云无留迹',
戍卫风雪的铁卫: '铁卫,风雪',
净庭教宗的圣骑士: '圣骑士,圣骑士',
筑城者的贝洛伯格: '筑城者,贝洛伯格,筑城',
星体差分机: '差分机,星体',
停转的萨尔索图: '停转,萨尔索图,萨尔',
不老者的仙舟: '仙舟,不老者,不老',
盗贼公国塔利亚: '盗贼,塔利亚',
泛银河商业公司: '泛银河,银河,商业',
太空封印站: '太空,封印站',
生命的翁瓦克: '翁瓦克,生命',
繁星竞技场: '繁星,竞技场',
折断的龙骨: '龙骨',
宝命长存的莳者: '莳者,时者',
骇域漫游的信使: '信使'
}
let alias = {}
lodash.forEach(aliasCfg, (txt, name) => {
lodash.forEach(txt.split(','), (t) => {
alias[t] = name
})
alias[name] = name
})
export const aliasMap = alias

View File

@ -1,5 +1,6 @@
import { Data } from '#miao' import { Data } from '#miao'
import lodash from 'lodash' import lodash from 'lodash'
import { abbr, alias } from './meta.js'
const types = '存护,丰饶,毁灭,同谐,虚无,巡猎,智识'.split(',') const types = '存护,丰饶,毁灭,同谐,虚无,巡猎,智识'.split(',')
@ -11,6 +12,11 @@ lodash.forEach(data, (ds) => {
aliasMap[ds.id] = ds.id aliasMap[ds.id] = ds.id
aliasMap[ds.name] = ds.id aliasMap[ds.name] = ds.id
}) })
lodash.forEach(alias, (name, alias) => {
if (aliasMap[name]) {
aliasMap[alias] = aliasMap[name]
}
})
export const weaponAlias = aliasMap export const weaponAlias = aliasMap
export const weaponData = data export const weaponData = data

View File

@ -0,0 +1,124 @@
import lodash from 'lodash'
export const abbr = {
// 巡猎
'烦恼着,幸福着': '烦恼着幸福着',
// 丰饶
// 毁灭
'汪!散步时间!': '散步时间',
'无可取代的东西': '无可取代东西',
'比阳光更明亮的': '比阳光更明亮,光一直亮',
'记一位星神的陨落': '星神的陨落',
// 存护
// 虚无
'决心如汗珠般闪耀': '汗珠般闪耀',
'新手任务开始前': '新手任务',
// 同谐
'但战斗还未结束': '战斗还未结束',
//智识
'别让世界静下来': '别让世界静',
'今日亦是和平的一日': '今日亦是和平'
}
let aliasCfg = {
// 巡猎
'锋镝': '',
'离弦': '',
'相抗': '',
'唯有沉默': '沉默',
'论剑': '',
'点个关注吧!': '点个关注吧,点个关注,点关注,关注,点个赞吧,点个赞,点赞',
'春水初生': '春水,纯水出生,纯水出生',
'重返幽冥': '幽冥',
'于夜色中': '于夜色中,与夜色中,夜色',
'如泥酣眠': '酣眠',
'烦恼着,幸福着': '烦恼着幸福着,烦恼着,幸福着,烦恼,幸福',
'星海巡航': '星海,巡航',
// 丰饶
'物穰': '',
'嘉果': '',
'蕃息': '',
'一场术后对话': '一场术后对话,术后对话',
'同一种心情': '',
'此时恰好': '',
'等价交换': '交换',
'暖夜不会漫长': '暖夜不漫长',
'棺的回响': '棺一直响,棺响',
'时节不居': '时节',
// 毁灭
'天倾': '',
'乐圮': '',
'俱殁': '',
'鼹鼠党欢迎你': '鼹鼠党',
'秘密誓心': '',
'在蓝天下': '',
'汪!散步时间!': '散步时间,散步',
'无处可逃': '',
'无可取代的东西': '无可取代',
'到不了的彼岸': '岸一直到,人一直活,彼岸一直到不了,到彼岸,彼岸',
'此身为剑': '',
'比阳光更明亮的': '比阳光更明亮,比阳的,阳光明亮,比阳光,比阳,阳光',
'记一位星神的陨落': '星神的陨落,星神陨落',
// 存护
'琥珀': '',
'戍御': '',
'开疆': '',
'余生的第一天': '余生第一天,第一天',
'朗道的选择': '朗道,朗道选择',
'宇宙市场趋势': '宇宙市场,市场趋势',
'我们是地火': '地火',
'这就是我啦!': '这就是我啦,就是我啦,就是我',
'制胜的瞬间': '致胜的瞬间,制胜,致胜',
'她已闭上双眼': '眼一直闭,闭上双眼,她已闭眼,闭眼',
'记忆的质料': '记忆质料,记忆',
// 虚无
'幽邃': '',
'渊环': '',
'匿影': '',
'晚安与睡颜': '晚安睡颜,晚安',
'猎物的视线': '猎物视线,猎物',
'决心如汗珠般闪耀': '决心,汗珠',
'延长记号': '记号延长,记号',
'后会有期': '后会无期',
'新手任务开始前': '新手任务,任务开始',
'以世界之名': '世界之名',
'只需等待': '妈一直等,菜一直等,等待',
'雨一直下': '',
'孤独的疗愈': '孤独疗愈,孤独',
// 同谐
'齐颂': '',
'轮契': '',
'调和': '',
'记忆中的模样': '记忆的模样,记忆模样,记忆',
'与行星相会': '行星相会',
'舞!舞!舞!': '舞舞舞',
'过往未来': '',
'镂月裁云之意': '镂月裁云之意,镂月裁云,镂云裁月之意,楼月裁云之意,楼月裁云',
'但战斗还未结束': '战斗还未结束',
// 智识
'智库': '',
'灵钥': '',
'睿见': '',
'「我」的诞生': '我的诞生',
'别让世界静下来': '让世界静下来',
'天才们的休憩': '天才的休憩',
'早餐的仪式感': '早餐',
'今日亦是和平的一日': '和平的一日,和平一日',
'银河铁道之夜': '银河铁道,星穹铁道之夜,星穹铁道',
'拂晓之前': '拂晓'
}
let alias = {}
lodash.forEach(aliasCfg, (txt, name) => {
if (txt) {
lodash.forEach(txt.split(','), (t) => {
alias[t] = name
})
}
alias[name] = name
})
export { alias }