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

import com.ghost.technic.server.board.Battleline;
import com.ghost.technic.server.card.effect.ConstantAbility;
import com.ghost.technic.server.card.playable.usable.impl.CreatureCard;
import com.ghost.technic.server.game.GameState;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
public class BulwarkConstantAbility implements ConstantAbility {

    private final CreatureCard bulwark;
    private final Battleline battleline;

    @Override
    public void apply() {
        log.info("[apply] Bulwark’s effect active: +2 armor to neighbours");
    }

    @Override
    public void remove() {
        log.info("[remove] Bulwark’s effect active: +2 armor to neighbours");
    }

    @Override
    public int armorBonus(CreatureCard target, GameState state) {
        if (!battleline.getCreatures().contains(bulwark)) return 0;
        List<CreatureCard> neighbors = battleline.getNeighbors(bulwark);
        return neighbors.contains(target) ? 2 : 0;
    }
}
