修正圣遗物评分下元素杯分数错误的问题

This commit is contained in:
Kokomi 2023-02-10 02:54:51 +08:00
parent 782a677322
commit a56e1cd81d
7 changed files with 122 additions and 145 deletions

View File

@ -1,13 +1,11 @@
import { Common, App, Data, Cfg } from '../components/index.js'
import { Character, Player } from '../models/index.js'
import { getTargetUid, getProfile, profileHelp } from './profile/ProfileCommon.js'
import { profileArtis, profileArtisList } from './profile/ProfileArtis.js'
import { renderProfile } from './profile/ProfileDetail.js'
import { App } from '../components/index.js'
import { getProfile, profileHelp } from './profile/ProfileCommon.js'
import { profileArtisList } from './profile/ProfileArtis.js'
import { profileDetail } from './profile/ProfileDetail.js'
import { profileStat } from './profile/ProfileStat.js'
import { profileList } from './profile/ProfileList.js'
import { uploadCharacterImg, delProfileImg, profileImgList } from './character/ImgUpload.js'
import { enemyLv } from './profile/ProfileUtils.js'
import ProfileChange from './profile/ProfileChange.js'
import { groupRank, resetRank, refreshRank, manageRank } from './profile/ProfileRank.js'
let app = App.init({
@ -91,119 +89,5 @@ app.reg('profile-img-list', profileImgList, {
rule: /^#?\s*(.+)(?:面板图列表)\s*$/,
describe: '【#刻晴面板图列表】 删除指定角色面板图(序号)'
})
/**
app.reg('del-uidflie', delProfile, {
rule: /^#?\s*(?:移除|清除|删除)面板数据$/,
describe: '【#删除面板数据】 删除面板数据'
})
*/
export default app
export async function delProfile (e) {
let uid = await getTargetUid(e)
if (!uid) {
return true
}
if (Data.delfile(`data/UserData/${uid}.json`)) {
e.reply(`uid:${uid}缓存面板数据已删除~`)
}
return true
}
// 查看当前角色
export async function profileDetail (e) {
let msg = e.original_msg || e.msg
if (!msg) {
return false
}
if (!/详细|详情|面板|面版|圣遗物|伤害|换/.test(msg)) {
return false
}
let mode = 'profile'
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
profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change)
if (profileChange && profileChange.char) {
msg = `#${profileChange.char?.name}${pc.mode || '面板'}`
e._profile = profileChange
e._profileMsg = changeMsg
}
}
let uidRet = /[0-9]{9}/.exec(msg)
if (uidRet) {
e.uid = uidRet[0]
msg = msg.replace(uidRet[0], '')
}
let name = msg.replace(/#|老婆|老公/g, '').trim()
msg = msg.replace('面版', '面板')
let dmgRet = /伤害(\d?)$/.exec(name)
let dmgIdx = 0
if (/(最强|最高|最高分|最牛|第一)/.test(msg)) {
mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'rank-mark' : 'rank-dmg'
name = name.replace(/(最强|最高分|第一|最高|最牛|圣遗物|评分|群)/g, '')
}
if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) {
mode = 'profile'
name = name.replace(/(详情|详细|面板)/, '').trim()
} else if (dmgRet) {
mode = 'dmg'
name = name.replace(/伤害[0-5]?/, '').trim()
if (dmgRet[1]) {
dmgIdx = dmgRet[1] * 1
}
} else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) {
mode = 'refresh'
name = name.replace(/详情|详细|面板|更新/g, '').trim()
} else if (/圣遗物/.test(msg)) {
mode = 'artis'
name = name.replace('圣遗物', '').trim()
}
if (!Common.cfg('avatarProfile')) {
// 面板开关关闭
return false
}
let char = Character.get(name.trim())
if (!char) {
return false
}
let uid = e.uid || await getTargetUid(e)
if (!uid) {
return true
}
e.uid = uid
e.avatar = char.id
if (char.isCustom) {
e.reply('自定义角色暂不支持此功能')
return true
}
if (!char.isRelease) {
if (!profileChange) {
e.reply('角色尚未实装')
return true
} else if (Cfg.get('notReleasedData') === false) {
e.reply('未实装角色面板已禁用...')
return true
}
}
if (mode === 'profile' || mode === 'dmg') {
return renderProfile(e, char, mode, { dmgIdx })
} else if (mode === 'refresh') {
await getProfile(e)
return true
} else if (mode === 'artis') {
return profileArtis(e)
}
return true
}

View File

