package com.ghost.technic.server.card;

import com.ghost.technic.server.Player;
import com.ghost.technic.server.board.Flank;
import com.ghost.technic.server.card.effect.impl.ScreeyanAbility;
import com.ghost.technic.server.card.impl.ArchonIdentityCard;
import com.ghost.technic.server.card.misc.House;
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.GameTurnManager;
import com.ghost.technic.server.game.event.EventBus;
import org.junit.jupiter.api.Test;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class ScreeyanTest {

    GameActionService actionService;
    GameTurnManager turnManager;
//    GameState gameState;
    Player alice;
    Player bob;

    @Test
    void testScreeyanPreventsOpponentFromChoosingDiscardedHouse() {
        // Setup players
        alice = Player.builder()
                .name("Alice")
                .archonIdentityCard(ArchonIdentityCard.builder().houses(Set.of(House.BROBNAR, House.SHADOWS, House.UNTAMED)).build())
                .build();

        bob = Player.builder()
                .name("Bob")
                .archonIdentityCard(ArchonIdentityCard.builder().houses(Set.of(House.SANCTUM, House.LOGOS, House.MARS)).build())
                .deck(new LinkedList<>(List.of(
                        CreatureCard.builder().name("Some Mars Creature").house(House.MARS).build()
                )))
                .build();

        var screeyan = CreatureCard.builder()
                .name("Screeyan")
                .power(5)
                .house(House.DIS)
                .abilities(List.of(new ScreeyanAbility()))
                .build();

        GameActionService actionService = new GameActionService(new GameState(new EventBus()));
        GameTurnManager turnManager = new GameTurnManager(actionService.getGameState(), actionService);

        actionService.getGameState().setPlayers(alice, bob);

        actionService.getGameState().setActivePlayer(alice);
        actionService.playCreature(alice, screeyan, Flank.LEFT);

        // Start Bob’s turn
        turnManager.endOfTurn(alice);
//        turnManager.takeTurn(bob);

        // Assert MARS is blocked
        assertEquals(actionService.getGameState().getRestrictedHouses(bob), Set.of(House.MARS));
    }

}
