package dk.itu.mario.level;

import java.util.List;

import dk.itu.mario.level.grammar.LevelParseTree;

public class FitnessEvaluator {
	public static boolean isFit(LevelParseTree parseTree, PlayerProfile playerProfile, LevelArchetype levelArchetype) {
		System.out.println("Evaluating LevelParseTree for fitness");
		List<LevelComponent> levelTemplate = parseTree.getLevelTemplate();
		//a good level has 8-24 components, plus some additional complexity depending on the player's skill level
		
		if (levelTemplate.size() < 8) {
			return false;
		}
		
		if (levelTemplate.size() > 24) {
			return false;
		}
		
		for (LevelComponent lc : levelTemplate) {
			if (!playerProfile.isEnabled(lc.getType())) {
				System.out.println("Level is not fit: " + lc.getType() + " is not enabled.");
				return false;
			}
		}
		
		return true;
	}
}
