package cz.jzitnik.game.logic.services.suffocating;

import cz.jzitnik.game.Game;
import cz.jzitnik.game.annotations.CustomLogic;
import cz.jzitnik.game.logic.CustomLogicInterface;
import cz.jzitnik.tui.ScreenRenderer;

@CustomLogic
public class Suffocating implements CustomLogicInterface {
    @Override
    public void nextIteration(Game game, ScreenRenderer screenRenderer) {
        var world = game.getWorld();
        int[] data = game.getPlayerCords();
        int x = data[0];
        int y = data[1];

        var blocks = world[y - 1][x];

        if (blocks.stream().anyMatch(i -> !i.isGhost())) {
            // Deal damage when solid block
            game.getPlayer().dealDamage(game, screenRenderer);
        }
    }
}
