package it.polimi.ingsw.gc14.Model.Orders;

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

import java.util.ArrayList;

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

class Order4Test {

    @Test
    void effect() {
        Player p1 = new Player("Marco");
        Player p2 = new Player("Luca");
        Player p3 = new Player("Antonio");
        Player p4 = new Player("Giovanni");

        Order4 order = new Order4(new ArrayList<>());


        order.push(p1);
        assertEquals(2, p1.getFoodValue());


        order.push(p2);
        assertEquals(1, p2.getFoodValue());


        order.push(p3);
        assertEquals(0, p3.getFoodValue());


        p4.addFood(1);
        order.push(p4);
        assertEquals(0, p4.getFoodValue());
        assertEquals(-2, p4.getPrestigeValue());

        Player p5 = new Player("test");
        Order4 order2 = new Order4(new ArrayList<>());
        order2.push(new Player("Ospite1"));
        order2.push(new Player("Ospite2"));
        order2.push(new Player("Ospite3"));
        order2.push(p5);
        assertEquals(0, p5.getFoodValue());
        assertEquals(0, p5.getPrestigeValue());

        Order4 order3 = new Order4(new ArrayList<>());
        assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 4));
        assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, -1));
    }
}