2022-09-04 21:03:23 +00:00
|
|
|
import Base from './Base.js'
|
|
|
|
import { Data } from '../components/index.js'
|
|
|
|
|
2022-09-24 12:19:59 +00:00
|
|
|
let data = {}
|
|
|
|
let abbr = {}
|
2022-09-04 21:03:23 +00:00
|
|
|
|
|
|
|
class Weapon extends Base {
|
|
|
|
constructor (name) {
|
|
|
|
super(name)
|
2022-09-24 12:19:59 +00:00
|
|
|
let meta = data[name]
|
2022-09-04 21:03:23 +00:00
|
|
|
if (!meta) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let cache = this._getCache(`weapon:${name}`)
|
|
|
|
if (cache) {
|
|
|
|
return cache
|
|
|
|
}
|
|
|
|
this.name = meta.name
|
|
|
|
this.meta = meta
|
|
|
|
this.type = meta.type
|
|
|
|
this.star = meta.star
|
2022-09-08 20:34:32 +00:00
|
|
|
return this._cache()
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get abbr () {
|
2022-09-23 22:57:42 +00:00
|
|
|
return abbr[this.name] || this.name
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get title () {
|
|
|
|
return this.name
|
|
|
|
}
|
|
|
|
|
|
|
|
get img () {
|
2022-09-24 12:19:59 +00:00
|
|
|
return `meta/weapon/${this.type}/${this.name}/icon.webp`
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get icon () {
|
|
|
|
return this.img
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Weapon.get = function (name) {
|
2022-09-24 12:19:59 +00:00
|
|
|
if (data[name]) {
|
2022-09-04 21:03:23 +00:00
|
|
|
return new Weapon(name)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Weapon
|
2022-09-24 12:19:59 +00:00
|
|
|
|
|
|
|
// lazy load
|
|
|
|
setTimeout(async function init () {
|
|
|
|
let ret = await Data.importModule('resources/meta/weapon/index.js')
|
|
|
|
data = ret.data
|
|
|
|
abbr = ret.abbr
|
|
|
|
})
|