mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-09-28 03:46:09 +00:00
为面板数据增加圣遗物检测,防止错误数据
This commit is contained in:
parent
673d813f6f
commit
782a677322
@ -137,6 +137,16 @@ export default class AvatarArtis extends Base {
|
||||
return !lodash.isEmpty(this.artis)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
mainAttr (idx = '') {
|
||||
if (!idx) {
|
||||
let ret = {}
|
||||
|
@ -4,6 +4,7 @@ import moment from 'moment'
|
||||
import { Character, AvatarArtis, ProfileData, Weapon } from './index.js'
|
||||
import { Data } from '../components/index.js'
|
||||
import AttrCalc from './profile-lib/AttrCalc.js'
|
||||
import Profile from './player-lib/Profile.js'
|
||||
|
||||
const charKey = 'name,abbr,sName,star,imgs,face,side,gacha,weaponTypeName'.split(',')
|
||||
|
||||
@ -107,7 +108,7 @@ export default class AvatarData extends Base {
|
||||
* 当前数据是否需要更新天赋
|
||||
* @returns {boolean}
|
||||
*/
|
||||
needRefreshTalent () {
|
||||
get needRefreshTalent () {
|
||||
// 不存在天赋数据
|
||||
if (!this.hasTalent) {
|
||||
return true
|
||||
@ -116,42 +117,6 @@ export default class AvatarData extends Base {
|
||||
return (new Date() * 1) - this._talent > 3600 * 2 * 1000
|
||||
}
|
||||
|
||||
async refreshTalent (mys) {
|
||||
if (mys && mys.isSelfCookie) {
|
||||
let char = this.char
|
||||
if (!char) {
|
||||
return false
|
||||
}
|
||||
let id = char.id
|
||||
let talent = {}
|
||||
let talentRes = await mys.getDetail(id)
|
||||
// { data: null, message: '请先登录', retcode: -100, api: 'detail' }
|
||||
if (talentRes && talentRes.skill_list) {
|
||||
let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc'])
|
||||
for (let val of talentList) {
|
||||
let { max_level: maxLv, level_current: lv } = val
|
||||
if (val.name.includes('普通攻击')) {
|
||||
talent.a = lv
|
||||
continue
|
||||
}
|
||||
if (maxLv >= 10 && !talent.e) {
|
||||
talent.e = lv
|
||||
continue
|
||||
}
|
||||
if (maxLv >= 10 && !talent.q) {
|
||||
talent.q = lv
|
||||
}
|
||||
}
|
||||
}
|
||||
let ret = char.getAvatarTalent(talent, this.cons, 'original')
|
||||
if (ret) {
|
||||
this.setTalent(ret, 'original', 'mys')
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
setArtis (ds, source) {
|
||||
this.artis.setArtisData(ds.artis, source)
|
||||
}
|
||||
@ -164,23 +129,9 @@ export default class AvatarData extends Base {
|
||||
return this.char?.name || ''
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// 是否是合法面板数据
|
||||
get isProfile () {
|
||||
// 检查数据源
|
||||
if (!this._source || !['enka', 'change', 'miao'].includes(this._source)) {
|
||||
return false
|
||||
}
|
||||
// 检查属性
|
||||
if (!this.weapon || !this.talent || !this.artis) {
|
||||
return false
|
||||
}
|
||||
// 检查旅行者
|
||||
if (['空', '荧'].includes(this.name)) {
|
||||
return !!this.elem
|
||||
}
|
||||
return true
|
||||
return Profile.isProfile(this)
|
||||
}
|
||||
|
||||
getProfile () {
|
||||
|
@ -78,7 +78,7 @@ const MysAvatar = {
|
||||
}
|
||||
lodash.forEach(ids, (id) => {
|
||||
let avatar = player.getAvatar(id)
|
||||
if (avatar.needRefreshTalent()) {
|
||||
if (avatar.needRefreshTalent) {
|
||||
ret.push(avatar.id)
|
||||
}
|
||||
})
|
||||
@ -110,7 +110,7 @@ const MysAvatar = {
|
||||
for (let val of avatarArr) {
|
||||
for (let id of val) {
|
||||
let avatar = player.getAvatar(id)
|
||||
skillRet.push(await avatar.refreshTalent(mys))
|
||||
skillRet.push(await MysAvatar.refreshAvatarTalent(avatar, mys))
|
||||
}
|
||||
skillRet = await Promise.all(skillRet)
|
||||
skillRet = skillRet.filter(item => item.id)
|
||||
@ -118,6 +118,42 @@ const MysAvatar = {
|
||||
}
|
||||
}
|
||||
player.save()
|
||||
},
|
||||
|
||||
async refreshAvatarTalent (avatar, mys) {
|
||||
if (mys && mys.isSelfCookie) {
|
||||
let char = avatar.char
|
||||
if (!char) {
|
||||
return false
|
||||
}
|
||||
let id = char.id
|
||||
let talent = {}
|
||||
let talentRes = await mys.getDetail(id)
|
||||
// { data: null, message: '请先登录', retcode: -100, api: 'detail' }
|
||||
if (talentRes && talentRes.skill_list) {
|
||||
let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc'])
|
||||
for (let val of talentList) {
|
||||
let { max_level: maxLv, level_current: lv } = val
|
||||
if (val.name.includes('普通攻击')) {
|
||||
talent.a = lv
|
||||
continue
|
||||
}
|
||||
if (maxLv >= 10 && !talent.e) {
|
||||
talent.e = lv
|
||||
continue
|
||||
}
|
||||
if (maxLv >= 10 && !talent.q) {
|
||||
talent.q = lv
|
||||
}
|
||||
}
|
||||
}
|
||||
let ret = char.getAvatarTalent(talent, avatar.cons, 'original')
|
||||
if (ret) {
|
||||
avatar.setTalent(ret, 'original', 'mys')
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
export default MysAvatar
|
||||
|
@ -54,6 +54,26 @@ const Profile = {
|
||||
e.reply(`UID:${uid}更新面板失败,更新服务:${serv.name}`)
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
isProfile (avatar) {
|
||||
// 检查数据源
|
||||
if (!avatar._source || !['enka', 'change', 'miao'].includes(avatar._source)) {
|
||||
return false
|
||||
}
|
||||
// 检查武器及天赋
|
||||
if (!avatar.weapon || !avatar.talent) {
|
||||
return false
|
||||
}
|
||||
// 检查圣遗物词条是否完备
|
||||
if (!avatar.artis || !avatar.artis.hasAttr) {
|
||||
return false
|
||||
}
|
||||
// 检查旅行者
|
||||
if (['空', '荧'].includes(avatar.name)) {
|
||||
return !!avatar.elem
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,9 @@ let ArtisMark = {
|
||||
let ret = 0
|
||||
let { attrs, posMaxMark } = charCfg
|
||||
let key = mainAttr?.key
|
||||
if (!key) {
|
||||
return 0
|
||||
}
|
||||
let fixPct = 1
|
||||
posIdx = posIdx * 1
|
||||
if (posIdx >= 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user