package gamecontrollers.turn;

import gamecontrollers.commands.GameplayActionCommand;
import java.util.List;
import java.util.Stack;
import models.palacefestival.JavaPlayer;


public class HistoryChannelController {
    private Stack<GameplayActionCommand> commandHistory;
    private List<GameplayActionCommand> lastRound;

    public HistoryChannelController(){

    }

    public void addCommand(GameplayActionCommand c){

    }

    public Stack<GameplayActionCommand> getGameHistory(){
        // TODO implemente
        return null;

    }

    public List<GameplayActionCommand> getLastRound(JavaPlayer p){
        // TODO implemente
        return null;
    }
}

@@ -79,16 +79,17 @@
 ommand;%0A
+%0A
 import j
@@ -101,21 +101,19 @@
 til.
-List;
+*;%0A
 %0Aimport 
 java
@@ -112,23 +112,25 @@
 ort 
-java.util.Stack
+models.board.Game
 ;%0Aim
@@ -218,21 +218,118 @@
     
-private Stack
+//Store history as a list of turns where that turn%0A    //is a list of commands%0A    private ArrayList%3CArrayList
 %3CGam
@@ -347,16 +347,17 @@
 Command%3E
+%3E
  command
@@ -381,148 +381,683 @@
 ate 
-List%3CGameplayActionCommand%3E lastRound;%0A%0A    public HistoryChannelController()%7B%0A%0A    %7D%0A%0A    public void addCommand(GameplayActionCommand c)%7B%0A
+int numPlayers;%0A    private int currentTurn = 0;%0A%0A    public HistoryChannelController(int numPlayers)%7B%0A        this.numPlayers = numPlayers;%0A        commandHistory = new ArrayList%3CArrayList%3CGameplayActionCommand%3E%3E();%0A        commandHistory.add(new ArrayList%3CGameplayActionCommand%3E());%0A    %7D%0A%0A    //Add the new command to the current turn list%0A    public void addCommand(GameplayActionCommand c)%7B%0A        commandHistory.get(currentTurn).add(c);%0A    %7D%0A%0A    //turn has ended, add a new turn list to the commandHistory%0A    //also increment the currentTurn index%0A    public void newTurn()%7B%0A        commandHistory.add(new ArrayList%3CGameplayActionCommand%3E());%0A        currentTurn++;
 %0A   
@@ -1075,13 +1075,12 @@
 lic 
-Stack
+List
 %3CGam
@@ -1125,34 +1125,228 @@
         
-// TODO implemente
+ArrayList%3CGameplayActionCommand%3E completeHistory = new ArrayList%3CGameplayActionCommand%3E();%0A%0A%0A       for(ArrayList%3CGameplayActionCommand%3E list : commandHistory) %7B%0A           completeHistory.addAll(list);%0A       %7D%0A
 %0A       
@@ -1353,20 +1353,31 @@
  return 
-null
+completeHistory
 ;%0A%0A    %7D
@@ -1459,50 +1459,570 @@
   //
- TODO implemente%0A        return null
+compile a list of all the turns in order%0A%0A        ArrayList%3CGameplayActionCommand%3E lastRound = new ArrayList%3CGameplayActionCommand%3E();%0A%0A        //get a ListIterator starting at the end%0A        ListIterator%3CArrayList%3CGameplayActionCommand%3E%3E it = commandHistory.listIterator(currentTurn);%0A%0A%0A        for(int i = currentTurn - numPlayers - 1; i %3C commandHistory.size(); i++)%7B%0A            //check that game has enough turns to go far enough back%0A            if(i %3E= 0)%0A                lastRound.addAll(commandHistory.get(i));%0A        %7D%0A%0A        return lastRound
 ;%0A    %7D%0A
 %7D%0A
@@ -2019,10 +2019,12 @@
 ;%0A    %7D%0A
+%0A%0A
 %7D%0A

Implement HistoryChannelController