ink-playing-cards
БесплатноБез исполняемых скриптовНе проверенUse when building terminal card games with ink-playing-cards, working with card components, deck management, zone systems, event systems, effect systems, or…
от gfargo135 установок в других каталогахОб этом скилле
ink-playing-cards v1.0.0
React component library for terminal-based card games with Ink 6 (React 19 for CLIs). Provides UI components, hooks, contexts, and game systems.
npm install ink-playing-cards
# deps: ink ^6.0.0, react ^19.0.0 — requires Node >= 20
Architecture
All state flows through DeckProvider (React context + useReducer). Zones are immutable TCard[] arrays. The useDeck hook wraps dispatch.
DeckProvider
├── zones.deck: TCard[]
├── zones.hands: Record<string, TCard[]>
├── zones.discardPile: TCard[]
├── zones.playArea: TCard[]
├── zones.custom: Record<string, TCard[]> // arbitrary named zones (tableau, foundation, ...)
├── players: string[]
├── eventManager / effectManager
└── dispatch(DeckAction)
Custom zones are addressed by name via moveCard/setZone/clearZone/getZone — useful for games (solitaire, etc.) that need more structure than deck/hand/discard/play. See MOVE_CARD/SET_ZONE/CLEAR_ZONE below.
Quick Start
import React from 'react'
import { render, Box, Text, useInput } from 'ink'
import { DeckProvider, useDeck, useHand, CardStack } from 'ink-playing-cards'
const Game = () => {
const { deck, shuffle, draw } = useDeck()
const { hand, playCard, discard } = useHand('player1')
React.useEffect(() => { shuffle(); draw(5, 'player1') }, [])
useInput((input) => { if (input === 'd') draw(1, 'player1') })
return (
<Box flexDirection="column">
<Text>Deck: {deck.length}</Text>
<CardStack cards={hand} name="Hand" isFaceUp maxDisplay={5} />
</Box>
)
}
render(<DeckProvider><Game /></DeckProvider>)
Types
type TCard = (CardProps | CustomCardProps) & { id: string } // every card has a unique `id`
type BaseCardProps = {
// `id` is optional here — only required on `TCard` (zone bookkeeping,
// React keys). A single decorative `<Card>`/`<CustomCard>` doesn't need one.
id?: string; effects?: CardEffect[]; faceUp?: boolean; selected?: boolean; rounded?: boolean
}
type CardProps = BaseCardProps & {
suit: 'hearts' | 'diamonds' | 'clubs' | 'spades'
value: '2' | '3' | ... | 'K' | 'A' | 'JOKER'
theme?: AsciiTheme // 'original' | 'geometric' | 'animal' | 'robot' | 'pixel' | 'medieval'
}
type CustomCardProps = BaseCardProps & {
size?: 'micro' | 'mini' | 'small' | 'medium' | 'large' // or explicit width/height
title?: string; cost?: string // header row
asciiArt?: string; artColor?: string // art region
typeLine?: string // between art and body
description?: string // body (auto-wraps)
footerLeft?: string; footerRight?: string // footer row
symbols?: CustomCardSymbol[] // corner symbols
content?: ReactNode // freeform mode — overrides all regions
back?: CustomCardBack // { art?, symbol?, color?, label? }
borderColor?: string; textColor?: string
value?: TCardValue | string; type?: string // game logic metadata (not rendered)
}
// Type guards
function isStandardCard(card: TCard): card is CardProps
function isCustomCard(card: TCard): card is CustomCardProps
function generateCardId(suit: TSuit, value: TCardValue): string // "hearts-A-<rand6>"
Hooks
useDeck — must be inside <DeckProvider>
const {
// State
deck, // TCard[]
hands, // Record<string, TCard[]>
discardPile, // TCard[]
playArea, // TCard[]
customZones, // Record<string, TCard[]> — named zones, keyed by name
players, // string[]
backArtwork, // { ascii, simple, minimal }
eventManager, // EventManager
effectManager, // EffectManager
// Actions
shuffle, // () => void
draw, // (count, playerId) => void — auto-registers player
deal, // (count, playerIds[]) => void — auto-registers players
reset, // (cards?) => void
cutDeck, // (index) => void
addPlayer, // (id) => void
removePlayer, // (id) => void
getPlayerHand, // (id) => TCard[]
addCustomCard, // (card: CustomCardProps) => void
removeCustomCard, // (cardId) => void
setBackArtwork, // (Partial<BackArtwork>) => void
moveCard, // (cardId, from, to, position?) => void — move between any two zones
setZone, // (name, cards) => void — seed/overwrite a custom zone
clearZone, // (name) => void — remove a custom zone
getZone, // (name) => TCard[] — read any zone (built-in or custom) by name
} = useDeck()
draw() and deal() dispatch actions — they do NOT return cards. Access drawn cards via hands[playerId] after re-render.
useHand(playerId) — convenience wrapper
const { hand, drawCard, playCard, discard } = useHand('player1')
// hand: TCard[]
// drawCard(count = 1) — draws from deck
// playCard(cardId: string) — hand → playArea
// discard(cardId: string) — hand → discardPile
useGame — must be inside `<GamePro
Установить ink-playing-cards в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ink-playing-cards?
Use when building terminal card games with ink-playing-cards, working with card components, deck management, zone systems, event systems, effect systems, or any card game logic using Ink and React for CLI rendering.
Как установить скилл ink-playing-cards?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ink-playing-cards запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
от Anthropicautomate-this
Analyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
от GitHubfrom-the-other-side-vega
Patterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
от GitHubplantuml-ascii
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…
от GitHub