import json

symbol_data = {}
value_data = {}

with open("data/symbol.json") as f:
    symbol_data: dict[str,int] = json.load(f)
with open("data/value.json") as f:
    value_data: dict[str,int] = json.load(f)

def map_id_to_str(pairs: dict[str, int], id: int):
    for key, key_value in pairs.items():
        if key_value == id:
            return key
    raise ValueError(f"id {id} not found in pairs")

class Card:
    def __init__(self, symbol_id, value_id):
        self.symbol = map_id_to_str(symbol_data, symbol_id)
        self.value = map_id_to_str(value_data, value_id)

    def __lt__(self, other):
        return (self.symbol, self.value) < (other.symbol, other.value)

    def __eq__(self, other):
        return isinstance(other, Card) and self.symbol == other.symbol and self.value == other.value

    def __hash__(self):
        return hash((self.symbol, self.value))