package cz.jzitnik.game.threads.list;

import cz.jzitnik.game.Game;
import cz.jzitnik.game.annotations.ThreadRegistry;
import cz.jzitnik.game.entities.Player;
import cz.jzitnik.tui.ScreenRenderer;
import lombok.AllArgsConstructor;

/**
 * A thread that periodically checks the player's hunger level.
 * If hunger reaches 0, it applies damage to the player.
 */
@AllArgsConstructor
@ThreadRegistry
public class NoHungerThread extends Thread {
    private final Player player;
    private final Game game;
    private final ScreenRenderer screenRenderer;

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(3000);
                if (player.getHunger() == 0) {
                    player.dealDamage(game, screenRenderer);
                }
            } catch (InterruptedException e) {
                break;
            }
        }
    }
}
