from .olives_abstractcontrollableobject import AbstractControllableObject
from olives_object import SlotType, ContainedStatusChange
from olives_objectcontrollable import ObjectControllable
from olives_job import Job
from olives_gamestate import GameState


def shower(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)
        self.handle_context_transition_step(job, game_state, obj, None, 'action', SlotType.JOB)

    elif current_step == 1:
        # nothing to do but to wait for the change to finish
        if obj.get_contained_status_change() == ContainedStatusChange.NONE:
            game_state.set_animation(self.object_id, 'shower', True)
            job.increment_step(1)

    elif current_step == 2:
        # 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 = 40
        # 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)
