Skip to content

Commit

Permalink
Merge pull request #40 from tiffanynwyeung/fix/four-star-pity
Browse files Browse the repository at this point in the history
fix: change 4* pity tracking
  • Loading branch information
Luzefiru authored Jun 4, 2024
2 parents be071cc + bf8b463 commit 23071fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
23 changes: 18 additions & 5 deletions src/components/convenes/convene-avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,32 @@ export function ConveneAvatar({
previousFourStarPullNumber,
}: Props) {
function getBadgeVariant(pullNumber: number) {
if (pullNumber >= 65) {
return "destructive";
} else if (pullNumber >= 30) {
return "warning";
const isFourStar = qualityLevel === 4 && fourStarCurrentPity === 0;

if (isFourStar) {
if (pullNumber >= 8) {
return "destructive";
} else if (pullNumber >= 4) {
return "warning";
} else {
return "success";
}
} else {
return "success";
if (pullNumber >= 65) {
return "destructive";
} else if (pullNumber >= 40){
return "warning";
} else {
return "success";
}
}
}

const pullNumberToDisplay = getPullNumber(
qualityLevel,
fourStarCurrentPity,
pullNumber,
previousFourStarPullNumber,
previousFiveStarPullNumber,
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/convenes/pull-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React from "react";
import InfiniteScroll from "../ui/scroll-area";
import getPullNumber from "@/lib/getPullNumber";

import { useState } from "react";
import { BannerStats } from "@/types/BannerStats";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import {
Expand Down Expand Up @@ -62,6 +61,7 @@ export function PullHistory({ stats }: Props) {
item.qualityLevel,
item.fourStarCurrentPity,
item.pullNumber,
item.previousFourStarPullNumber,
item.previousFiveStarPullNumber,
)}
</TableCell>
Expand Down
7 changes: 3 additions & 4 deletions src/lib/getPullNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
* @param qualityLevel - the rarity level of a character
* @param fourStarCurrentPity - the current pity for four star items (out of 10)
* @param pullNumber - the overall pull number which an item was acquired
* @param previousFourStarPullNumber - the last pity in which a four star item was pulled
* @param previousFiveStarPullNumber - the last pity in which a five star item was pulled
* @returns an integer that represents an item's current pull number within pity
*/
export default function getPullNumber(
qualityLevel: number,
fourStarCurrentPity: number,
pullNumber: number,
previousFourStarPullNumber: number,
previousFiveStarPullNumber: number,
) {
const isFourStar = qualityLevel === 4 && fourStarCurrentPity === 0;

if (isFourStar) {
return pullNumber - previousFiveStarPullNumber;
}
return pullNumber - previousFiveStarPullNumber;
return pullNumber - (isFourStar ? previousFourStarPullNumber : previousFiveStarPullNumber);
}

0 comments on commit 23071fe

Please sign in to comment.