package Server;


import java.util.List;

public class TurnTileOld {

     private final Player[] positions;
     private int place;
     private int currentplayer;


     public TurnTileOld(int numP) {

          this.positions = new Player[numP];
          this.place = 0;
          this.currentplayer = 0;

     }

     public Player[] startOrder (List<Player> players){

          for (Player p: players){

               positions[place]=p;
               place++;

          }
          //Collections.shuffle(Arrays.asList(positions));

          return positions;
     }

     public Player giveReward (Player player){

          if (player == positions[positions.length-1]){

               if (!player.removeFood(1)){

                    player.removePrestigePoints(2);
               }



          }

          else if (player == positions[0]){

               if (positions.length==2){

                    player.addFood(1);
               }
               else if (positions.length == 5){

                    player.addFood(3);
               }
               else{

                    player.addFood(2);
               }
          }

          else if (player == positions[1] && positions.length >= 4){

               player.addFood(1);
          }


          return player;
     }

     public Player nextPlayer() {

          currentplayer++;
          if (currentplayer== positions.length){
               currentplayer=0;
          }

          return positions[currentplayer];
     }

     public Player addPlayer(Player player){

          positions[currentplayer]=player;

          return positions[currentplayer];

     }
}
