mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2025-03-13 19:27:45 +01:00
Add rate up and constellation to global wish stats
This commit is contained in:
parent
a8f6b5b062
commit
2a8da2dbfa
2 changed files with 94 additions and 0 deletions
|
@ -83,6 +83,15 @@ export async function process(id) {
|
|||
},
|
||||
featured: e.featured,
|
||||
featuredRare: e.featuredRare,
|
||||
rateOffLegendary: {
|
||||
win: 0,
|
||||
lose: 0,
|
||||
},
|
||||
rateOffRare: {
|
||||
win: 0,
|
||||
lose: 0,
|
||||
},
|
||||
constellation: {},
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -95,6 +104,7 @@ export async function process(id) {
|
|||
const currentPulls = [];
|
||||
const allLegendary = [];
|
||||
const allRare = [];
|
||||
const constellation = {};
|
||||
let currentBanner = null;
|
||||
let grouped = false;
|
||||
let striped = false;
|
||||
|
@ -105,6 +115,18 @@ export async function process(id) {
|
|||
let hasManualInput = false;
|
||||
let lastBanner;
|
||||
let lastBannerIndex;
|
||||
let rateOffLegendary = {
|
||||
win: 0,
|
||||
lose: 0,
|
||||
maxStreak: 0,
|
||||
currentStreak: 0,
|
||||
};
|
||||
let rateOffRare = {
|
||||
win: 0,
|
||||
lose: 0,
|
||||
maxStreak: 0,
|
||||
currentStreak: 0,
|
||||
};
|
||||
|
||||
let pity = 0;
|
||||
for (let i = 0; i < pullData.length; i++) {
|
||||
|
@ -161,6 +183,16 @@ export async function process(id) {
|
|||
if (currentBanner.featured) {
|
||||
newPull.guaranteed = rateUp;
|
||||
rateUp = !currentBanner.featured.includes(newPull.id);
|
||||
if (rateUp) {
|
||||
selectedBanners[currentBannerIndex].rateOffLegendary.lose++;
|
||||
rateOffLegendary.lose++;
|
||||
rateOffLegendary.maxStreak = Math.max(rateOffLegendary.maxStreak, rateOffLegendary.currentStreak);
|
||||
rateOffLegendary.currentStreak = 0;
|
||||
} else if (newPull.guaranteed === false) {
|
||||
selectedBanners[currentBannerIndex].rateOffLegendary.win++;
|
||||
rateOffLegendary.win++;
|
||||
rateOffLegendary.currentStreak++;
|
||||
}
|
||||
}
|
||||
|
||||
selectedBanners[currentBannerIndex].legendary.push(newPull);
|
||||
|
@ -170,6 +202,17 @@ export async function process(id) {
|
|||
if (currentBanner.featuredRare) {
|
||||
newPull.guaranteed = rateUpRare;
|
||||
rateUpRare = !currentBanner.featuredRare.includes(newPull.id);
|
||||
|
||||
if (rateUpRare) {
|
||||
selectedBanners[currentBannerIndex].rateOffRare.lose++;
|
||||
rateOffRare.lose++;
|
||||
rateOffRare.maxStreak = Math.max(rateOffRare.maxStreak, rateOffRare.currentStreak);
|
||||
rateOffRare.currentStreak = 0;
|
||||
} else if (newPull.guaranteed === false) {
|
||||
selectedBanners[currentBannerIndex].rateOffRare.win++;
|
||||
rateOffRare.win++;
|
||||
rateOffRare.currentStreak++;
|
||||
}
|
||||
}
|
||||
|
||||
allRare.push(newPull);
|
||||
|
@ -181,6 +224,20 @@ export async function process(id) {
|
|||
}
|
||||
}
|
||||
|
||||
if (newPull.id === 'raiden_shogun') console.log(newPull);
|
||||
|
||||
if (newPull.rarity > 3) {
|
||||
if (selectedBanners[currentBannerIndex].constellation[newPull.id] === undefined) {
|
||||
selectedBanners[currentBannerIndex].constellation[newPull.id] = 0;
|
||||
}
|
||||
selectedBanners[currentBannerIndex].constellation[newPull.id]++;
|
||||
|
||||
if (constellation[newPull.id] === undefined) {
|
||||
constellation[newPull.id] = 0;
|
||||
}
|
||||
constellation[newPull.id]++;
|
||||
}
|
||||
|
||||
if (!grouped && pull.time === next.time) {
|
||||
striped = !striped;
|
||||
newPull.group = 'start';
|
||||
|
@ -208,6 +265,8 @@ export async function process(id) {
|
|||
currentPulls.push(newPull);
|
||||
}
|
||||
|
||||
console.log(constellation);
|
||||
|
||||
return {
|
||||
pulls: currentPulls,
|
||||
banner: selectedBanners,
|
||||
|
@ -216,6 +275,9 @@ export async function process(id) {
|
|||
allTotal: data.total,
|
||||
legendaryTotal: allLegendary.length,
|
||||
rareTotal: allRare.length,
|
||||
rateOffLegendary,
|
||||
rateOffRare,
|
||||
constellation,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -29,12 +29,26 @@ async function sendWishTotal(data) {
|
|||
}
|
||||
}
|
||||
|
||||
async function sendWishConstellation(data) {
|
||||
try {
|
||||
await fetch(`${__paimon.env.API_HOST}/wish/constellation`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
export async function submitWishTally() {
|
||||
let prefixId = 0;
|
||||
|
||||
const prefixAccount = getAccountPrefix();
|
||||
const uid = await readSave(`${prefixAccount}wish-uid`);
|
||||
|
||||
const constellations = {};
|
||||
|
||||
for (const id of bannerCategories) {
|
||||
prefixId += 100000;
|
||||
|
||||
|
@ -52,6 +66,8 @@ export async function submitWishTally() {
|
|||
total: tally.allTotal,
|
||||
legendary: tally.legendaryTotal,
|
||||
rare: tally.rareTotal,
|
||||
rateOffLegendary: tally.rateOffLegendary,
|
||||
rateOffRare: tally.rateOffRare,
|
||||
});
|
||||
|
||||
const firstFivePulls = pulls
|
||||
|
@ -118,6 +134,22 @@ export async function submitWishTally() {
|
|||
pityCount,
|
||||
uid,
|
||||
});
|
||||
|
||||
await sendWishConstellation({
|
||||
banner: prefixId + i + 1,
|
||||
uid,
|
||||
items: Object.entries(banner[i].constellation).map(([name, count]) => [name, count]),
|
||||
});
|
||||
}
|
||||
|
||||
for (const [id, count] of Object.entries(tally.constellation)) {
|
||||
if (constellations[id] === undefined) constellations[id] = 0;
|
||||
constellations[id] += count;
|
||||
}
|
||||
}
|
||||
|
||||
await sendWishConstellation({
|
||||
uid,
|
||||
items: Object.entries(constellations).map(([name, count]) => [name, count]),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue