🐞 fix: *抽卡记录显示 (#300)

* 🐞 fix: *抽卡记录显示

* 🐞 fix: 参数穿透
This commit is contained in:
story-x 2023-10-31 03:34:38 +08:00 committed by GitHub
parent 084791bae2
commit 9326da0003
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 35 deletions

View File

@ -58,7 +58,7 @@ export default class GachaLog extends base {
if (i <= 1) await common.sleep(500) if (i <= 1) await common.sleep(500)
} }
MakeMsg.push(tmpMsg) MakeMsg.push(tmpMsg)
MakeMsg.push(`\n抽卡记录更新完成,您还可回复\n${this?.e?.isSr ? '*' : '#'}全部记录】统计全部抽卡数据\n${this?.e?.isSr ? '*光锥' : '#武器'}记录】统计${this?.e?.isSr ? '星铁光锥' : '武器'}池数据\n${this?.e?.isSr ? '*' : '#'}角色统计】按卡池统计数据\n${this?.e?.isSr ? '' : '#导出记录】导出记录数据'}`) MakeMsg.push(`\n抽卡记录更新完成,您还可回复\n${this?.e?.isSr ? '*' : '#'}全部记录】统计全部抽卡数据\n${this?.e?.isSr ? '*光锥' : '#武器'}记录】统计${this?.e?.isSr ? '星铁光锥' : '武器'}池数据\n${this?.e?.isSr ? '*' : '#'}角色统计】按卡池统计数据\n${this?.e?.isSr ? '*' : '#'}导出记录】导出记录数据`)
await this.e.reply(MakeMsg) await this.e.reply(MakeMsg)
this.isLogUrl = true this.isLogUrl = true
@ -428,11 +428,13 @@ export default class GachaLog extends base {
async getGcLogData () { async getGcLogData () {
/** 卡池 */ /** 卡池 */
this.getPool() const { type, typeName } = this.getPool()
/** 更新记录 */ /** 更新记录 */
if (!this.isLogUrl) await this.updateLog() if (!this.isLogUrl) await this.updateLog()
/** 统计计算记录 */ /** 统计计算记录 */
let data = this.analyse() let data = this.analyse()
data.type = type
data.typeName = typeName
/** 渲染数据 */ /** 渲染数据 */
data = this.randData(data) data = this.randData(data)
return data return data
@ -440,33 +442,36 @@ export default class GachaLog extends base {
getPool () { getPool () {
let msg = this.e.msg.replace(/#|抽卡|记录|祈愿|分析|池|原神|星铁|崩坏星穹铁道|铁道/g, '') let msg = this.e.msg.replace(/#|抽卡|记录|祈愿|分析|池|原神|星铁|崩坏星穹铁道|铁道/g, '')
this.type = this.e.isSr ? 11 : 301 let type = this.e.isSr ? 11 : 301
this.typeName = '角色' let typeName = '角色'
switch (msg) { switch (msg) {
case 'up': case 'up':
case '抽卡': case '抽卡':
case '角色': case '角色':
case '抽奖': case '抽奖':
this.type = this.e.isSr ? 11 : 301 type = this.e.isSr ? 11 : 301
this.typeName = '角色' typeName = '角色'
break break
case '常驻': case '常驻':
this.type = this.e.isSr ? 1 : 200 type = this.e.isSr ? 1 : 200
this.typeName = '常驻' typeName = '常驻'
break break
case '武器': case '武器':
this.type = this.e.isSr ? 12 : 302 type = this.e.isSr ? 12 : 302
this.typeName = this.e.isSr ? '光锥' : '武器' typeName = this.e.isSr ? '光锥' : '武器'
break break
case '光锥': case '光锥':
this.type = 12 type = 12
this.typeName = '光锥' typeName = '光锥'
break break
case '新手': case '新手':
this.type = this.e.isSr ? 2 : 100 type = this.e.isSr ? 2 : 100
this.typeName = '新手' typeName = '新手'
break break
} }
this.type = type
this.typeName = typeName
return { type, typeName }
} }
async getUid () { async getUid () {
@ -717,10 +722,12 @@ export default class GachaLog extends base {
/** 渲染数据 */ /** 渲染数据 */
randData (data) { randData (data) {
const max = this.type === 12 || this.type === 302 ? 80 : 90 const type = data.type || this.type
const typeName = data.typeName || this.typeName
const max = type === 12 || type === 302 ? 80 : 90
let line = [] let line = []
let weapon = this.e.isSr ? '光锥' : '武器' let weapon = this.e.isSr ? '光锥' : '武器'
if ([301, 11].includes(this.type)) { if ([301, 11].includes(type)) {
line = [[ line = [[
{ lable: '未出五星', num: data.noFiveNum, unit: '抽' }, { lable: '未出五星', num: data.noFiveNum, unit: '抽' },
{ lable: '五星', num: data.fiveNum, unit: '个' }, { lable: '五星', num: data.fiveNum, unit: '个' },
@ -734,7 +741,7 @@ export default class GachaLog extends base {
]] ]]
} }
// 常驻池 // 常驻池
if ([200, 1].includes(this.type)) { if ([200, 1].includes(type)) {
line = [[ line = [[
{ lable: '未出五星', num: data.noFiveNum, unit: '抽' }, { lable: '未出五星', num: data.noFiveNum, unit: '抽' },
{ lable: '五星', num: data.fiveNum, unit: '个' }, { lable: '五星', num: data.fiveNum, unit: '个' },
@ -748,7 +755,7 @@ export default class GachaLog extends base {
]] ]]
} }
// 武器池 // 武器池
if ([302, 12].includes(this.type)) { if ([302, 12].includes(type)) {
line = [[ line = [[
{ lable: '未出五星', num: data.noFiveNum, unit: '抽' }, { lable: '未出五星', num: data.noFiveNum, unit: '抽' },
{ lable: '五星', num: data.fiveNum, unit: '个' }, { lable: '五星', num: data.fiveNum, unit: '个' },
@ -762,7 +769,7 @@ export default class GachaLog extends base {
]] ]]
} }
// 新手池 // 新手池
if ([100, 2].includes(this.type)) { if ([100, 2].includes(type)) {
line = [[ line = [[
{ lable: '未出五星', num: data.noFiveNum, unit: '抽' }, { lable: '未出五星', num: data.noFiveNum, unit: '抽' },
{ lable: '五星', num: data.fiveNum, unit: '个' }, { lable: '五星', num: data.fiveNum, unit: '个' },
@ -776,17 +783,17 @@ export default class GachaLog extends base {
]] ]]
} }
let hasMore = false let hasMore = false
if (this.e.isGroup && data.fiveLog.length > 48) { // if (this.e.isGroup && data.fiveLog.length > 48) {
data.fiveLog = data.fiveLog.slice(0, 48) // data.fiveLog = data.fiveLog.slice(0, 48)
hasMore = true // hasMore = true
} // }
return { return {
...this.screenData, ...this.screenData,
saveId: this.uid, saveId: this.uid,
uid: this.uid, uid: this.uid,
type: this.type, type,
typeName: this.typeName, typeName,
allNum: data.allNum, allNum: data.allNum,
firstTime: data.firstTime, firstTime: data.firstTime,
lastTime: data.lastTime, lastTime: data.lastTime,

View File

@ -45,7 +45,7 @@
<div class="card_list"> <div class="card_list">
{{each fiveLog val}} {{each fiveLog val}}
<div class="item star5 {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (num<max*0.83) ? 'normal': 'bad')}}"> <div class="item star5 {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (val.num<max*0.83) ? 'normal': 'bad')}}">
{{ if val.isUp && typeName == '角色' }} {{ if val.isUp && typeName == '角色' }}
<span class="minimum">UP</span> <span class="minimum">UP</span>
{{/if}} {{/if}}

View File

@ -46,7 +46,7 @@
<div class="card_list"> <div class="card_list">
{{each fiveLog val}} {{each fiveLog val}}
<div class="item star5 {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (num<max*0.83) ? 'normal': 'bad')}}"> <div class="item star5 {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (val.num<max*0.83) ? 'normal': 'bad')}}">
{{ if val.isUp && typeName == '角色' }} {{ if val.isUp && typeName == '角色' }}
<span class="minimum">UP</span> <span class="minimum">UP</span>
{{/if}} {{/if}}
@ -54,7 +54,7 @@
src="{{pluResPath}}img/{{val.item_type=='角色'?'role':'weapon'}}/{{val.name}}.png" src="{{pluResPath}}img/{{val.item_type=='角色'?'role':'weapon'}}/{{val.name}}.png"
onerror="whenError(this,'{{val.item_type=='角色'?'role':'weapon'}}')"/> onerror="whenError(this,'{{val.item_type=='角色'?'role':'weapon'}}')"/>
<!-- <div class="num">{{val.num}}</div>--> <!-- <div class="num">{{val.num}}</div>-->
<div class="num_name {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (num<max*0.83) ? 'normal': 'bad')}}" >{{val.num}}</div> <div class="num_name {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (val.num<max*0.83) ? 'normal': 'bad')}}" >{{val.num}}</div>
</div> </div>
{{/each}} {{/each}}
</div> </div>
@ -68,12 +68,12 @@
</body> </body>
<script type="text/javascript"> <script type="text/javascript">
function whenError(a, type) { function whenError(a, type) {
// a.onerror = null; // a.onerror = null;
// if(type=="role"){ // if(type=="role"){
// a.src = "{{_res_path}}/genshin/logo/role/荧.png"; // a.src = "{{_res_path}}/genshin/logo/role/荧.png";
// }else{ // }else{
// a.src = "{{_res_path}}/genshin/logo/weapon/旅行剑.png"; // a.src = "{{_res_path}}/genshin/logo/weapon/旅行剑.png";
// } // }
} }
</script> </script>
</html> </html>