xiaohongshu
xiaohongshu
convex-game-management
Manage game lifecycle, player turns, round rotation, scoring, and game state transitions. Use when implementing game creation, turn management, score updates, and game completion flows in PictionAI.
Full skill instructions
This skill handles the complete game lifecycle for PictionAI's multiplayer Pictionary game, including game creation, player management, turn-based rotation, atomic turn completion with scoring, and game state transitions.
Turns are completed atomically to ensure data consistency:
startNewTurn mutationStart a new drawing turn, assign card, initialize timer.
mutation startNewTurn {
args: {
game_id: Id<"games">
}
// Returns: {
// turn_id: Id<"turns">,
// card: { word: string, category: string },
// drawer_id: Id<"users">,
// time_limit: number
// }
}
Submit a guess and complete the turn with atomic scoring.
mutation submitGuessAndCompleteTurn {
args: {
game_id: Id<"games">,
turn_id: Id<"turns">,
guesser_id: Id<"users">,
guess: string,
elapsed_time: number,
is_correct?: boolean
}
// Handles three scenarios atomically:
// 1. Correct guess → Award points to both
// 2. Manual selection → Drawer chooses winner
// 3. Time up → Skip to next turn
}
Drawer selects a guesser as the winner when time expires.
mutation selectWinner {
args: {
turn_id: Id<"turns">,
selected_guesser_id: Id<"users">
}
// Awards 30 points to guesser, 25 to drawer
}
Fetch complete game state with players, current turn, scores.
query getGame {
args: { game_id: Id<"games"> }
// Returns full game with nested players, turns, scores
}
Get all turns in a game with guesses and results.
query getGameTurns {
args: { game_id: Id<"games"> }
// Returns array of turns with scoring details
}
// Start a new turn
const startTurn = useMutation(api.mutations.game.startNewTurn);
await startTurn({ game_id: gameId });
// Submit guess and complete turn
const submitGuess = useMutation(api.mutations.game.submitGuessAndCompleteTurn);
await submitGuess({
game_id: gameId,
turn_id: turnId,
guesser_id: userId,
guess: "elephant",
elapsed_time: 45,
});
// Fetch game state
const game = useQuery(api.queries.games.getGame, { game_id: gameId });
// Games table
games: defineTable({
code: v.string(), // Unique game code
creator_id: v.id("users"),
players: v.array(
v.object({
user_id: v.id("users"),
score: v.number(),
is_drawer: v.boolean(),
})
),
state: v.union(
v.literal("waiting"),
v.literal("started"),
v.literal("finished")
),
current_turn_index: v.number(),
created_at: v.optional(v.number()),
round_count: v.number(),
});
// Turns table
turns: defineTable({
game_id: v.id("games"),
drawer_id: v.id("users"),
card_id: v.id("cards"),
state: v.union(
v.literal("drawing"),
v.literal("completed"),
v.literal("time_up")
),
timer_started_at: v.number(),
time_limit: v.number(),
correct_guesser_id: v.optional(v.id("users")),
guesses: v.array(
v.object({
guesser_id: v.id("users"),
guess: v.string(),
timestamp: v.number(),
is_correct: v.optional(v.boolean()),
})
),
});
const game = useQuery(api.queries.games.getGame, { game_id });
const currentTurn = game?.turns[game.current_turn_index];
const isMyTurn = currentTurn?.drawer_id === userId;
// When drawer completes turn with guess result
const completeWithCorrect = useMutation(
api.mutations.game.submitGuessAndCompleteTurn
);
await completeWithCorrect({
game_id: gameId,
turn_id: turnId,
guesser_id: guesserId,
guess: "elephant",
elapsed_time: 30,
is_correct: true,
});
The mutation automatically:
convex/mutations/game.ts - Complete mutation implementationscomponents/game/game-board.tsx - UI integrationxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience