Skip to content
Snippets Groups Projects
Commit 76a2668b authored by Anne Høgdahl Skjærseth's avatar Anne Høgdahl Skjærseth
Browse files

architecture comments

parent 5889d269
Branches
No related tags found
No related merge requests found
Showing with 35 additions and 11 deletions
...@@ -33,6 +33,9 @@ public class AndroidInterfaceClass implements FirebaseServices { ...@@ -33,6 +33,9 @@ public class AndroidInterfaceClass implements FirebaseServices {
static ArrayList<List<Integer>> opponentBoard; static ArrayList<List<Integer>> opponentBoard;
/** /**
* DESIGN PATTERN: observer
* The methods that use a ValueEventListener use the observer pattern.
*
* AndroidInterfaceClass contains all the logic to write and retrieve data from our firebase * AndroidInterfaceClass contains all the logic to write and retrieve data from our firebase
* realtime database. The class contains the singleton gameCodeHolder to save the gameId * realtime database. The class contains the singleton gameCodeHolder to save the gameId
* and playerId throughout the game. * and playerId throughout the game.
...@@ -136,7 +139,6 @@ public class AndroidInterfaceClass implements FirebaseServices { ...@@ -136,7 +139,6 @@ public class AndroidInterfaceClass implements FirebaseServices {
} }
/** /**
* Design pattern: Listener
* A listener to when it is two players in the waitingRoom and when onChildRemoved() is fired the player * A listener to when it is two players in the waitingRoom and when onChildRemoved() is fired the player
* moves them self to the game. The LoadingController knows that both players are ready. * moves them self to the game. The LoadingController knows that both players are ready.
* Remove the waitingRoom in firebase since there are no players left. * Remove the waitingRoom in firebase since there are no players left.
...@@ -177,7 +179,6 @@ public class AndroidInterfaceClass implements FirebaseServices { ...@@ -177,7 +179,6 @@ public class AndroidInterfaceClass implements FirebaseServices {
} }
/** /**
* Design pattern: Observer
* Initialize a listener to the turn attribute in firebase first time it is called. * Initialize a listener to the turn attribute in firebase first time it is called.
* onDataChange() is called every time changeTurn() changes the turn variable after the initial call. * onDataChange() is called every time changeTurn() changes the turn variable after the initial call.
* @return true if it is the local players turn and pass it on to PlayController * @return true if it is the local players turn and pass it on to PlayController
...@@ -241,7 +242,6 @@ public class AndroidInterfaceClass implements FirebaseServices { ...@@ -241,7 +242,6 @@ public class AndroidInterfaceClass implements FirebaseServices {
} }
/** /**
* Design pattern: Listener
* Checks if both players have initialized their board, so the Board attribute in firebase have more then one child. * Checks if both players have initialized their board, so the Board attribute in firebase have more then one child.
* The boolean variable, playersReady, in LoadingController is then set to true. * The boolean variable, playersReady, in LoadingController is then set to true.
*/ */
...@@ -272,7 +272,6 @@ public class AndroidInterfaceClass implements FirebaseServices { ...@@ -272,7 +272,6 @@ public class AndroidInterfaceClass implements FirebaseServices {
} }
/** /**
* Design pattern: observer
* PlayController initialize the observer when the game starts. Every time the shot is changed the new values are retrieved and * PlayController initialize the observer when the game starts. Every time the shot is changed the new values are retrieved and
* passed on to the PlayController by changing a shotChanged variable to true. * passed on to the PlayController by changing a shotChanged variable to true.
*/ */
...@@ -361,7 +360,6 @@ public class AndroidInterfaceClass implements FirebaseServices { ...@@ -361,7 +360,6 @@ public class AndroidInterfaceClass implements FirebaseServices {
} }
/** /**
* Design pattern: Listener
* When a game starts from PlayController it is added a listener to changes in the variable GameFinished, so * When a game starts from PlayController it is added a listener to changes in the variable GameFinished, so
* both players will receive information that a game has ended. * both players will receive information that a game has ended.
*/ */
......
...@@ -16,7 +16,7 @@ public class GameCodeHolder implements FirebaseServices{ ...@@ -16,7 +16,7 @@ public class GameCodeHolder implements FirebaseServices{
private FirebaseServices firebaseServices; private FirebaseServices firebaseServices;
/** /**
* Design pattern: Singelton * DESIGN PATTERN: Singelton
*/ */
private GameCodeHolder(FirebaseServices firebaseServices){ private GameCodeHolder(FirebaseServices firebaseServices){
this.firebaseServices = firebaseServices; this.firebaseServices = firebaseServices;
......
...@@ -42,6 +42,10 @@ public class GameStateController { ...@@ -42,6 +42,10 @@ public class GameStateController {
private static Collection<FeedbackDelay> feedbackDelayListeners = new ArrayList<FeedbackDelay>(); private static Collection<FeedbackDelay> feedbackDelayListeners = new ArrayList<FeedbackDelay>();
private static Collection<Feedback> feedbackListeners = new ArrayList<>(); private static Collection<Feedback> feedbackListeners = new ArrayList<>();
/**
* DESIGN PATTERN: Observer
* Feedback listeners and feedback delay listener use the observer pattern
*/
public GameStateController(){ public GameStateController(){
this.playerController = new PlayerController(); this.playerController = new PlayerController();
......
...@@ -18,6 +18,9 @@ public abstract class Ship { ...@@ -18,6 +18,9 @@ public abstract class Ship {
private int shipNr; private int shipNr;
/** /**
* QUALITY ATTRIBUTE: Modifiability
* Tactic: Abstract common services
*
* Sets the color of the ships, creates a new list for the shotCoordinates and sets isSunk to false * Sets the color of the ships, creates a new list for the shotCoordinates and sets isSunk to false
* @param color The color of the ship * @param color The color of the ship
*/ */
......
...@@ -6,6 +6,8 @@ import java.util.Stack; ...@@ -6,6 +6,8 @@ import java.util.Stack;
public class GameStateManager { public class GameStateManager {
/** /**
* DESIGN PATTERN: State and Singelton
*
* The game state manager (gsm) has the overview of the state. * The game state manager (gsm) has the overview of the state.
* This is out state pattern whitch controls what view is used and showed on the screen. * This is out state pattern whitch controls what view is used and showed on the screen.
* Witch state that is used is controlled by making a Stack, where you will have access to the top element/"plate" * Witch state that is used is controlled by making a Stack, where you will have access to the top element/"plate"
......
...@@ -37,7 +37,10 @@ public class MakeBoardView extends State implements Feedback { ...@@ -37,7 +37,10 @@ public class MakeBoardView extends State implements Feedback {
/** /**
* QUALITY ATTRIBUTE: USABILITY * QUALITY ATTRIBUTE: USABILITY
* The user can initialize the board by placing the ships where the user wants. * The user can initialize the board by placing the ships where the user wants and recieve feedback.
* The user can also read a tutorial.
* Tactics: Tutorial, support user initative
*
* *
* This view presents the board for the player * This view presents the board for the player
* The player can place the ships at preferred position. * The player can place the ships at preferred position.
......
...@@ -19,6 +19,9 @@ public class MenuView extends State { ...@@ -19,6 +19,9 @@ public class MenuView extends State {
private TutorialView TutorialView; private TutorialView TutorialView;
/** /**
* QUALITY ATTRIBUTE: Usability
* Tactics: Tutorial
*
* This is the first view and state that is added to the stack in the gsm. * This is the first view and state that is added to the stack in the gsm.
* It is the front page of the application. * It is the front page of the application.
* There are two buttons witch sends the user to the game or to a tutorial of the game. * There are two buttons witch sends the user to the game or to a tutorial of the game.
......
...@@ -34,6 +34,10 @@ public class PlayView extends State implements FeedbackDelay { ...@@ -34,6 +34,10 @@ public class PlayView extends State implements FeedbackDelay {
private static Sound hitSound; private static Sound hitSound;
private static Sound missSound; private static Sound missSound;
/**
* QUALITY ATTRIBUTE: Usability
* tactic: Tutorial
*/
/** /**
* the constructor, sets background * the constructor, sets background
......
...@@ -31,7 +31,6 @@ public class SinglePlayerView extends State implements FeedbackDelay { ...@@ -31,7 +31,6 @@ public class SinglePlayerView extends State implements FeedbackDelay {
public SinglePlayerView(GameStateManager gsm, GameStateController gsc) { public SinglePlayerView(GameStateManager gsm, GameStateController gsc) {
super(gsm, gsc); super(gsm, gsc);
background = Assets.playBackground; background = Assets.playBackground;
......
...@@ -7,9 +7,12 @@ import com.mygdx.game.controller.GameStateController; ...@@ -7,9 +7,12 @@ import com.mygdx.game.controller.GameStateController;
public abstract class State { public abstract class State {
/* /**
State is an abstract class that is implemented in all the View classes. With the gsm we can control * QUALITY ATTRIBUTE: MODIFIABILITY
which state that is showing on the screen. * tactic: Abstract common services
*
* State is an abstract class that is implemented in all the View classes. With the gsm we can control
* which state that is showing on the screen.
*/ */
protected OrthographicCamera cam; protected OrthographicCamera cam;
protected Vector3 mouse; protected Vector3 mouse;
......
...@@ -3,6 +3,11 @@ package com.mygdx.game.view.ViewComponents; ...@@ -3,6 +3,11 @@ package com.mygdx.game.view.ViewComponents;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
public class Assets { public class Assets {
/**
* QUALITY ATTRIBUTE: Performance
* Tactic: Increase efficiency
*/
// Backgrounds // Backgrounds
public static Texture mainBackground; public static Texture mainBackground;
public static Texture playBackground; public static Texture playBackground;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment