2022-11-23 20:26:07 +00:00
|
|
|
/**
|
|
|
|
* 面板圣遗物
|
|
|
|
*/
|
2022-08-18 10:13:42 +00:00
|
|
|
import lodash from 'lodash'
|
2023-02-09 16:57:25 +00:00
|
|
|
import AvatarArtis from './AvatarArtis.js'
|
2022-09-24 12:19:59 +00:00
|
|
|
import { Artifact, ArtifactSet, Character } from './index.js'
|
2023-03-27 19:42:50 +00:00
|
|
|
import { Format } from '../components/index.js'
|
2023-02-13 19:47:22 +00:00
|
|
|
import ArtisMark from './profile/ArtisMark.js'
|
2023-02-13 08:31:23 +00:00
|
|
|
import { attrMap } from '../resources/meta/artifact/index.js'
|
2023-02-13 19:47:22 +00:00
|
|
|
import CharArtis from './profile/CharArtis.js'
|
2022-08-18 10:13:42 +00:00
|
|
|
|
2023-02-09 16:57:25 +00:00
|
|
|
export default class ProfileArtis extends AvatarArtis {
|
2022-11-22 20:25:36 +00:00
|
|
|
constructor (charid = 0, elem = '') {
|
2023-02-09 16:57:25 +00:00
|
|
|
super(charid)
|
2022-11-22 20:25:36 +00:00
|
|
|
this.elem = elem
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 19:28:46 +00:00
|
|
|
setProfile (profile, artis) {
|
|
|
|
this.profile = profile
|
2023-02-09 18:54:51 +00:00
|
|
|
this.elem = profile.elem || profile.char?.elem
|
2022-11-24 15:27:03 +00:00
|
|
|
if (artis) {
|
2023-02-11 07:24:44 +00:00
|
|
|
this.setArtisData(artis, true)
|
2022-11-24 15:27:03 +00:00
|
|
|
}
|
2022-09-06 19:28:46 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
/**
|
|
|
|
* 获取角色配置
|
|
|
|
* @returns {{classTitle: *, weight: *, posMaxMark: {}, mark: {}, attrs: {}}}
|
|
|
|
*/
|
2022-08-18 10:13:42 +00:00
|
|
|
getCharCfg () {
|
|
|
|
let char = Character.get(this.charid)
|
2022-09-10 19:59:45 +00:00
|
|
|
let { attrWeight, title } = CharArtis.getCharArtisCfg(char, this.profile, this)
|
2022-09-14 19:31:10 +00:00
|
|
|
let attrs = {}
|
2022-09-03 21:08:57 +00:00
|
|
|
let baseAttr = char.baseAttr || { hp: 14000, atk: 230, def: 700 }
|
2022-09-14 19:31:10 +00:00
|
|
|
lodash.forEach(attrMap, (attr, key) => {
|
|
|
|
let k = attr.base || ''
|
|
|
|
let weight = attrWeight[k || key]
|
|
|
|
if (!weight || weight * 1 === 0) {
|
|
|
|
return true
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
2022-09-14 19:31:10 +00:00
|
|
|
let ret = {
|
|
|
|
...attr,
|
|
|
|
weight,
|
|
|
|
fixWeight: weight,
|
2023-02-13 08:31:23 +00:00
|
|
|
mark: weight / attr.value
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
2022-09-14 19:31:10 +00:00
|
|
|
if (!k) {
|
2023-02-13 08:31:23 +00:00
|
|
|
ret.mark = weight / attr.value
|
2022-09-14 19:31:10 +00:00
|
|
|
} else {
|
|
|
|
let plus = k === 'atk' ? 520 : 0
|
2023-02-13 08:31:23 +00:00
|
|
|
ret.mark = weight / attrMap[k].value / (baseAttr[k] + plus) * 100
|
2022-09-14 19:31:10 +00:00
|
|
|
ret.fixWeight = weight * attr.value / attrMap[k].value / (baseAttr[k] + plus) * 100
|
|
|
|
}
|
|
|
|
attrs[key] = ret
|
2022-08-18 10:13:42 +00:00
|
|
|
})
|
2022-11-23 20:26:07 +00:00
|
|
|
let posMaxMark = ArtisMark.getMaxMark(attrs)
|
2022-09-16 13:16:51 +00:00
|
|
|
// 返回内容待梳理简化
|
2022-09-06 19:28:46 +00:00
|
|
|
return {
|
2022-09-14 19:31:10 +00:00
|
|
|
attrs,
|
2022-09-06 19:28:46 +00:00
|
|
|
classTitle: title,
|
2022-11-23 20:26:07 +00:00
|
|
|
posMaxMark
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
2022-09-06 19:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getMarkDetail (withDetail = true) {
|
|
|
|
let charCfg = this.getCharCfg()
|
|
|
|
let artis = {}
|
|
|
|
let setCount = {}
|
|
|
|
let totalMark = 0
|
2023-03-27 19:42:50 +00:00
|
|
|
let totalCrit = 0
|
|
|
|
let totalVaild = 0
|
2022-09-06 19:28:46 +00:00
|
|
|
this.forEach((arti, idx) => {
|
2022-11-22 20:25:36 +00:00
|
|
|
let mark = ArtisMark.getMark(charCfg, idx, arti.main, arti.attrs, this.elem)
|
2023-03-27 19:42:50 +00:00
|
|
|
let crit = ArtisMark.getCritMark(charCfg, idx, arti.main, arti.attrs, this.elem)
|
|
|
|
let vaild = ArtisMark.getValidMark(charCfg, idx, arti.main, arti.attrs, this.elem)
|
2022-09-06 19:28:46 +00:00
|
|
|
totalMark += mark
|
2023-03-27 19:42:50 +00:00
|
|
|
totalCrit += crit
|
|
|
|
totalVaild += vaild
|
2022-09-06 19:28:46 +00:00
|
|
|
setCount[arti.set] = (setCount[arti.set] || 0) + 1
|
|
|
|
if (!withDetail) {
|
|
|
|
artis[idx] = {
|
|
|
|
_mark: mark,
|
|
|
|
mark: Format.comma(mark, 1),
|
|
|
|
markClass: ArtisMark.getMarkClass(mark)
|
|
|
|
}
|
|
|
|
} else {
|
2022-09-24 12:19:59 +00:00
|
|
|
let artifact = Artifact.get(arti.name)
|
2022-09-06 19:28:46 +00:00
|
|
|
artis[idx] = {
|
2022-09-24 12:19:59 +00:00
|
|
|
name: artifact.name,
|
|
|
|
set: artifact.setName,
|
|
|
|
img: artifact.img,
|
2022-09-06 19:28:46 +00:00
|
|
|
level: arti.level,
|
|
|
|
_mark: mark,
|
|
|
|
mark: Format.comma(mark, 1),
|
|
|
|
markClass: ArtisMark.getMarkClass(mark),
|
2022-11-23 20:26:07 +00:00
|
|
|
main: ArtisMark.formatArti(arti.main, charCfg.attrs, true, this.elem || ''),
|
|
|
|
attrs: ArtisMark.formatArti(arti.attrs, charCfg.attrs)
|
2022-09-06 19:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let sets = {}
|
|
|
|
let names = []
|
2022-09-24 12:19:59 +00:00
|
|
|
let imgs = []
|
2022-09-06 19:28:46 +00:00
|
|
|
for (let set in setCount) {
|
|
|
|
if (setCount[set] >= 2) {
|
|
|
|
sets[set] = setCount[set] >= 4 ? 4 : 2
|
2022-09-24 12:19:59 +00:00
|
|
|
let artiSet = ArtifactSet.get(set)
|
|
|
|
imgs.push(artiSet.img)
|
|
|
|
names.push(artiSet.name)
|
2022-09-06 19:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.mark = totalMark
|
|
|
|
this.markClass = ArtisMark.getMarkClass(totalMark / 5)
|
|
|
|
let ret = {
|
|
|
|
mark: Format.comma(totalMark, 1),
|
|
|
|
_mark: totalMark,
|
2023-03-27 19:42:50 +00:00
|
|
|
crit: Format.comma(totalCrit, 1),
|
|
|
|
_crit: totalCrit,
|
|
|
|
valid: Format.comma(totalVaild, 1),
|
|
|
|
_valid: totalVaild,
|
2022-09-06 19:28:46 +00:00
|
|
|
markClass: ArtisMark.getMarkClass(totalMark / 5),
|
|
|
|
artis,
|
|
|
|
sets,
|
|
|
|
names,
|
2022-09-24 12:19:59 +00:00
|
|
|
imgs,
|
2022-09-06 19:28:46 +00:00
|
|
|
classTitle: charCfg.classTitle
|
|
|
|
}
|
|
|
|
if (withDetail) {
|
2022-11-24 03:38:23 +00:00
|
|
|
ret.charWeight = lodash.mapValues(charCfg.attrs, ds => ds.weight)
|
2022-09-06 19:28:46 +00:00
|
|
|
}
|
|
|
|
return ret
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
}
|