package com.ghost.technic.server.card.effect.impl;

import com.ghost.technic.server.Player;
import com.ghost.technic.server.card.effect.CardAbility;
import com.ghost.technic.server.card.misc.House;
import com.ghost.technic.server.card.playable.PlayableCard;
import com.ghost.technic.server.card.playable.usable.impl.CreatureCard;
import com.ghost.technic.server.game.GameActionService;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class BlindingLightAbility implements CardAbility {

    @Override
    public void register(GameActionService gameActionService, Player controller, PlayableCard source) {
        House chosen = controller.chooseHouse(House.getAllHouses());
        log.info("{} chooses {} for Blinding Light", controller.getName(), chosen);

        List<CreatureCard> targets = gameActionService.getGameState().getAllCreatures().stream()
                .filter(c -> c.getHouse() == chosen)
                .toList();

        for (CreatureCard creature : targets) {
            creature.getCounters().addStun(); // assumes a stun counter is supported
            log.info("{} is stunned by Blinding Light", creature.getName());
        }
    }
}
