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

Technology: View Models
Feature:    MTG Parent View Model

Description:
Parent data model for MTG views
"""


# internal
from business_objects.tcg.mtg_deck import MTG_Deck, Parameters_MTG_Deck
from business_objects.tcg.mtg_deck_commander_bracket import MTG_Deck_Commander_Bracket
from business_objects.tcg.mtg_game import MTG_Game, Parameters_MTG_Game
from business_objects.tcg.mtg_game_player import MTG_Game_Player, Parameters_MTG_Game_Player
from business_objects.tcg.mtg_game_round import MTG_Game_Round, Parameters_MTG_Game_Round
from business_objects.tcg.mtg_game_round_player_damage import MTG_Game_Round_Player_Damage, Parameters_MTG_Game_Round_Player_Damage
from business_objects.tcg.statistic import Statistic
from helpers.helper_app import Helper_App
import lib.argument_validation as av
from models.model_view_base import Model_View_Base
# external
from flask import send_file, jsonify
from flask_sqlalchemy import SQLAlchemy
import locale
from typing import ClassVar
from abc import abstractmethod


class Model_View_MTG_Base(Model_View_Base):
    ATTR_COMMANDER_BRACKET_ID: ClassVar[str] = MTG_Deck_Commander_Bracket.ATTR_COMMANDER_BRACKET_ID
    ATTR_DAMAGE_ID: ClassVar[str] = MTG_Game_Round_Player_Damage.ATTR_DAMAGE_ID
    ATTR_DECK_ID: ClassVar[str] = MTG_Deck.ATTR_DECK_ID
    ATTR_ENTITY_RECORD_ID: ClassVar[str] = Statistic.ATTR_ENTITY_RECORD_ID
    ATTR_GAME_ID: ClassVar[str] = MTG_Game.ATTR_GAME_ID
    ATTR_PLAYER_ID: ClassVar[str] = MTG_Game_Player.ATTR_PLAYER_ID
    ATTR_ROUND_ID: ClassVar[str] = MTG_Game_Round.ATTR_ROUND_ID
    FLAG_COMMANDER_DEATHS: ClassVar[str] = MTG_Game_Round_Player_Damage.FLAG_COMMANDER_DEATHS
    FLAG_DAMAGE: ClassVar[str] = MTG_Game_Round_Player_Damage.FLAG_DAMAGE
    FLAG_DECK: ClassVar[str] = MTG_Deck.FLAG_DECK
    FLAG_ENTITY_TYPE_CODE: ClassVar[str] = Statistic.FLAG_ENTITY_TYPE_CODE
    FLAG_GAME: ClassVar[str] = MTG_Game.FLAG_GAME
    FLAG_IS_BOOL: ClassVar[str] = Statistic.FLAG_IS_BOOL
    FLAG_IS_FLOAT: ClassVar[str] = Statistic.FLAG_IS_FLOAT
    FLAG_IS_INTERVAL: ClassVar[str] = Statistic.FLAG_IS_INTERVAL
    FLAG_IS_TEXT: ClassVar[str] = Statistic.FLAG_IS_TEXT
    FLAG_IS_TIMESTAMP: ClassVar[str] = Statistic.FLAG_IS_TIMESTAMP
    FLAG_IS_COMMANDER: ClassVar[str] = MTG_Game.FLAG_IS_COMMANDER
    FLAG_IS_DRAFT: ClassVar[str] = MTG_Game.FLAG_IS_DRAFT
    FLAG_IS_SEALED: ClassVar[str] = MTG_Game.FLAG_IS_SEALED
    FLAG_LIFE_GAIN: ClassVar[str] = MTG_Game_Round_Player_Damage.FLAG_LIFE_GAIN
    FLAG_LIFE_LOSS: ClassVar[str] = MTG_Game_Round_Player_Damage.FLAG_LIFE_LOSS
    FLAG_LOCATION_NAME: ClassVar[str] = MTG_Game.FLAG_LOCATION_NAME
    FLAG_PLAYER: ClassVar[str] = MTG_Game_Player.FLAG_PLAYER
    FLAG_ROUND: ClassVar[str] = MTG_Game_Round.FLAG_ROUND
    FLAG_STARTING_LIFE: ClassVar[str] = MTG_Game.FLAG_STARTING_LIFE
    FLAG_VALUE_BOOL: ClassVar[str] = Statistic.FLAG_VALUE_BOOL
    FLAG_VALUE_FLOAT: ClassVar[str] = Statistic.FLAG_VALUE_FLOAT
    FLAG_VALUE_INTERVAL: ClassVar[str] = Statistic.FLAG_VALUE_INTERVAL
    FLAG_VALUE_TEXT: ClassVar[str] = Statistic.FLAG_VALUE_TEXT
    FLAG_VALUE_TIMESTAMP: ClassVar[str] = Statistic.FLAG_VALUE_TIMESTAMP
    HASH_GET_MTG_GAME_DAMAGE_RECORDS: ClassVar[str] = '/mtg/api/game/<game_id>/damage-records'
    HASH_GET_MTG_GAME_PLAYERS: ClassVar[str] = '/mtg/api/game/<game_id>/players'
    HASH_GET_MTG_GAME_ROUNDS: ClassVar[str] = '/mtg/api/game/<game_id>/rounds'
    HASH_SAVE_MTG_DECK: ClassVar[str] = '/mtg/save-deck'
    HASH_SAVE_MTG_GAME: ClassVar[str] = '/mtg/save-game'
    HASH_SAVE_MTG_GAME_PLAYER: ClassVar[str] = '/mtg/save-game-player'
    HASH_SAVE_MTG_GAME_ROUND: ClassVar[str] = '/mtg/save-game-round'
    HASH_SAVE_MTG_GAME_ROUND_PLAYER_DAMAGE: ClassVar[str] = '/mtg/save-game-round-player-damage'
    
    is_page_mtg: bool = True

    def __init__(self, hash_page_current, **kwargs):
        _m = 'Model_View_MTG_Base.__init__'
        # Helper_App.console_log(f'{_m}\nstarting')
        super().__init__(hash_page_current=hash_page_current, **kwargs)
        self.is_page_mtg = True
        if self.hash_page_current == Model_View_MTG_Base.HASH_PAGE_MTG_TRIAL_GAME:
            self._title = 'MTG Home'
