2022-09-25 13:56:10 +00:00
|
|
|
/*
|
|
|
|
* 圣遗物
|
|
|
|
* */
|
2022-09-24 12:19:59 +00:00
|
|
|
import Base from './Base.js'
|
2023-03-07 17:52:11 +00:00
|
|
|
import { Format } from '#miao'
|
2022-09-24 12:19:59 +00:00
|
|
|
import { ArtifactSet } from './index.js'
|
2023-02-11 19:51:50 +00:00
|
|
|
import { artiMap, attrMap, mainIdMap, attrIdMap } from '../resources/meta/artifact/index.js'
|
2023-05-21 18:13:38 +00:00
|
|
|
import { idMap as idMapSR, artiMap as artiMapSR, metaData as metaDataSR, abbr as abbrSR } from '../resources/meta-sr/artifact/index.js'
|
2023-02-11 19:51:50 +00:00
|
|
|
import lodash from 'lodash'
|
2022-09-24 12:19:59 +00:00
|
|
|
|
|
|
|
class Artifact extends Base {
|
2023-02-11 19:51:50 +00:00
|
|
|
static getAttrs
|
|
|
|
|
2023-05-16 05:04:43 +00:00
|
|
|
constructor (name, game = 'gs') {
|
2022-09-24 12:19:59 +00:00
|
|
|
super()
|
2023-05-16 05:04:43 +00:00
|
|
|
let cache = this._getCache(`arti:${game}:${name}`)
|
2022-09-24 12:19:59 +00:00
|
|
|
if (cache) {
|
|
|
|
return cache
|
|
|
|
}
|
2023-05-16 05:04:43 +00:00
|
|
|
this.game = game
|
|
|
|
let data = (this.isGs ? artiMap : artiMapSR)[name]
|
2022-09-24 12:19:59 +00:00
|
|
|
if (!data) {
|
|
|
|
return false
|
|
|
|
}
|
2023-05-16 05:04:43 +00:00
|
|
|
this.id = data.id || ''
|
|
|
|
this.name = data.name
|
2022-09-24 12:19:59 +00:00
|
|
|
this.meta = data
|
|
|
|
return this._cache()
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
|
2022-09-24 12:19:59 +00:00
|
|
|
get artiSet () {
|
2023-05-16 05:04:43 +00:00
|
|
|
return ArtifactSet.get(this.set, this.game)
|
2022-09-24 12:19:59 +00:00
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
|
2022-09-24 12:19:59 +00:00
|
|
|
get setName () {
|
|
|
|
return this.set
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
|
2023-05-21 18:13:38 +00:00
|
|
|
get abbr () {
|
|
|
|
return (abbrSR && abbrSR[this.name]) || this.name
|
|
|
|
}
|
|
|
|
|
2023-02-11 19:51:50 +00:00
|
|
|
get img () {
|
2023-05-18 20:23:19 +00:00
|
|
|
return this.isGs ? `meta/artifact/imgs/${this.setName}/${this.idx}.webp` : `meta-sr/artifact/${this.setName}/arti-${this.idx}.webp`
|
2023-02-11 19:51:50 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 05:04:43 +00:00
|
|
|
static get (name, game = 'gs') {
|
|
|
|
if (!name) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (game === 'sr') {
|
|
|
|
name = idMapSR[name]?.name || name
|
|
|
|
}
|
|
|
|
if ((game === 'gs' ? artiMap : artiMapSR)[name]) {
|
|
|
|
return new Artifact(name, game)
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
|
|
|
return false
|
2022-09-24 12:19:59 +00:00
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
|
2022-09-24 12:19:59 +00:00
|
|
|
static getSetNameByArti (name) {
|
|
|
|
let arti = Artifact.get(name)
|
|
|
|
if (arti) {
|
|
|
|
return arti.setName
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
2022-09-07 19:48:03 +00:00
|
|
|
|
2022-09-24 12:19:59 +00:00
|
|
|
static getMeta () {
|
2022-08-18 10:13:42 +00:00
|
|
|
return {
|
|
|
|
attrMap
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 19:51:50 +00:00
|
|
|
|
2023-02-12 11:56:47 +00:00
|
|
|
static getMainById (id, level = 20, star = 5) {
|
|
|
|
let key = mainIdMap[id]
|
|
|
|
if (!key) {
|
2023-02-11 19:51:50 +00:00
|
|
|
return false
|
|
|
|
}
|
2023-02-12 11:56:47 +00:00
|
|
|
let attrCfg = attrMap[Format.isElem(key) ? 'dmg' : key]
|
|
|
|
let posEff = ['hpPlus', 'atkPlus', 'defPlus'].includes(key) ? 2 : 1
|
|
|
|
let starEff = { 1: 0.21, 2: 0.36, 3: 0.6, 4: 0.9, 5: 1 }
|
2023-02-11 19:51:50 +00:00
|
|
|
return {
|
2023-02-12 11:56:47 +00:00
|
|
|
key,
|
|
|
|
value: attrCfg.value * (1.2 + 0.34 * level) * posEff * (starEff[star || 5])
|
2023-02-11 19:51:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 11:56:47 +00:00
|
|
|
static getAttrsByIds (ids, star = 5) {
|
2023-02-11 19:51:50 +00:00
|
|
|
let ret = []
|
|
|
|
let tmp = {}
|
|
|
|
lodash.forEach(ids, (id) => {
|
|
|
|
let cfg = attrIdMap[id]
|
|
|
|
if (!cfg) {
|
|
|
|
return true
|
|
|
|
}
|
2023-02-13 08:31:23 +00:00
|
|
|
let { key, value } = cfg
|
2023-02-11 19:51:50 +00:00
|
|
|
if (!tmp[key]) {
|
|
|
|
tmp[key] = {
|
|
|
|
key,
|
2023-02-13 08:31:23 +00:00
|
|
|
upNum: 0,
|
2023-04-13 20:13:17 +00:00
|
|
|
eff: 0,
|
2023-02-13 08:31:23 +00:00
|
|
|
value: 0
|
2023-02-11 19:51:50 +00:00
|
|
|
}
|
|
|
|
ret.push(tmp[key])
|
|
|
|
}
|
2023-02-21 19:49:49 +00:00
|
|
|
tmp[key].value += value * (attrMap[key].format === 'pct' ? 100 : 1)
|
2023-02-11 19:51:50 +00:00
|
|
|
tmp[key].upNum++
|
2023-04-13 20:13:17 +00:00
|
|
|
tmp[key].eff += value / attrMap[key].value * (attrMap[key].format === 'pct' ? 100 : 1)
|
2023-02-11 19:51:50 +00:00
|
|
|
})
|
|
|
|
return ret
|
|
|
|
}
|
2023-05-16 05:04:43 +00:00
|
|
|
|
|
|
|
getStarById (id) {
|
|
|
|
return this.meta.ids[id] || ''
|
|
|
|
}
|
|
|
|
|
2023-05-18 20:23:19 +00:00
|
|
|
getAttrData (mainId, attrData, level = 1, star = 5, idx = 1) {
|
|
|
|
let mainKey = metaDataSR.mainIdx[idx][mainId]
|
2023-05-16 05:04:43 +00:00
|
|
|
let starCfg = metaDataSR.starData[star]
|
2023-05-18 20:23:19 +00:00
|
|
|
let mainCfg = starCfg.main[mainKey]
|
2023-05-16 05:04:43 +00:00
|
|
|
if (!mainId || !mainCfg) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let main = {
|
|
|
|
id: mainId,
|
2023-05-18 20:23:19 +00:00
|
|
|
key: mainKey,
|
2023-05-16 05:04:43 +00:00
|
|
|
value: mainCfg.base + mainCfg.step * level
|
|
|
|
}
|
|
|
|
let attrs = []
|
|
|
|
lodash.forEach(attrData, (ds) => {
|
2023-05-19 18:50:39 +00:00
|
|
|
let _ds = ds
|
|
|
|
if (lodash.isString(ds)) {
|
|
|
|
let [id, count, step] = ds.split(',')
|
|
|
|
ds = { id, count, step }
|
|
|
|
}
|
2023-05-16 05:04:43 +00:00
|
|
|
let attrCfg = starCfg.sub[ds.id]
|
2023-05-19 18:50:39 +00:00
|
|
|
if (!attrCfg) {
|
|
|
|
console.log('not found attr', ds, _ds)
|
|
|
|
return true
|
|
|
|
}
|
2023-05-16 05:04:43 +00:00
|
|
|
attrs.push({
|
|
|
|
...ds,
|
2023-05-19 18:50:39 +00:00
|
|
|
key: attrCfg?.key,
|
|
|
|
value: attrCfg?.base * ds.count + attrCfg.step * ds.step
|
2023-05-16 05:04:43 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
return {
|
|
|
|
main,
|
|
|
|
attrs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
2022-09-24 12:19:59 +00:00
|
|
|
|
2022-08-18 10:13:42 +00:00
|
|
|
export default Artifact
|