Skip to content

Commit

Permalink
Fix SRGacha rankings UP% calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
stdcall0 committed Apr 16, 2024
1 parent d199593 commit 0e3fab7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apps/starrail_gacha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SRGachaPlugin extends Plugin {
fnc: 'single'
},
{
reg: '^#星铁抽卡排名.*$',
reg: '^#星铁抽卡(排名|排行).*$',
fnc: 'showrank'
}
]
Expand Down Expand Up @@ -164,8 +164,10 @@ export class SRGachaPlugin extends Plugin {
}

getUpPercentage(rankData: RankData): number {
if (rankData.star5 == 0) return 0;
return rankData.up / rankData.star5;
if (rankData.up == 0) return 0;
const wai = rankData.star5 - rankData.up;
const buwai = rankData.up - wai;
return buwai / rankData.up;
}

getAverageUpCount(rankData: RankData): number {
Expand All @@ -181,7 +183,7 @@ export class SRGachaPlugin extends Plugin {

msg.push(""); msg.push("排行榜 (小保底不歪): ");
let top1 = Object.values(rank)
.filter(r => r.star5 > 0).sort((a, b) => this.getUpPercentage(b) - this.getUpPercentage(a));
.filter(r => r.up > 0).sort((a, b) => this.getUpPercentage(b) - this.getUpPercentage(a));
let top2 = Object.values(rank)
.filter(r => r.star5 > 0).sort((a, b) => this.getAverageUpCount(a) - this.getAverageUpCount(b));

Expand Down

0 comments on commit 0e3fab7

Please sign in to comment.