2022-09-04 21:03:23 +00:00
|
|
|
import lodash from 'lodash'
|
|
|
|
import Base from './Base.js'
|
|
|
|
import { Data } from '../components/index.js'
|
2022-09-05 17:05:06 +00:00
|
|
|
import WeaponMeta from './weapon/WeaponMeta.js'
|
2022-09-04 21:03:23 +00:00
|
|
|
|
|
|
|
let data = Data.readJSON('resources/meta/weapons/data.json')
|
|
|
|
let wData = {}
|
|
|
|
lodash.forEach(data, (ds) => {
|
|
|
|
wData[ds.name] = ds
|
|
|
|
})
|
|
|
|
|
|
|
|
class Weapon extends Base {
|
|
|
|
constructor (name) {
|
|
|
|
super(name)
|
|
|
|
let meta = wData[name]
|
|
|
|
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-05 17:05:06 +00:00
|
|
|
return WeaponMeta.getAbbr(this.name)
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get title () {
|
|
|
|
return this.name
|
|
|
|
}
|
|
|
|
|
|
|
|
get img () {
|
2022-09-05 17:05:06 +00:00
|
|
|
return `meta/weapons/icon/${this.name}.png`
|
2022-09-04 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get icon () {
|
|
|
|
return this.img
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Weapon.get = function (name) {
|
|
|
|
if (wData[name]) {
|
|
|
|
return new Weapon(name)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Weapon
|