@ -1,7 +1,105 @@
import lodash from 'lodash'
import { autoRefresh } from './ProfileCommon.js'
import { Common, Format } from '../../components/index.js'
import { MysApi, ProfileRank, ProfileArtis, Player } from '../../models/index.js'
import { autoRefresh, getProfile, getTargetUid } from './ProfileCommon.js'
import { Cfg, Common, Format } from '../../components/index.js'
import { MysApi, ProfileRank, ProfileArtis, Player, Character } from '../../models/index.js'
import ProfileChange from './ProfileChange.js'
import { profileArtis } from './ProfileArtis.js'
// 查看当前角色
export async function profileDetail (e) {
let msg = e.original_msg || e.msg
if (!msg) {
return false
}
if (!/详细|详情|面板|面版|圣遗物|伤害|换/.test(msg)) {
return false
}
let mode = 'profile'
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
profileChange = ProfileChange.getProfile(e.uid, pc.char, pc.change)
if (profileChange && profileChange.char) {
msg = `#${profileChange.char?.name}${pc.mode || '面板'}`
e._profile = profileChange
e._profileMsg = changeMsg
}
}
let uidRet = /[0-9]{9}/.exec(msg)
if (uidRet) {
e.uid = uidRet[0]
msg = msg.replace(uidRet[0], '')
}
let name = msg.replace(/#|老婆|老公/g, '').trim()
msg = msg.replace('面版', '面板')
let dmgRet = /伤害(\d?)$/.exec(name)
let dmgIdx = 0
if (/(最强|最高|最高分|最牛|第一)/.test(msg)) {
mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'rank-mark' : 'rank-dmg'
name = name.replace(/(最强|最高分|第一|最高|最牛|圣遗物|评分|群)/g, '')
}
if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) {
mode = 'profile'
name = name.replace(/(详情|详细|面板)/, '').trim()
} else if (dmgRet) {
mode = 'dmg'
name = name.replace(/伤害[0-5]?/, '').trim()
if (dmgRet[1]) {
dmgIdx = dmgRet[1] * 1
}
} else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) {
mode = 'refresh'
name = name.replace(/详情|详细|面板|更新/g, '').trim()
} else if (/圣遗物/.test(msg)) {
mode = 'artis'
name = name.replace('圣遗物', '').trim()
}
if (!Common.cfg('avatarProfile')) {
return false // 面板开关关闭
}
let char = Character.get(name.trim())
if (!char) {
return false
}
let uid = e.uid || await getTargetUid(e)
if (!uid) {
return true
}
e.uid = uid
e.avatar = char.id
if (char.isCustom) {
e.reply('自定义角色暂不支持此功能')
return true
}
if (!char.isRelease) {
if (!profileChange) {
e.reply('角色尚未实装')
return true
} else if (Cfg.get('notReleasedData') === false) {
e.reply('未实装角色面板已禁用...')
return true
}
}
if (mode === 'profile' || mode === 'dmg') {
return renderProfile(e, char, mode, { dmgIdx })
} else if (mode === 'refresh') {
await getProfile(e)
return true
} else if (mode === 'artis') {
return profileArtis(e)
}
return true
}
export async function renderProfile (e, char, mode = 'profile', params = {}) {
let selfUser = await MysApi.initUser(e)

View File

@ -77,6 +77,7 @@ export async function profileList (e) {
chars = lodash.sortBy(chars, ['isNew', 'star', 'level', 'id'])
chars = chars.reverse()
player.save()
// 渲染图像
return await Common.render('character/profile-list', {
save_id: uid,

View File

@ -14,21 +14,8 @@ export default class AvatarArtis extends Base {
this.artis = {}
}
static isProfileArtis (ds) {
let ret = true
for (let idx = 1; idx <= 5; idx++) {
if (ds[idx]) {
if (!ds[idx].main || !ds[idx].attrs) {
ret = false
return ret
}
}
}
return ret
}
setArtisData (ds = {}, source) {
if (!this.hasArtis || AvatarArtis.isProfileArtis(ds) || !AvatarArtis.isProfileArtis(this.artis)) {
if (!this.hasArtis || ArtisMark.hasAttr(ds) || !ArtisMark.hasAttr(this.artis)) {
for (let idx = 1; idx <= 5; idx++) {
if (ds[idx]) {
this.setArtis(idx, ds[idx] || ds[`arti${idx}`] || {})
@ -138,13 +125,7 @@ export default class AvatarArtis extends Base {
}
get hasAttr () {
for (let idx = 1; idx <= 5; idx++) {
let ds = this.artis[idx]
if (ds && (!ds.name || !ds.main || !ds.attrs)) {
return false
}
}
return true
return ArtisMark.hasAttr(this.artis)
}
mainAttr (idx = '') {

View File

@ -47,6 +47,7 @@ export default class Player extends Base {
this.setBasicData(data)
if (data.chars) {
this.setAvatars(data.chars)
// 暂时保留旧数据,防止异常情况
this._chars = data.chars
}
this.setAvatars(data.avatars || [])
@ -61,6 +62,7 @@ export default class Player extends Base {
lodash.forEach(this._avatars, (ds) => {
ret.avatars[ds.id] = ds.toJSON()
})
// 暂时保留旧数据,防止异常情况
if (this._chars) {
ret.chars = this._chars
}

View File

@ -17,6 +17,7 @@ export default class ProfileArtis extends AvatarArtis {
setProfile (profile, artis) {
this.profile = profile
this.elem = profile.elem || profile.char?.elem
if (artis) {
this.setArtisData(artis)
}

View File

@ -5,7 +5,7 @@ import { attrNameMap, mainAttr, subAttr, attrMap } from '../../resources/meta/ar
let ArtisMark = {
// 根据Key获取标题
getKeyByTitle (title, dmg = false) {
if (/元素伤害加成/.test(title)) {
if (/元素伤害加成/.test(title) || Format.isElem(title)) {
let elem = Format.matchElem(title)
return dmg ? 'dmg' : elem
} else if (title === '物理伤害加成') {
@ -229,6 +229,16 @@ let ArtisMark = {
let ret = []
lodash.forEach(tmp, (ds) => ret.push(ds.attr))
return ret.slice(0, maxLen)
},
hasAttr (artis) {
for (let idx = 1; idx <= 5; idx++) {
let ds = artis[idx]
if (ds && (!ds.name || !ds.main || !ds.attrs || !ds?.main?.key)) {
return false
}
}
return true
}
}