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

import se.urmo.game.entities.ghost.Ghost;
import se.urmo.game.entities.pacman.PacMan;
import se.urmo.game.map.GameMap;

import java.awt.Point;

public class ClydeStrategy implements GhostStrategy {
    @Override
    public Point chooseTarget(Ghost clyde, PacMan pacman, GameMap map) {
        Point pacTile = pacman.getPosition();
        Point clydeTile = clyde.getPosition().asPoint(); // ghost’s current tile

        double distance = pacTile.distance(clydeTile);

        if (distance > 8) {
            return pacTile; // chase Pac-Man
        } else {
            return new Point(0, GameMap.OFFSET_Y + (map.rows() * GameMap.MAP_TILESIZE)); // retreat to corner
        }
    }
}
