コード例 #1
0
ファイル: BaseConvo.cs プロジェクト: proxeeus/RunUO.T2A
        public AttitudeList(FileStrBuff file)
        {
            string    tok;
            ArrayList att = new ArrayList(5);

            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    att.Add(Enum.Parse(typeof(Attitude), tok, true));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (file.Eof())
            {
                return;
            }

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (att.Count > 0)
            {
                m_Atts = (Attitude[])att.ToArray(typeof(Attitude));
            }
            else
            {
                m_Strings = null;
            }
        }
コード例 #2
0
ファイル: BaseConvo.cs プロジェクト: proxeeus/RunUO.T2A
        public NotorietyList(FileStrBuff file)
        {
            string    tok;
            ArrayList noto = new ArrayList(5);

            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    noto.Add(Enum.Parse(typeof(NotoVal), tok, true));
                }
                catch
                {
                }
            }

            if (file.Eof())
            {
                return;
            }

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (noto.Count > 0)
            {
                m_Notos = (NotoVal[])noto.ToArray(typeof(NotoVal));
            }
            else
            {
                m_Strings = null;
            }
        }
コード例 #3
0
ファイル: BaseConvo.cs プロジェクト: proxeeus/RunUO.T2A
        public Fragment(FileStrBuff file)
        {
            m_Collections = new KeywordCollection[3];
            while (!file.Eof())
            {
                string tok = file.GetNextToken().ToLower();
                if (tok == null || tok.Length <= 0)
                {
                    continue;
                }

                if (tok == "#sophistication")
                {
                    Sophistication s;
                    string         level = file.GetNextToken();
                    try
                    {
                        s = (Sophistication)Enum.Parse(typeof(Sophistication), level, true);
                    }
                    catch
                    {
                        Console.WriteLine("Fragment : Error, invalid Sophistication {0}", level);
                        continue;
                    }

                    m_Collections[(int)s] = new KeywordCollection(file);
                }
                else if (tok == "#fragment")
                {
                    while (!file.Eof())
                    {
                        if (file.GetNextToken() == "{")
                        {
                            break;
                        }
                    }
                }
                else if (tok != "{" && tok != "}")
                {
                    Console.WriteLine("Fragment : Unknown token '{0}'", tok);
                }
            }
        }
コード例 #4
0
ファイル: BaseConvo.cs プロジェクト: greeduomacro/divinity
        public KeywordCollection(FileStrBuff file)
        {
            m_Keys = new ArrayList();

            file.SkipUntil('{');
            file.NextChar();

            int brace = 1;
            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                    case '#':
                        {
                            if (tok.ToLower() != "#key")
                            {
                                //Console.WriteLine( "KeywordCollection : Unknown command '{0}'", tok );
                                continue;
                            }

                            StringBuilder keyExp = new StringBuilder();
                            int count = 0;
                            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
                            {
                                if (tok[0] == '@')
                                {
                                    if (tok == "@InternalGreeting")
                                    {
                                        if (count > 0)
                                            keyExp.Append("|");
                                        count += 7;
                                        keyExp.Append("(*hi*)|(*hello*)|(*hail*)|(*greeting*)|(*how*((*you*)|(*thou*)))|(*good*see*thee*)");
                                    }

                                    continue;
                                }
                                else
                                {
                                    count++;
                                    if (count > 1)
                                        keyExp.Append("|");
                                    keyExp.AppendFormat("({0})", tok);
                                }
                            }

                            if (!file.Eof())
                            {
                                file.Seek(-1); // leave the { in the input

                                IStringList[] lists = MakeList(file);
                                //Console.WriteLine( "KC '{0}' loaded {1} sub-lists...", exp, lists.Length );
                                if (lists != null && keyExp.Length > 0)
                                {
                                    keyExp.Replace("*", ".*");
                                    string exp = keyExp.ToString();
                                    if (exp != null && exp.Length > 0)
                                        m_Keys.Add(new Keyword(exp, lists));
                                }
                            }
                            break;
                        }
                    case '{':
                        brace++;
                        break;
                    case '}':
                        brace--;
                        break;
                    default:
                        //Console.WriteLine( "KeywordCollection : Unknown token '{0}'", tok );
                        break;
                }
            }
        }
