test_class.declarator: mockGameContext
test_class.modifier: @Mock(answer = Answers.RETURNS_DEEP_STUBS)
test_class.original_string: @Mock(answer = Answers.RETURNS_DEEP_STUBS)
      IGameContext mockGameContext;
test_class.type: IGameContext
test_class.var_name: mockGameContext
test_class.declarator: mockStats
test_class.modifier: @Mock
test_class.original_string: @Mock
      Stats mockStats;
test_class.type: Stats
test_class.var_name: mockStats
test_class.declarator: mockConfig
test_class.modifier: @Mock
test_class.original_string: @Mock
      Configuration mockConfig;
test_class.type: Configuration
test_class.var_name: mockConfig
test_class.declarator: FILESEPARATOR = File.separator
test_class.modifier: private static final
test_class.original_string: private static final String FILESEPARATOR = File.separator;
test_class.type: String
test_class.var_name: FILESEPARATOR
test_class.file: gazeplay-games/src/test/java/net/gazeplay/games/whereisit/WhereIsItTest.java
test_class.identifier: WhereIsItTest
test_case.body: @Test
      void shouldPickAndBuildRandomCustomPictures() {
          final WhereIsIt whereIsIt = new WhereIsIt(WhereIsItGameType.CUSTOMIZED, 2, 2, false, mockGameContext, mockStats);
          when(mockConfig.getLanguage()).thenReturn("eng");
          final String currentDir = System.getProperty("user.dir") +
              FILESEPARATOR + "src" +
              FILESEPARATOR + "test" +
              FILESEPARATOR + "resources";
          when(mockConfig.getWhereIsItDir()).thenReturn(currentDir);
  
          final Dimension2D mockDimension = new Dimension2D(20, 20);
          when(mockGameContext.getGamePanelDimensionProvider().getDimension2D()).thenReturn(mockDimension);
          when(mockGameContext.getConfiguration()).thenReturn(mockConfig);
  
          final ReplayablePseudoRandom random = new ReplayablePseudoRandom();
          final RoundDetails randomPictures = whereIsIt.pickAndBuildRandomPictures(4, random, 0);
          assert randomPictures.getPictureCardList().size() == 4;
      }
test_case.class_method_signature: WhereIsItTest.shouldPickAndBuildRandomCustomPictures()
test_case.full_signature: @Test void shouldPickAndBuildRandomCustomPictures()
test_case.identifier: shouldPickAndBuildRandomCustomPictures
test_case.invocations: thenReturn when getLanguage getProperty thenReturn when getWhereIsItDir thenReturn when getDimension2D getGamePanelDimensionProvider thenReturn when getConfiguration pickAndBuildRandomPictures size getPictureCardList
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldPickAndBuildRandomCustomPictures()
focal_class.declarator: NBMAXPICTO = 10
focal_class.modifier: private static final
focal_class.original_string: private static final int NBMAXPICTO = 10;
focal_class.type: int
focal_class.var_name: NBMAXPICTO
focal_class.declarator: MAXSIZEPICTO = 250
focal_class.modifier: private static final
focal_class.original_string: private static final double MAXSIZEPICTO = 250;
focal_class.type: double
focal_class.var_name: MAXSIZEPICTO
focal_class.declarator: questionText
focal_class.modifier: private
focal_class.original_string: private Text questionText;
focal_class.type: Text
focal_class.var_name: questionText
focal_class.declarator: gameType
focal_class.modifier: @Getter
      private final
focal_class.original_string: @Getter
      private final WhereIsItGameType gameType;
focal_class.type: WhereIsItGameType
focal_class.var_name: gameType
focal_class.declarator: nbLines
focal_class.modifier: private final
focal_class.original_string: private final int nbLines;
focal_class.type: int
focal_class.var_name: nbLines
focal_class.declarator: nbColumns
focal_class.modifier: private final
focal_class.original_string: private final int nbColumns;
focal_class.type: int
focal_class.var_name: nbColumns
focal_class.declarator: fourThree
focal_class.modifier: private final
focal_class.original_string: private final boolean fourThree;
focal_class.type: boolean
focal_class.var_name: fourThree
focal_class.declarator: gameContext
focal_class.modifier: private final
focal_class.original_string: private final IGameContext gameContext;
focal_class.type: IGameContext
focal_class.var_name: gameContext
focal_class.declarator: stats
focal_class.modifier: private final
focal_class.original_string: private final Stats stats;
focal_class.type: Stats
focal_class.var_name: stats
focal_class.declarator: currentRoundDetails
focal_class.modifier: private
focal_class.original_string: private RoundDetails currentRoundDetails;
focal_class.type: RoundDetails
focal_class.var_name: currentRoundDetails
focal_class.declarator: targetAOIList
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<TargetAOI> targetAOIList;
focal_class.type: ArrayList<TargetAOI>
focal_class.var_name: targetAOIList
focal_class.file: gazeplay-games/src/main/java/net/gazeplay/games/whereisit/WhereIsIt.java
focal_class.identifier: WhereIsIt
focal_class.interfaces: implements GameLifeCycle
focal_class.class_method_signature: WhereIsIt.WhereIsIt(final WhereIsItGameType gameType, final int nbLines, final int nbColumns, final boolean fourThree,
                       final IGameContext gameContext, final Stats stats)
