package fanch.multijeu.common.core;

import fanch.multijeu.common.utils.StringUtils;

public class Word extends Saveable {


    public int compareTo(String s) {
        return mString.compareTo(s);
    }

    public int indexOf(String prefix) {
        return indexOf(prefix);
    }

    public String toLowerCase() {
        return mString.toLowerCase();
    }


    public String toUpperCase() {
        return mString.toLowerCase();
    }

    public static class WordType extends Saveable {
        public static final int NOUN = 1;
        public static final int VERB = 2;

        private int value=0;
    }

    protected String   mString="";
    protected int      mCount=0;
    protected WordType mType=new WordType();

    public Word(){}
    public Word(String s){mString=s;}
    public Word(String s, int c){mString=s; mCount=c;}
    public Word(String s, int c, WordType t){mString=s; mCount=c; mType=t;}


    public String toString()
    {
        return mString;
    }

    public int count()
    {
        return mCount;
    }


    public char[] toCharArray() {
        return mString.toCharArray();
    }

    public WordType type()
    {
        return mType;
    }

    public boolean equals(Word w, boolean ignoreCase, boolean accentSensitive)
    {
        if(accentSensitive)
        {
            if(ignoreCase) return mString.toLowerCase().equals(w.mString.toLowerCase());
            else return mString.equals(w.mString);
        }else
        {
            if(ignoreCase)
                return toAscii().toLowerCase().equals(w.toAscii());
            else
                return toAscii().equals(w.toAscii());

        }
    }

    public int length()
    {
        return mString.length();
    }

    public char charAt(int i)
    {
        return mString.charAt(i);
    }

    public String toAscii()
    {
        return StringUtils.toAscii(mString);
    }



}