コード例 #5
0
ファイル: BaseConvo.cs プロジェクト: greeduomacro/divinity
        public Fragment(FileStrBuff file)
        {
            m_Collections = new KeywordCollection[3];
            while (!file.Eof())
            {
                string tok = file.GetNextToken().ToLower();
                if (tok == null || tok.Length <= 0)
                    continue;

                if (tok == "#sophistication")
                {
                    Sophistication s;
                    string level = file.GetNextToken();
                    try
                    {
                        s = (Sophistication)Enum.Parse(typeof(Sophistication), level, true);
                    }
                    catch
                    {
                        //Console.WriteLine( "Fragment : Error, invalid Sophistication {0}", level );
                        continue;
                    }

                    m_Collections[(int)s] = new KeywordCollection(file);
                }
                else if (tok == "#fragment")
                {
                    while (!file.Eof())
                    {
                        if (file.GetNextToken() == "{")
                            break;
                    }
                }
                else if (tok != "{" && tok != "}")
                {
                    //Console.WriteLine( "Fragment : Unknown token '{0}'", tok );
                }
            }
        }
コード例 #6
0
ファイル: BaseConvo.cs プロジェクト: greeduomacro/divinity
        public AttitudeList(FileStrBuff file)
        {
            string tok;
            ArrayList att = new ArrayList(5);
            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    att.Add(Enum.Parse(typeof(Attitude), tok, true));
                }
                catch
                {
                }
            }

            if (file.Eof())
                return;

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (att.Count > 0)
                m_Atts = (Attitude[])att.ToArray(typeof(Attitude));
            else
                m_Strings = null;
        }
コード例 #7
0
ファイル: BaseConvo.cs プロジェクト: greeduomacro/divinity
        public NotorietyList(FileStrBuff file)
        {
            string tok;
            ArrayList noto = new ArrayList(5);
            while (!file.Eof() && (tok = file.GetNextToken()) != "{")
            {
                try
                {
                    noto.Add(Enum.Parse(typeof(NotoVal), tok, true));
                }
                catch
                {
                }
            }

            if (file.Eof())
                return;

            file.Seek(-1);
            m_Strings = KeywordCollection.MakeList(file);
            if (noto.Count > 0)
                m_Notos = (NotoVal[])noto.ToArray(typeof(NotoVal));
            else
                m_Strings = null;
        }
コード例 #8
0
ファイル: BaseConvo.cs プロジェクト: greeduomacro/divinity
        public static IStringList[] MakeList(FileStrBuff file)
        {
            file.SkipUntil('{');
            file.NextChar();
            int brace = 1;

            ArrayList list = new ArrayList();
            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                    case '{':
                        brace++;
                        break;
                    case '}':
                        brace--;
                        break;
                    case '#':
                        {
                            string lwr = tok.ToLower();
                            if (lwr == "#attitude")
                                list.Add(new AttitudeList(file));
                            else if (lwr == "#notoriety")
                                list.Add(new NotorietyList(file));
                            //else
                            //	Console.WriteLine( "MakeList : Unknown token '{0}'", lwr );
                            break;
                        }
                    default:
                        {
                            PhraseList pl = new PhraseList();
                            pl.Add(tok);
                            //if ( brace <= 0 )
                            //	Console.WriteLine( "MakeList : Warning, no opening brace for PhraseList." );
                            while (!file.Eof() && brace > 0)
                            {
                                tok = file.GetNextToken();
                                if (tok == "{")
                                    brace++;
                                else if (tok == "}")
                                    brace--;
                                else
                                    pl.Add(tok);
                            }
                            list.Add(pl);
                            break;
                        }
                }
            }//while

            if (list.Count > 0)
                return (IStringList[])list.ToArray(typeof(IStringList));
            else
                return null;
        }
