from src.gameplay.core.tasks.collectDeadCorpse import CollectDeadCorpseTask
from src.gameplay.core.tasks.lootCorpse import LootCorpseTask
from src.gameplay.core.tasks.walkToCoordinate import WalkToCoordinateTask


context = {}
creature = {'coordinate': (0, 0, 0)}


def test_should_test_default_params():
    task = LootCorpseTask(creature)
    assert task.name == 'lootCorpse'
    assert task.isRootTask == True
    assert task.creature == creature


def test_onBeforeStart():
    task = LootCorpseTask(creature)
    assert task.onBeforeStart(context) == context
    assert len(task.tasks) == 2
    # Erst neben die Leiche laufen, dann looten.
    assert isinstance(task.tasks[0], WalkToCoordinateTask)
    assert task.tasks[0].coordinate == creature['coordinate']
    assert task.tasks[0].tolerance == 1
    assert task.tasks[0].parentTask == task
    assert task.tasks[0].rootTask == task
    assert isinstance(task.tasks[1], CollectDeadCorpseTask)
    assert task.tasks[1].creature == creature
    assert task.tasks[1].parentTask == task
    assert task.tasks[1].rootTask == task
