2022-08-18 10:13:42 +00:00
|
|
|
|
import lodash from 'lodash'
|
2023-02-09 16:57:25 +00:00
|
|
|
|
import AvatarData from './AvatarData.js'
|
2023-03-07 17:52:11 +00:00
|
|
|
|
import { Data, Cfg } from '#miao'
|
2023-02-09 16:57:25 +00:00
|
|
|
|
import { ProfileArtis, ProfileDmg } from './index.js'
|
2023-02-13 19:47:22 +00:00
|
|
|
|
import AttrCalc from './profile/AttrCalc.js'
|
|
|
|
|
import CharImg from './character/CharImg.js'
|
2022-08-18 10:13:42 +00:00
|
|
|
|
|
2023-02-09 16:57:25 +00:00
|
|
|
|
export default class ProfileData extends AvatarData {
|
2023-05-16 05:04:43 +00:00
|
|
|
|
constructor (ds = {}, game = 'gs', calc = true) {
|
|
|
|
|
super(ds, game)
|
|
|
|
|
if (calc) {
|
2023-02-10 14:01:18 +00:00
|
|
|
|
this.calcAttr()
|
|
|
|
|
}
|
2022-11-24 16:31:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 19:51:50 +00:00
|
|
|
|
// 判断当前profileData是否具有有效数据
|
|
|
|
|
get hasData () {
|
|
|
|
|
return this.isProfile
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-22 17:48:44 +00:00
|
|
|
|
get imgs () {
|
|
|
|
|
return this.char.getImgs(this.costume) || {}
|
2023-02-21 19:49:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 11:56:47 +00:00
|
|
|
|
get costumeSplash () {
|
2023-02-11 19:51:50 +00:00
|
|
|
|
let costume = this._costume
|
2023-02-12 11:56:47 +00:00
|
|
|
|
costume = this.char.checkCostume(costume) ? '2' : ''
|
|
|
|
|
|
2023-02-22 17:48:44 +00:00
|
|
|
|
if (!Cfg.get('costumeSplash', true)) {
|
|
|
|
|
return this.char.getImgs(this._costume).splash
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 11:56:47 +00:00
|
|
|
|
let nPath = `meta/character/${this.name}`
|
|
|
|
|
let isSuper = false
|
2023-02-11 19:51:50 +00:00
|
|
|
|
let talent = this.talent ? lodash.map(this.talent, (ds) => ds.original).join('') : ''
|
|
|
|
|
if (this.cons === 6 || ['ACE', 'ACE²'].includes(this.artis?.markClass) || talent === '101010') {
|
2023-02-12 11:56:47 +00:00
|
|
|
|
isSuper = true
|
|
|
|
|
}
|
|
|
|
|
if (isSuper) {
|
|
|
|
|
return CharImg.getRandomImg(
|
|
|
|
|
[`profile/super-character/${this.name}`, `profile/normal-character/${this.name}`],
|
|
|
|
|
[`${nPath}/imgs/splash0.webp`, `${nPath}/imgs/splash${costume}.webp`, `/${nPath}/imgs/splash.webp`]
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return CharImg.getRandomImg(
|
|
|
|
|
[`profile/normal-character/${this.name}`],
|
|
|
|
|
[`${nPath}/imgs/splash${costume}.webp`, `/${nPath}/imgs/splash.webp`]
|
|
|
|
|
)
|
2023-02-11 19:51:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get hasDmg () {
|
2023-05-21 18:13:38 +00:00
|
|
|
|
return this.hasData && !!ProfileDmg.dmgRulePath(this.name, this.game)
|
2023-02-09 16:57:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-16 05:04:43 +00:00
|
|
|
|
static create (ds, game = 'gs') {
|
|
|
|
|
let profile = new ProfileData(ds, game)
|
2022-11-24 16:31:36 +00:00
|
|
|
|
if (!profile) {
|
|
|
|
|
return false
|
2022-11-22 20:25:36 +00:00
|
|
|
|
}
|
2022-11-24 16:31:36 +00:00
|
|
|
|
return profile
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 19:51:50 +00:00
|
|
|
|
initArtis () {
|
2023-05-16 05:04:43 +00:00
|
|
|
|
this.artis = new ProfileArtis(this.id, this.elem, this.game)
|
2023-02-11 19:51:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-09 16:57:25 +00:00
|
|
|
|
setAttr (ds) {
|
|
|
|
|
this.attr = lodash.extend(Data.getData(ds, 'atk,atkBase,def,defBase,hp,hpBase,mastery,recharge'), {
|
|
|
|
|
heal: ds.heal || ds.hInc || 0,
|
|
|
|
|
cpct: ds.cpct || ds.cRate,
|
|
|
|
|
cdmg: ds.cdmg || ds.cDmg,
|
|
|
|
|
dmg: ds.dmg || ds.dmgBonus || 0,
|
|
|
|
|
phy: ds.phy || ds.phyBonus || 0
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-26 08:12:32 +00:00
|
|
|
|
calcAttr () {
|
2023-05-16 19:15:00 +00:00
|
|
|
|
this._attr = AttrCalc.create(this)
|
2022-11-26 08:12:32 +00:00
|
|
|
|
this.attr = this._attr.calc()
|
2023-03-05 07:21:44 +00:00
|
|
|
|
this.base = this._attr.getBase()
|
2022-11-26 08:12:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-18 10:13:42 +00:00
|
|
|
|
setArtis (ds = false) {
|
2023-02-09 16:57:25 +00:00
|
|
|
|
this.artis?.setProfile(this, ds.artis?.artis || ds.artis || ds)
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-18 23:08:16 +00:00
|
|
|
|
// 获取当前profileData的圣遗物评分,withDetail=false仅返回简略信息
|
2022-08-18 10:13:42 +00:00
|
|
|
|
getArtisMark (withDetail = true) {
|
2022-09-08 20:34:32 +00:00
|
|
|
|
if (this.hasData) {
|
2022-09-08 09:38:15 +00:00
|
|
|
|
return this.artis.getMarkDetail(withDetail)
|
|
|
|
|
}
|
|
|
|
|
return {}
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-18 23:08:16 +00:00
|
|
|
|
// 计算当前profileData的伤害信息
|
2022-08-18 10:13:42 +00:00
|
|
|
|
async calcDmg ({ enemyLv = 91, mode = 'profile', dmgIdx = 0 }) {
|
|
|
|
|
if (!this.dmg) {
|
2023-05-21 18:13:38 +00:00
|
|
|
|
let ds = this.getData('id,level,attr,cons,artis:artis.sets,trees')
|
2022-08-22 20:53:31 +00:00
|
|
|
|
ds.talent = lodash.mapValues(this.talent, 'level')
|
|
|
|
|
ds.weapon = Data.getData(this.weapon, 'name,affix')
|
2023-05-21 18:13:38 +00:00
|
|
|
|
this.dmg = new ProfileDmg(ds, this.game)
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
return await this.dmg.calcData({ enemyLv, mode, dmgIdx })
|
|
|
|
|
}
|
|
|
|
|
}
|