Skip to content

Commit

Permalink
fix: shit now works
Browse files Browse the repository at this point in the history
  • Loading branch information
djpiper28 committed Aug 30, 2024
1 parent 5cf368b commit d1ce708
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions cahfrontend/src/components/gameControls/GameLobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ import CurrentRoundResults from "../gameItems/CurrentRoundResults";

// Exported for testing reasons
export function GameLobbyLoaded(props: Readonly<LobbyLoadedProps>) {
const isGameOwner = () => props.state.ownerId === gameState.getPlayerId();
const isCzar = () =>
props.roundState.currentCardCzarId === gameState.getPlayerId();
const settings = () => props.state.settings;
const isGameOwner = () => props.state.ownerId === props.playerId;
const isCzar = () => props.roundState.currentCardCzarId === props.playerId;
const isGameStarted = () => props.state.gameState !== GameStateInLobby;
const isCzarJudgingPhase = () =>
props.state.gameState === GameStateCzarJudgingCards;
const settings = () => props.state.settings;

createEffect(() => {
cookieStorage.setItem(gamePasswordCookie, settings().gamePassword);
Expand Down Expand Up @@ -112,7 +111,7 @@ export function GameLobbyLoaded(props: Readonly<LobbyLoadedProps>) {
</Show>
<SubHeader text="Your hand:" />
<PlayerCards
czarId={props.roundState.currentCardCzarId}
isCzar={isCzar()}
isJudging={isCzarJudgingPhase()}
cards={props.roundState.yourHand.map((x) => {
return {
Expand Down Expand Up @@ -265,6 +264,7 @@ export default function GameLobby() {
<>
<Show when={!!state()}>
<GameLobbyLoaded
playerId={gameState.getPlayerId()}
state={state()!}
roundState={roundState()!}
setSettings={(settings) => {
Expand Down
1 change: 1 addition & 0 deletions cahfrontend/src/components/gameControls/gameLoadedProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export interface LobbyLoadedProps {
state: GameLobbyState;
roundState: RpcRoundInformationMsg;
allPlays: WhiteCard[][];
playerId: string;
}
9 changes: 4 additions & 5 deletions cahfrontend/src/components/gameItems/PlayerCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ interface GameCard {
}

interface Props {
czarId: string;
cards: GameCard[];
selectedCardIds: string[];
isJudging: boolean;
isCzar: boolean;
onSelectCard?: (cardId: string) => void;
}

Expand Down Expand Up @@ -51,7 +51,7 @@ export default function PlayerCards(props: Readonly<Props>) {

return (
<>
<Show when={props.czarId === gameState.getPlayerId()}>
<Show when={props.isCzar}>
{cardComp()}
</Show>
<Show when={props.czarId !== gameState.getPlayerId()}>
Expand All @@ -74,8 +74,7 @@ export default function PlayerCards(props: Readonly<Props>) {
</div>
);

const isCzar = () => props.czarId === gameState.getPlayerId();
const blockCardPlays = () => isCzar() || props.isJudging;
const blockCardPlays = () => props.isCzar || props.isJudging;
return (
<>
<Show when={blockCardPlays()}>
Expand All @@ -84,7 +83,7 @@ export default function PlayerCards(props: Readonly<Props>) {
id="czar"
class="absolute flex flex-col gap-3 top-0 left-0 right-0 bottom-0 z-10 justify-center items-center text-center bg-[#bababa60] rounded-2xl"
>
<Show when={isCzar()}>
<Show when={props.isCzar}>
<Header text="You are the Card Czar." />
</Show>
<Show when={props.isJudging}>
Expand Down
2 changes: 1 addition & 1 deletion cahfrontend/src/gameState/gameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class GameState {
case MsgOnWhiteCardPlayPhase:
console.log("Handling on white card play phase message");
return this.handleOnWhiteCardPlayPhase(
rpcMessage as RpcOnWhiteCardPlayPhase,
rpcMessage.data as RpcOnWhiteCardPlayPhase,
);
default:
throw new Error(
Expand Down

0 comments on commit d1ce708

Please sign in to comment.