Skip to content

Commit

Permalink
feat: add stone execution ui
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed Nov 16, 2024
1 parent 7590a7a commit 4e63eae
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 45 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/content/requiredText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Text } from "@chakra-ui/react";
export default function RequiredText({
children,
}: {
children: React.ReactNode;
children?: React.ReactNode;
}) {
return (
<Text size="md" textAlign="center" opacity={0.6}>
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/constants/enhance/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import POTENTIAL from "../../assets/item/potential/potential.webp";
import POTENTIAL_ADDI from "../../assets/item/potential/potential-addi.webp";

export enum MATERIAL_TYPE {
SPEEL_TRACE = "SPEEL_TRACE",
INCREDIBLE_CHAOS = "INCREDIBLE_CHAOS",
PREMIUM_ACCESSORY_ATTACK = "PREMIUM_ACCESSORY_ATTACK",
PREMIUM_ACCESSORY_MAGIC_ATTACK = "PREMIUM_ACCESSORY_MAGIC_ATTACK",
STARFORCE = "STARFORCE",
SPEEL_TRACE = "SPEEL_TRACE", // 주흔
INCREDIBLE_CHAOS = "INCREDIBLE_CHAOS", // 놀긍혼
PREMIUM_ACCESSORY_ATTACK = "PREMIUM_ACCESSORY_ATTACK", // 프악공
PREMIUM_ACCESSORY_MAGIC_ATTACK = "PREMIUM_ACCESSORY_MAGIC_ATTACK", // 프악마
STARFORCE = "STARFORCE", // 스타포스

POWERFUL = "POWERFUL",
ETERNAL = "ETERNAL",
BLACK_REBIRTH = "BLACK_REBIRTH",
ABYSS = "ABYSS",
GRINDSTONE = "GRINDSTONE",
POWERFUL = "POWERFUL", // 강활불
ETERNAL = "ETERNAL", // 영환불
BLACK_REBIRTH = "BLACK_REBIRTH", // 검환불
ABYSS = "ABYSS", // 심환불
GRINDSTONE = "GRINDSTONE", // 연마석

STRANGE = "STRANGE", // 수상한
MASTER = "MASTER", // 장인
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/enhance/4-config/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export default function Config({
)
return <Guarantee materialType={materialType} />;

return <></>;
return <RequiredText>필요한 추가 설정이 없습니다.</RequiredText>;
}
9 changes: 6 additions & 3 deletions frontend/src/pages/enhance/7-execute/execute.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import RequiredText from "../../../components/content/requiredText";
import { MATERIAL_TYPE } from "../../../constants/enhance/material";
import GrindStone from "./grindStone/grindStone";
import Potential from "./potential/potential";

export default function Execute({
Expand Down Expand Up @@ -32,11 +33,13 @@ export default function Execute({
MATERIAL_TYPE.POTENTIAL,
MATERIAL_TYPE.POTENTIAL_ADDI,
].includes(materialType)
) {
)
return (
<Potential inventoryIndex={inventoryIndex} materialType={materialType} />
);
}

return <></>;
if (materialType == MATERIAL_TYPE.GRINDSTONE)
return <GrindStone inventoryIndex={inventoryIndex} />;

return <RequiredText>개발중인 기능입니다.</RequiredText>;
}
121 changes: 121 additions & 0 deletions frontend/src/pages/enhance/7-execute/grindStone/grindStone.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import {
Button,
Flex,
Icon,
IconButton,
Image,
Stack,
Tag,
Text,
useColorMode,
} from "@chakra-ui/react";
import RequiredText from "../../../../components/content/requiredText";
import { useAppSelector } from "../../../../stores/hooks";
import GRINDSTONE from "../../../../assets/item/scroll/grindstone.png";
import MESO from "../../../../assets/item/meso/coin.png";
import { RxPlus, RxDoubleArrowRight } from "react-icons/rx";
import { FaPlus, FaMinus, FaPlusCircle } from "react-icons/fa";
import Slot from "./slot";

export default function GrindStone({
inventoryIndex,
}: {
inventoryIndex: number;
}) {
const inventory = useAppSelector((state) => state.user.inventory);
const item = inventory[inventoryIndex].after;

const { colorMode } = useColorMode();
const dark = colorMode === "dark";
const palette600 = dark ? ".300" : ".600";

if (!item.special_ring_level)
return (
<RequiredText>선택한 아이템은 특수 스킬 반지가 아닙니다.</RequiredText>
);

return (
<Stack>
<Tag as={Stack} px={4} py={2} gap={1}>
<Text>
사용할 <b>연마석 수량을 설정</b>해주세요.
</Text>
<Text>
연마석 수량에 따라 연마 <b>성공 확률</b> 및 연마에 사용되는{" "}
<b>메소</b>가 설정됩니다.
</Text>
</Tag>
<Flex align="center" gap={2}>
<Slot
bgColorScheme="blue"
spec={
<Text>
Lv.&nbsp;<b>4</b>
</Text>
}
>
<Image
src={item.item_icon}
transform={{ base: undefined, sm: "scale(2)" }}
/>
</Slot>
<Icon
as={RxPlus}
boxSize={8}
strokeWidth={2}
color={"gray" + palette600}
/>
<Slot bgColorScheme="purple" spec={<Text>1 / 5</Text>}>
<Image
src={GRINDSTONE}
transform={{ base: undefined, sm: "scale(2)" }}
/>
</Slot>
<Icon
as={RxDoubleArrowRight}
boxSize={8}
strokeWidth={2}
color={"gray" + palette600}
/>
<Slot
bgColorScheme="blue"
spec={
<Text>
Lv.&nbsp;<b>5</b>
</Text>
}
>
<Image
src={item.item_icon}
transform={{ base: undefined, sm: "scale(2)" }}
/>
</Slot>
</Flex>
<Flex justify="center" gap={1}>
<IconButton aria-label="decrease" size="xs" icon={<FaMinus />} />
<IconButton aria-label="decrease" size="xs" icon={<FaPlus />} />
<Button size="xs">MAX</Button>
</Flex>
<Flex justify="center" py={2} gap={2}>
<Tag fontSize={12}>
<b>성공 확률</b>&nbsp; 10%
</Tag>
<Tag>
<Image src={MESO} pr={2} />
<Text fontSize={12}>500,000,000</Text>
</Tag>
</Flex>
<Flex justify="center">
<Button
w={{ base: "100%", md: "auto" }}
px={8}
size="sm"
colorScheme="blue"
leftIcon={<FaPlusCircle />}
>
강화
</Button>
</Flex>
</Stack>
);
}
54 changes: 54 additions & 0 deletions frontend/src/pages/enhance/7-execute/grindStone/slot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { AspectRatio, Box, Flex, useColorMode } from "@chakra-ui/react";

export default function Slot({
bgColorScheme,
spec,
children,
}: {
bgColorScheme: string;
spec?: React.ReactNode;
children?: React.ReactNode;
}) {
const { colorMode } = useColorMode();
const dark = colorMode === "dark";
const palette50 = dark ? ".900" : ".50";
const palette200 = dark ? ".600" : ".200";
const palette400 = dark ? ".500" : ".400";

return (
<AspectRatio
as={Flex}
ratio={1}
flex={1}
justify="center"
align="center"
bgColor={bgColorScheme + palette50}
borderRadius={4}
>
<Box p={2}>
<Flex
w="100%"
h="100%"
borderWidth={bgColorScheme == "blue" ? 2 : undefined}
borderStyle="dashed"
borderRadius={2}
borderColor={"gray" + palette400}
justify="center"
align="center"
>
{children}
<Box
position="absolute"
bottom={1}
px={2}
fontSize={12}
bgColor={bgColorScheme + palette200}
borderRadius="full"
>
{spec}
</Box>
</Flex>
</Box>
</AspectRatio>
);
}
26 changes: 26 additions & 0 deletions frontend/src/pages/enhance/common/itemIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Box, Image } from "@chakra-ui/react";
import { ItemEquipmentDetail } from "../../../types/character/itemEquipment/itemEquipment";
import { getSpecialRingIcon } from "../../../utils/icon";

export default function ItemIcon({
item,
opacity,
}: {
item: ItemEquipmentDetail;
opacity?: number;
}) {
return (
<Box>
<Image src={item?.item_icon} opacity={opacity} maxW="none" />
{item?.special_ring_level ? (
<Image
position="absolute"
left={1}
bottom={1}
src={getSpecialRingIcon(item?.special_ring_level)}
opacity={opacity}
/>
) : undefined}
</Box>
);
}
12 changes: 2 additions & 10 deletions frontend/src/pages/enhance/common/itemTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
POTENTIAL_INFOS,
} from "../../../constants/enhance/potential";
import { getMaxGrade, parseGrade } from "../../../services/enhance/potential";
import { getSpecialRingIcon } from "../../../utils/icon";
import ItemIcon from "./itemIcon";

export default function ItemToolTip({ item }: { item: ItemEquipmentDetail }) {
const grade = getMaxGrade(item);
Expand Down Expand Up @@ -149,15 +149,7 @@ function ImageAndReqLevel({
borderColor={potentialColor}
backgroundColor="gray.300"
>
<Image src={item.item_icon} style={{ imageRendering: "pixelated" }} />
{item.special_ring_level ? (
<Image
position="absolute"
left={1}
bottom={1}
src={getSpecialRingIcon(Number(item?.special_ring_level))}
/>
) : undefined}
<ItemIcon item={item} />
</Flex>
{potentialColor && (
<Flex align="start">
Expand Down
23 changes: 3 additions & 20 deletions frontend/src/pages/enhance/common/slotButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IconButton, Image, Tooltip } from "@chakra-ui/react";
import { IconButton, Tooltip } from "@chakra-ui/react";
import { ItemEquipmentDetail } from "../../../types/character/itemEquipment/itemEquipment";
import ItemToolTip from "./itemTooltip";
import { getMaxGrade } from "../../../services/enhance/potential";
import { POTENTIAL_INFOS } from "../../../constants/enhance/potential";
import { getSpecialRingIcon } from "../../../utils/icon";
import ItemIcon from "./itemIcon";

export default function SlotButton({
item,
Expand Down Expand Up @@ -35,24 +35,7 @@ export default function SlotButton({
grade && !transparent ? POTENTIAL_INFOS[grade].borderColor : undefined
}
colorScheme={colorScheme}
icon={
<>
<Image
src={item?.item_icon}
opacity={transparent ? 0.1 : 1}
maxW="none"
/>
{item?.special_ring_level ? (
<Image
position="absolute"
left={1}
bottom={1}
src={getSpecialRingIcon(item?.special_ring_level)}
opacity={transparent ? 0.1 : 1}
/>
) : undefined}
</>
}
icon={<ItemIcon item={item} opacity={transparent ? 0.1 : 1} />}
onClick={onClick}
/>
</Tooltip>
Expand Down

0 comments on commit 4e63eae

Please sign in to comment.