from .olives_abstractcontrollableobject import AbstractControllableObject
from olives_objectcontrollable import ObjectControllable
from olives_job import Job
from olives_gamestate import GameState


def wash_hands(self: AbstractControllableObject, job: Job, game_state: GameState, elapsed_ticks: int, obj: ObjectControllable, parameter: str):
    current_step = job.get_step().get_current_step()
    if current_step == 0:
        # navigate to the context object and set the appropriate animation when done (successfully)
        def success_callback() -> bool:
            game_state.set_animation(self.object_id, "wash_hands", True)
            return True
        self.handle_context_transition_step(job, game_state, obj, success_callback)

    elif current_step == 1:
        # reset the step progress upon first run
        self.reset_step_progress(job, game_state, job.get_step().get_price())
        # set the overall target progress for this step
        value = 20
        # update the elapsed ticks
        self.update_elapsed_ticks(job, elapsed_ticks)
        # get the progress value to add
        obj.set_hygiene(obj.get_hygiene() + self.get_relative_progress_limited(job, elapsed_ticks, value))
        # and see if we have finished the step already. if so, finish the job
        self.check_for_completion(job)
