///<reference path="ContentDifferential.ts"/>
class AdaptiveDifferential {
    public compareFunction : (noun : any) => boolean = () => false;
    public countsAs = 0;
    public score = 0;

    public getScore () {
        return this.score;
    }

    constructor (replacer : (noun : any) => boolean, score : number) {
        this.compareFunction = replacer;
    }

    public isMatch (noun : any) {
        return this.compareFunction(noun);
    }

    public static ANYOF (...acceptableValues) {
        return new AdaptiveDifferential((noun : any) => {
            //console.log(acceptableValues, noun);
            for (let i = 0; i < acceptableValues.length; i++) {
                if (ContentDifferential.compareNouns(acceptableValues[i], noun)) {
                    return true;
                }
            }
            return false;
        }, (new ContentDifferential(...acceptableValues).getScore()));
    }

    public static FULLYADAPTIVE (...acceptableValues) {
        let ad = AdaptiveDifferential.ANYOF(...acceptableValues);
        ad.countsAs = -1;
        return ad;
    }

    public static MALE = new AdaptiveDifferential((noun : any) => {
        if (noun instanceof Humanoid) {
            return noun.isMale();
        }
        return false;
    }, new ContentDifferential(Humanoid).getScore());

    public static FEMALE = new AdaptiveDifferential((noun : any) => {
        if (noun instanceof Humanoid) {
            return noun.isMale();
        }
        return false;
    }, new ContentDifferential(Humanoid).getScore());

    public static MASCULINE = new AdaptiveDifferential((noun : any) => {
        if (noun instanceof Humanoid) {
            return noun.getGenderValue().genderValueCorrected <= 50;
        }
        return false;
    }, new ContentDifferential(Humanoid).getScore());

    public static FEMININE = new AdaptiveDifferential((noun : any) => {
        if (noun instanceof Humanoid) {
            return noun.getGenderValue().genderValueCorrected >= 50;
        }
        return false;
    }, new ContentDifferential(Humanoid).getScore());
}