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 Order5Test {

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

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

        order.push(p1);
        assertEquals(3, p1.getFoodValue());
        assertEquals(0, p1.getPrestigeValue());

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

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

        order.push(p4);
        assertEquals(0, p4.getFoodValue());
        assertEquals(0, p4.getPrestigeValue());

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


        Player p6 = new Player("Giulio");
        Order5 order2 = new Order5(new ArrayList<>());
        order2.push(new Player("Guest1"));
        order2.push(new Player("Guest2"));
        order2.push(new Player("Guest3"));
        order2.push(new Player("Guest4"));
        order2.push(p6);
        assertEquals(0, p6.getFoodValue());
        assertEquals(0, p6.getPrestigeValue());


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