The easiest way to run the game, is by dragging the provided wordwar.apk
file located in the dist/releases
folder into your android emulator. The game has been tested on a Pixel 2 emulator with API level 29.
It’s also possible to download the apk file to your Android device if applicable. OnePlus 9 and OnePlus 8 on Android 11 have been tried and confirmed working. Note that the app does not support dark mode.
- Clone this repo.
- Open the repo by opening the
build.gradle
file as a project in Android Studio - Gradle will sync the dependencies. This might take a while.
- Run the game as an Android application configuration.
- The game will open in your emulator.
The code structure follows the Model-View-ViewModel (MVVM). The code that is associated to MVVM is found in app/src/main/java
facilitates all the business logic relevant to the app. The details of each package and how it is relevant to the different design and architectural patterns are elaborated further in the report. However, a quick summary follows:
The model package includes all the objects that are used within the game. Since Firebase is not object oriented, the repository pattern maps between database entities and objects useful in the game. The objects that are associated to their related entities are located in the model package.
The observers package follows the observer pattern. The content of this package acts as abservers to notify whenever a user changes its local state of the game. For example, the PlayerEventSource
notifies the PlayerObserver
interface when all users have submitted their word for each round. Finally, the host is notifed through the interface and is allowed to continue to the next round.
The storage package is part of the repository pattern and translates database entities to game objects in model
. Since the database entity and game object do not always strictly inherit all fields, a data transferable object (DTO) is created. For example, when a new game is created, the id of the lobby is generated back-end. The game dto (GameDoc.kt in this case) is sent to the server without an id field. In the next step, when fetching the same game, the Repository interface translates the game back to a game object.
Storage also includes the logic for interacting with observers from observers
The view package contains all views that are displayed to the user. These are implemented through the Fragment class of the Android SDK. The views of the view package ties the user interaction into business logic. Since the GUI is drawn from the xml files in the res folder, the views creates a binding between user interactable objects and business logic. For example, GameRoundFragment.kt - Line 85 is invoked when the player presses the “Submit Word" button in a round.
The viewmodel package contains the layer between view and model layer. When clicking the button from the example above, the GameViewModel
operates as the binding between UI elements to its corresponding controls. For the “Submit Word" button case, the GameViewModel
invokes the repository to update the user's answer.