コード例 #9
0
ファイル: BaseConvo.cs プロジェクト: proxeeus/RunUO.T2A
        public static IStringList[] MakeList(FileStrBuff file)
        {
            file.SkipUntil('{');
            file.NextChar();
            int brace = 1;

            ArrayList list = new ArrayList();

            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                case '{':
                    brace++;
                    break;

                case '}':
                    brace--;
                    break;

                case '#':
                {
                    string lwr = tok.ToLower();
                    if (lwr == "#attitude")
                    {
                        list.Add(new AttitudeList(file));
                    }
                    else if (lwr == "#notoriety")
                    {
                        list.Add(new NotorietyList(file));
                    }
                    //else
                    //	Console.WriteLine( "MakeList : Unknown token '{0}'", lwr );
                    break;
                }

                default:
                {
                    PhraseList pl = new PhraseList();
                    pl.Add(tok);
                    //if ( brace <= 0 )
                    //	Console.WriteLine( "MakeList : Warning, no opening brace for PhraseList." );
                    while (!file.Eof() && brace > 0)
                    {
                        tok = file.GetNextToken();
                        if (tok == "{")
                        {
                            brace++;
                        }
                        else if (tok == "}")
                        {
                            brace--;
                        }
                        else
                        {
                            pl.Add(tok);
                        }
                    }
                    list.Add(pl);
                    break;
                }
                }
            }            //while

            if (list.Count > 0)
            {
                return((IStringList[])list.ToArray(typeof(IStringList)));
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
ファイル: BaseConvo.cs プロジェクト: proxeeus/RunUO.T2A
        public KeywordCollection(FileStrBuff file)
        {
            m_Keys = new ArrayList();

            file.SkipUntil('{');
            file.NextChar();

            int brace = 1;

            while (!file.Eof() && brace > 0)
            {
                string tok = file.GetNextToken();
                switch (tok[0])
                {
                case '#':
                {
                    if (tok.ToLower() != "#key")
                    {
                        //Console.WriteLine( "KeywordCollection : Unknown command '{0}'", tok );
                        continue;
                    }

                    StringBuilder keyExp = new StringBuilder();
                    int           count  = 0;
                    while (!file.Eof() && (tok = file.GetNextToken()) != "{")
                    {
                        if (tok[0] == '@')
                        {
                            if (tok == "@InternalGreeting")
                            {
                                if (count > 0)
                                {
                                    keyExp.Append("|");
                                }
                                count += 7;
                                keyExp.Append("(*hi*)|(*hello*)|(*hail*)|(*greeting*)|(*how*((*you*)|(*thou*)))|(*good*see*thee*)");
                            }

                            continue;
                        }
                        else
                        {
                            count++;
                            if (count > 1)
                            {
                                keyExp.Append("|");
                            }
                            keyExp.AppendFormat("({0})", tok);
                        }
                    }

                    if (!file.Eof())
                    {
                        file.Seek(-1);                                   // leave the { in the input

                        IStringList[] lists = MakeList(file);
                        //Console.WriteLine( "KC '{0}' loaded {1} sub-lists...", exp, lists.Length );
                        if (lists != null && keyExp.Length > 0)
                        {
                            keyExp.Replace("*", ".*");
                            string exp = keyExp.ToString();
                            if (exp != null && exp.Length > 0)
                            {
                                m_Keys.Add(new Keyword(exp, lists));
                            }
                        }
                    }
                    break;
                }

                case '{':
                    brace++;
                    break;

                case '}':
                    brace--;
                    break;

                default:
                    //Console.WriteLine( "KeywordCollection : Unknown token '{0}'", tok );
                    break;
                }
            }
        }