focal_class.full_signature: public  WhereIsIt(final WhereIsItGameType gameType, final int nbLines, final int nbColumns, final boolean fourThree,
                       final IGameContext gameContext, final Stats stats)
focal_class.identifier: WhereIsIt
focal_class.modifiers: public
focal_class.parameters: (final WhereIsItGameType gameType, final int nbLines, final int nbColumns, final boolean fourThree,
                       final IGameContext gameContext, final Stats stats)
focal_class.signature:  WhereIsIt(final WhereIsItGameType gameType, final int nbLines, final int nbColumns, final boolean fourThree,
                       final IGameContext gameContext, final Stats stats)
focal_class.class_method_signature: WhereIsIt.launch()
focal_class.full_signature: @Override public void launch()
focal_class.identifier: launch
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void launch()
focal_class.class_method_signature: WhereIsIt.createQuestionTransition(final String question, final List<Image> listOfPictos)
focal_class.full_signature: private Transition createQuestionTransition(final String question, final List<Image> listOfPictos)
focal_class.identifier: createQuestionTransition
focal_class.modifiers: private
focal_class.parameters: (final String question, final List<Image> listOfPictos)
focal_class.return: Transition
focal_class.signature: Transition createQuestionTransition(final String question, final List<Image> listOfPictos)
focal_class.class_method_signature: WhereIsIt.playQuestionSound()
focal_class.full_signature:  void playQuestionSound()
focal_class.identifier: playQuestionSound
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void playQuestionSound()
focal_class.class_method_signature: WhereIsIt.dispose()
focal_class.full_signature: @Override public void dispose()
focal_class.identifier: dispose
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void dispose()
focal_class.class_method_signature: WhereIsIt.removeAllIncorrectPictureCards()
focal_class.full_signature:  void removeAllIncorrectPictureCards()
focal_class.identifier: removeAllIncorrectPictureCards
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void removeAllIncorrectPictureCards()
focal_class.class_method_signature: WhereIsIt.fileIsImageFile(File file)
focal_class.full_signature: static boolean fileIsImageFile(File file)
focal_class.identifier: fileIsImageFile
focal_class.modifiers: static
focal_class.parameters: (File file)
focal_class.return: boolean
focal_class.signature: boolean fileIsImageFile(File file)
focal_class.class_method_signature: WhereIsIt.pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_class.full_signature:  RoundDetails pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_class.identifier: pickAndBuildRandomPictures
focal_class.parameters: (final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_class.return: RoundDetails
focal_class.signature: RoundDetails pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_class.class_method_signature: WhereIsIt.getFiles(final File folder)
focal_class.full_signature: private File[] getFiles(final File folder)
focal_class.identifier: getFiles
focal_class.modifiers: private
focal_class.parameters: (final File folder)
focal_class.return: File[]
focal_class.signature: File[] getFiles(final File folder)
focal_class.class_method_signature: WhereIsIt.error(final String language)
focal_class.full_signature: private void error(final String language)
focal_class.identifier: error
focal_class.modifiers: private
focal_class.parameters: (final String language)
focal_class.return: void
focal_class.signature: void error(final String language)
focal_class.class_method_signature: WhereIsIt.getPathSound(final String folder, final String language)
focal_class.full_signature: private String getPathSound(final String folder, final String language)
focal_class.identifier: getPathSound
focal_class.modifiers: private
focal_class.parameters: (final String folder, final String language)
focal_class.return: String
focal_class.signature: String getPathSound(final String folder, final String language)
focal_class.class_method_signature: WhereIsIt.getQuestionText(final String folder, final String language)
focal_class.full_signature: private String getQuestionText(final String folder, final String language)
focal_class.identifier: getQuestionText
focal_class.modifiers: private
focal_class.parameters: (final String folder, final String language)
focal_class.return: String
focal_class.signature: String getQuestionText(final String folder, final String language)
focal_class.class_method_signature: WhereIsIt.getPictogramms(final String folder)
focal_class.full_signature: private List<Image> getPictogramms(final String folder)
focal_class.identifier: getPictogramms
focal_class.modifiers: private
focal_class.parameters: (final String folder)
focal_class.return: List<Image>
focal_class.signature: List<Image> getPictogramms(final String folder)
focal_method.body: RoundDetails pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages) {
  
          final Configuration config = gameContext.getConfiguration();
  
          int filesCount;
          final String directoryName;
          List<File> imagesFolders = new LinkedList<>();
          List<String> resourcesFolders = new LinkedList<>();
  
          if (this.gameType == CUSTOMIZED) {
              final File imagesDirectory = new File(config.getWhereIsItDir() + "/images/");
              directoryName = imagesDirectory.getPath();
              filesCount = 0;
              File[] listOfTheFiles = imagesDirectory.listFiles();
              if(listOfTheFiles!=null) {
                  for (File f : listOfTheFiles) {
                      File[] filesInf = f.listFiles();
                      if(filesInf != null) {
                          if (f.isDirectory() && filesInf.length > 0){
                              boolean containsImage = false;
                              int i = 0;
                              while( !containsImage && i < filesInf.length) {
                                  File file = filesInf[i];
                                  containsImage = fileIsImageFile(file);
                                  i++;
                              }
                              if(containsImage) {
                                  imagesFolders.add(f);
                                  filesCount++;
                              }
                          }
                      }
                  }
              }
          } else {
              final String resourcesDirectory = "data/" + this.gameType.getResourcesDirectoryName();
              final String imagesDirectory = resourcesDirectory + "/images/";
              directoryName = imagesDirectory;
  
              // Here we filter out any unwanted resource folders, based on the difficulty JSON file
              Set<String> difficultySet;
              try {
                  SourceSet sourceSet = new SourceSet(resourcesDirectory + "/difficulties.json");
                  difficultySet = (sourceSet.getResources(this.gameType.getDifficulty()));
              } catch (FileNotFoundException fe) {
                  log.info("No difficulty file found; Reading from all directories");
                  difficultySet = Collections.emptySet();
              }
  
              Set<String> tempResourcesFolders = ResourceFileManager.getResourceFolders(imagesDirectory);
  
              // If nothing can be found we take the entire folder contents.
              if (!difficultySet.isEmpty()) {
                  Set<String> finalDifficultySet = difficultySet;
                  tempResourcesFolders = tempResourcesFolders
                      .parallelStream()
                      .filter(s ->
                          finalDifficultySet.parallelStream().anyMatch(s::contains)
                      )
                      .collect(Collectors.toSet());
              }
  
              resourcesFolders.addAll(tempResourcesFolders);
  
              filesCount = resourcesFolders.size();
          }
  
          final String language = config.getLanguage();
  
          if (filesCount == 0) {
              log.warn("No images found in Directory " + directoryName);
              error(language);
              return null;
          }
  
          int posX = 0;
          int posY = 0;
  
          final GameSizing gameSizing = new GameSizingComputer(nbLines, nbColumns, fourThree)
              .computeGameSizing(gameContext.getGamePanelDimensionProvider().getDimension2D());
  
          final List<PictureCard> pictureCardList = new ArrayList<>();
          String questionSoundPath = null;
          String question = null;
          List<Image> pictograms = null;
          if (this.gameType == FIND_ODD) {
  
              int index = random.nextInt(resourcesFolders.size());
              final String folder = resourcesFolders.remove((index) % filesCount);
  
              index = random.nextInt(resourcesFolders.size());
              final String winnerFolder = resourcesFolders.remove((index) % filesCount);
              final String folderName = (new File(winnerFolder)).getName();
  
              for (int i = 0; i < numberOfImagesToDisplayPerRound; i++) {
                  final Set<String> files;
                  if (i == winnerImageIndexAmongDisplayedImages) {
                      files = ResourceFileManager.getResourcePaths(winnerFolder);
                  } else {
                      files = ResourceFileManager.getResourcePaths(folder);
                  }
  
                  final int numFile = random.nextInt(files.size());
  
                  final String randomImageFile = (String) files.toArray()[numFile];
  
                  if (winnerImageIndexAmongDisplayedImages == i) {
  
                      // TODO for now the line under is commented to avoid freeze
                      //questionSoundPath = getPathSound(imagesFolders[(index) % filesCount].getName(), language);
  
                      question = MultilinguismFactory.getSingleton().getTranslation("findodd", config.getLanguage());
  
                      pictograms = getPictogramms(folderName);
  
                  }
  
                  final PictureCard pictureCard = new PictureCard(gameSizing.width * posX + gameSizing.shift,
                      gameSizing.height * posY, gameSizing.width, gameSizing.height, gameContext, winnerImageIndexAmongDisplayedImages == i,
                      randomImageFile + "", stats, this);
  
                  final TargetAOI targetAOI = new TargetAOI(gameSizing.width * (posX + 0.25), gameSizing.height * (posY+1), (int)gameSizing.height,
                      System.currentTimeMillis());
                  targetAOIList.add(targetAOI);
  
                  pictureCardList.add(pictureCard);
  
                  if ((i + 1) % nbColumns != 0) {
                      posX++;
                  } else {
                      posY++;
                      posX = 0;
                  }
              }
  
          } else if (this.gameType == CUSTOMIZED) {
  
              for (int i = 0; i < numberOfImagesToDisplayPerRound; i++) {
  
                  int index = random.nextInt(imagesFolders.size());
  
                  final File folder = imagesFolders.remove((index) % filesCount);
  
                  final File[] files = getFiles(folder);
  
                  List<File> validImageFiles = new ArrayList<>();
  
                  for ( File file: files){
                      if(fileIsImageFile(file)){
                          validImageFiles.add(file);
                      }
                  }
  
                  final int numFile = random.nextInt(validImageFiles.size());
  
                  final File randomImageFile = validImageFiles.get(numFile);
  
                  if (winnerImageIndexAmongDisplayedImages == i) {
  
                      questionSoundPath = getPathSound(folder.getName(), language);
  
                      question = getQuestionText(folder.getName(), language);
  
                      pictograms = getPictogramms(folder.getName());
  
                  }
  
                  // The image file needs 'file:' prepended as this will get images from a local source, not resources.
                  final PictureCard pictureCard = new PictureCard(gameSizing.width * posX + gameSizing.shift,
                      gameSizing.height * posY, gameSizing.width, gameSizing.height, gameContext,
                      winnerImageIndexAmongDisplayedImages == i, "file:" + randomImageFile, stats, this);
  
                  final TargetAOI targetAOI = new TargetAOI(gameSizing.width * (posX + 0.25), gameSizing.height * (posY+1), (int)gameSizing.height,
                      System.currentTimeMillis());
                  targetAOIList.add(targetAOI);
  
                  pictureCardList.add(pictureCard);
  
  
                  if ((i + 1) % nbColumns != 0) {
                      posX++;
                  } else {
                      posY++;
                      posX = 0;
                  }
              }
          } else {
              for (int i = 0; i < numberOfImagesToDisplayPerRound; i++) {
                  int index = random.nextInt(resourcesFolders.size());
  
                  final String folder = resourcesFolders.remove((index) % filesCount);
                  final String folderName = (new File(folder)).getName();
  
                  final Set<String> files = ResourceFileManager.getResourcePaths(folder);
  
                  final int numFile = random.nextInt(files.size());
  
                  final String randomImageFile = (String) files.toArray()[numFile];
  
                  if (winnerImageIndexAmongDisplayedImages == i) {
  
                      questionSoundPath = getPathSound(folderName, language);
  
                      question = getQuestionText(folderName, language);
  
                      pictograms = getPictogramms(folderName);
  
                  }
  
                  final PictureCard pictureCard = new PictureCard(gameSizing.width * posX + gameSizing.shift,
                      gameSizing.height * posY, gameSizing.width, gameSizing.height, gameContext,
                      winnerImageIndexAmongDisplayedImages == i, randomImageFile + "", stats, this);
  
                  pictureCardList.add(pictureCard);
  
                  final TargetAOI targetAOI = new TargetAOI(gameSizing.width * (posX + 0.25), gameSizing.height * (posY+1), (int)gameSizing.height,
                      System.currentTimeMillis());
                  targetAOIList.add(targetAOI);
  
  
                  if ((i + 1) % nbColumns != 0) {
                      posX++;
                  } else {
                      posY++;
                      posX = 0;
                  }
              }
          }
          return new RoundDetails(pictureCardList, winnerImageIndexAmongDisplayedImages, questionSoundPath, question,
              pictograms);
      }
focal_method.class_method_signature: WhereIsIt.pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_method.full_signature:  RoundDetails pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_method.identifier: pickAndBuildRandomPictures
focal_method.invocations: getConfiguration getWhereIsItDir getPath listFiles listFiles isDirectory fileIsImageFile add getResourcesDirectoryName getResources getDifficulty info emptySet getResourceFolders isEmpty collect filter parallelStream anyMatch parallelStream toSet addAll size getLanguage warn error computeGameSizing getDimension2D getGamePanelDimensionProvider nextInt size remove nextInt size remove getName getResourcePaths getResourcePaths nextInt size toArray getTranslation getSingleton getLanguage getPictogramms currentTimeMillis add add nextInt size remove getFiles fileIsImageFile add nextInt size get getPathSound getName getQuestionText getName getPictogramms getName currentTimeMillis add add nextInt size remove getName getResourcePaths nextInt size toArray getPathSound getQuestionText getPictogramms add currentTimeMillis add
focal_method.parameters: (final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)
focal_method.return: RoundDetails
focal_method.signature: RoundDetails pickAndBuildRandomPictures(final int numberOfImagesToDisplayPerRound, final ReplayablePseudoRandom random,
                                              final int winnerImageIndexAmongDisplayedImages)