Skip to main content

A Python implementation of the Scoundrel roguelike card game

Project description

PyScoundrel ๐Ÿƒ

A Python implementation of Scoundrel, a single-player roguelike card game by Zach Gage and Kurt Bieg.

Experience the thrill of dungeon crawling through a deck of cards with a modern, clean terminal interface!

๐ŸŽฎ Features

  • Full Scoundrel Implementation: Complete game mechanics including weapons, monsters, and health potions
  • Modern CLI Interface: Clean terminal UI powered by Rich with:
    • Rounded borders and clean tables
    • Integer-based menu system (1, 2, 3... 0 to quit)
    • Color-coded cards by type
    • Health percentage display
    • Damage calculations shown clearly
  • Fast Flow Gameplay: No pauses or confirmations - continuous action
  • Smart Choices: Only valid actions are displayed (no disabled options)
  • Configurable Dungeons: YAML-based card pool system - customize or create themed dungeons
  • Agent Support: Create automated players with custom strategies
  • Comprehensive Logging: Track every game event with JSON logs for analysis
    • Console logging for real-time monitoring
    • File logging with complete game state
    • Auto-generated filenames with timestamps
  • Reproducible Games: Random seed support for consistent playthroughs

๐Ÿ“ฆ Installation

From source

git clone https://github.com/yourusername/pyscoundrel.git
cd pyscoundrel
pip install -r requirements.txt

Dependencies

  • Python 3.8+
  • rich >= 13.0.0
  • pyyaml >= 6.0.0

๐ŸŽฏ Quick Start

Play the game

# Run with default settings
python -m pyscoundrel

# Use a specific random seed (for reproducible games)
python -m pyscoundrel --seed 42

# Skip title screen
python -m pyscoundrel --no-title

# Use a custom dungeon
python -m pyscoundrel --dungeon my_dungeon.yaml

Command-line options

--seed INT           # Random seed for reproducible games
--no-title           # Skip title screen
--dungeon PATH       # Path to custom dungeon YAML

๐ŸŽฒ How to Play

Game Rules

Scoundrel is played with a 44-card dungeon deck (26 monsters, 9 weapons, 9 potions).

Card Types:

  • Monsters: Deal damage equal to their value (2-14)
  • Weapons: Reduce monster damage. Important weapon rule: After killing a monster, the weapon can only be used on monsters โ‰ค last kill value
  • Health Potions: Restore health (max 20 HP). One per turn only

Gameplay:

  1. Draw 4 cards to form a Room
  2. Choose to avoid the room (cards go to bottom of deck) or face it
    • Cannot avoid two rooms in a row
  3. If facing the room, choose 3 of 4 cards to face (one carries over to next room)
  4. Handle each card:
    • Weapon: Equip it (discards old weapon)
    • Potion: Heal (max 20 HP, one per turn)
    • Monster: Fight barehanded OR with weapon (if available)

Winning/Losing:

  • Win: Clear the entire deck while staying alive
  • Lose: Health reaches 0
  • Quit: Press 0 anytime (counts as defeat)

Scoring:

  • Victory: Your remaining health
  • Defeat: Negative value = sum of remaining monster damage

๐Ÿฐ Dungeon Configuration

PyScoundrel uses a YAML-based dungeon system for complete card customization.

Default Dungeon

The default dungeon uses standard playing card names (Jโ™ฃ, 7โ™ฅ, Kโ™ , etc.) matching classic Scoundrel.

Custom Dungeons

Create your own themed dungeons:

# my_dungeon.yaml
version: "1.0"

cards:
  # Monsters
  - id: "Goblin"
    name: "Goblin"
    type: monster
    value: 3
    count: 4

  - id: "Dragon"
    name: "Dragon"
    type: monster
    value: 13
    count: 2

  # Weapons
  - id: "Sword"
    name: "Steel Sword"
    type: weapon
    value: 7
    count: 1

  # Potions
  - id: "Potion"
    name: "Healing Potion"
    type: health_potion
    value: 5
    count: 3

See DUNGEON_CONFIGURATION.md for full documentation.

๐Ÿ“š Documentation

๐Ÿ—๏ธ Package Structure

