2022-09-04 21:03:23 +00:00
|
|
|
import Base from './Base.js'
|
|
|
|
import { Data } from '../components/index.js'
|
2022-11-22 20:25:36 +00:00
|
|
|
import { data as weaponData, abbr } from '../resources/meta/weapon/index.js'
|
2022-09-04 21:03:23 +00:00
|
|
|
|
|
|
|
class Weapon extends Base {
|
|
|
|
constructor (name) {
|
|
|
|
super(name)
|
2022-11-22 20:25:36 +00:00
|
|
|
let meta = weaponData[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
|
|
|
|
}
|
|
|
|
|
2022-11-20 20:45:27 +00:00
|
|
|
get detail () {
|
|
|
|
return this.getDetail()
|
|
|
|
}
|
|
|
|
|
|
|
|
getDetail () {
|
|
|
|
if (this._detail) {
|
|
|
|
return this._detail
|
|
|
|
}
|
|
|
|
const path = 'resources/meta/weapon'
|
|
|
|
try {
|
|
|
|
this._detail = Data.readJSON(`${path}/${this.type}/${this.name}/data.json`)
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e)
|
|
|
|
}
|
|
|
|
return this._detail
|
|
|
|
}
|
|
|
|
|
|
|
|
static get (name) {
|
2022-11-22 20:25:36 +00:00
|
|
|
if (weaponData[name]) {
|
2022-11-20 20:45:27 +00:00
|
|
|
return new Weapon(name)
|
|
|
|
}
|
|
|
|
return false
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Weapon
|