knife-fight/README.md
Jacob VanDomelen ae221e29bc
Initial commit
2026-01-19 10:34:44 -08:00

135 lines
3.8 KiB
Markdown

# Knife Fight
A terminal-based card game where lower cards win and players bleed to death. Built with Clojure and Lanterna.
## Game Rules
### Objective
Force your opponent to bleed out (run out of deck cards).
### How to Play
1. **Setup**: Each player starts with a deck of cards (configurable, default is 2 suits = 27 cards) and draws 3 cards to their hand.
2. **Each Round**:
- Both players play one card simultaneously
- **Lower card wins** (Ace=1 is the lowest, highest numbered cards lose)
- Winner's card goes to loser's damage pile
- Both players draw back to 3 cards
- **Bleeding**: Each player discards cards from their deck equal to (damage pile sum ÷ 3, rounded up)
3. **Winning**: When a player runs out of deck cards (bleeds to death), they lose.
### Face Card Abilities
- **Jack (Parry)**: Nullifies the round completely - no damage dealt to either player
- **Queen (Field Dressing)**: Swap a card from your damage pile with opponent's played card (not yet implemented)
- **King (Feint)**: After cards are revealed, play a second card from your hand (not yet implemented)
- **Joker (Reflect)**: Reverse damage direction - opponent's card goes to their own damage pile
### Deck Configuration
You can configure the number of suits per player (1-4):
- **1 suit**: 14 cards per player (quick game)
- **2 suits**: 27 cards per player (standard game) [Default]
- **3 suits**: 40 cards per player (longer game)
- **4 suits**: 54 cards per player (maximum length game)
Each suit includes:
- 13 numbered cards (Ace through King)
- 1 Joker
## Installation & Running
### Prerequisites
- Leiningen (already in your Nix flake)
- Clojure (already in your Nix flake)
- A terminal with at least 80x24 size
### Running the Game
```bash
cd /Users/tepichord/Projects/knife-fight
lein run
```
### Building a Standalone JAR
```bash
lein uberjar
java -jar target/uberjar/knife-fight-0.1.0-SNAPSHOT-standalone.jar
```
## Game Controls
### Main Menu
- `1` - Start a new game
- `2` - Configure deck size
- `3` - View help/rules
- `4` - Quit
### During Gameplay
- `1`, `2`, `3` - Select card from your hand (numbered left to right)
- `Q` - Quit to main menu
### Configuration Screen
- `1`, `2`, `3`, `4` - Select number of suits per player
- `Q` - Return to main menu
## Game Architecture
The game follows functional programming principles with immutable data structures:
- **cards.clj**: Card data structures and operations
- **deck.clj**: Deck generation and manipulation (configurable sizes)
- **game.clj**: Game state management
- **config.clj**: Configuration system for deck sizes
- **rules.clj**: Game mechanics (damage, bleeding, abilities)
- **ai.clj**: AI opponent strategy
- **ui/**: Terminal UI layer
- **screen.clj**: Lanterna screen management
- **menu.clj**: Main menu and configuration screens
- **render.clj**: Game state rendering
- **input.clj**: Keyboard input handling
- **core.clj**: Main menu loop and game orchestration
## AI Strategy
The AI uses a scoring system to select cards:
- Prioritizes medium-value cards (4-7) for consistent wins
- Saves very low cards (Ace, 2, 3) for critical moments
- Uses Jokers strategically when opponent has high damage (>15)
- Adapts strategy based on hand size and opponent's damage
## Development
### REPL
```bash
lein repl
```
### Checking Code
```bash
lein check
```
## Known Limitations
- Queen (Field Dressing) ability requires UI selection - simplified in current version
- King (Feint) ability requires playing a second card - not yet implemented
- No save/load functionality
- No multiplayer support (only Human vs AI)
## Future Enhancements
- Full implementation of Queen and King abilities
- Save/load game state
- Statistics tracking
- Multiple AI difficulty levels
- Tournament mode (best of N games)
- Network multiplayer
- Replay system
## License
EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0