miao-plugin/models/Artifact.js

59 lines
973 B
JavaScript
Raw Normal View History

/*
* 圣遗物
* */
import Base from './Base.js'
import { ArtifactSet } from './index.js'
import { artiMap, attrMap } from '../resources/meta/artifact/index.js'
class Artifact extends Base {
constructor (name) {
super()
let cache = this._getCache(`arti:${name}`)
if (cache) {
return cache
}
let data = artiMap[name]
if (!data) {
return false
}
this.name = name
this.meta = data
return this._cache()
}
2022-08-18 10:13:42 +00:00
get artiSet () {
return ArtifactSet.get(this.set)
}
2022-08-18 10:13:42 +00:00
get setName () {
return this.set
}
2022-08-18 10:13:42 +00:00
static get (name) {
if (artiMap[name]) {
return new Artifact(name)
2022-08-18 10:13:42 +00:00
}
return false
}
2022-08-18 10:13:42 +00:00
get img () {
return `meta/artifact/${this.setName}/${this.idx}.webp`
}
2022-08-18 10:13:42 +00:00
static getSetNameByArti (name) {
let arti = Artifact.get(name)
if (arti) {
return arti.setName
}
return ''
}
2022-09-07 19:48:03 +00:00
static getMeta () {
2022-08-18 10:13:42 +00:00
return {
attrMap
}
}
}
2022-08-18 10:13:42 +00:00
export default Artifact