package ua.ansymo.hintco

import java.util.Deque
import ua.ansymo.hintco.VariantDiagram

class VariantValidator implements IVariantValidator {
	override validVariant(VariantDiagram v, Iterable<VariantDiagram> alternatives, Deque<VariantDiagram> selectedVariants){
		/*
		 * A new variant can be selected if none of the previous variants imply that an alternative is selected instead.
		 */
		 ! selectedVariants.exists[n | 
		 	n.alternative !== null &&
		 	alternatives.exists[a | 
		 		n.alternative.implies.contains(a.alternative)
		 ]]
	}
	
}