package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;

import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Shaman;
import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;

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

class ShamanicRitualTest {

    @Test
    void uniqueWinnerGetsPrestige() {
        Player p1 = new Player("Marco");
        Player p2 = new Player("Luca");

        ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));

        new Shaman(1, 3).insert(p1);
        new Shaman(1, 1).insert(p2);

        ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
        ritual.activateEvent(players);

        assertEquals(10, p1.getPrestigeValue());
        assertEquals(-5, p2.getPrestigeValue());
    }

    @Test
    void tiedPlayersNoDoublePrestige() {
        Player p3 = new Player("Marco");
        Player p4 = new Player("Luca");

        ArrayList<Player> players = new ArrayList<>(Arrays.asList(p3, p4));

        new Shaman(1, 3).insert(p3);
        new Shaman(1, 3).insert(p4);

        ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
        ritual.activateEvent(players);

        assertEquals(10, p3.getPrestigeValue());
        assertEquals(10, p4.getPrestigeValue());
    }

    @Test
    void uniqueWinnerWithDoublePrestige() {
        Player p1 = new Player("Marco");
        Player p2 = new Player("Luca");

        ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));

        new Shaman(1, 3).insert(p1);
        new Shaman(1, 1).insert(p2);

        BuildingCard b = new BuildingCard(6, 1, 5, 1);
        p1.addFood(5);
        b.buy(p1);

        ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
        ritual.activateEvent(players);

        assertEquals(20, p1.getPrestigeValue());
        assertEquals(-5, p2.getPrestigeValue());
    }
}