basic hand viewing

This commit is contained in:
2025-08-26 21:42:44 -04:00
parent aeb7d9174b
commit 686529507e
4 changed files with 40 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "games", "name": "games",
"type": "module", "type": "module",
"version": "0.0.4", "version": "0.0.5",
"scripts": { "scripts": {
"dev": "pnpm --parallel dev", "dev": "pnpm --parallel dev",
"build": "pnpm run -F client build", "build": "pnpm run -F client build",

View File

@@ -0,0 +1,21 @@
import type { Hand } from "@games/shared/cards";
import { For } from "solid-js";
import Card from "./Card";
export default (props: { handCount: number }) => {
return (
<div class="flex">
<For each={Array(props.handCount)}>
{() => (
<Card
face="down"
style={{
"margin-left": "-15px",
transform: "translate(0, 40px)",
}}
/>
)}
</For>
</div>
);
};

View File

@@ -1,4 +1,4 @@
import { Accessor, createContext, useContext } from "solid-js"; import { Accessor, createContext, For, useContext } from "solid-js";
import type { import type {
SimpleAction, SimpleAction,
SimplePlayerView, SimplePlayerView,
@@ -7,6 +7,8 @@ import { me, profile } from "~/profile";
import Hand from "./Hand"; import Hand from "./Hand";
import Pile from "./Pile"; import Pile from "./Pile";
import { TableContext } from "./Table"; import { TableContext } from "./Table";
import { Portal } from "solid-js/web";
import FannedHand from "./FannedHand";
export const GameContext = createContext<{ export const GameContext = createContext<{
view: Accessor<SimplePlayerView>; view: Accessor<SimplePlayerView>;
@@ -46,6 +48,17 @@ export default () => {
> >
Quit Quit
</button> </button>
<For each={Object.entries(view().playerHandCounts)}>
{([playerKey, handCount]) => (
<Portal
mount={document.getElementById(`player-${playerKey}`)!}
>
<div class="absolute center">
<FannedHand handCount={handCount} />
</div>
</Portal>
)}
</For>
</GameContext.Provider> </GameContext.Provider>
); );
}; };

View File

@@ -3,6 +3,7 @@ import { playerColor, profile } from "~/profile";
import { TableContext } from "./Table"; import { TableContext } from "./Table";
import { Stylable } from "./toolbox"; import { Stylable } from "./toolbox";
import { createObservable, createObservableWithInit } from "~/fn"; import { createObservable, createObservableWithInit } from "~/fn";
import { GameContext } from "./Game";
export default (props: { playerKey: string } & Stylable) => { export default (props: { playerKey: string } & Stylable) => {
const table = useContext(TableContext); const table = useContext(TableContext);
@@ -13,8 +14,11 @@ export default (props: { playerKey: string } & Stylable) => {
.thru((Evt) => createObservableWithInit(Evt, false)) ?? .thru((Evt) => createObservableWithInit(Evt, false)) ??
createSignal(false)[0]; createSignal(false)[0];
const game = useContext(GameContext);
return ( return (
<div <div
id={`player-${props.playerKey}`}
style={{ style={{
...props.style, ...props.style,
"background-color": playerColor(props.playerKey), "background-color": playerColor(props.playerKey),