package components;

import com.badlogic.ashley.core.Component;
import dataObjects.Profile;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;

/**
 * Created by Thagus on 19/10/16.
 */
public class ProfileComponent implements Component{
    public CityBlockComponent home, work;

    public Profile profile;

    public HashMap<CityBlockComponent.BlockType, ArrayList<CityBlockComponent>> locations;  //For each block type we have a set of blocks where the user will be

    //movingProfession might not be necessary, if we use the WORK field of the Excel to determine if he works on the Traffic

    public ProfileComponent(Profile profile, HashMap<CityBlockComponent.BlockType, ArrayList<CityBlockComponent>> cityBlocksIndex){
        this.profile = profile;

        Random random = new Random();

        home = cityBlocksIndex.get(CityBlockComponent.BlockType.RESIDENTIAL).get(random.nextInt(cityBlocksIndex.get(CityBlockComponent.BlockType.RESIDENTIAL).size()));

        //Select a work area based on the workArea attribute of the profile
        work = cityBlocksIndex.get(CityBlockComponent.BlockType.BUSINESS).get(random.nextInt(cityBlocksIndex.get(CityBlockComponent.BlockType.BUSINESS).size()));



        //Select random locations for different categories

        /*for(ArrayList<String> arrayList : schedule){

        }*/
    }
}

@@ -302,17 +302,16 @@
 , work;%0A
-%0A
     publ
@@ -335,296 +335,8 @@
 e;%0A%0A
-    public HashMap%3CCityBlockComponent.BlockType, ArrayList%3CCityBlockComponent%3E%3E locations;  //For each block type we have a set of blocks where the user will be%0A%0A    //movingProfession might not be necessary, if we use the WORK field of the Excel to determine if he works on the Traffic%0A%0A
     
@@ -491,25 +491,24 @@
  = profile;%0A
-%0A
         Rand
@@ -530,24 +530,62 @@
  Random();%0A%0A
+        //Select the home of the user%0A
         home
@@ -755,146 +755,483 @@
   //
-Select a work area based on the workArea attribute of the profile%0A        work = cityBlocksIndex.get(CityBlockComponent.BlockType.BUSINESS
+Define the work block%0A        if(profile.isHomeWorker())%7B //If he/she works from home, the work block ant the home block are the same%0A            work = home;%0A        %7D%0A        else%7B%0A            switch(profile.getWorkArea())%7B  //We must select the work block according the profession%0A                case RESIDENTIAL:%0A                case BUSINESS:%0A                case SHOPPING:%0A                case PARK:%0A                    work = cityBlocksIndex.get(profile.getWorkArea()
 ).ge
@@ -1271,45 +1271,29 @@
 get(
-CityBlockComponent.BlockType.BUSINESS
+profile.getWorkArea()
 ).si
@@ -1304,19 +1304,16 @@
 ));%0A
-%0A%0A%0A
         
 //Se
@@ -1312,115 +1312,130 @@
     
-//Select random locations for different categories%0A%0A        /*for(ArrayList%3CString%3E arrayList : schedule)%7B%0A
+            break;%0A                case TRAFFIC:%0A                    work = null;%0A                    break;%0A            %7D
 %0A   
@@ -1440,18 +1440,16 @@
        %7D
-*/
 %0A    %7D%0A%7D

Correct selection of work block based on profession