2022-11-23 20:26:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* 面板圣遗物
|
|
|
|
|
*/
|
2022-08-18 10:13:42 +00:00
|
|
|
|
import lodash from 'lodash'
|
|
|
|
|
import Base from './Base.js'
|
2022-09-24 12:19:59 +00:00
|
|
|
|
import { Artifact, ArtifactSet, Character } from './index.js'
|
2022-09-10 19:59:45 +00:00
|
|
|
|
import { Format, Data } from '../components/index.js'
|
2022-08-18 10:13:42 +00:00
|
|
|
|
import ArtisMark from './profile-lib/ArtisMark.js'
|
2022-11-24 08:25:04 +00:00
|
|
|
|
import { attrMap, attrValue } from '../resources/meta/artifact/index.js'
|
2022-09-10 19:59:45 +00:00
|
|
|
|
import CharArtis from './profile-lib/CharArtis.js'
|
2022-08-18 10:13:42 +00:00
|
|
|
|
|
|
|
|
|
export default class ProfileArtis extends Base {
|
2022-11-22 20:25:36 +00:00
|
|
|
|
constructor (charid = 0, elem = '') {
|
2022-08-18 10:13:42 +00:00
|
|
|
|
super()
|
|
|
|
|
this.charid = charid
|
2022-11-22 20:25:36 +00:00
|
|
|
|
this.elem = elem
|
2022-08-18 10:13:42 +00:00
|
|
|
|
this.artis = {}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 19:28:46 +00:00
|
|
|
|
setProfile (profile, artis) {
|
|
|
|
|
this.profile = profile
|
|
|
|
|
this.setArtisSet(artis)
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-18 10:13:42 +00:00
|
|
|
|
setArtisSet (ds) {
|
|
|
|
|
for (let key in ds) {
|
|
|
|
|
this.setArtis(key, ds[key] || {})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setArtis (idx = 1, ds = {}) {
|
|
|
|
|
idx = idx.toString().replace('arti', '')
|
|
|
|
|
let ret = {}
|
2022-09-24 12:19:59 +00:00
|
|
|
|
ret.name = ds.name || ArtifactSet.getArtiNameBySet(ds.set, idx) || ''
|
2022-11-03 19:29:57 +00:00
|
|
|
|
ret.set = ds.set || Artifact.getSetNameByArti(ret.name) || ''
|
2022-08-18 10:13:42 +00:00
|
|
|
|
ret.level = ds.level || 1
|
|
|
|
|
ret.main = ArtisMark.formatAttr(ds.main || {})
|
|
|
|
|
ret.attrs = []
|
|
|
|
|
for (let attrIdx in ds.attrs || []) {
|
|
|
|
|
if (ds.attrs[attrIdx]) {
|
|
|
|
|
ret.attrs.push(ArtisMark.formatAttr(ds.attrs[attrIdx]))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.artis[idx] = ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
forEach (fn) {
|
|
|
|
|
lodash.forEach(this.artis, (ds, idx) => {
|
|
|
|
|
if (ds.name) {
|
|
|
|
|
fn(ds, idx)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-08 20:34:32 +00:00
|
|
|
|
_get (key) {
|
|
|
|
|
let artis = this.artis
|
|
|
|
|
switch (key) {
|
|
|
|
|
case 'length':
|
2022-09-11 01:21:01 +00:00
|
|
|
|
return lodash.keys(artis).length
|
2022-09-08 20:34:32 +00:00
|
|
|
|
}
|
|
|
|
|
if (artis[key]) {
|
|
|
|
|
return artis[key]
|
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toJSON () {
|
|
|
|
|
return this.getData('1,2,3,4,5')
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 19:28:46 +00:00
|
|
|
|
get sets () {
|
2022-09-16 22:13:32 +00:00
|
|
|
|
return this.getSetData().sets || {}
|
2022-09-06 19:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get names () {
|
2022-09-16 22:13:32 +00:00
|
|
|
|
return this.getSetData().names || []
|
2022-09-06 19:28:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-10 19:59:45 +00:00
|
|
|
|
mainAttr (idx = '') {
|
|
|
|
|
if (!idx) {
|
|
|
|
|
let ret = {}
|
|
|
|
|
for (let i = 1; i <= 5; i++) {
|
|
|
|
|
ret[i] = this.mainAttr(i)
|
|
|
|
|
}
|
|
|
|
|
return ret
|
|
|
|
|
}
|
2022-09-06 19:28:46 +00:00
|
|
|
|
let main = this.artis[idx]?.main
|
|
|
|
|
if (!main) {
|
|
|
|
|
return ''
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
2022-11-23 20:26:07 +00:00
|
|
|
|
return ArtisMark.getKeyByTitle(main.key, true) || ''
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-10 19:59:45 +00:00
|
|
|
|
is (check, pos = '') {
|
|
|
|
|
if (pos) {
|
|
|
|
|
return this.isAttr(check, pos)
|
|
|
|
|
}
|
|
|
|
|
let sets = this.getSetData()?.abbrs || []
|
|
|
|
|
let ret = false
|
|
|
|
|
Data.eachStr(check, (s) => {
|
|
|
|
|
if (sets.includes(s)) {
|
|
|
|
|
ret = true
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isAttr (attr, pos = '3,4,5') {
|
|
|
|
|
let mainAttr = this.mainAttr()
|
|
|
|
|
let check = true
|
2022-09-21 21:26:19 +00:00
|
|
|
|
Data.eachStr(pos.toString(), (p) => {
|
2022-09-10 19:59:45 +00:00
|
|
|
|
if (!attr.split(',').includes(mainAttr[p])) {
|
|
|
|
|
check = false
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return check
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
|
// 获取圣遗物数据
|
2022-09-24 12:19:59 +00:00
|
|
|
|
getArtisData () {
|
|
|
|
|
let ret = {}
|
|
|
|
|
this.forEach((ds, idx) => {
|
|
|
|
|
let arti = Artifact.get(ds.name)
|
|
|
|
|
ret[idx] = {
|
|
|
|
|
...ds,
|
|
|
|
|
name: arti.name,
|
|
|
|
|
img: arti.img
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return ret
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* 获取圣遗物套装数据
|
|
|
|
|
* @returns {*|{imgs: *[], names: *[], sets: {}, abbrs: *[], sName: string, name: (string|*)}}
|
|
|
|
|
* sets: 套装名:2/4
|
|
|
|
|
* names: [套装名]
|
|
|
|
|
* imgs: [img]
|
|
|
|
|
* abbrs:[别名]
|
|
|
|
|
* name: '组合名字', 若为4件套会使用套装完整名
|
|
|
|
|
* sName: '简写名字',若为4件套也会使用简写
|
|
|
|
|
*/
|
2022-08-22 20:53:31 +00:00
|
|
|
|
getSetData () {
|
2022-09-10 19:59:45 +00:00
|
|
|
|
if (this._setData) {
|
|
|
|
|
return this._setData
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
let setCount = {}
|
|
|
|
|
this.forEach((arti, idx) => {
|
|
|
|
|
setCount[arti.set] = (setCount[arti.set] || 0) + 1
|
|
|
|
|
})
|
|
|
|
|
let sets = {}
|
|
|
|
|
let names = []
|
2022-09-24 12:19:59 +00:00
|
|
|
|
let imgs = []
|
2022-09-10 19:59:45 +00:00
|
|
|
|
let abbrs = []
|
2022-09-19 19:16:00 +00:00
|
|
|
|
let abbrs2 = []
|
2022-08-22 20:53:31 +00:00
|
|
|
|
for (let set in setCount) {
|
|
|
|
|
if (setCount[set] >= 2) {
|
2022-09-24 12:19:59 +00:00
|
|
|
|
let count = setCount[set] >= 4 ? 4 : 2
|
|
|
|
|
sets[set] = count
|
|
|
|
|
let artiSet = ArtifactSet.get(set)
|
|
|
|
|
names.push(artiSet.name)
|
|
|
|
|
imgs.push(artiSet.img)
|
|
|
|
|
abbrs.push(artiSet.abbr + count)
|
|
|
|
|
abbrs2.push(artiSet.name + count)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-19 19:16:00 +00:00
|
|
|
|
this._setData = {
|
|
|
|
|
sets,
|
|
|
|
|
names,
|
2022-09-24 12:19:59 +00:00
|
|
|
|
imgs,
|
2022-09-19 19:16:00 +00:00
|
|
|
|
abbrs: [...abbrs, ...abbrs2],
|
2022-11-12 15:01:24 +00:00
|
|
|
|
name: (abbrs.length > 1 || abbrs2[0]?.length > 7) ? abbrs.join('+') : abbrs2[0],
|
2022-11-12 13:29:53 +00:00
|
|
|
|
sName: abbrs.join('+')
|
2022-09-19 19:16:00 +00:00
|
|
|
|
}
|
2022-09-10 19:59:45 +00:00
|
|
|
|
return this._setData
|
2022-08-22 20:53:31 +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,
|
|
|
|
|
mark: weight / attrValue[key]
|
2022-08-18 10:13:42 +00:00
|
|
|
|
}
|
2022-09-14 19:31:10 +00:00
|
|
|
|
if (!k) {
|
|
|
|
|
ret.mark = weight / attrValue[key]
|
|
|
|
|
} else {
|
|
|
|
|
let plus = k === 'atk' ? 520 : 0
|
|
|
|
|
ret.mark = weight / attrValue[k] / (baseAttr[k] + plus) * 100
|
|
|
|
|
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
|
|
|
|
|
this.forEach((arti, idx) => {
|
2022-11-22 20:25:36 +00:00
|
|
|
|
let mark = ArtisMark.getMark(charCfg, idx, arti.main, arti.attrs, this.elem)
|
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 {
|
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,
|
|
|
|
|
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-11-21 21:26:06 +00:00
|
|
|
|
|
|
|
|
|
static _eachArtisSet (sets, fn) {
|
|
|
|
|
lodash.forEach(sets || [], (v, k) => {
|
|
|
|
|
let artisSet = ArtifactSet.get(k)
|
|
|
|
|
if (artisSet) {
|
|
|
|
|
if (v >= 4) {
|
|
|
|
|
fn(artisSet, 2)
|
|
|
|
|
}
|
|
|
|
|
fn(artisSet, v)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eachArtisSet (fn) {
|
|
|
|
|
ProfileArtis._eachArtisSet(this.sets, fn)
|
|
|
|
|
}
|
2022-11-23 20:26:07 +00:00
|
|
|
|
|
|
|
|
|
static getArtisKeyTitle () {
|
|
|
|
|
return ArtisMark.getKeyTitleMap()
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|