diff --git a/src/App.tsx b/src/App.tsx index 54769c5..8f9afed 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,24 +5,27 @@ import { machine } from "./machine"; import { useMachine } from "@xstate/react"; function App() { - const [state, send] = useMachine(machine); + const [state, send] = useMachine(machine); - const deckNames = exportDecks.map((deck) => deck.name); - function handleChoose(name1: string, name2: string) { - const deck = exportDecks.find((deck) => deck.name === name1)!; - const deck2 = exportDecks.find((deck) => deck.name === name2)!; - send({ type: "choose_decks", player1Cards: deck.deck().cards, player2Cards: deck2.deck().cards }); - } - - return ( - <> - {state.matches("SelectDecks") && ( - - )} - {state.matches("Play") && - } - - ); + const deckNames = exportDecks.map((deck) => deck.name); + function handleChoose(name1: string, name2: string) { + const deck = exportDecks.find((deck) => deck.name === name1)!; + const deck2 = exportDecks.find((deck) => deck.name === name2)!; + send({ + type: "choose_decks", + player1Cards: deck.deck().cards, + player2Cards: deck2.deck().cards, + }); + } + + return ( + <> + {state.matches("SelectDecks") && ( + + )} + {state.matches("Play") && } + + ); } export default App; diff --git a/src/DeckSelectScreen.tsx b/src/DeckSelectScreen.tsx index 0ae9343..91aea8b 100644 --- a/src/DeckSelectScreen.tsx +++ b/src/DeckSelectScreen.tsx @@ -1,54 +1,67 @@ import { FormEvent, ReactNode, useState } from "react"; import { exportDecks } from "./engine/CardMap"; -import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./components/ui/dropdown-menu"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "./components/ui/dropdown-menu"; import { Button } from "./components/ui/button"; import { ChevronDownIcon } from "./components/ChevronDownIcon"; export function DeckDropdownMenu({ - buttonContent, - onChange, - deckNames - }: { - buttonContent: ReactNode; - onChange: (deckName: string) => void; - deckNames: string[]; - }) { - return ( - - - - - - {deckNames.map((deckName, i) => ( - onChange(deckName)}>{deckName} - ))} - - - ); - } + buttonContent, + onChange, + deckNames, +}: { + buttonContent: ReactNode; + onChange: (deckName: string) => void; + deckNames: string[]; +}) { + return ( + + + + + + {deckNames.map((deckName, i) => ( + onChange(deckName)}> + {deckName} + + ))} + + + ); +} -export function DeckSelectScreen({ onChoose, deckNames }: { onChoose: (a: string, b:string) => void, deckNames: string[] }) { +export function DeckSelectScreen({ + onChoose, + deckNames, +}: { + onChoose: (a: string, b: string) => void; + deckNames: string[]; +}) { + const [p1, setP1] = useState(deckNames[0]); + const [p2, setP2] = useState(deckNames[0]); - const [p1, setP1] = useState(deckNames[0]); - const [p2, setP2] = useState(deckNames[0]); - - function handleClick() { - // dont trigger choose if not valid - if (deckNames.includes(p1) && deckNames.includes(p2)) { - onChoose(p1, p2); - } + function handleClick() { + // dont trigger choose if not valid + if (deckNames.includes(p1) && deckNames.includes(p2)) { + onChoose(p1, p2); } + } - return (
-
+
); } - diff --git a/src/PlayGameScreen.tsx b/src/PlayGameScreen.tsx index f466d1e..de58e11 100644 --- a/src/PlayGameScreen.tsx +++ b/src/PlayGameScreen.tsx @@ -14,22 +14,15 @@ export function dumbStupidFunction(r: number) { } } - export default function PlayGameScreen({ game }: { game: Game }) { - const [, forceUpdate] = useState(0); - function setBegin(b: boolean) { - if (b) { - location.reload(); - } + const [, forceUpdate] = useState(0); + function setBegin(b: boolean) { + if (b) { + location.reload(); } - return ( - - ); } - - - - + return ; +} /** * @author Tanner Brown @@ -39,7 +32,7 @@ export default function PlayGameScreen({ game }: { game: Game }) { * @param player: gotta know which player we rendering * @returns markup that shows what I just wrote above */ -export function PlayerDisplay({ player }: { player: Player; }) { +export function PlayerDisplay({ player }: { player: Player }) { return (
@@ -60,10 +53,10 @@ export function PlayerDisplay({ player }: { player: Player; }) { * @param game: the actual game object. board: the board from the game. why do i pass this as a parameter even? setHover: magnify the cards when hovered. */ - - export function Board({ - game, board, setHover, + game, + board, + setHover, }: { game: Game; board: SidedBoard; @@ -84,7 +77,7 @@ export function Board({ landscapeColor: board.getBoardPosByOwnerId(p1.id, i)?.landscape, setHover: setHover, //building: game.board.getBoardPosByOwnerId(0, i)?.building - }) + }), ); p2Board.push( @@ -94,7 +87,7 @@ export function Board({ landscapeColor: board.getBoardPosByOwnerId(p1.id, i)?.landscape, setHover: setHover, //building: game.board.getBoardPosByOwnerId(1, i)?.building, - }) + }), ); } @@ -122,10 +115,13 @@ export function Board({ * phase: the current turn phase. needed for exclusivity reasons. setHover: statechange for magnifying cards. */ - - export function HandOfCards({ - playerHand, stateChange, currentPlayer, ownerPlayer, phase, setHover, + playerHand, + stateChange, + currentPlayer, + ownerPlayer, + phase, + setHover, }: { playerHand: Card[]; stateChange: React.Dispatch>; @@ -148,7 +144,7 @@ export function HandOfCards({ currentPlayer: currentPlayer, position: i, phase: phase, - }) + }), ); //not really relevant anymore since back-end axed spells/buildings, but in case we have time and they re-implement them i see no reason to remove this // else statement. currently does not execute @@ -162,7 +158,7 @@ export function HandOfCards({ ownerPlayer: ownerPlayer, currentPlayer: currentPlayer, phase: phase, - }) + }), ); } } @@ -180,7 +176,12 @@ export function HandOfCards({ * @returns markup for summoning buttons */ export function SummoningButtons({ - cardPos, game, setSummonState, playerid, log, setLog, + cardPos, + game, + setSummonState, + playerid, + log, + setLog, }: { cardPos: number; game: Game; @@ -218,7 +219,7 @@ export function SummoningButtons({ type="button" onClick={function () { handle(0, playerid); - } } + }} > Zone 1 @@ -226,7 +227,7 @@ export function SummoningButtons({ type="button" onClick={function () { handle(1, playerid); - } } + }} > Zone 2 @@ -234,7 +235,7 @@ export function SummoningButtons({ type="button" onClick={function () { handle(2, playerid); - } } + }} > Zone 3 @@ -242,7 +243,7 @@ export function SummoningButtons({ type="button" onClick={function () { handle(3, playerid); - } } + }} > Zone 4 @@ -258,7 +259,11 @@ export function SummoningButtons({ * @returns mark up for attacking buttons */ export function AttackingButtons({ - player, game, reset, resetState, setBegin, + player, + game, + reset, + resetState, + setBegin, }: { player: Player; game: Game; @@ -272,7 +277,7 @@ export function AttackingButtons({ game.simulateCombat(boardPos, playerid); if (game.getOtherPlayer(player.id).hp <= 0) { alert( - `${player.username} has won. Press OK to return to deck select screen.` + `${player.username} has won. Press OK to return to deck select screen.`, ); setBegin(false); } @@ -284,7 +289,7 @@ export function AttackingButtons({ type="button" onClick={function () { handle(0, playerid); - } } + }} > Attack with monster at zone 1 @@ -292,7 +297,7 @@ export function AttackingButtons({ type="button" onClick={function () { handle(1, playerid); - } } + }} > Attack with monster at zone 2 @@ -300,7 +305,7 @@ export function AttackingButtons({ type="button" onClick={function () { handle(2, playerid); - } } + }} > Attack with monster at zone 3 @@ -308,7 +313,7 @@ export function AttackingButtons({ type="button" onClick={function () { handle(3, playerid); - } } + }} > Attack with monster at zone 4 @@ -320,7 +325,10 @@ export function AttackingButtons({ * @returns markup that displays the gamelog in the browser */ export function GameLog({ - turn, phase, currentPlayer, log, + turn, + phase, + currentPlayer, + log, }: { turn: number; phase: number; @@ -352,7 +360,8 @@ export function GameLog({ ); } export let globalTempVariable = -1; -export const setGlobalTempVariable = (val: number) => globalTempVariable = val; +export const setGlobalTempVariable = (val: number) => + (globalTempVariable = val); /** * @author Tanner Brown * So basically this is the markup that sits on the left of the screen. If its null (ie. no one has hovered a card yet) then its blank. However, if a card @@ -361,7 +370,7 @@ export const setGlobalTempVariable = (val: number) => globalTempVariable = val; * @param param0 * @returns */ -export function HoverCard({ card }: { card: Creature; }) { +export function HoverCard({ card }: { card: Creature }) { if (card === null) { return
; } @@ -376,7 +385,8 @@ export function HoverCard({ card }: { card: Creature; }) { style={{ objectFit: "cover", }} - width={350} /> + width={350} + />

{card.name}

@@ -404,7 +414,7 @@ export function HoverCard({ card }: { card: Creature; }) { * @returns Markup to display the game * @param game: the game object we're rendering. setBegin: when we set this as true the game ends and we go backto deck select screen */ -export function GameBoard({ game, setBegin }: { game: Game; setBegin: any; }) { +export function GameBoard({ game, setBegin }: { game: Game; setBegin: any }) { // grab our players. a lot of components need this guys as parameters let player1 = game.getPlayerById(0); let player2 = game.getPlayerById(1); @@ -595,7 +605,12 @@ export function GameBoard({ game, setBegin }: { game: Game; setBegin: any; }) { */ export function PhaseButton({ - game, imagePath, setPhase, setTurn, setCurrentPlayer, setSummoning, + game, + imagePath, + setPhase, + setTurn, + setCurrentPlayer, + setSummoning, }: { game: Game; imagePath: string; @@ -617,4 +632,3 @@ export function PhaseButton({ ); } - diff --git a/src/assets/bog-frog-bomb.png b/src/assets/bog-frog-bomb.png new file mode 100644 index 0000000..bf2219d Binary files /dev/null and b/src/assets/bog-frog-bomb.png differ diff --git a/src/assets/dr-stuffenstein.png b/src/assets/dr-stuffenstein.png new file mode 100644 index 0000000..58774cb Binary files /dev/null and b/src/assets/dr-stuffenstein.png differ diff --git a/src/assets/furious-chick.png b/src/assets/furious-chick.png new file mode 100644 index 0000000..9e53a3a Binary files /dev/null and b/src/assets/furious-chick.png differ diff --git a/src/assets/ms-mummy.png b/src/assets/ms-mummy.png new file mode 100644 index 0000000..c34d1ab Binary files /dev/null and b/src/assets/ms-mummy.png differ diff --git a/src/assets/mud-angel.png b/src/assets/mud-angel.png new file mode 100644 index 0000000..2f7fa27 Binary files /dev/null and b/src/assets/mud-angel.png differ diff --git a/src/assets/pieclops.png b/src/assets/pieclops.png new file mode 100644 index 0000000..9f17fb0 Binary files /dev/null and b/src/assets/pieclops.png differ diff --git a/src/assets/prickle.png b/src/assets/prickle.png new file mode 100644 index 0000000..5eb4dfc Binary files /dev/null and b/src/assets/prickle.png differ diff --git a/src/assets/sand-angel.png b/src/assets/sand-angel.png new file mode 100644 index 0000000..f5ee8f3 Binary files /dev/null and b/src/assets/sand-angel.png differ diff --git a/src/assets/sand-eyebat.png b/src/assets/sand-eyebat.png new file mode 100644 index 0000000..d933ae5 Binary files /dev/null and b/src/assets/sand-eyebat.png differ diff --git a/src/assets/sand-jackal.png b/src/assets/sand-jackal.png new file mode 100644 index 0000000..23381e8 Binary files /dev/null and b/src/assets/sand-jackal.png differ diff --git a/src/assets/sand-knight.png b/src/assets/sand-knight.png new file mode 100644 index 0000000..ee6208f Binary files /dev/null and b/src/assets/sand-knight.png differ diff --git a/src/assets/sand-snake.png b/src/assets/sand-snake.png new file mode 100644 index 0000000..449a1e8 Binary files /dev/null and b/src/assets/sand-snake.png differ diff --git a/src/assets/sand-witch.png b/src/assets/sand-witch.png new file mode 100644 index 0000000..12746df Binary files /dev/null and b/src/assets/sand-witch.png differ diff --git a/src/assets/sandasaurus-rex.png b/src/assets/sandasaurus-rex.png new file mode 100644 index 0000000..7e8e6de Binary files /dev/null and b/src/assets/sandasaurus-rex.png differ diff --git a/src/assets/sandbacho.png b/src/assets/sandbacho.png new file mode 100644 index 0000000..ac91e6c Binary files /dev/null and b/src/assets/sandbacho.png differ diff --git a/src/assets/sandfoot.png b/src/assets/sandfoot.png new file mode 100644 index 0000000..a5e8a1a Binary files /dev/null and b/src/assets/sandfoot.png differ diff --git a/src/assets/wall-of-chocolate.png b/src/assets/wall-of-chocolate.png new file mode 100644 index 0000000..c42bdd5 Binary files /dev/null and b/src/assets/wall-of-chocolate.png differ diff --git a/src/components/Card.tsx b/src/components/Card.tsx index f0327a4..839ab4d 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -15,7 +15,13 @@ import { CreatureComponentOnBoard } from "./Creature"; * player the cards are assigned to. phase: current turn phase. needed for making events phase exclusive */ export function CardComponent({ - card, state, position, setHover, currentPlayer, ownerPlayer, phase, + card, + state, + position, + setHover, + currentPlayer, + ownerPlayer, + phase, }: { card: Card | Creature; children?: ReactNode; @@ -49,7 +55,9 @@ export function CardComponent({ return ( ); -}/** +} /** * @author Tanner Brown * I spoke about this in my documentation on the CreatureComponentOnBoard component. Check there for why this is a thing * @param param0 * @returns */ export function CardComponentOnBoard({ - card, setHover, + card, + setHover, }: { card: Card | Creature; children?: ReactNode; @@ -99,7 +109,7 @@ export function CardComponentOnBoard({ className={className} onMouseOver={() => { setHover(card); - } } + }} >
+ width={350} + />

{card.name}

@@ -130,7 +141,10 @@ export function CardComponentOnBoard({ */ export function LandscapeCard({ //building, - creature, player, landscapeColor, setHover, + creature, + player, + landscapeColor, + setHover, }: { //building: Building | undefined; creature: Creature | undefined; @@ -153,13 +167,14 @@ export function LandscapeCard({ // } return (
{c} {/* {b} */}
); } - diff --git a/src/components/Creature.tsx b/src/components/Creature.tsx index d976505..5019949 100644 --- a/src/components/Creature.tsx +++ b/src/components/Creature.tsx @@ -12,7 +12,13 @@ import { CardComponent, CardComponentOnBoard } from "./Card"; * @returns CardComponent, but with attack/defense values */ export function CreatureComponent({ - card, state, position, setHover, currentPlayer, ownerPlayer, phase, + card, + state, + position, + setHover, + currentPlayer, + ownerPlayer, + phase, }: { card: Creature; state: React.Dispatch>; @@ -41,14 +47,15 @@ export function CreatureComponent({ {child} ); -}/** +} /** * Kinda dumb, but since cards on board have different function than ones in hand I felt this was necessary. Currently, this just is the other creature/card * component but without triggering summoning buttons * @param param0 * @returns */ export function CreatureComponentOnBoard({ - card, setHover, + card, + setHover, }: { card: Creature; setHover: any; @@ -66,4 +73,3 @@ export function CreatureComponentOnBoard({ > ); } - diff --git a/src/components/Deck.tsx b/src/components/Deck.tsx index 333cce1..3a02a81 100644 --- a/src/components/Deck.tsx +++ b/src/components/Deck.tsx @@ -1,7 +1,4 @@ -import { - Game, - Player -} from "../engine/game"; +import { Game, Player } from "../engine/game"; import { dumbStupidFunction } from "../PlayGameScreen"; /** @@ -12,7 +9,12 @@ import { dumbStupidFunction } from "../PlayGameScreen"; * log: the log. needed for if player cannot draw anymore and game must tell player as such. setLog: useState for re-rendering log. game: the game object */ export function Deck({ - player, resetState, reset, log, setLog, game, + player, + resetState, + reset, + log, + setLog, + game, }: { player: Player; resetState: any; @@ -39,7 +41,9 @@ export function Deck({ return (