A Java implementation of the two-player card game Rivals for Catan, featuring network play, extensible architecture, and comprehensive game mechanics.
Rivals for Catan is a card-based strategy game where two players build principalities by constructing settlements, producing resources, and expanding territories. First player to reach 7 Victory Points wins.
This digital implementation includes the complete base game (94 cards), network multiplayer, automated bot players, and an extensible architecture for adding expansions.
Gameplay:
- Complete base game implementation (94 cards)
- Turn-based phases: Roll, Action, Replenish
- Resource production and management
- Card building with costs and placement rules
- Event system and card effects
- Victory condition (7 VP)
Technical:
- Network multiplayer (local/remote via sockets)
- Bot players for testing
- Extensible architecture (Strategy, Factory, Observer patterns)
- 33 acceptance tests covering all requirements
- Clean separation of concerns
The project follows SOLID principles and implements several design patterns:
src/main/java/com/rivalofcatan/
├── cards/ # Card models and effects (Strategy pattern)
├── events/ # Domain events
├── hooks/ # Card interactions (Observer pattern)
├── model/ # Game logic and rules
├── player/ # Player state management (Facade pattern)
├── builder/ # Card creation (Factory pattern)
└── network/ # Communication layer (Strategy pattern)
Key Patterns: Strategy, Factory, Observer, Facade
Documentation: See DEVELOPER_GUIDE.md
- Java 17 or higher
- Gson library (included in
lib/gson.jar)
IntelliJ IDEA (Recommended):
- Open project in IntelliJ IDEA
- Project will auto-compile
- Run
ServerMain.java(right-click → Run)
Manual Compilation:
Windows (PowerShell/CMD):
mkdir target
Get-ChildItem -Path src\main\java -Filter *.java -Recurse | ForEach-Object { $_.FullName } | Out-File -FilePath sources.txt -Encoding ascii
javac -cp "lib\gson.jar" -d target "@sources.txt"Linux/macOS:
mkdir -p target
find src/main/java -name "*.java" > sources.txt
javac -cp "lib/gson.jar" -d target @sources.txtNote: This compiles all .java files including classes loaded via reflection (hooks, placement requirements).
Network Play - Option 1 (2 terminals):
Server hosts the game AND plays locally (using --player flag) + 1 remote client.
Terminal 1 - Server with local player (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.server.ServerMain --playerTerminal 1 - Server with local player (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.server.ServerMain --playerTerminal 2 - Remote client (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Terminal 2 - Remote client (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Network Play - Option 2 (3 terminals):
Server ONLY hosts the game (no --player flag) + 2 remote clients.
Terminal 1 - Server (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.server.ServerMainTerminal 1 - Server (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.server.ServerMainTerminal 2 and 3 - Remote clients (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Terminal 2 and 3 - Remote clients (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Bot Testing (Local Bot - server-side):
Terminal 1 - Server with local bot (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.server.ServerMain --botTerminal 1 - Server with local bot (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.server.ServerMain --botTerminal 2 - Human player (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Terminal 2 - Human player (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Bot Testing (Remote Bot - client-side):
Terminal 1 - Server (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.server.ServerMainTerminal 1 - Server (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.server.ServerMainTerminal 2 - Human player (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Terminal 2 - Human player (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.client.RemoteClientMain localhost 8080Terminal 3 - Remote bot (Windows):
java -cp "target;lib\gson.jar;src\main\resources" com.rivalforcatan.network.client.RemoteBotMain localhost 8080Terminal 3 - Remote bot (Linux/macOS):
java -cp "target:lib/gson.jar:src/main/resources" com.rivalforcatan.network.client.RemoteBotMain localhost 8080Server Flags:
--player- Local human player--bot- Automated bot player--port <num>- Custom port (default: 8080)
Note: Windows uses ; as classpath separator, Linux/macOS use :
Run acceptance tests in IntelliJ: Right-click acceptance/ package → Run Tests
Test Coverage: 33 tests across 5 requirements (network play, card composition, initial draw, turn sequence, victory condition)
RivalsOfCatan/
├── src/main/java/com/rivalofcatan/ # Source code
│ ├── cards/ # Card models and effects
│ ├── events/ # Domain events
│ ├── hooks/ # Card interactions
│ ├── model/ # Game logic
│ ├── player/ # Player state
│ ├── builder/ # Card factory
│ └── network/ # Communication
├── src/main/resources/ # Card data (JSON)
├── src/test/java/ # 33 acceptance tests
└── DEVELOPER_GUIDE.md # Extension guide
- DEVELOPER_GUIDE.md - How to add cards, effects, hooks, events
- Java 17
- JUnit 5 (Testing)
- Gson (JSON parsing)
Academic project. Game "Rivals for Catan" owned by Catan GmbH/Kosmos.
Titouan Pastor
Luleå University of Technology
GitHub Repository