pyscoundrel/
โ”œโ”€โ”€ models/          # Core game entities
โ”‚   โ”œโ”€โ”€ card.py      # Card model (supports both legacy and dungeon formats)
โ”‚   โ”œโ”€โ”€ deck.py      # Deck management with dungeon support
โ”‚   โ”œโ”€โ”€ weapon.py    # Weapon with kill history tracking
โ”‚   โ”œโ”€โ”€ player.py    # Player state (health, equipped weapon)
โ”‚   โ””โ”€โ”€ room.py      # Room with 4 cards
โ”œโ”€โ”€ game/            # Game logic
โ”‚   โ”œโ”€โ”€ state.py     # GameState and GamePhase
โ”‚   โ”œโ”€โ”€ engine.py    # Core game logic and rules
โ”‚   โ””โ”€โ”€ actions.py   # Player actions and results
โ”œโ”€โ”€ dungeon/         # Dungeon card pool system
โ”‚   โ”œโ”€โ”€ card_pool.py # Dungeon loader and validator
โ”‚   โ””โ”€โ”€ default_dungeon.yaml  # Default card pool
โ”œโ”€โ”€ ui/              # Rich-based terminal UI
โ”‚   โ”œโ”€โ”€ renderer.py  # Game renderer
โ”‚   โ”œโ”€โ”€ theme.py     # Color theme
โ”‚   โ””โ”€โ”€ input.py     # Input handling
โ””โ”€โ”€ config.py        # Game configuration

๐Ÿ’ป Programmatic Usage

Use PyScoundrel as a library:

from pyscoundrel.game.engine import GameEngine
from pyscoundrel.dungeon import Dungeon
from pyscoundrel.config import GameConfig

# Create game with default dungeon
engine = GameEngine(seed=42)
engine.start_game()

# Or use a custom dungeon
dungeon = Dungeon(config_path="my_dungeon.yaml")
engine = GameEngine(dungeon=dungeon, seed=42)

# Game loop
while not engine.is_game_over:
    result = engine.draw_room()
    # Handle room...
    result = engine.face_card(0)
    # Handle card...

# Get final score
print(f"Victory: {engine.state.victory}")
print(f"Final Score: {engine.state.score}")

๐ŸŽจ UI Features

Modern Interface:

  • Numbered menu system (1-5 for actions, 0 to quit)
  • Rounded borders and clean tables
  • Color-coded card types
  • Health bar with percentage
  • Weapon status with restrictions

Smart Display:

  • Monster combat options expanded in menu (barehanded + weapon as separate choices)
  • Only valid choices shown (no grayed-out disabled options)
  • Immediate feedback - no pauses between actions

Fast Flow:

  • No "Press Enter to continue" prompts
  • No quit confirmations
  • Continuous gameplay

๐Ÿ“ License

This implementation is released under the MIT License. The original Scoundrel game is ยฉ 2011 Zach Gage and Kurt Bieg.

๐Ÿ™ Credits

  • Original Game Design: Zach Gage and Kurt Bieg
  • Python Implementation: PyScoundrel Contributors
  • UI Library: Rich by Will McGugan

๐Ÿค Contributing

Contributions are welcome! This package focuses on clean game logic implementation with a modern CLI experience.


Enjoy dungeon crawling through a deck of cards! ๐Ÿƒโš”๏ธ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyscoundrel-0.1.0.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyscoundrel-0.1.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file pyscoundrel-0.1.0.tar.gz.

File metadata

  • Download URL: pyscoundrel-0.1.0.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for pyscoundrel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c8e46e69a40ed1cd3e34f90132eecdf04d31d1f9bc4b087419fe6b21a2552a7
MD5 59312005f1d55da66e870f9eb343c8a4
BLAKE2b-256 4275fdd629dacfec735890e19795fb81ac876bc4feb8b185ec3c0f7a8b873d3f

See more details on using hashes here.

File details

Details for the file pyscoundrel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyscoundrel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for pyscoundrel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc54f4d96f2186c0dd454889d2e2f62229ffbc578f5f4062e59a373c6edfe242
MD5 3df335d1398b815c25d3dbd2374ff099
BLAKE2b-256 ebe4ec918e8705185448f7526548b8e6e6f180c8565412bb72691009fa423e83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page