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.game.GameActionService;
import com.ghost.technic.server.game.event.AmberChangeType;
import com.ghost.technic.server.game.event.EventType;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AllusionsOfGrandeurAbility implements CardAbility {

    @Override
    public void register(GameActionService service, Player controller, PlayableCard source) {
        Player opponent = service.getGameState().getOpponentOf(controller);
        House chosen = controller.chooseHouse(opponent.getArchonIdentityCard().getHouses());

        service.getGameState().getEventBus().subscribe(EventType.HOUSE_CHOSEN, event -> {
            Player player = event.get("player");
            House house = event.get("house");

            if (player.equals(opponent) && house != chosen) {
                service.adjustAmber(controller, 3, AmberChangeType.GAINED, source);
            }
        });
    }
}
