diff --git a/apps/profile/ProfileChange.js b/apps/profile/ProfileChange.js index cc2fef8c..28eb519d 100644 --- a/apps/profile/ProfileChange.js +++ b/apps/profile/ProfileChange.js @@ -20,15 +20,22 @@ const ProfileChange = { * @param msg * @returns {{}} */ - matchMsg (msg, game = 'gs') { + matchMsg (msg) { if (!/(变|改|换)/.test(msg)) { return false } - msg = msg.toLowerCase().replace(/uid ?:? ?/, '') - let regRet = /^#*(?:原神|星铁)?(\d{9})?(.+?)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)?\s*(\d{9})?[变换改](.+)/.exec(msg) + msg = msg.toLowerCase().replace(/uid ?:? ?/, '').replace('', '') + let regRet = /^#*(\d{9})?(.+?)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)?\s*(\d{9})?[变换改](.+)/.exec(msg) if (!regRet || !regRet[2]) { return false } + let ret = {} + let change = {} + let char = Character.get(lodash.trim(regRet[2]).replace('星铁', '')) + if (!char) { + return false + } + const game = char.game const isGs = game === 'gs' const keyMap = isGs ? { artis: '圣遗物', @@ -56,12 +63,6 @@ const ProfileChange = { }) const keyReg = new RegExp(`^(\\d{9})?\\s*(.+?)\\s*(\\d{9})?\\s*((?:${lodash.keys(keyTitleMap).join('|')}|\\+)+)$`) - let ret = {} - let change = {} - let char = Character.get(lodash.trim(regRet[2])) - if (!char || char.game !== game) { - return false - } ret.char = char.id ret.mode = regRet[3] === '换' ? '面板' : regRet[3] ret.uid = regRet[1] || regRet[4] || '' @@ -79,7 +80,7 @@ const ProfileChange = { let keyRet = keyReg.exec(txt) if (keyRet && keyRet[4]) { let char = Character.get(lodash.trim(keyRet[2])) - if (char && char.game === game) { + if (char && (char.game === game)) { lodash.forEach(keyRet[4].split('+'), (key) => { key = lodash.trim(key) let type = keyTitleMap[key] @@ -89,7 +90,7 @@ const ProfileChange = { type } }) - } else if (!['武器', '光锥', '花'].includes(keyRet[4])) { + } else if (!['武器', '光锥', '花', '手'].includes(keyRet[4])) { return true } } @@ -148,7 +149,6 @@ const ProfileChange = { } // 天赋匹配 - 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) { @@ -167,7 +167,7 @@ const ProfileChange = { txt = lodash.trim(txt) if (txt) { let chars = Character.get(txt) - if (chars && char.game === game) { + if (chars && (chars.game === game)) { char.char = chars.id } } @@ -201,6 +201,7 @@ const ProfileChange = { if (!source || !source.hasData) { source = {} } + let char = Character.get(dc?.char || source.id || charid) if (!char) { return false @@ -236,7 +237,8 @@ const ProfileChange = { elem: char.elem, dataSource: 'change', _source: 'change', - promote + promote, + trees: lodash.extend([], source.trees) }, char.game, false) // 设置武器 @@ -280,6 +282,7 @@ const ProfileChange = { if (artis[idx] && ds.artisSet && ds.artisSet[artisIdx]) { let as = ArtifactSet.get(ds.artisSet[artisIdx], game) if (as) { + artis[idx].id = as.getArti(idx)?.getIdByStar(artis[idx].star || 5) artis[idx]._name = artis[idx].name = as.getArtiName(idx) artis[idx]._set = artis[idx].set = as.name } diff --git a/apps/profile/ProfileDetail.js b/apps/profile/ProfileDetail.js index f1ef3f08..232f8c89 100644 --- a/apps/profile/ProfileDetail.js +++ b/apps/profile/ProfileDetail.js @@ -23,12 +23,15 @@ let ProfileDetail = { let profileChange = false let changeMsg = msg let pc = ProfileChange.matchMsg(msg) + if (pc && pc.char && pc.change) { if (!Cfg.get('profileChange')) { e.reply('面板替换功能已禁用...') return true } - e.uid = pc.uid || e.runtime.uid + e.game = pc.game + e.isSr = e.game === 'sr' + e.uid = pc.uid || await getTargetUid(e) profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change, pc.game) if (profileChange && profileChange.char) { msg = `#${profileChange.char?.name}${pc.mode || '面板'}` diff --git a/models/Artifact.js b/models/Artifact.js index 2b223563..e7a4a6cc 100644 --- a/models/Artifact.js +++ b/models/Artifact.js @@ -114,6 +114,15 @@ class Artifact extends Base { return this.meta.ids[id] || '' } + getIdByStar (star = 5) { + let ids = this.meta.ids || {} + for (let key in ids) { + if (ids[key] * 1 === star) { + return key + } + } + } + getAttrData (mainId, attrData, level = 1, star = 5, idx = 1) { let mainKey = metaDataSR.mainIdx[idx][mainId] let starCfg = metaDataSR.starData[star] diff --git a/models/ArtifactSet.js b/models/ArtifactSet.js index 0e4abb15..836c27d4 100644 --- a/models/ArtifactSet.js +++ b/models/ArtifactSet.js @@ -4,7 +4,13 @@ import lodash from 'lodash' import Base from './Base.js' import { abbr, aliasMap, artiMap, artiSetMap, calc as artisBuffs } from '../resources/meta/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 { + 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' @@ -79,7 +85,7 @@ class ArtifactSet extends Base { } getArti (idx = 1) { - return Artifact.get(this.getArtiName(idx)) + return Artifact.get(this.getArtiName(idx), this.game) } static getAliasMap (game = 'gs') {