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

    @Test
    void effect() {
        Player p1 = new Player("Luca");
        Player p2 = new Player("Mario");
        Player p3 = new Player("Gabriele");

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

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

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

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

        Player p4 = new Player("Giorgio");
        Order3 order2 = new Order3(new ArrayList<>());
        order2.push(new Player("Tommaso"));
        order2.push(new Player("Antonio"));
        order2.push(p4);
        assertEquals(0, p4.getFoodValue());
        assertEquals(0, p4.getPrestigeValue());

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