package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;

import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.Test;

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

class Building13Test {


    @Test
    void Building13() {
        assertThrows(IllegalArgumentException.class, () -> {
            Building13 b2 = new Building13(0, 15, 1);
        });

        assertThrows(IllegalArgumentException.class, () -> {
            Building13 b3 = new Building13(-1, 15, 1);
        });

        assertThrows(IllegalArgumentException.class, () -> {
            Building13 b4 = new Building13(4, 15, 1);
        });

        assertThrows(IllegalArgumentException.class, () -> {
            Building13 b5 = new Building13(2, 0, 1);
        });

        assertThrows(IllegalArgumentException.class, () -> {
            Building13 b6 = new Building13(1, -15, 1);
        });

        Building13 b1 = new Building13(1, 10, 1);
        assertEquals(1, b1.getEra());


    }

    @Test
    void applyEffect() {
        Player p1 = new Player("gigi");
        p1.addPrestige(10);
        Building13 b1 = new Building13(1, 10, 1);
        p1.addFood(b1.getPrice());
        b1.buy(p1);

        b1.applyEffect(p1);
        assertEquals(35, p1.getPrestigeValue());
    }

    @Test
    void applyEffectException() {
        assertThrows(IllegalArgumentException.class, () -> {
            Building13 b13 = new Building13(1, 10, 1);
            Player p = new Player("test");
            b13.applyEffect(p);
        });
    }
    @Test
    void applyEffectMultiplePlayerException() {
        Building13 b13 = new Building13(1, 10, 1);
        Player p1 = new Player("test1");
        Player p2 = new Player("test2");
        b13.buy(p1);
        assertFalse(b13.buy(p2));
    }
}