package com.example.vdcscore.ui.livegames;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.util.ArrayList;
import java.util.List;

public class GameViewModel extends ViewModel {

    private final MutableLiveData<List<Game>> mGames;
    private final MutableLiveData<Game> mSelectedGame;

    public GameViewModel() {
        mGames = new MutableLiveData<>();
        mSelectedGame = new MutableLiveData<>();
        loadMockGames();
    }

    public LiveData<List<Game>> getGames() {
        return mGames;
    }

    public LiveData<Game> getSelectedGame() {
        return mSelectedGame;
    }

    public void selectGame(Game game) {
        mSelectedGame.setValue(game);
    }

    private void loadMockGames() {
        List<Game> games = new ArrayList<>();
        games.add(new Game("1", "VDC", "Benfica", 2, 1, "45'"));
        games.add(new Game("2", "Sporting", "Porto", 0, 0, "12'"));
        games.add(new Game("3", "Braga", "V. Guimarães", 1, 3, "88'"));
        mGames.setValue(games);
    }
}
