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.effect.ConstantAbility;
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 com.ghost.technic.server.game.GameState;
import com.ghost.technic.server.game.event.EventType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RequiredArgsConstructor
public class BarristerJoyaConstantAbility implements ConstantAbility {

    private final CreatureCard joya;

    @Override
    public void apply() {
        log.info("[apply] Barrister Joya’s effect active: enemy creatures cannot reap");
    }

    @Override
    public void remove() {
        log.info("[remove] Barrister Joya’s effect removed");
    }

    @Override
    public boolean canReap(CreatureCard creature, Player actingPlayer, GameState gameState) {
        Player joyaOwner = gameState.getOwnerOf(joya);
        Player creatureOwner = gameState.getOwnerOf(creature);

        if (creatureOwner == null) {
            log.warn("[canReap] No owner found for creature: {}", creature.getName());
        }

        return creatureOwner == null || creatureOwner.equals(joyaOwner);
    }

    @Override
    public String toString() {
        return joya.getName();
    }
}
