Skip to content
 
 

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midterm UNO CLI

A standalone command-line UNO-like game written in Java.

This repository is set up as a standard Maven project with automated tests, logging of important game events, and Docker support.

Requirements

  • Java 21 (JDK)
  • Maven is not required to be installed: a Maven Wrapper (mvnw / mvnw.cmd) is included and will download the correct Maven version automatically.
  • Docker (optional, only for the Docker workflow)

On Linux/macOS use ./mvnw. On Windows use .\mvnw.cmd (or mvnw.cmd). If you already have Maven installed, you can replace ./mvnw with mvn.

Project Layout

pom.xml                 Maven build configuration
Dockerfile              Multi-stage build + run image
src/main/java/          Application source (default package)
src/test/java/          JUnit 5 tests

The main class is Main.

Command Reference

Local build

./mvnw clean compile

Windows:

.\mvnw.cmd clean compile

Local test

Runs the JUnit suite, which executes all existing characterization checks through Maven Surefire (no manual classpath setup).

./mvnw test

Windows:

.\mvnw.cmd test

Package creation

Produces the executable jar at target/uno-cli.jar (runs tests first).

./mvnw clean package

Windows:

.\mvnw.cmd clean package

Local run

Run the packaged jar:

java -jar target/uno-cli.jar --bots 3 --games 1 --quiet

Or run directly through Maven without packaging:

./mvnw -q compile exec:java -Dexec.args="--bots 3 --games 1 --quiet"

Interactive game vs. bots:

java -jar target/uno-cli.jar --human --bots 2 --games 1

Available arguments: --bots N, --games N, --human, --quiet, --seed N, --report, --limit N, --no-persist, --self-test, --help.

View game history / statistics

Completed games are saved to a local database (see docs/database.md). View the reports with:

java -jar target/uno-cli.jar --report
java -jar target/uno-cli.jar --report --limit 5

This prints recent games, player win counts, and highest scores.

Docker build

docker build -t uno-cli .

Docker run

Non-interactive bot game (uses the image default arguments):

docker run --rm uno-cli

Pass custom arguments:

docker run --rm uno-cli --bots 4 --games 3 --quiet

Interactive game (allocate a TTY so the game can read your input):

docker run --rm -it uno-cli --human --bots 2 --games 1

Logging

The game uses java.util.logging. Important events are logged to logs/uno.log (created on first run):

  • game start
  • player turn
  • card played
  • card drawn
  • invalid input
  • round/game end

Logs are written to the log file only, so normal player-facing CLI output on the console stays clean and readable.

Persistence (Database)

Game results are persisted with Hibernate ORM (JPA) into an embedded H2 database (./data/uno.mv.db). Players, games, rounds, per-player scores, the winner, and timestamps are all stored, and three report queries are available via --report. Tests run against an isolated in-memory H2 database.

Full details (schema, configuration, credentials/overrides, how to run the persistence tests, and how to view statistics) are in docs/database.md.

Card Input Examples

R5   red 5
YS   yellow skip
BR   blue reverse
G+2  green draw two
W    wild
W4   wild draw four
draw draw a card

Rules

See docs/rules.html for the implemented game rules.

About

my midterm solution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages