PySide6 app that follows MTG Arena's Player.log under Steam/Proton and shows my remaining library with draw odds, my zones, and everything revealed about the opponent (board, graveyard, exile, known hand/library, seen this match). - Auto-detects the Steam library, Proton prefix log and MTGA install - Card names/costs/types from MTGA's local SQLite card database - Tracks card identity across zone changes, shuffles and Bo3 games - Scryfall card images with a lazy, size-capped LRU disk cache - Live log following with restart detection, plus --replay mode - Flags log gaps where MTGA omits oversized game-state messages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
import pytest
|
|
|
|
from mtga_assistant import paths
|
|
from mtga_assistant.carddb import CardDB, mana_value, parse_mana
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"text,symbols,mv",
|
|
[
|
|
("o2oU", ["2", "U"], 3),
|
|
("oW", ["W"], 1),
|
|
("", [], 0),
|
|
("o1o(R/G)", ["1", "R/G"], 2),
|
|
("o1o(B/P)o(B/P)", ["1", "B/P", "B/P"], 3),
|
|
("o(2/B)o(2/R)", ["2/B", "2/R"], 4),
|
|
("oXoXoR", ["X", "X", "R"], 1),
|
|
("o10", ["10"], 10),
|
|
],
|
|
)
|
|
def test_parse_mana(text, symbols, mv):
|
|
assert parse_mana(text) == symbols
|
|
assert mana_value(symbols) == mv
|
|
|
|
|
|
def test_missing_db_gives_placeholder():
|
|
db = CardDB(None)
|
|
assert not db.available
|
|
assert db.get(123).name == "Unknown card #123"
|
|
assert db.base_grp(123) == 123
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def real_db():
|
|
mtga = paths.find_mtga_dir(paths.load_config())
|
|
path = paths.find_card_db(mtga) if mtga else None
|
|
if path is None:
|
|
pytest.skip("MTGA is not installed on this machine")
|
|
return CardDB(path)
|
|
|
|
|
|
def test_real_db_lookup(real_db):
|
|
island = real_db.get(97169)
|
|
assert island.name == "Island"
|
|
assert island.is_land
|
|
|
|
|
|
def test_real_db_split_card_half_maps_to_whole(real_db):
|
|
# Desist (half) -> Cease // Desist
|
|
assert real_db.base_grp(89160) == 89158
|
|
assert real_db.base_grp(89158) == 89158
|