Class GameViewModel

    • Constructor Detail

      • GameViewModel

        public GameViewModel​(@NonNull
                             Application application)
        The constructor initializes repositories, services, and other elements needed by the ViewModel.
        Parameters:
        application - The ScaleScroller application.
    • Method Detail

      • getScale

        public LiveData<Scale> getScale​(Note tonic,
                                        Mode mode)
        Returns LiveData of a scale, given tonic and mode.
        Parameters:
        tonic - The scale's tonic.
        mode - The scale's mode.
        Returns:
        LiveData of the Scale.
      • getLevelWon

        public MutableLiveData<Boolean> getLevelWon()
        Returns LiveData of a Boolean indicating whether the player has won the level.
        Returns:
        LiveData of a Boolean.
      • getScales

        public LiveData<List<Scale>> getScales()
        Returns LiveData of a list of scales, ordered by difficulty.
        Returns:
        LiveData of a List of Scale
      • getResume

        public LiveData<Boolean> getResume()
        Returns LiveData of a Boolean value indicating dialog directions.
        Returns:
        LiveData of a Boolean.
      • setResume

        public void setResume​(boolean resume)
        Sets the resume value indicating dialog directions.
        Parameters:
        resume - A boolean value.
      • getHearts

        public LiveData<Integer> getHearts()
        Returns LiveData of an Integer value that holds the player's hearts.
        Returns:
        LiveData of a Integer.
      • getScore

        public LiveData<Integer> getScore()
        Returns LiveData of an Integer value that holds the player's score.
        Returns:
        LiveData of a Integer.
      • setGameMode

        public void setGameMode​(GameFragment.GameMode gameMode)
        Sets the GameMode of the ViewModel to the enumerated types LEARN or CHALLENGE.
        Parameters:
        gameMode - A enumerated GameFragment.GameMode type.
      • getTonic

        public Note getTonic()
        Returns the tonic of the scale.
        Returns:
        The tonic of the scale.
      • setTonic

        public void setTonic​(Note tonic)
        Sets the tonic of the scale in the ViewModel to one of the enumerated types.
        Parameters:
        tonic - A enumerated Note type.
      • getMode

        public Mode getMode()
        Returns the mode of the scale.
        Returns:
        The mode of the scale.
      • setMode

        public void setMode​(Mode mode)
        Sets the mode of the scale in the ViewModel to one of the enumerated types.
        Parameters:
        mode - A enumerated Mode type.
      • getLevel

        public Level getLevel()
        Returns the Level object.
        Returns:
        The level.
      • setLevel

        public void setLevel​(Level level)
        Sets the Level object.
        Parameters:
        level - The leve.
      • startLevel

        public void startLevel()
        Starts a single level.
      • setPaused

        public void setPaused​(boolean paused)
        Sets a boolean value indicating whether the game is paused or not.
        Parameters:
        paused - A boolean that indicates whether the game is paused or not.
      • getNotesString

        public String getNotesString()
        Returns a String representation of the correct notes of the scale.
        Returns:
        A String of correctNotes.
      • getNotes

        public Note[] getNotes()
        Returns an array of correct notes.
        Returns:
        An array of correct notes.
      • save

        public void save​(ChallengeAttempt challengeAttempt)
        Saves a challenge attempt to the database.
        Parameters:
        challengeAttempt - The attempt to be saved.
      • save

        public void save​(LearnLevelAttempt learnLevelAttempt)
        Saves a learn attempt to the database.
        Parameters:
        learnLevelAttempt - The attempt to be saved.
      • getPlayer

        public LiveData<Player> getPlayer()
        Returns LiveData of the current player.
        Returns:
        LiveData of the current Player.