package engine.element;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import annotations.parameter;
import engine.Endable;
import engine.UpdateAndReturnable;


/**
 * This class contains a wave, which is a set of enemies who are sent out from one spawn point. The
 * enemies may be sent all at once, randomly, or spaced evenly.
 * 
 * @author Qian Wang
 * @author Bojia Chen
 *
 */
public class Wave implements UpdateAndReturnable, Endable {

    @parameter(settable = true, playerDisplay = false, defaultValue = "null")
    private List<List<String>> myEnemies;
    @parameter(settable = true, playerDisplay = false, defaultValue = "1.0")
    private double mySendRate;

    private int myEnemyIndex = 0;
    private int myTimer = 0;

    public Wave () {
        myEnemies = new ArrayList<>();
    }

    @Override
    public boolean hasEnded () {
        return myEnemyIndex == myEnemies.size();
    }

    @Override
    public Map<Object, List<String>> update (int counter) {
        Map<Object, List<String>> tempReturnMap = null;
        if (++myTimer == mySendRate && !hasEnded()) {
            myTimer = 0;
            tempReturnMap = new HashMap<>();
            //TODO: be aware of pathID and pass that up instead of null
            tempReturnMap.put(null, myEnemies.get(myEnemyIndex++));
        }
        return tempReturnMap; // Null if no enemies to return
    }

}

@@ -580,21 +580,16 @@
 private 
-List%3C
 List%3CStr
@@ -592,17 +592,16 @@
 %3CString%3E
-%3E
  myEnemi
@@ -679,11 +679,12 @@
  = %22
-1.0
+null
 %22)%0A 
@@ -698,25 +698,32 @@
 ate 
-d
+List%3CD
 ouble
+%3E
  mySend
-Rate
+Times
 ;%0A%0A 
@@ -783,16 +783,43 @@
 mer = 0;
+%0A    private String myPath;
 %0A%0A    pu
@@ -871,32 +871,110 @@
 ist%3C%3E();%0A    %7D%0A%0A
+    public void setPath (String pathGUID) %7B%0A        myPath = pathGUID;%0A    %7D%0A%0A
     @Override%0A  
@@ -1190,16 +1190,25 @@
 = null;%0A
+        %0A
         
@@ -1211,18 +1211,16 @@
     if (
-++
 myTimer 
@@ -1232,95 +1232,136 @@
 Send
-Rate && !hasEnded()) %7B%0A            myTimer = 0;%0A            temp
+Times.get(myEnemyIndex)) %7B%0A            tempReturnMap = new HashMap%3C%3E();%0A            List%3CString%3E enemiesTo
 Return
-Map
  = new 
-HashMap
+ArrayList
 %3C%3E()
@@ -1378,145 +1378,249 @@
     
-//TODO: be aware of pathID and pass that up instead of null%0A            tempReturnMap.put(null, myEnemies.get(myEnemyIndex++));%0A        %7D
+while (myTimer == mySendTimes.get(myEnemyIndex) && !hasEnded()) %7B%0A                enemiesToReturn.add(myEnemies.get(myEnemyIndex++));%0A            %7D%0A            tempReturnMap.put(myPath, enemiesToReturn);%0A        %7D%0A        %0A        myTimer++;
 %0A   

Allow storing path in wave, modified wave to use new gamedata format