32 lines
871 B
Java
32 lines
871 B
Java
package it.polimi.ingsw.gc14.Model;
|
|
|
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
|
|
|
import java.util.*;
|
|
|
|
public abstract class OrderLogicCard {
|
|
private Queue<Player> players;
|
|
public OrderLogicCard(ArrayList<Player> players) {
|
|
Collections.shuffle(players);
|
|
this.players = new LinkedList<>(players);
|
|
}
|
|
public void push(Player player){
|
|
effect(player,players.size());
|
|
players.add(player);
|
|
}
|
|
public Player pull(){
|
|
return players.poll();
|
|
}
|
|
public Player getFirst()
|
|
{
|
|
return players.peek();
|
|
}
|
|
protected abstract void effect(Player player, int index) throws IndexOutOfBoundsException;
|
|
|
|
protected void buildingEffect(Player player)
|
|
{
|
|
for(BuildingCard b : player.buildingCards.stream().filter(x->x.getEffectId()==3).toList())
|
|
player.addFood(1);
|
|
}
|
|
}
|