import lemonyellow.data.npc as npc
from lemonyellow.data.pokemon_data import pokemon
from lemonyellow.core.framework import trainer
from lemonyellow.core.kernel import clear_trainer, load_trainer


def test_load_trainer():
    clear_trainer()
    assert trainer.name == "TRAINER"
    assert trainer.cash == 123
    assert trainer.dialogue_intro is None

    load_trainer(npc.trainer37)

    assert trainer.name == "Annie"
    assert trainer.cash == 80
    assert trainer.t_type == "Swimmer"
    assert trainer.slot[1].pokebase == pokemon.horsea
    assert trainer.slot[2].pokebase == pokemon.shellder
    assert trainer.slot[3].pokebase == "Test"


def test_load_trainer_special_dialogue_no_extra():
    # only other guy in Brock's gym
    load_trainer(npc.trainer15, special=0)
    assert trainer.name == "Jerry"
    assert trainer.slot[1].pokebase == pokemon.diglett
    assert trainer.dialogue_intro == (
        "Stop right there, kid! You're still" " light years from facing BROCK!"
    )
    assert trainer.dialogue_loss == (
        "Darn! Light years isn't time! It " "measures distance!"
    )
    assert trainer.dialogue_after == (
        "You're pretty hot, but not as hot as" " BROCK!"
    )  # d'aww, thanks
    assert trainer.dialogue_extra is None


def test_load_trainer_special_dialogue_with_extra():
    # Brock himself
    load_trainer(npc.leader1, special=1)
    assert trainer.name == "Brock"
    assert trainer.slot[1].pokebase == pokemon.geodude
    assert "I'm PEWTER GYM's GYM LEADER!" in trainer.dialogue_intro
    assert "I took you for granted. As proof" in trainer.dialogue_loss
    assert "Go to the GYM in CERULEAN" in trainer.dialogue_after
    assert "TM34 contains BIDE!" in trainer.dialogue_extra
