Quest Game is a text-based adventure where players navigate through different scenes, making choices that determine the story’s progression. The game is built using Java Servlets and a simple front-end interface.
- 🌍 Dynamic scene transitions based on player choices
- 📝 User session management to track progress
- 📊 Statistics tracking (correct and incorrect moves)
- 🛠️ REST API for game logic handling
- 🎨 Retro-inspired design with interactive UI
- ✅ Comprehensive unit and integration tests
📦 Quest-Game
├── 📁 src
│ ├── 📁 main
│ │ ├── 📁 java
│ │ │ ├── 📁 controller # Servlets for handling HTTP requests
│ │ │ ├── 📁 model # Game models (Player, Game, Choices)
│ │ │ ├── 📁 repository # Stores game data (scenes, choices)
│ │ │ ├── 📁 service # Business logic implementation
│ │ │ ├── 📁 service.session # Manages user game sessions
│ │ │ ├── 📁 util # Utility classes
│ ├── 📁 test
│ │ ├── 📁 java
│ │ │ ├── 📁 controller # Tests for servlets
│ │ │ ├── 📁 service # Tests for service logic
│ │ │ ├── 📁 session # Tests for game session management
├── 📁 webapp
│ ├── 📁 images # Game assets and background images
│ ├── 📁 css # Front-end styling
│ ├── 📁 js # Client-side scripts
│ ├── 📝 index.html # Main game page
├── 📝 pom.xml # Maven dependencies
└── 📝 README.md # Documentation
- JDK 17+
- Apache Tomcat 10+
- Maven
-
Clone the repository
https://github.com/CrapMind/GameWithServlets.git
-
Build the project using Maven
mvn clean package
-
Deploy the application to Tomcat
- Move
target/GameWithServlets.warto thewebappsdirectory of Tomcat - Start the server:
cd apache-tomcat/bin ./startup.sh (Linux/macOS) startup.bat (Windows)
- Move
-
Open the game in a browser
http://localhost:8080/
| Method | Endpoint | Description |
|---|---|---|
GET |
/rest/scene?scene=X |
Retrieves the text of scene X |
GET |
/rest/move |
Processes a move based on choice |
POST |
/rest/setPlayerName |
Sets the player's name |
GET |
/rest/newGame |
Starts a new game session |
The project includes unit and integration tests to ensure correctness.
To execute tests, run:
mvn test- Unit Tests: Cover individual components (
MovingService,GameSession,Repository). - Servlet Tests: Use
Mockitoto mock HTTP requests and responses. - Integration Tests: Simulate full game sessions.
- Parameterized Tests: Ensure a variety of input scenarios are tested.
Pull requests are welcome! If you'd like to contribute, please open an issue first to discuss the proposed changes.
For any inquiries, reach out via GitHub Issues or email: crapmindd@gmail.com