From e99b2a75bd8a5126145448ca76e4425a22569145 Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 03:52:16 +0100 Subject: [PATCH 1/6] add boost commands and add boost removal and cancel from regular commit actions --- components/DeckPool/PoolFns.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/components/DeckPool/PoolFns.ts b/components/DeckPool/PoolFns.ts index dbe3926..514aae5 100644 --- a/components/DeckPool/PoolFns.ts +++ b/components/DeckPool/PoolFns.ts @@ -181,10 +181,30 @@ export const commitCard = (pool: PoolType, cardIndex: number): PoolType => { return pool; }; +export const boostCard = (pool: PoolType, cardIndex: number): PoolType => { + if (!pool?.hand) return pool; + pool.commit.boost = pool.hand[cardIndex]; + pool.hand.splice(cardIndex, 1); + return pool; +}; + +export const cancelBoost = (pool: PoolType): PoolType => { + if (!pool?.commit.boost) return pool; + pool.hand.push(pool.commit.boost); + pool.commit.boost = null; + return pool; +}; + export const discardCommit = (pool: PoolType): PoolType => { if (!pool.commit.main) return pool; pool.discard.push(pool.commit.main); pool.commit.main = null; + + if (pool.commit.boost) { + pool.discard.push(pool.commit.boost); + pool.commit.boost = null; + } + pool.commit.reveal = false; return pool; }; @@ -194,6 +214,12 @@ export const cancelCommit = (pool: PoolType): PoolType => { pool.hand.push(pool.commit.main); pool.commit.main = null; pool.commit.reveal = false; + + if (pool.commit.boost) { + pool.hand.push(pool.commit.boost); + pool.commit.boost = null; + } + return pool; }; From f92b49bf2fd691738fe6a9d61fafeec0143e656c Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 03:52:28 +0100 Subject: [PATCH 2/6] add boost actions to the hand --- components/Game/Hand/hand.container.tsx | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/components/Game/Hand/hand.container.tsx b/components/Game/Hand/hand.container.tsx index 9733b82..069e67b 100644 --- a/components/Game/Hand/hand.container.tsx +++ b/components/Game/Hand/hand.container.tsx @@ -1,5 +1,7 @@ import { PoolType, + boostCard, + cancelBoost, commitCard, discardCard, draw, @@ -16,6 +18,7 @@ import { HandCardItems } from "../game.carousel"; import styled from "@emotion/styled"; import { flow } from "lodash"; import { ModalType } from "@/pages/game"; +import { CloseIcon } from "@chakra-ui/icons"; export const HandContainer = ({ setModal, @@ -47,6 +50,12 @@ export const HandContainer = ({ const gDraw = flow(draw, setGameState); const gDiscard = flow(discardCard, setGameState); + const gBoost = flow( + (cardIndex: number) => + playerState?.pool && boostCard(playerState.pool, cardIndex), + setGameState, + ); + const gCancelBoost = flow(cancelBoost, setGameState); const gCommit = flow( (cardIndex: number) => playerState?.pool && commitCard(playerState?.pool, cardIndex), @@ -67,13 +76,29 @@ export const HandContainer = ({ setModal("deck")}>Deck setModal("discard")}>Discard + {playerState?.pool?.commit?.boost && ( + gCancelBoost(playerState?.pool as PoolType)} + > + Boost: {playerState?.pool?.commit?.boost?.boost} + + + )} - playerState?.pool && gDiscard(playerState?.pool, discardIndex), + gDiscard(playerState?.pool as PoolType, discardIndex), commitFn: (cardIndex: number) => gCommit(cardIndex), + boostFn: (cardIndex: number) => gBoost(cardIndex), }} /> From 7b8af36dc9449f8421b0f54ee70c03bdcda01ac6 Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 03:52:38 +0100 Subject: [PATCH 3/6] add boostfn --- components/Game/game.carousel.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/Game/game.carousel.tsx b/components/Game/game.carousel.tsx index 02f06d6..05c25b3 100644 --- a/components/Game/game.carousel.tsx +++ b/components/Game/game.carousel.tsx @@ -11,6 +11,7 @@ import { } from "../DeckPool/deck-import.type"; import styled from "@emotion/styled"; import { CarouselTray } from "./game.styles"; +import { PoolType } from "../DeckPool/PoolFns"; const handleDragStart = (e) => { e.preventDefault(); @@ -21,8 +22,9 @@ const { cards: mockCards } = mockDeck.deck_data; type CardWrapperProps = { cards: DeckImportCardType[] | undefined; functions: { - discardFn: (index: number) => PoolType; + discardFn: (index: number) => void; commitFn: (index: number) => PoolType; + boostFn: (index: number) => PoolType; }; }; export const cardItemMapper = ({ cards, functions }: CardWrapperProps) => { @@ -42,7 +44,6 @@ export const cardItemMapper = ({ cards, functions }: CardWrapperProps) => { > - {/* + */} functions.discardFn(index)}>- @@ -114,6 +115,7 @@ export const HandCardItems: React.FC = ({ functions.commitFn(index)}>+ functions.discardFn(index)}>- + functions.boostFn(index)}>B From ef3b69646315493855e995888a38f262fd8b027b Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 04:20:02 +0100 Subject: [PATCH 4/6] restyle boost text --- components/Game/game.carousel.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/Game/game.carousel.tsx b/components/Game/game.carousel.tsx index 05c25b3..e9c5e63 100644 --- a/components/Game/game.carousel.tsx +++ b/components/Game/game.carousel.tsx @@ -12,6 +12,7 @@ import { import styled from "@emotion/styled"; import { CarouselTray } from "./game.styles"; import { PoolType } from "../DeckPool/PoolFns"; +import { GiUpgrade as IconBoost } from "react-icons/gi"; const handleDragStart = (e) => { e.preventDefault(); @@ -115,7 +116,13 @@ export const HandCardItems: React.FC = ({ functions.commitFn(index)}>+ functions.discardFn(index)}>- - functions.boostFn(index)}>B + functions.boostFn(index)} + > + Boost + From 93cf3bb83f2b15f247b1d2c32dd87f09fc38bccf Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 04:20:09 +0100 Subject: [PATCH 5/6] add boost to the modal commit --- components/Game/game.modal-body.tsx | 41 ++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/components/Game/game.modal-body.tsx b/components/Game/game.modal-body.tsx index 98f21c0..114f3e2 100644 --- a/components/Game/game.modal-body.tsx +++ b/components/Game/game.modal-body.tsx @@ -4,6 +4,8 @@ import { DeckImportCardType } from "../DeckPool/deck-import.type"; import { PoolType } from "../DeckPool/PoolFns"; import { useState } from "react"; +import { GiUpgrade as IconBoost } from "react-icons/gi"; + export const DeckModalContent = ({ cards, add, @@ -78,16 +80,22 @@ const CommitCard: React.FC<{ commit: PlayerCommit }> = ({ commit }) => { if (commit.commit.main === null) return ; const onEnter = () => setIsHover(true); const onLeave = () => setIsHover(false); + const hasBoost = commit.commit.boost !== null; return ( {commit?.player && ( - + + {hasBoost ? :
} {commit.player} @@ -98,7 +106,34 @@ const CommitCard: React.FC<{ commit: PlayerCommit }> = ({ commit }) => { {!commit.commit.reveal ? ( ) : ( - + + + + {commit.commit.boost && ( + <> + + {commit.commit.boost.boost} + + + + )} + + )} From 8f3f438704f54a249f9e86e5e50ec56bfb2e3c6e Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 04:20:25 +0100 Subject: [PATCH 6/6] dont allow boost if a boost exists --- components/DeckPool/PoolFns.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/DeckPool/PoolFns.ts b/components/DeckPool/PoolFns.ts index 514aae5..9a6f1a7 100644 --- a/components/DeckPool/PoolFns.ts +++ b/components/DeckPool/PoolFns.ts @@ -183,6 +183,7 @@ export const commitCard = (pool: PoolType, cardIndex: number): PoolType => { export const boostCard = (pool: PoolType, cardIndex: number): PoolType => { if (!pool?.hand) return pool; + if (pool.commit.boost) return pool; pool.commit.boost = pool.hand[cardIndex]; pool.hand.splice(cardIndex, 1); return pool; @@ -190,18 +191,18 @@ export const boostCard = (pool: PoolType, cardIndex: number): PoolType => { export const cancelBoost = (pool: PoolType): PoolType => { if (!pool?.commit.boost) return pool; - pool.hand.push(pool.commit.boost); + pool.hand.unshift(pool.commit.boost); pool.commit.boost = null; return pool; }; export const discardCommit = (pool: PoolType): PoolType => { if (!pool.commit.main) return pool; - pool.discard.push(pool.commit.main); + pool.discard.unshift(pool.commit.main); pool.commit.main = null; if (pool.commit.boost) { - pool.discard.push(pool.commit.boost); + pool.discard.unshift(pool.commit.boost); pool.commit.boost = null; }