From 191ff7c78e5774a674694923faac0bc7efb1b5e6 Mon Sep 17 00:00:00 2001 From: KeziahMoselle Date: Sun, 5 Mar 2023 17:11:44 +0100 Subject: [PATCH] feat: improve sources, display refining ability on costume page --- src/components/Ability.tsx | 2 +- src/components/WeaponInfo.tsx | 46 +++++++++------- src/pages/weapons/[[...weapon]].tsx | 6 ++- src/utils/alterCostumeToAddWeapon.ts | 79 +++++++++++++++------------- 4 files changed, 77 insertions(+), 56 deletions(-) diff --git a/src/components/Ability.tsx b/src/components/Ability.tsx index 37ac380f..9d879c9a 100644 --- a/src/components/Ability.tsx +++ b/src/components/Ability.tsx @@ -53,7 +53,7 @@ export default function Ability({ )} - {level && ( + {level > 0 && ( { setSelectedWeapon(weapons[evolutionStage]); }, [evolutionStage, weapons]); @@ -125,17 +120,33 @@ export default function WeaponInfo({
- {events.length === 0 && !selectedWeapon.is_ex_weapon && ( - Sorry, no potential event source found. - )} - + {events.length === 0 && + !selectedWeapon.is_ex_weapon && + !selectedWeapon.is_rd_weapon && + !selectedWeapon.is_subjugation_weapon && ( + Sorry, no potential event source found. + )} {selectedWeapon.is_ex_weapon && ( This weapon can be obtained while clearing the story. (hard mode) )} - + {selectedWeapon.is_rd_weapon && ( + + This weapon can be obtained in the "Recollections of Dusk" game + mode. See{" "} + + Recollections of Dusk guide + + + )} + {selectedWeapon.is_subjugation_weapon && ( + + This weapon can be obtained while playing the "Subjugation" game + mode. + + )} {events.length > 0 && (

@@ -149,12 +160,13 @@ export default function WeaponInfo({

)}
- -
- {events.map((event) => ( - - ))} -
+ {events.length > 0 && ( +
+ {events.map((event) => ( + + ))} +
+ )} {selectedWeapon.weapon_story_link.length > 0 && ( @@ -391,7 +403,6 @@ export function SingleWeapon({ {weapon.weapon_ability_link .sort((a, b) => a.slot_number - b.slot_number) - .filter((ability) => ability.ability_level === abilityLevel) .slice(3, 4).length > 0 && ( a.slot_number - b.slot_number) - .filter((ability) => ability.ability_level === abilityLevel) .slice(3, 4) .map((ability) => ( GLOBAL_RELEASE_DATE + selectedWeapon[selectedWeapon.length - 1].release_time > + GLOBAL_RELEASE_DATE && + !selectedWeapon[selectedWeapon.length - 1].is_ex_weapon && + !selectedWeapon[selectedWeapon.length - 1].is_rd_weapon && + !selectedWeapon[selectedWeapon.length - 1].is_subjugation_weapon ) { const releaseTimeGte = sub( selectedWeapon[selectedWeapon.length - 1].release_time, diff --git a/src/utils/alterCostumeToAddWeapon.ts b/src/utils/alterCostumeToAddWeapon.ts index a4de1b25..ec51de14 100644 --- a/src/utils/alterCostumeToAddWeapon.ts +++ b/src/utils/alterCostumeToAddWeapon.ts @@ -3,13 +3,13 @@ import prisma from "@libs/prisma"; export default async function alterCostumeToAddWeapon(costume) { const link = await prisma.nrg.costumes_link.findUnique({ where: { - costume_id: costume.costume_id - } - }) + costume_id: costume.costume_id, + }, + }); if (!link) { costume.weapon = null; - return + return; } const weapon = await prisma.dump.weapon.findUnique({ @@ -17,36 +17,43 @@ export default async function alterCostumeToAddWeapon(costume) { weapon_id: link.weapon_id, }, include: { - weapon_stat: { - orderBy: { - level: "desc", - }, - take: 1, - }, - weapon_ability_link: { - where: { - ability_level: 15, - }, - orderBy: { - slot_number: "asc", - }, - include: { - weapon_ability: true, - }, - }, - weapon_skill_link: { - where: { - skill_level: 15, - }, - orderBy: { - slot_number: "asc", - }, - include: { - weapon_skill: true, - }, - }, - }, - }) + weapon_stat: { + orderBy: { + level: "desc", + }, + take: 1, + }, + weapon_ability_link: { + where: { + OR: [ + { + slot_number: 4, + }, + { + ability_level: 15, + }, + ], + }, + orderBy: { + slot_number: "asc", + }, + include: { + weapon_ability: true, + }, + }, + weapon_skill_link: { + where: { + skill_level: 15, + }, + orderBy: { + slot_number: "asc", + }, + include: { + weapon_skill: true, + }, + }, + }, + }); - costume.weapon = weapon - } \ No newline at end of file + costume.weapon = weapon; +}