计算宝箱总数

This commit is contained in:
小花花花儿 2024-01-25 12:31:37 +08:00
parent 12e280b38c
commit a5cb607c98
2 changed files with 34 additions and 32 deletions

View File

@ -7,9 +7,6 @@ avatar: 77
# 等级 # 等级
level: 60 level: 60
# 总宝箱
all_chest: 6044
# 奇馈宝箱 # 奇馈宝箱
magic_chest: 221 magic_chest: 221

View File

@ -10,7 +10,7 @@ let dsz = '待实装'
let imgFile = {} let imgFile = {}
export default class RoleIndex extends base { export default class RoleIndex extends base {
constructor (e) { constructor(e) {
super(e) super(e)
this.model = 'roleIndex' this.model = 'roleIndex'
this.other = gsCfg.getdefSet('role', 'other') this.other = gsCfg.getdefSet('role', 'other')
@ -29,17 +29,22 @@ export default class RoleIndex extends base {
枫丹: 9 枫丹: 9
} }
this.all_chest = 0
lodash.forEach(this.lable, (v, i) => {
if (i.includes('_chest')) this.all_chest += v
})
this.areaName = lodash.invert(this.area) this.areaName = lodash.invert(this.area)
this.headIndexStyle = `<style> .head_box { background: url(${this.screenData.pluResPath}img/roleIndex/namecard/${lodash.random(1, 8)}.png) #f5f5f5; background-position-x: 30px; background-repeat: no-repeat; border-radius: 15px; font-family: tttgbnumber; padding: 10px 20px; position: relative; background-size: auto 101%; }</style>` this.headIndexStyle = `<style> .head_box { background: url(${this.screenData.pluResPath}img/roleIndex/namecard/${lodash.random(1, 8)}.png) #f5f5f5; background-position-x: 30px; background-repeat: no-repeat; border-radius: 15px; font-family: tttgbnumber; padding: 10px 20px; position: relative; background-size: auto 101%; }</style>`
} }
static async get (e) { static async get(e) {
let roleIndex = new RoleIndex(e) let roleIndex = new RoleIndex(e)
return await roleIndex.getIndex() return await roleIndex.getIndex()
} }
async getIndex () { async getIndex() {
let ApiData = { let ApiData = {
index: '', index: '',
spiralAbyss: { schedule_type: 1 }, spiralAbyss: { schedule_type: 1 },
@ -63,7 +68,7 @@ export default class RoleIndex extends base {
return data return data
} }
dealData (data) { dealData(data) {
let [resIndex, resAbyss, resDetail, basicInfo] = data let [resIndex, resAbyss, resDetail, basicInfo] = data
let avatars = resDetail.avatars || [] let avatars = resDetail.avatars || []
@ -121,7 +126,7 @@ export default class RoleIndex extends base {
stats.exquisite_chest_number + stats.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number) / stats.magic_chest_number) /
this.lable.all_chest) * this.all_chest) *
100, 100,
1 1
) )
@ -150,7 +155,7 @@ export default class RoleIndex extends base {
stats.exquisite_chest_number + stats.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number, stats.magic_chest_number,
extra: this.lable.all_chest extra: this.all_chest
}, },
{ {
@ -240,7 +245,7 @@ export default class RoleIndex extends base {
} }
// 处理深渊数据 // 处理深渊数据
abyssAll (roleArr, resAbyss) { abyssAll(roleArr, resAbyss) {
let abyss = {} let abyss = {}
if (roleArr.length <= 0) { if (roleArr.length <= 0) {
@ -327,14 +332,14 @@ export default class RoleIndex extends base {
} }
} }
dayCount (num) { dayCount(num) {
let daysDifference = Math.floor((new Date() - new Date('2020-09-15')) / (1000 * 60 * 60 * 24)) + 1 let daysDifference = Math.floor((new Date() - new Date('2020-09-15')) / (1000 * 60 * 60 * 24)) + 1
let days = Math.floor(num) let days = Math.floor(num)
let msg = '活跃天数:' + days + `/${daysDifference}` let msg = '活跃天数:' + days + `/${daysDifference}`
return msg return msg
} }
async roleCard () { async roleCard() {
this.model = 'roleCard' this.model = 'roleCard'
let res = await MysInfo.get(this.e, 'index') let res = await MysInfo.get(this.e, 'index')
@ -343,7 +348,7 @@ export default class RoleIndex extends base {
return this.roleCardData(res.data) return this.roleCardData(res.data)
} }
roleCardData (res) { roleCardData(res) {
this.initFile() this.initFile()
let stats = res.stats let stats = res.stats
@ -430,7 +435,7 @@ export default class RoleIndex extends base {
} }
} }
async roleExplore () { async roleExplore() {
this.model = 'roleExplore' this.model = 'roleExplore'
let ApiData = { let ApiData = {
index: '', index: '',
@ -446,7 +451,7 @@ export default class RoleIndex extends base {
return this.roleExploreData(ret) return this.roleExploreData(ret)
} }
async roleExploreData (res) { async roleExploreData(res) {
let [resIndex, basicInfo] = res let [resIndex, basicInfo] = res
let stats = resIndex.stats let stats = resIndex.stats
@ -457,7 +462,7 @@ export default class RoleIndex extends base {
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number) * stats.magic_chest_number) *
100) / 100) /
this.lable.all_chest, this.all_chest,
2 2
) )
@ -492,7 +497,7 @@ export default class RoleIndex extends base {
stats.exquisite_chest_number + stats.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number, stats.magic_chest_number,
extra: this.lable.all_chest extra: this.all_chest
}, },
{ {
lable: '宝箱获取率', lable: '宝箱获取率',
@ -621,7 +626,7 @@ export default class RoleIndex extends base {
} }
} }
initFile () { initFile() {
if (imgFile['刻晴']) return imgFile if (imgFile['刻晴']) return imgFile
let path = './plugins/genshin/resources/img/gacha/' let path = './plugins/genshin/resources/img/gacha/'
let character = fs.readdirSync(path + 'character/') let character = fs.readdirSync(path + 'character/')