This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Smákrafl is an Icelandic word game (similar to Scrabble) built with CoffeeScript, Node.js, Express, and Socket.IO. It's a multiplayer web-based game where players swap letters on a grid to form words.
- Start server:
coffee ssserver.coffee - Install dependencies:
npm install - Deploy to Heroku:
git push heroku master(uses Procfile)
- CoffeeScript >= 1.2.0
- Express >= 2.5.8
- Socket.IO >= 0.9.2
- Node.js 0.6.10
Main Server (ssserver.coffee):
- Express HTTP server serving static files from
/client - Socket.IO WebSocket server for real-time game communication
- Game session management with player invitations and matchmaking
- Timer-based turn system (60 second turns, 10 moves max per player)
Core Game Classes:
GameManager: Manages multiple games, player login/logout, game creation and recyclingGame: Individual game state, players, scoring, turn managementPlayer: Player data including ID, name, score, move countDictionary: Icelandic word validation using word list fromnonfetlc.jsGrid: 8x8 game board for letter tiles
Main Client (client/ssclient.coffee):
- Socket.IO client for server communication
- jQuery-based UI with tile selection and game board rendering
- Real-time turn timer and move validation
- Icelandic character encoding utilities
UI Files:
index.html: Player login/lobby pagegame.html: Main game interfacestyle.css&lobbyStyle.css: Game styling
- Login: Players connect via lobby (
index.html) and provide username - Matchmaking: Server manages player invitations and game pairing
- Game Start: Two players are placed in a
Gameinstance with fresh grid - Turns: 60-second timed turns, players swap two letters to form words
- Scoring: Points awarded based on new words formed (word count × word length)
- End Game: After 10 moves each, highest score wins
Client → Server Messages:
login: Player authentication with usernameinvite: Send game invitation to another playerinviteResponse: Accept/decline invitationmove: Submit letter swap coordinatesnewGame: Start game between two specified players
Server → Client Messages:
welcome: Game start data (tiles, players, turn info)moveResult: Move validation and scoring resultstick/tock: Turn timer updatestimeIsUp/yourTurnNow: Turn timeout handlinggameOver: Final results and winner
Grid: 2D array of Icelandic letters with special characters (Á, Ð, É, Í, Ó, Ú, Ý, Þ, Æ, Ö)
Move Coordinates: {x1, y1, x2, y2} for letter swapping
Player State: ID (socket ID), name, score, move count, player number (1 or 2)
- All server code is in CoffeeScript, client uses both CoffeeScript and compiled JavaScript
- Uses legacy Express v2 syntax and older Socket.IO patterns
- Extensive console logging for debugging multiplayer state
- Game recycling system to reuse completed games
- Icelandic language support with proper character encoding
- Client-side URL parameter parsing for player names