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-05-29 19:42:13 +00:00
|
|
|
import { attrMap as attrMapGS } from '../resources/meta/artifact/index.js'
|
|
|
|
import { attrMap as attrMapSR } from '../resources/meta-sr/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 {
|
2023-05-16 05:04:43 +00:00
|
|
|
constructor (charid = 0, elem = '', game = 'gs') {
|
|
|
|
super(charid, game)
|
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)
|
2023-05-29 19:42:13 +00:00
|
|
|
let { game, isGs } = char
|
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 }
|
2023-05-29 19:42:13 +00:00
|
|
|
let attrMap = isGs ? attrMapGS : attrMapSR
|
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
|
|
|
})
|
2023-05-29 19:42:13 +00:00
|
|
|
let posMaxMark = ArtisMark.getMaxMark(attrs, game)
|
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-05-21 00:57:31 +00:00
|
|
|
let self = this
|
2022-09-06 19:28:46 +00:00
|
|
|
this.forEach((arti, idx) => {
|
2023-05-21 00:57:31 +00:00
|
|
|
let mark = ArtisMark.getMark({
|
|
|
|
charCfg,
|
|
|
|
idx,
|
|
|
|
arti,
|
|
|
|
elem: this.elem,
|
|
|
|
game: self.game
|
|
|
|
})
|
2022-09-06 19:28:46 +00:00
|
|
|
totalMark += mark
|
|
|
|
setCount[arti.set] = (setCount[arti.set] || 0) + 1
|
|
|
|
if (!withDetail) {
|
|
|
|
artis[idx] = {
|
|
|
|
_mark: mark,
|
|
|
|
mark: Format.comma(mark, 1),
|
|
|
|
markClass: ArtisMark.getMarkClass(mark)
|
|
|
|
}
|
|
|
|
} else {
|
2023-05-18 20:23:19 +00:00
|
|
|
let artifact = Artifact.get(arti.name, this.game)
|
2022-09-06 19:28:46 +00:00
|
|
|
artis[idx] = {
|
2022-09-24 12:19:59 +00:00
|
|
|
name: artifact.name,
|
2023-05-21 18:13:38 +00:00
|
|
|
abbr: artifact.abbr,
|
2022-09-24 12:19:59 +00:00
|
|
|
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),
|
2023-05-16 19:15:00 +00:00
|
|
|
main: ArtisMark.formatArti(arti.main, charCfg.attrs, true, this.game),
|
|
|
|
attrs: ArtisMark.formatArti(arti.attrs, charCfg.attrs, false, this.game)
|
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,
|
|
|
|
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
|
|
|
}
|