A modern, native Android implementation of the classic Battleship board game. Engineered using 100% Kotlin and Jetpack Compose, this project demonstrates the application of Clean Architecture principles within a scalable, multi-module Gradle configuration.
- Single Player: Features an AI opponent with varying difficulty algorithms.
- Pass & Play: Facilitates local multiplayer on a single device, utilizing a secure hand-off screen to protect player board states.
- Online Multiplayer: Enables remote peer-to-peer gameplay via private 6-digit room codes. The network layer is powered by Firebase Realtime Database to ensure low-latency state synchronization.
- Local Statistics: Persists lifetime user data including win/loss records, total shots fired, and overall accuracy metrics using a local SQLite database (Room).
- Haptic Integration: Utilizes system haptics to provide tactile feedback for critical game events such as shots fired, hits, misses, and ship destruction.
- Declarative UI: The presentation layer is built entirely with Jetpack Compose, featuring custom Canvas drawing for grids and complex drag-and-drop gesture detection for ship placement.
This project strictly adheres to modern Android development standards and best practices:
- UI Framework: Jetpack Compose
- Language: Kotlin
- Architecture: MVVM (Model-View-ViewModel) + Clean Architecture (Multi-module design)
- Dependency Injection: Dagger Hilt
- Asynchronous Programming: Kotlin Coroutines & StateFlow
- Local Storage: * Room (SQLite) for structured game statistics.
- Preferences DataStore for lightweight application settings.
- Backend Integration: * Firebase Realtime Database for multiplayer synchronization.
- Firebase Anonymous Authentication for frictionless session management.
- Navigation: Jetpack Navigation Compose with type-safe routing.
The codebase is partitioned into isolated modules to strictly enforce separation of concerns and optimize build times:
:app— The main application module containing dependency injection entry points and the global navigation graph.:core:domain— A pure Kotlin module encapsulating core business logic, game rules, ship validation algorithms, and the internal Game Engine.:core:ui— Shared UI components, theming definitions, custom Compose modifiers, and the Haptic Manager.:core:data— Data access layer containing Room entities, Data Access Objects (DAOs), and DataStore repositories.:core:multiplayer— Network implementation handling Firebase interactions, matchmaking room generation, and state synchronization mapping.:feature:*— Isolated presentation modules representing distinct application flows (e.g.,:feature:setup,:feature:game,:feature:lobby,:feature:menu,:feature:stats).
- Android Studio (Latest stable release recommended)
- A configured Firebase Project (required for online multiplayer functionality)
- Clone the repository
git clone [https://github.com/Mannava-Daasaradhi/Battleship_android.git](https://github.com/Mannava-Daasaradhi/Battleship_android.git) cd Battleship_android
2. **Configure Firebase**
Due to the reliance on Firebase Authentication and Realtime Database, a valid `google-services.json` file is required.
* Navigate to the [Firebase Console](https://console.firebase.google.com/).
* Initialize a new Android project matching your application's package name (e.g., `com.battleship.fleetcommand`).
* Enable **Anonymous Authentication** within the Authentication providers.
* Provision a **Realtime Database** instance.
* Apply the security rules defined in the `database.rules.json` file (located in the repository root) to your Firebase Database Rules configuration.
* Download the generated `google-services.json` file and place it in the `app/` directory of your local project.
3. **Build and Execute**
* Open the project in Android Studio.
* Execute a Gradle sync.
* Deploy the application to an emulator or physical device.
---
## Future Roadmap (Version 1.1+)
* [ ] **Google Play Games Services (PGS):** Transition from Anonymous Authentication to PGS to support persistent cloud statistics, user profiles, and achievement tracking.
* [ ] **Native Animations:** Implement Jetpack Compose Canvas animations for enhanced visual feedback (e.g., explosions and water splashes).
* [ ] **Audio Subsystem:** Integrate Android's `SoundPool` API for low-latency sound effects and background music playback.
* [ ] **Monetization Layer:** Integrate Google AdMob for targeted advertisement displays across menus and post-match screens.
---
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.