Skip to content

Commit

Permalink
feat: improve sources, display refining ability on costume page
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Mar 5, 2023
1 parent 2695d3e commit 191ff7c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/components/Ability.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function Ability({
</span>
</span>
)}
{level && (
{level > 0 && (
<span
className={classNames(
"absolute top-2 right-4 text-xs mt-2 bg-brown px-2 py-1",
Expand Down
46 changes: 28 additions & 18 deletions src/components/WeaponInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import RARITY from "@utils/rarity";
import Star from "@components/decorations/Star";
import Lines from "@components/decorations/Lines";
import Element from "@components/Element";
import Radio from "@components/form/Radio";
import Skill from "@components/Skill";
import Ability from "@components/Ability";
import Slider from "rc-slider";
import { useEffect, useState } from "react";
import SVG from "react-inlinesvg";
import { CDN_URL } from "@config/constants";
Expand Down Expand Up @@ -68,9 +66,6 @@ export default function WeaponInfo({
const [isShowingModel, setIsShowingModel] = useState(false);
const [selectedWeapon, setSelectedWeapon] = useState(weapons[evolutionStage]);

/* // 0 is Lv. 1 and 14 is Lv. 15
const [skillAbilitiesLevel, setSkillAbilitiesLevel] = useState(14); */

useEffect(() => {
setSelectedWeapon(weapons[evolutionStage]);
}, [evolutionStage, weapons]);
Expand Down Expand Up @@ -125,17 +120,33 @@ export default function WeaponInfo({
</div>

<div className="bg-grey-dark bordered relative p-4 text-sm max-w-xl mx-auto text-center mb-8">
{events.length === 0 && !selectedWeapon.is_ex_weapon && (
<span>Sorry, no potential event source found.</span>
)}

{events.length === 0 &&
!selectedWeapon.is_ex_weapon &&
!selectedWeapon.is_rd_weapon &&
!selectedWeapon.is_subjugation_weapon && (
<span>Sorry, no potential event source found.</span>
)}
{selectedWeapon.is_ex_weapon && (
<span>
This weapon can be obtained while clearing the story. (hard
mode)
</span>
)}

{selectedWeapon.is_rd_weapon && (
<span>
This weapon can be obtained in the "Recollections of Dusk" game
mode. See{" "}
<a href="https://nierrein.guide/guide/recollections-of-dusk">
Recollections of Dusk guide
</a>
</span>
)}
{selectedWeapon.is_subjugation_weapon && (
<span>
This weapon can be obtained while playing the "Subjugation" game
mode.
</span>
)}
{events.length > 0 && (
<div>
<p>
Expand All @@ -149,12 +160,13 @@ export default function WeaponInfo({
</div>
)}
</div>

<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
{events.map((event) => (
<EventItem key={event.id} {...event} />
))}
</div>
{events.length > 0 && (
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
{events.map((event) => (
<EventItem key={event.id} {...event} />
))}
</div>
)}
</div>

{selectedWeapon.weapon_story_link.length > 0 && (
Expand Down Expand Up @@ -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 && (
<Lines
className="mb-2 mt-8"
Expand All @@ -403,7 +414,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)
.map((ability) => (
<Ability
Expand Down
6 changes: 5 additions & 1 deletion src/pages/weapons/[[...weapon]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ export async function getStaticProps(context) {
* Only weapons released after global release date because we don't want to link events to release stuff
*/
if (
selectedWeapon[selectedWeapon.length - 1].release_time > 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,
Expand Down
79 changes: 43 additions & 36 deletions src/utils/alterCostumeToAddWeapon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,57 @@ 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({
where: {
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
}
costume.weapon = weapon;
}

0 comments on commit 191ff7c

Please sign in to comment.