Skip to content

Commit

Permalink
Che bato/custom decks (#25)
Browse files Browse the repository at this point in the history
- Renamed S3Assets to S3Utils
- Added utility functions to convert deck data from SWUDB to deck data
compatible with the server. Located in the s3Utils.ts
- Added a new GET method in the API/S3Bucket/route.ts to receive json
files from the S3Bucket.
  • Loading branch information
CheBato authored Dec 11, 2024
1 parent df58591 commit 2b07569
Show file tree
Hide file tree
Showing 50 changed files with 409 additions and 176 deletions.
2 changes: 1 addition & 1 deletion src/app/GameBoard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use client";
import React, { useState, useRef, useEffect, useContext } from "react";
import { Box, Grid2 as Grid } from "@mui/material";
import { s3ImageURL } from "../_utils/s3Assets";
import { s3ImageURL } from "../_utils/s3Utils";
import ChatDrawer from "../_components/Gameboard/_subcomponents/Overlays/ChatDrawer/ChatDrawer";
import OpponentCardTray from "../_components/Gameboard/OpponentCardTray/OpponentCardTray";
import Board from "../_components/Gameboard/Board/Board";
Expand Down
4 changes: 2 additions & 2 deletions src/app/_components/Auth/AuthTypes.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";

export interface LoginProps {
export interface ILoginProps {
handleSubmit: (provider: "google" | "discord") => void;
}

export interface StyledTextFieldProps {
export interface IStyledTextFieldProps {
variant?: "outlined" | "filled" | "standard";
fullWidth?: boolean;
value?: string | null;
Expand Down
4 changes: 2 additions & 2 deletions src/app/_components/Auth/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import React from "react";
import { Box, Button, Card, CardContent, Typography } from "@mui/material";
import { LoginProps } from "../AuthTypes";
import { ILoginProps } from "../AuthTypes";

const Login: React.FC<LoginProps> = ({ handleSubmit }) => {
const Login: React.FC<ILoginProps> = ({ handleSubmit }) => {
//------------------------STYLES------------------------//
const loginStyles = {
container: {
Expand Down
4 changes: 2 additions & 2 deletions src/app/_components/ClientProviders/ClientProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { ThemeContextProvider } from "@/app/_contexts/Theme.context";
import { UserProvider } from "@/app/_contexts/User.context";
import { SessionProvider } from "next-auth/react";

interface ClientProvidersProps {
interface IClientProvidersProps {
children: React.ReactNode;
}

const ClientProviders: React.FC<ClientProvidersProps> = ({ children }) => {
const ClientProviders: React.FC<IClientProvidersProps> = ({ children }) => {
return (
<SessionProvider>
<UserProvider>
Expand Down
4 changes: 2 additions & 2 deletions src/app/_components/Gameboard/Board/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from "react";
import Grid from "@mui/material/Grid2";
import UnitsBoard from "../_subcomponents/UnitsBoard";
import LeaderBaseBoard from "../../_sharedcomponents/LeaderBaseBoard/LeaderBaseBoard";
import { BoardProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IBoardProps } from "@/app/_components/Gameboard/GameboardTypes";

const Board: React.FC<BoardProps> = ({
const Board: React.FC<IBoardProps> = ({
sidebarOpen,
}) => {
//----------------Styles----------------//
Expand Down
38 changes: 19 additions & 19 deletions src/app/_components/Gameboard/GameboardTypes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { CardData } from "@/app/_components/_sharedcomponents/Cards/CardTypes";
import { ICardData } from "@/app/_components/_sharedcomponents/Cards/CardTypes";

export type ParticipantType = "player" | "opponent";
export type IParticipantType = "player" | "opponent";

export interface Participant {
export interface IParticipant {
id: string;
name: string;
type: ParticipantType;
type: IParticipantType;
initiative: boolean | null;
deckSize: number;
cards: CardData[];
fullDeck: CardData[];
cards: ICardData[];
fullDeck: ICardData[];
}

export interface ChatDrawerProps {
export interface IChatDrawerProps {
sidebarOpen: boolean;
toggleSidebar: () => void;
chatHistory: string[];
Expand All @@ -22,48 +22,48 @@ export interface ChatDrawerProps {
currentRound: number;
}

export interface PlayerCardTrayProps {
export interface IPlayerCardTrayProps {
trayPlayer: string;
handleModalToggle: () => void;
handleBasicPromptToggle: () => void;
}

export interface OpponentCardTrayProps {
export interface IOpponentCardTrayProps {
trayPlayer: string;
}

export interface BoardProps {
export interface IBoardProps {
sidebarOpen: boolean;
}

export interface DeckDiscardProps {
export interface IDeckDiscardProps {
trayPlayer: string;
}

export interface ResourcesProps {
export interface IResourcesProps {
trayPlayer: string;
handleModalToggle?: () => void;
}

export interface ResourcesOverlayProps {
export interface IResourcesOverlayProps {
isModalOpen: boolean;
handleModalToggle: () => void;
}

export interface BasicPromptProps {
export interface IBasicPromptProps {
isBasicPromptOpen: boolean;
handleBasicPromptToggle: () => void;
}

export interface CardAreaProps {
cards: CardData[];
export interface ICardAreaProps {
cards: ICardData[];
}

export interface UnitsBoardProps {
export interface IUnitsBoardProps {
sidebarOpen: boolean;
arena: string;
}

export interface PlayerHandProps {
cards: CardData[];
export interface IPlayerHandProps {
cards: ICardData[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Grid from "@mui/material/Grid2";
import Resources from "../_subcomponents/PlayerTray/Resources";
import PlayerHand from "../_subcomponents/PlayerTray/PlayerHand";
import DeckDiscard from "../_subcomponents/PlayerTray/DeckDiscard";
import { OpponentCardTrayProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IOpponentCardTrayProps } from "@/app/_components/Gameboard/GameboardTypes";
import { useGame } from "@/app/_contexts/Game.context";

const OpponentCardTray: React.FC<OpponentCardTrayProps> = ({ trayPlayer }) => {
const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer }) => {
//---------------Styles------------------- //
const leftColumn = {
display: "flex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Resources from "../_subcomponents/PlayerTray/Resources";
import DeckDiscard from "../_subcomponents/PlayerTray/DeckDiscard";
import CardActionTray from "../_subcomponents/PlayerTray/CardActionTray";
import PlayerHand from "../_subcomponents/PlayerTray/PlayerHand";
import { PlayerCardTrayProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IPlayerCardTrayProps } from "@/app/_components/Gameboard/GameboardTypes";
import { useGame } from "@/app/_contexts/Game.context";

const PlayerCardTray: React.FC<PlayerCardTrayProps> = ({
const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({
trayPlayer,
handleModalToggle,
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { forwardRef } from "react";
import { Drawer, Box, IconButton, Typography } from "@mui/material";
import { Settings, Close } from "@mui/icons-material";
import Chat from "@/app/_components/_sharedcomponents/Chat/Chat";
import { ChatDrawerProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IChatDrawerProps } from "@/app/_components/Gameboard/GameboardTypes";

const ChatDrawer = forwardRef<HTMLDivElement, ChatDrawerProps>(
const ChatDrawer = forwardRef<HTMLDivElement, IChatDrawerProps>(
function ChatDrawer(
{
sidebarOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
} from "@mui/material";
import { Close } from "@mui/icons-material";
import { useGame } from "@/app/_contexts/Game.context";
import { BasicPromptProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IBasicPromptProps } from "@/app/_components/Gameboard/GameboardTypes";

const BasicPrompt: React.FC<BasicPromptProps> = ({
const BasicPrompt: React.FC<IBasicPromptProps> = ({
isBasicPromptOpen,
handleBasicPromptToggle,
}) => {
Expand Down Expand Up @@ -54,7 +54,7 @@ const BasicPrompt: React.FC<BasicPromptProps> = ({
{playerState.promptTitle || ""}
</Typography>
<Box>
{playerState.buttons.map((button: ButtonsProps) => (
{playerState.buttons.map((button: IButtonsProps) => (
<PromptButton
key={button.arg}
button={button}
Expand Down Expand Up @@ -82,19 +82,19 @@ const BasicPrompt: React.FC<BasicPromptProps> = ({
);
};

interface PromptButtonProps {
button: ButtonsProps
interface IPromptButtonProps {
button: IButtonsProps
sendGameMessage: (args: [string, string, string]) => void;
}

interface ButtonsProps {
interface IButtonsProps {
command: string;
arg: string;
text: string;
uuid: string;
}

const PromptButton: React.FC<PromptButtonProps> = ({ button, sendGameMessage }) => {
const PromptButton: React.FC<IPromptButtonProps> = ({ button, sendGameMessage }) => {
return (
<Button
variant="contained"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
} from "@mui/material";
import { Close } from "@mui/icons-material";
import CardArea from "../../../../_sharedcomponents/CardArea/CardArea";
import { ResourcesOverlayProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IResourcesOverlayProps } from "@/app/_components/Gameboard/GameboardTypes";
import { useGame } from "@/app/_contexts/Game.context";

const ResourcesOverlay: React.FC<ResourcesOverlayProps> = ({
const ResourcesOverlay: React.FC<IResourcesOverlayProps> = ({
isModalOpen,
handleModalToggle,
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CardActionTray: React.FC = () => {
{playerState.menuTitle}
</Typography>
<Box>
{playerState.buttons.map((button: ButtonsProps) => (
{playerState.buttons.map((button: IButtonsProps) => (
<PromptButton
key={button.arg}
button={button}
Expand All @@ -38,19 +38,19 @@ const CardActionTray: React.FC = () => {
);
};

interface PromptButtonProps {
button: ButtonsProps
interface IPromptButtonProps {
button: IButtonsProps
sendGameMessage: (args: [string, string, string]) => void;
}

interface ButtonsProps {
interface IButtonsProps {
command: string;
arg: string;
text: string;
uuid: string;
}

const PromptButton: React.FC<PromptButtonProps> = ({ button, sendGameMessage }) => {
const PromptButton: React.FC<IPromptButtonProps> = ({ button, sendGameMessage }) => {
return (
<Button
variant="contained"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { Card, CardContent, Box, Typography } from "@mui/material";
import GameCard from "../../../_sharedcomponents/Cards/GameCard/GameCard";
import { DeckDiscardProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IDeckDiscardProps } from "@/app/_components/Gameboard/GameboardTypes";
import { useGame } from "@/app/_contexts/Game.context";

const DeckDiscard: React.FC<DeckDiscardProps> = (
const DeckDiscard: React.FC<IDeckDiscardProps> = (
trayPlayer
) => {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Grid2 as Grid, Box } from "@mui/material";
import { useDragScroll } from "@/app/_utils/useDragScroll";
import GameCard from "@/app/_components/_sharedcomponents/Cards/GameCard/GameCard";
import { PlayerHandProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IPlayerHandProps } from "@/app/_components/Gameboard/GameboardTypes";

const PlayerHand: React.FC<PlayerHandProps> = ({
const PlayerHand: React.FC<IPlayerHandProps> = ({
cards = []
}) => {
const {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { Card, CardContent, Box, Typography } from "@mui/material";
import Image from "next/image";
import { ResourcesProps } from "@/app/_components/Gameboard/GameboardTypes";
import { IResourcesProps } from "@/app/_components/Gameboard/GameboardTypes";
import { useGame } from "@/app/_contexts/Game.context";

const Resources: React.FC<ResourcesProps> = ({
const Resources: React.FC<IResourcesProps> = ({
trayPlayer,
handleModalToggle,
}) => {
Expand Down
10 changes: 5 additions & 5 deletions src/app/_components/Gameboard/_subcomponents/UnitsBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import { Box, Grid2 as Grid } from "@mui/material";
import GameCard from "../../_sharedcomponents/Cards/GameCard/GameCard";
import { CardData } from "../../_sharedcomponents/Cards/CardTypes";
import { UnitsBoardProps } from "@/app/_components/Gameboard/GameboardTypes";
import { ICardData } from "../../_sharedcomponents/Cards/CardTypes";
import { IUnitsBoardProps } from "@/app/_components/Gameboard/GameboardTypes";
import { useGame } from "@/app/_contexts/Game.context";

const UnitsBoard: React.FC<UnitsBoardProps> = ({
const UnitsBoard: React.FC<IUnitsBoardProps> = ({
sidebarOpen,
arena
}) => {
Expand Down Expand Up @@ -53,7 +53,7 @@ const UnitsBoard: React.FC<UnitsBoardProps> = ({
<Grid container direction="column" sx={containerStyle}>
{/* Opponent's Ground Units */}
<Grid sx={opponentGridStyle}>
{opponentUnits.map((card: CardData) => (
{opponentUnits.map((card: ICardData) => (
<Box key={card.id} sx={{ flex: "0 0 auto" }}>
<GameCard card={card} size="square" />
</Box>
Expand All @@ -62,7 +62,7 @@ const UnitsBoard: React.FC<UnitsBoardProps> = ({

{/* Player's Ground Units */}
<Grid sx={playerGridStyle}>
{playerUnits.map((card: CardData) => (
{playerUnits.map((card: ICardData) => (
<Box key={card.id} sx={{ flex: "0 0 auto" }}>
<GameCard card={card} size="square" />
</Box>
Expand Down
18 changes: 9 additions & 9 deletions src/app/_components/HomePage/HomePageTypes.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
export interface HexagonProps {
export interface IHexagonProps {
backgroundColor: string;
}

export interface GameInProgressPlayerProps {
export interface IGameInProgressPlayerProps {
playerImage: string;
}

export interface PublicGameInProgressProps {
export interface IPublicGameInProgressProps {
match: {
player1: GameInProgressPlayerProps;
player2: GameInProgressPlayerProps;
player1: IGameInProgressPlayerProps;
player2: IGameInProgressPlayerProps;
};
}

export interface PublicGamesProps {
export interface IPublicGamesProps {
format: string;
}

export type Article = {
export type IArticle = {
title: string;
content: string;
date: string;
image: string;
imageAlt: string;
};

export interface NewsItemProps {
article: Article;
export interface INewsItemProps {
article: IArticle;
}
4 changes: 2 additions & 2 deletions src/app/_components/HomePage/PublicGames/PublicGames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from "react";
import { Card, CardContent, Typography, Divider } from "@mui/material";
import JoinableGame from "../_subcomponents/JoinableGame/JoinableGame";
import GamesInProgress from "../_subcomponents/GamesInProgress/GamesInProgress";
import { PublicGamesProps } from "../HomePageTypes";
import { IPublicGamesProps } from "../HomePageTypes";

const PublicGames: React.FC<PublicGamesProps> = ({ format }) => {
const PublicGames: React.FC<IPublicGamesProps> = ({ format }) => {

const styles = {
publicGamesWrapper: {
Expand Down
Loading

0 comments on commit 2b07569

Please sign in to comment.