mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
更新面板Model数据结构,修正一些已知问题
This commit is contained in:
parent
cde805a146
commit
3096374f4b
@ -5,7 +5,7 @@
|
||||
import lodash from 'lodash'
|
||||
import { Cfg, Common } from '#miao'
|
||||
import { getTargetUid, profileHelp, getProfileRefresh } from './ProfileCommon.js'
|
||||
import { Artifact, Character, ProfileArtis, Player } from '#miao.models'
|
||||
import { Artifact, Character, Player } from '#miao.models'
|
||||
|
||||
/*
|
||||
* 角色圣遗物面板
|
||||
|
@ -2,7 +2,7 @@ import lodash from 'lodash'
|
||||
import { getTargetUid, getProfileRefresh } from './ProfileCommon.js'
|
||||
import ProfileList from './ProfileList.js'
|
||||
import { Cfg, Common, Data, Format } from '#miao'
|
||||
import { MysApi, ProfileRank, ProfileArtis, Character, Weapon } from '#miao.models'
|
||||
import { MysApi, ProfileRank, Character, Weapon, Artifact } from '#miao.models'
|
||||
import ProfileChange from './ProfileChange.js'
|
||||
import { profileArtis } from './ProfileArtis.js'
|
||||
import { ProfileWeapon } from './ProfileWeapon.js'
|
||||
|
@ -77,7 +77,7 @@ export default class Avatar extends AvatarBase {
|
||||
|
||||
calcAttr () {
|
||||
this._attr = Attr.create(this)
|
||||
this.attr = this._attr.calc()
|
||||
this.attr = this._attr.calc(this)
|
||||
this.base = this._attr.getBase()
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ export default class Avatar extends AvatarBase {
|
||||
// 获取当前profileData的圣遗物评分,withDetail=false仅返回简略信息
|
||||
getArtisMark (withDetail = true) {
|
||||
if (this.hasData) {
|
||||
return this.artis.getMarkDetail(withDetail)
|
||||
return this.artis.getMarkDetail(this, withDetail)
|
||||
}
|
||||
return {}
|
||||
}
|
||||
@ -108,4 +108,23 @@ export default class Avatar extends AvatarBase {
|
||||
}
|
||||
return await this.dmg.calcData({ enemyLv, mode, dmgIdx, idxIsInput })
|
||||
}
|
||||
|
||||
// toJSON 供保存使用
|
||||
toJSON () {
|
||||
let keys = this.isGs ?
|
||||
'name,id,elem,level,promote,fetter,costume,cons,talent:originalTalent' :
|
||||
'name,id,elem,level,promote,cons,talent:originalTalent,trees'
|
||||
let ret = {
|
||||
...this.getData(keys),
|
||||
weapon: Data.getData(this.weapon, this.isGs ? 'name,level,promote,affix' : 'id,level,promote,affix'),
|
||||
artis: this.artis.toJSON()
|
||||
}
|
||||
if (!this.mysArtis.isSameArtis(this.artis)) {
|
||||
ret.mysArtis = this.mysArtis.toJSON()
|
||||
}
|
||||
return {
|
||||
...ret,
|
||||
...this.getData('_source,_time,_update,_talent')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ export default class Artis extends ArtisBase {
|
||||
* 获取角色配置
|
||||
* @returns {{classTitle: *, weight: *, posMaxMark: {}, mark: {}, attrs: {}}}
|
||||
*/
|
||||
getCharCfg () {
|
||||
let char = Character.get(this.charid)
|
||||
getCharCfg (profile) {
|
||||
let char = profile.char
|
||||
let { game, isGs } = char
|
||||
let { attrWeight, title } = ArtisMarkCfg.getCharArtisCfg(char, this.profile, this)
|
||||
let { attrWeight, title } = ArtisMarkCfg.getCharArtisCfg(char, profile, this)
|
||||
let attrs = {}
|
||||
let baseAttr = char.baseAttr || { hp: 14000, atk: 230, def: 700 }
|
||||
let attrMap = isGs ? attrMapGS : attrMapSR
|
||||
@ -60,8 +60,8 @@ export default class Artis extends ArtisBase {
|
||||
}
|
||||
}
|
||||
|
||||
getMarkDetail (withDetail = true) {
|
||||
let charCfg = this.getCharCfg()
|
||||
getMarkDetail (profile, withDetail = true) {
|
||||
let charCfg = this.getCharCfg(profile)
|
||||
let artis = {}
|
||||
let setCount = {}
|
||||
let totalMark = 0
|
||||
@ -216,4 +216,15 @@ export default class Artis extends ArtisBase {
|
||||
})
|
||||
return check
|
||||
}
|
||||
|
||||
isSameArtis (target) {
|
||||
let k = (ds) => [ds?.name || '', ds?.level || '', ds?.star || ''].join('|')
|
||||
let ret = true
|
||||
this.eachIdx((ds, idx) => {
|
||||
if (k[ds] !== k(target[idx])) {
|
||||
return ret = false
|
||||
}
|
||||
})
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,10 @@ export default class ArtisBase extends Base {
|
||||
eachIdx (fn) {
|
||||
for (let idx = 1; idx <= (this.isGs ? 5 : 6); idx++) {
|
||||
this.artis[idx] = this.artis[idx] || {}
|
||||
fn(this.artis[idx], idx)
|
||||
let ret = fn(this.artis[idx], idx)
|
||||
if (ret === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,9 +83,9 @@ export default class ArtisBase extends Base {
|
||||
arti.star = artiObj.getStarById(ds.id) || arti.star || 5
|
||||
} else {
|
||||
arti.name = ds.name || arti.name || ''
|
||||
arti.set = ds.set || Artifact.getSetNameByArti(arti.name) || ''
|
||||
arti.set = ds.set || Artifact.getSetNameByArti(arti.name) || ''
|
||||
arti.level = ds.level || 1
|
||||
arti.star = ds.star || 5
|
||||
arti.star = ds.star || 5
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,28 @@ import { usefulAttr as usefulAttrGS } from '../../resources/meta/artifact/artis-
|
||||
import { usefulAttr as usefulAttrSR } from '../../resources/meta-sr/artifact/artis-mark.js'
|
||||
import lodash from 'lodash'
|
||||
|
||||
const weaponCfg = {
|
||||
磐岩结绿: {
|
||||
attr: 'hp',
|
||||
abbr: '绿剑'
|
||||
},
|
||||
赤角石溃杵: {
|
||||
attr: 'def',
|
||||
abbr: '赤角'
|
||||
},
|
||||
猎人之径: {
|
||||
attr: 'mastery'
|
||||
},
|
||||
薙草之稻光: {
|
||||
attr: 'recharge',
|
||||
abbr: '薙刀'
|
||||
},
|
||||
护摩之杖: {
|
||||
attr: 'hp',
|
||||
abbr: '护摩'
|
||||
}
|
||||
}
|
||||
|
||||
const ArtisMarkCfg = {
|
||||
|
||||
getCharArtisCfg (char, profile, artis) {
|
||||
@ -36,28 +58,6 @@ const ArtisMarkCfg = {
|
||||
// 对原神一些特殊情况做适配与判定
|
||||
|
||||
// 增加攻击力或直接伤害类武器判定
|
||||
const weaponCfg = {
|
||||
磐岩结绿: {
|
||||
attr: 'hp',
|
||||
abbr: '绿剑'
|
||||
},
|
||||
赤角石溃杵: {
|
||||
attr: 'def',
|
||||
abbr: '赤角'
|
||||
},
|
||||
猎人之径: {
|
||||
attr: 'mastery'
|
||||
},
|
||||
薙草之稻光: {
|
||||
attr: 'recharge',
|
||||
abbr: '薙刀'
|
||||
},
|
||||
护摩之杖: {
|
||||
attr: 'hp',
|
||||
abbr: '护摩'
|
||||
}
|
||||
}
|
||||
|
||||
if (weight.atk > 0 && weaponCfg[wn]) {
|
||||
let wCfg = weaponCfg[wn]
|
||||
if (check(wCfg.attr, wCfg.max || 75, wCfg.plus || 75)) {
|
||||
@ -85,7 +85,7 @@ const ArtisMarkCfg = {
|
||||
}
|
||||
|
||||
let charRule = char.getArtisCfg() || function ({ def }) {
|
||||
return def(usefulAttr[char.name] || { atk: 75, cpct: 100, cdmg: 100 })
|
||||
return def(usefulAttr[char.name] || { })
|
||||
}
|
||||
|
||||
if (charRule) {
|
||||
|
@ -11,7 +11,6 @@ import lodash from 'lodash'
|
||||
class Attr {
|
||||
constructor (profile) {
|
||||
this.profile = profile
|
||||
this.char = profile.char
|
||||
this.game = this.char.game
|
||||
}
|
||||
|
||||
@ -23,6 +22,10 @@ class Attr {
|
||||
return this.game === 'sr'
|
||||
}
|
||||
|
||||
get char () {
|
||||
return this.profile?.char
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态调用入口
|
||||
* @param profile
|
||||
@ -75,6 +78,10 @@ class Attr {
|
||||
|
||||
|
||||
addAttr (key, val, isBase = false) {
|
||||
console.log(key, val, isBase)
|
||||
if (isNaN(val)) {
|
||||
cs.log(val)
|
||||
}
|
||||
this.attr.addAttr(key, val, isBase)
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ export default class AvatarBase extends Base {
|
||||
this.char = char
|
||||
this.game = char.game || game
|
||||
this._mysArtis = new Artis(this.game)
|
||||
this.setAvatar(ds)
|
||||
}
|
||||
|
||||
get hasTalent () {
|
||||
@ -263,18 +262,7 @@ export default class AvatarBase extends Base {
|
||||
return this.isProfile && this.artis.length > 0
|
||||
}
|
||||
|
||||
// toJSON 供保存使用
|
||||
toJSON () {
|
||||
let keys = this.isGs ?
|
||||
'name,id,elem,level,promote,fetter,costume,cons,talent:originalTalent' :
|
||||
'name,id,elem,level,promote,cons,talent:originalTalent,trees'
|
||||
return {
|
||||
...this.getData(keys),
|
||||
weapon: Data.getData(this.weapon, this.isGs ? 'name,level,promote,affix' : 'id,level,promote,affix'),
|
||||
...this.getData('artis,_source,_time,_update,_talent')
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据详情
|
||||
getDetail (keys = '') {
|
||||
let imgs = this.char.getImgs(this.costume)
|
||||
if (this.isGs) {
|
||||
|
Loading…
Reference in New Issue
Block a user