Esempio n. 1
0
 /// <summary>
 /// Adds the quest quietly.
 /// </summary>
 /// <param name="questToAdd">The quest to add.</param>
 public void AddQuestQuiet(IQuest questToAdd)
 {
     if (questToAdd != null)
     {
         QuestList.Add(questToAdd);
         QuestList.Sort();
         OnPropertyChanged(nameof(HasQuests));
     }
 }
Esempio n. 2
0
        public QuestList <Element> AllTurnScripts()
        {
            QuestList <Element> result = new QuestList <Element>();

            foreach (Element item in m_worldModel.GetAllObjects().Where(o => o.Type == ObjectType.TurnScript))
            {
                result.Add(item);
            }
            return(result);
        }
Esempio n. 3
0
        public QuestList<Element> AllTurnScripts()
        {
            QuestList<Element> result = new QuestList<Element>();

            foreach (Element item in m_worldModel.GetAllObjects().Where(o => o.Type == ObjectType.TurnScript))
            {
                result.Add(item);
            }
            return result;
        }
Esempio n. 4
0
 public QuestList<Element> AllCommands()
 {
     QuestList<Element> result = new QuestList<Element>();
     foreach (Element item in m_worldModel.GetAllObjects())
     {
         if (item.Type == ObjectType.Command)
             result.Add(item);
     }
     return result;
 }
Esempio n. 5
0
        public void Setup()
        {
            m_worldModel = new WorldModel();

            m_object = m_worldModel.GetElementFactory(ElementType.Object).Create("object");
            var list = new QuestList<object> {"string1"};
            var dictionary = new QuestDictionary<object> {{"key1", "nested string"}};
            list.Add(dictionary);
            m_object.Fields.Set("list", list);
            m_object.Fields.Resolve(null);
        }
Esempio n. 6
0
        private QuestList <Element> GetAllChildren(/* Element */ object obj, ObjectType type)
        {
            Element             element = GetParameter <Element>(obj, "GetAllChildren", "object");
            QuestList <Element> result  = new QuestList <Element>();

            foreach (Element child in m_worldModel.Elements.GetDirectChildren(element).Where(e => e.ElemType == ElementType.Object && e.Type == type))
            {
                result.Add(child);
                result.AddRange(GetAllChildren(child, type));
            }
            return(result);
        }
Esempio n. 7
0
        public QuestList <Element> AllCommands()
        {
            QuestList <Element> result = new QuestList <Element>();

            foreach (Element item in m_worldModel.GetAllObjects())
            {
                if (item.Type == ObjectType.Command)
                {
                    result.Add(item);
                }
            }
            return(result);
        }
Esempio n. 8
0
        protected override object ConvertField(Element e, string fieldName, object value)
        {
            if (fieldName == "steps")
            {
                QuestList<string> steps = (QuestList<string>)value;
                QuestList<string> result = new QuestList<string>();

                foreach (string step in steps)
                {
                    if (step.StartsWith("assert:"))
                    {
                        string expr = step.Substring(7);
                        Expression expression = new Expression(expr, e.Loader);
                        result.Add("assert:" + expression.Save());
                    }
                    else
                    {
                        result.Add(step);
                    }
                }
                return result;
            }
            return value;
        }
Esempio n. 9
0
        public void Setup()
        {
            m_worldModel = new WorldModel();

            m_object = m_worldModel.GetElementFactory(ElementType.Object).Create("object");
            var list = new QuestList <object> {
                "string1"
            };
            var dictionary = new QuestDictionary <object> {
                { "key1", "nested string" }
            };

            list.Add(dictionary);
            m_object.Fields.Set("list", list);
            m_object.Fields.Resolve(null);
        }
Esempio n. 10
0
        public FunctionCallParameters(WorldModel worldModel, IList <IFunction <object> > parameters)
        {
            if (worldModel.EditMode)
            {
                m_parameterStrings.UndoLog = worldModel.UndoLogger;
            }
            m_parameters = parameters;

            if (parameters != null)
            {
                foreach (var param in parameters)
                {
                    string paramString = param.Save();
                    m_parameterStrings.Add(paramString);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Adds a new quest to the quest list, selects it, and notifies any
        /// listeners that it happened.
        /// </summary>
        /// <param name="parameter"></param>
        private void DoAddQuest(object parameter)
        {
            if (parameter is IQuest quest)
            {
                QuestList.Add(quest);
                SelectedQuest = quest;
            }
            else
            {
                IQuest newEntry = QuestList.AddNewQuest();

                if (newEntry != null)
                {
                    SelectedQuest = newEntry;
                }
            }

            OnPropertyChanged("AddQuest");
            OnPropertyChanged(nameof(HasQuests));
        }
Esempio n. 12
0
        public IEditableList<string> CreateNewEditableList(string parent, string attribute, string item, bool useTransaction)
        {
            if (useTransaction)
            {
                WorldModel.UndoLogger.StartTransaction(string.Format("Set '{0}' {1} to '{2}'", parent, attribute, item));
            }
            Element element = (parent == null) ? null : m_worldModel.Elements.Get(parent);

            QuestList<string> newList = new QuestList<string>();

            if (item != null) newList.Add(item);

            if (element != null)
            {
                element.Fields.Set(attribute, newList);

                // setting an element field will clone the value, so we want to return the new list
                newList = element.Fields.GetAsType<QuestList<string>>(attribute);
            }

            EditableList<string> newValue = new EditableList<string>(this, newList);

            if (useTransaction)
            {
                WorldModel.UndoLogger.EndTransaction();
            }

            return newValue;
        }
Esempio n. 13
0
        public static void LoadQuests()
        {
            using (SQLiteConnection conn = new SQLiteConnection("Data Source=greyflare.db"))
            {
                conn.Open();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM Quests";
                using (SQLiteDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        string name = rdr[1].ToString();
                        string desc = rdr[2].ToString();

                        string       rqstring  = rdr[3].ToString();
                        List <Quest> rqList    = new List <Quest>();
                        string[]     splstring = new string[] { "<>" };
                        if (rqstring != string.Empty)
                        {
                            string[] split = rqstring.Split(splstring, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string s in split)
                            {
                                rqList.Add(QuestList.Find(x => x.QuestName == s));
                            }
                        }

                        string       rsstring = rdr[4].ToString();
                        List <Skill> rsList   = new List <Skill>();
                        if (rsstring != string.Empty)
                        {
                            string[] split = rsstring.Split(splstring, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string s in split)
                            {
                                rsList.Add(SkillsList.Find(x => x.SkillName == s));
                            }
                        }

                        string          ristring = rdr[5].ToString();
                        List <GameItem> riList   = new List <GameItem>();
                        if (ristring != string.Empty)
                        {
                            string[] split = ristring.Split(splstring, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string s in split)
                            {
                                riList.Add(ItemList[s]);
                            }
                        }

                        string          rwstring = rdr[6].ToString();
                        List <GameItem> rwList   = new List <GameItem>();
                        if (rwstring != string.Empty)
                        {
                            string[] split = rwstring.Split(splstring, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string s in split)
                            {
                                rwList.Add(ItemList[s]);
                            }
                        }
                        bool iscomp = false;
                        if (rdr[7].ToString() == "true")
                        {
                            iscomp = true;
                        }
                        QuestList.Add(new Quest(name, desc, rqList, rsList, riList, rwList, iscomp));
                    }
                }
            }
        }