package se.urmo.game.entities.ghost.mode;

import lombok.extern.slf4j.Slf4j;
import se.urmo.game.entities.ghost.Ghost;
import se.urmo.game.entities.ghost.strategy.HouseStrategy;
import se.urmo.game.entities.pacman.PacMan;
import se.urmo.game.map.GameMap;

@Slf4j
public class HouseGhostMode extends AbstractGhostModeImpl {
    public HouseGhostMode(Ghost ghost) {
        super(ghost, new HouseStrategy(), ghost.getLevelManager(), ghost.getAnimation());
    }

    @Override
    public void update(Ghost ghost, PacMan pacman, GameMap map) {
        if (getPosition().asPoint().distance(Ghost.getHouseEntrance().asPoint()) < 15) {
            log.debug("Ghost left home, switching to chase mode");
            ghost.requestModeChange(GhostMode.CHASE);
        }
        updatePosition(ghost, pacman, map);
    }
}
