Skip to content

Commit

Permalink
feature: added perspective deck and graveyard;
Browse files Browse the repository at this point in the history
- lifepoints change input bug fix
  • Loading branch information
LucasLimaAZ committed Jun 21, 2024
1 parent eeffbfd commit 0c4a0dc
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 74 deletions.
54 changes: 15 additions & 39 deletions src/components/Deck/index.jsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,33 @@
import React from "react";
import CardIMG from "../../assets/img/yugioh-back.jpg";
import useDeck from "../../shared/hooks/deck";
import { Box, Paper, Typography } from "@mui/material";
import { Box, Typography } from "@mui/material";
import useField from "../../shared/hooks/field";

const Deck = () => {
const { drawCard, deck } = useDeck();
const { rotateBoard } = useField();

return (
<Paper
<Box
sx={{
paddingX: "2%",
margin: "30px 0 2% 0",
backgroundColor: "rgba(255, 255, 255, 0.2);",
cursor: "pointer",
}}
onClick={drawCard}
>
<Box
sx={{
cursor: "pointer",
img: {
width: "70%",
},
width: "100%",
transform: rotateBoard && "rotate(180deg)",
}}
onClick={drawCard}
>
<Box
sx={{ marginTop: "15%" }}
component="img"
src={CardIMG}
alt="deckcard"
/>
<Box
sx={{ marginTop: "-300px", marginLeft: "5px" }}
component="img"
src={CardIMG}
alt="deckcard"
/>
<Box
sx={{ marginTop: "-298px", marginLeft: "7px" }}
component="img"
src={CardIMG}
alt="deckcard"
/>
<Box
sx={{ marginTop: "-296px", marginLeft: "9px" }}
component="img"
src={CardIMG}
alt="deckcard"
/>
<Box>
<Typography>{deck}</Typography>
</Box>
component="img"
src={CardIMG}
alt="deckcard"
/>
<Box>
<Typography textAlign="center">{deck}</Typography>
</Box>
</Paper>
</Box>
);
};

Expand Down
33 changes: 12 additions & 21 deletions src/components/Graveyard/index.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
import React from "react";
import useGraveyard from "../../shared/hooks/graveyard";
import { Box, Typography, Paper } from "@mui/material";
import { Box, Typography } from "@mui/material";

const Graveyard = () => {
const { graveyard } = useGraveyard();

return (
<Paper
<Box
sx={{
paddingX: "2%",
margin: "30px 0 2% 0",
backgroundColor: "rgba(255, 255, 255, 0.2);",
maxHeight: "300px",
overflow: "auto",
padding: "2%",
}}
>
<Box
sx={{
marginTop: "30px",
maxHeight: "300px",
overflow: "auto",
padding: "2%",
}}
>
<Typography variant="body1">Graveyard({graveyard.length}): </Typography>
{graveyard?.map((card, index) => (
<Box key={index}>
<Typography variant="caption">{card.name}</Typography>
</Box>
))}
</Box>
</Paper>
<Typography variant="body1">Graveyard({graveyard.length}): </Typography>
{graveyard?.map((card, index) => (
<Box key={index}>
<Typography variant="caption">{card.name}</Typography>
</Box>
))}
</Box>
);
};

Expand Down
6 changes: 5 additions & 1 deletion src/components/attackCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ const AttackModal = (props) => {
variant="h4"
sx={{ color: "red", textShadow: "2px 2px rgba(0,0,0,0.3)" }}
>
- {Math.abs(attack - props.card?.atk) || 0}
-{" "}
{Math.abs(
attack -
(props.card.def_mode ? props.card?.def : props.card?.atk)
) || 0}
</Typography>
)}
</Box>
Expand Down
8 changes: 1 addition & 7 deletions src/components/container/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Grid, Box } from "@mui/material";
import ScoreBoard from "../scoreboard";
import Deck from "../deck";
import Graveyard from "../graveyard";
import ToolBar from "../toolBar";
import Field from "../field";

Expand All @@ -19,11 +17,7 @@ const Container = () => {
<Grid item xs={12}>
<ScoreBoard />
</Grid>
<Grid item xs={2}>
<Deck />
<Graveyard />
</Grid>
<Grid item xs={10}>
<Grid item xs={12}>
<Field />
</Grid>
<Grid item xs={12}>
Expand Down
10 changes: 9 additions & 1 deletion src/components/field/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Card from "../card";
import useField from "../../shared/hooks/field";
import { Box, Paper } from "@mui/material";
import Deck from "../deck";
import Graveyard from "../graveyard";

const Field = () => {
const { generateMonster, generateMagicTrap, field, rotateBoard } = useField();
Expand All @@ -21,7 +23,7 @@ const Field = () => {
rotateBoard && {
perspective: "1200px",
maxWidth: "90%",
marginLeft: "5%",
margin: "auto",
}
}
>
Expand All @@ -34,6 +36,9 @@ const Field = () => {
}}
>
<Box display="flex" gap="64px" justifyContent="space-between">
<Box sx={{ width: "100%" }} key={"deck"}>
<Deck />
</Box>
{[...Array(5)].map((_, i) => (
<Box
sx={{ width: "100%" }}
Expand All @@ -50,6 +55,9 @@ const Field = () => {
gap="64px"
justifyContent="space-between"
>
<Box sx={{ width: "100%" }} key={"grave"}>
<Graveyard />
</Box>
{[...Array(5)].map((_, i) => (
<Box
sx={{ width: "100%" }}
Expand Down
12 changes: 8 additions & 4 deletions src/components/scoreboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ const ScoreBoard = () => {
setLpInput(e.target.value);
};

const handleLpOptionChange = (_, newInputValue) => {
setLpInput(newInputValue);
const handleLpOptionChange = ({ _reactName }, newInputValue) => {
if (_reactName !== "onBlur") {
setLpInput(newInputValue);
}
};

const handleOpponentInputChange = (e) => {
setOpponentLpInput(e.target.value);
};

const handleOpponentOptionChange = (_, newInputValue) => {
setOpponentLpInput(newInputValue);
const handleOpponentOptionChange = ({ _reactName }, newInputValue) => {
if (_reactName !== "onBlur") {
setOpponentLpInput(newInputValue);
}
};

const handleResetDuel = () => {
Expand Down
7 changes: 6 additions & 1 deletion src/shared/cardLists/damageSpellCards.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
"5318639",
"88279736",
"82003859",
"4031928"
"4031928",
"66788016",
"87910978",
"45986603",
"42703248",
"19159413"
]

0 comments on commit 0c4a0dc

Please sign in to comment.