"""
Project:    PARTS Website
Author:     Edward Middleton-Smith
            Precision And Research Technology Systems Limited

Technology: View Models
Feature:    MTG Games View Model

Description:
Data model for MTG games view
"""

# internal
from business_objects.tcg.mtg_game import MTG_Game, Parameters_MTG_Game
from datastores.datastore_mtg import DataStore_MTG
from models.model_view_mtg_base import Model_View_MTG_Base
from helpers.helper_app import Helper_App
import lib.argument_validation as av

# external
from pydantic import BaseModel
from typing import ClassVar


class Model_View_MTG_Games(Model_View_MTG_Base):
    form_filters: object = None
    games: list = None
    parameters_game: Parameters_MTG_Game = None

    def __init__(self, parameters_game=None, hash_page_current=Model_View_MTG_Base.HASH_PAGE_MTG_GAMES):
        _m = 'Model_View_MTG_Games.__init__'
        # Helper_App.console_log(f'{_m}\nstarting...')
        super().__init__(hash_page_current=hash_page_current)
        self._title = 'MTG Games'
        datastore = DataStore_MTG()

        # Initialize parameters with defaults if not provided
        if parameters_game is None:
            user_session = datastore.get_user_session()
            self.parameters_game = Parameters_MTG_Game.get_default(user_session.user_id)
        else:
            self.parameters_game = parameters_game

        # Helper_App.console_log(f'Query args: {self.parameters_game}')
        self.games, errors = datastore.get_many_mtg_game(self.parameters_game)
