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

import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.*;

public class Order2 extends OrderLogicCard {
    public Order2(ArrayList<Player> players) {
        super(players);
    }
    @Override
    public void effect(Player player,int index) throws IndexOutOfBoundsException
    {
        if(index >= 2 || index < 0)
        {
            throw new IndexOutOfBoundsException("index out of bounds");
        }
        if(index==0)
        {
            player.addFood(1);
            buildingEffect(player);
            return;
        }
        if(index==1){
            if(!player.removeFood(1)){
                player.removePrestige(2);
                return;
            }
        }
    }
}
