Skip to content

Commit

Permalink
feat: display base weapons rarity instead of max state
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Oct 13, 2022
1 parent fff5dd2 commit 342b947
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 15 deletions.
44 changes: 31 additions & 13 deletions src/components/pages/weapons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
import Radio from "@components/form/Radio";
import classNames from "classnames";
import AbilityThumbnail from "@components/AbilityThumbnail";
import getBaseRarity from "@utils/getBaseRarity";

interface CharactersPageProps {
weapons: (weapon & {
Expand Down Expand Up @@ -66,9 +67,9 @@ export const weaponTypesLookup = {
};

export const rarityLookup = {
RARE: "2*",
S_RARE: "3*",
SS_RARE: "4*",
LEGEND: "5*",
};

export default function WeaponsPage({
Expand Down Expand Up @@ -182,10 +183,19 @@ export function WeaponsTable({
return (
<MaterialTable
title={title ?? `${weapons.length} weapons in the database.`}
data={weapons.filter((weapon) => {
if (showUnreleasedContent) return true;
return new Date() > new Date(weapon.release_time);
})}
data={weapons
.filter((weapon) => {
if (showUnreleasedContent) return true;
return new Date() > new Date(weapon.release_time);
})
.map((weap) => ({
...weap,
base_rarity: getBaseRarity({
rarity: weap.rarity,
is_ex_weapon: weap.is_ex_weapon,
evolution_order: weap.evolution_order,
}),
}))}
columns={[
{
field: "name",
Expand All @@ -196,7 +206,7 @@ export function WeaponsTable({
<div className="flex items-center gap-x-4 w-80 relative bg-white bg-opacity-5 rounded-lg hover:bg-opacity-20 focus-within:bg-opacity-20 transition">
<WeaponThumbnail
element={weapon.attribute}
rarity={weapon.rarity}
rarity={weapon.base_rarity}
type={weapon.weapon_type}
isDark={weapon.is_ex_weapon}
alt={weapon.name}
Expand Down Expand Up @@ -481,16 +491,16 @@ export function WeaponsTable({
),
},
{
field: "rarity",
title: "Rarity",
field: "base_rarity",
title: "Base Rarity",
lookup: rarityLookup,
customFilterAndSearch: (term, costume) => {
customFilterAndSearch: (term, weapon) => {
if (term.length === 0) return true;
return term.includes(costume.rarity);
return term.includes(weapon.base_rarity);
},
render: (costume) => (
render: (weapon) => (
<div className="w-8 h-8 mx-auto">
<Star rarity={RARITY[costume.rarity]} />
<Star rarity={RARITY[weapon.base_rarity]} />
</div>
),
},
Expand Down Expand Up @@ -563,6 +573,14 @@ export function WeaponsGrid({
if (showUnreleasedContent) return true;
return new Date() > new Date(weapon.release_time);
})
.map((weap) => ({
...weap,
base_rarity: getBaseRarity({
rarity: weap.rarity,
is_ex_weapon: weap.is_ex_weapon,
evolution_order: weap.evolution_order,
}),
}))
.map((weap) => (
<div
className={classNames(
Expand All @@ -584,7 +602,7 @@ export function WeaponsGrid({
alt={weap.name}
type={weap.weapon_type}
element={weap.attribute}
rarity={weap.rarity}
rarity={weap.base_rarity}
isLarge
isDark={weap.is_ex_weapon}
imgClasses="transform transition-transform ease-out-cubic group-hover:scale-110"
Expand Down
7 changes: 6 additions & 1 deletion src/pages/tierlist/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getTierlist } from "@models/tiers";
import { useInventoryStore } from "@store/inventory";
import Checkbox from "@components/form/Checkbox";
import { useState } from "react";
import getBaseRarity from "@utils/getBaseRarity";

interface TierListProps {
tierlist: tierlists & {
Expand Down Expand Up @@ -233,7 +234,11 @@ export function TierlistContent({ tierlist, items }) {
: undefined
}
element={weapon?.attribute}
rarity={weapon?.rarity}
rarity={getBaseRarity({
rarity: weapon?.rarity,
is_ex_weapon: weapon?.is_ex_weapon,
evolution_order: weapon?.evolution_order,
})}
type={weapon?.weapon_type}
isDark={weapon?.is_ex_weapon}
alt={weapon?.name}
Expand Down
7 changes: 6 additions & 1 deletion src/pages/tools/tierlist-builder/weapons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import WeaponThumbnail from "@components/WeaponThumbnail";
import ATTRIBUTES from "@utils/attributes";
import { RANK_THUMBNAILS } from "@utils/rankThumbnails";
import { useCreatedTierlists } from "@store/created-tierlists";
import getBaseRarity from "@utils/getBaseRarity";

const DEFAULT_DESCRIPTION = "<p>My awesome (and objective) tierlist.</p>";

Expand Down Expand Up @@ -548,7 +549,11 @@ export default function TierlistBuilder({
<WeaponThumbnail
key={`${item.weapon_id}-${index}`}
element={item.attribute}
rarity={item.rarity}
rarity={getBaseRarity({
rarity: item.rarity,
is_ex_weapon: item.is_ex_weapon,
evolution_order: item.evolution_order,
})}
type={item.weapon_type}
isDark={item.is_ex_weapon}
alt={item.name}
Expand Down
30 changes: 30 additions & 0 deletions src/utils/getBaseRarity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
interface getBaseRarityArgs {
rarity: string;
evolution_order: number;
is_ex_weapon: boolean;
}

export default function getBaseRarity({
rarity,
evolution_order,
is_ex_weapon
}: getBaseRarityArgs) {
if (is_ex_weapon) {
return 'S_RARE';
}

if (evolution_order === 2 && rarity === 'LEGEND') {
return 'SS_RARE'
}

if (evolution_order === 2 && rarity === 'SS_RARE') {
return 'S_RARE';
}

if (evolution_order === 2 && rarity === 'S_RARE') {
return 'RARE';
}


return rarity;
}

0 comments on commit 342b947

Please sign in to comment.