package dk.itu.mario.engine;

public class ArgParser {
	public static ParsedArgs parse(String[] cmdLineArgs) {
		ParsedArgs parsedArgs = new ParsedArgs();
		for (int i = 0; i < cmdLineArgs.length; i++) {
			if (cmdLineArgs[i].toUpperCase().startsWith("GENERATOR=")) {
				String generatorClass = cmdLineArgs[i].split("=")[1];
				parsedArgs.setGeneratorClass(generatorClass);
				System.out.println("Generator class set to: " + generatorClass);
			} else if (cmdLineArgs[i].toUpperCase().startsWith("SEED=")) {
				String levelRandSeed = cmdLineArgs[i].split("=")[1];
				if (parsedArgs.setLevelRandSeed(levelRandSeed)) {
					System.out.println("Level randomizer seed set to: " + levelRandSeed);
				} else {
					System.out.println("Unable to parse value of levelRandSeed: " 
							+ levelRandSeed +".  Keeping default value of: " 
							+ parsedArgs.getLevelRandSeed());
				}
			} else if (cmdLineArgs[i].toUpperCase().startsWith("VIDEO=")) {
				String videoFileName = cmdLineArgs[i].split("=")[1];
				parsedArgs.setVideoFileName(videoFileName);
			}
		}
		return parsedArgs;
	}
}
