mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2025-03-13 19:27:45 +01:00
Add 50:50 rank
This commit is contained in:
parent
6ef0c74622
commit
e213abb4ed
4 changed files with 117 additions and 2 deletions
|
@ -479,6 +479,7 @@
|
|||
"totalPull": "Total Pull",
|
||||
"luck5": "Luckiness 5★",
|
||||
"luck4": "Luckiness 4★",
|
||||
"luckWinRateOff": "Luckiness Win 50:50",
|
||||
"medianTotal": "Global Median {median} pulls",
|
||||
"medianLuck": "Global Median {median}%",
|
||||
"moreTotal": "More pulls than {percentage}% of paimon.moe users",
|
||||
|
|
|
@ -479,6 +479,7 @@
|
|||
"totalPull": "Total Wish",
|
||||
"luck5": "Keberuntungan 5★",
|
||||
"luck4": "Keberuntungan 4★",
|
||||
"luckWinRateOff": "Keberuntungan Menang 50:50",
|
||||
"medianTotal": "Median Global {median} pull",
|
||||
"medianLuck": "Median Global {median}%",
|
||||
"moreTotal": "Lebih banyak dari {percentage}% pengguna paimon.moe",
|
||||
|
|
|
@ -22,12 +22,26 @@
|
|||
legendary: '...',
|
||||
rare: '...',
|
||||
};
|
||||
let percentageWinRateOff = {
|
||||
legendary: 0,
|
||||
rare: 0,
|
||||
};
|
||||
let medianWinRateOff = {
|
||||
legendary: '...',
|
||||
rare: '...',
|
||||
};
|
||||
let loading = {
|
||||
total: true,
|
||||
legendary: true,
|
||||
rare: true,
|
||||
winRateOff: {
|
||||
legendary: true,
|
||||
rare: true,
|
||||
},
|
||||
};
|
||||
|
||||
let disableWinRateOff = false;
|
||||
|
||||
export async function getData() {
|
||||
loading.total = true;
|
||||
percentage = 0;
|
||||
|
@ -73,7 +87,6 @@
|
|||
}
|
||||
|
||||
percentage = 100 - (totalLower / total) * 100;
|
||||
console.log(totalLower, percentage, value);
|
||||
|
||||
loading.total = false;
|
||||
}
|
||||
|
@ -122,16 +135,69 @@
|
|||
}
|
||||
|
||||
percentageLuck[rarity] = 100 - (totalLower / total) * 100;
|
||||
console.log(totalLower, percentage, value);
|
||||
|
||||
loading[rarity] = false;
|
||||
}
|
||||
|
||||
export async function getDataWinRateOff(rarity, percentages) {
|
||||
loading.winRateOff[rarity] = true;
|
||||
percentageWinRateOff[rarity] = 0;
|
||||
medianWinRateOff[rarity] = '...';
|
||||
|
||||
if (percentages[current] === undefined) return;
|
||||
if (percentages[current].winRateOff === undefined) {
|
||||
disableWinRateOff = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(`${__paimon.env.API_HOST}/wish/summary/winrateoff`);
|
||||
const query = new URLSearchParams({ banner: current, rarity });
|
||||
url.search = query.toString();
|
||||
|
||||
const res = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
|
||||
data = await res.json();
|
||||
|
||||
total = 0;
|
||||
const sorted = [];
|
||||
for (const item of data) {
|
||||
total += item[1];
|
||||
sorted.push(...new Array(item[1]).fill(item[0]));
|
||||
}
|
||||
medianWinRateOff[rarity] = (sorted[Math.round(sorted.length / 2)] * 100).toFixed(2);
|
||||
|
||||
getPercentileWinRateOff(percentages[current].winRateOff[rarity], rarity);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
function getPercentileWinRateOff(value, rarity) {
|
||||
let totalLower = 0;
|
||||
for (const item of data) {
|
||||
const qty = item[0];
|
||||
const amount = item[1];
|
||||
totalLower += amount;
|
||||
|
||||
if (qty >= value) break;
|
||||
}
|
||||
|
||||
percentageWinRateOff[rarity] = 100 - (totalLower / total) * 100;
|
||||
|
||||
loading.winRateOff[rarity] = false;
|
||||
}
|
||||
|
||||
export function getDataLuckAll(percentages) {
|
||||
const sources = percentages === undefined ? wishPercentage : percentages;
|
||||
|
||||
getDataLuck('legendary', sources);
|
||||
getDataLuck('rare', sources);
|
||||
|
||||
getDataWinRateOff('legendary', sources);
|
||||
}
|
||||
|
||||
function change(type) {
|
||||
|
@ -143,6 +209,7 @@
|
|||
$: fixedPoint = percentage < 0.1 ? 2 : percentage < 2 ? 1 : 0;
|
||||
$: fixedPointLegendary = percentageLuck.legendary < 0.1 ? 2 : percentageLuck.legendary < 2 ? 1 : 0;
|
||||
$: fixedPointRare = percentageLuck.rare < 0.1 ? 2 : percentageLuck.rare < 2 ? 1 : 0;
|
||||
$: fixedPointWinRateOff = percentageWinRateOff < 0.1 ? 2 : percentageWinRateOff < 2 ? 1 : 0;
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col items-center bg-item rounded-xl p-4 w-full mt-4">
|
||||
|
@ -182,6 +249,44 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{#if current !== 'standard' && !disableWinRateOff}
|
||||
<div class="bg-background flex-row items-center justify-center mb-2 p-4 rounded-xl flex relative group w-full">
|
||||
<div
|
||||
class="group-hover:flex hidden absolute left-0 items-center z-10"
|
||||
style="max-width: 80%; bottom: 12px; left: 12px;"
|
||||
>
|
||||
<div class="bg-gray-200 text-gray-900 px-4 py-1 rounded-xl text-sm md:text-base">
|
||||
{$t('wish.rank.medianLuck', { values: { median: medianWinRateOff.legendary } })}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-gray-200 flex-1">
|
||||
<p class="text-gray-200">{$t('wish.rank.luckWinRateOff')}</p>
|
||||
<p class="text-sm text-gray-600 leading-none">
|
||||
{#if percentageWinRateOff.legendary < 50}
|
||||
{$t('wish.rank.moreLuck', {
|
||||
values: { percentage: (100 - percentageWinRateOff.legendary).toFixed(fixedPointRare) },
|
||||
})}
|
||||
{:else}
|
||||
{$t('wish.rank.lessLuck', { values: { percentage: percentageWinRateOff.legendary.toFixed(0) } })}
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
<div class="pl-3">
|
||||
<span class="text-sm font-black text-white opacity-75 block leading-none">
|
||||
{loading.winRateOff.legendary
|
||||
? $t('wish.rank.top')
|
||||
: $t(`wish.rank.${percentageWinRateOff.legendary < 50 ? 'top' : 'bottom'}`)}
|
||||
</span>
|
||||
<span class="text-white font-black text-3xl leading-none block" style="line-height: 0.75;">
|
||||
{loading.winRateOff.legendary
|
||||
? '...'
|
||||
: percentageWinRateOff.legendary < 50
|
||||
? percentageWinRateOff.legendary.toFixed(fixedPointWinRateOff)
|
||||
: (100 - percentageWinRateOff.legendary).toFixed(fixedPointWinRateOff)}%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="bg-background flex-row items-center justify-center mb-2 p-4 rounded-xl flex relative group w-full">
|
||||
<div
|
||||
class="group-hover:flex hidden absolute left-0 items-center z-10"
|
||||
|
|
|
@ -227,9 +227,17 @@
|
|||
(counterData.rateoff.legendary.win + counterData.rateoff.legendary.lose),
|
||||
};
|
||||
}
|
||||
|
||||
percentages[type.id] = {
|
||||
winRateOff: {
|
||||
legendary: avg[type.id].legendary.rateOff.percentage,
|
||||
rare: avg[type.id].rare.rateOff.percentage,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
percentages[type.id] = {
|
||||
...percentages[type.id],
|
||||
legendary: avg[type.id].legendary.percentage,
|
||||
rare: avg[type.id].rare.percentage,
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue