Example #1
0
        public void deleteCreation(Creation to_be_deleted)
        {
            if (to_be_deleted.Type == GeneratorTypesEnum.NPC)
            {
                savedNpcNames.Remove(to_be_deleted.Name);
            }
            else if (to_be_deleted.Type == GeneratorTypesEnum.Location)
            {
                savedLocationNames.Remove(to_be_deleted.Name);
            }
            else if (to_be_deleted.Type == GeneratorTypesEnum.Encounter)
            {
                savedEncounterNames.Remove(to_be_deleted.Name);
            }

            currentlySavedCreations.Remove(currentlySavedCreations.Where(i => i.Name == to_be_deleted.Name).Single());

            string delete = "DELETE FROM SavedCreationsTbl WHERE \"" + to_be_deleted.Name + "\" = CreationName;";

            string temp = "Data Source=";

            temp += "..\\..\\sqlDatabase\\MasterDB.db";
            temp += ";Version=3;New=False;Compress=False";

            SQLiteConnection db = new SQLiteConnection(temp);

            db.Open();
            var cmd = new SQLiteCommand(db);

            cmd.CommandText = delete;
            cmd.ExecuteNonQuery();
            db.Close();
        }
Example #2
0
        /// <summary>
        /// Adds a new creation to the list of recent creations
        /// </summary>
        /// <param name="creationName">name of the creation to be added</param>
        /// <param name="creationType">type fo the creation to be added</param>
        /// <param name="creation">creation to be added</param>
        public void AddCreation(String creationName, GeneratorTypesEnum creationType, Dictionary <string, string> creation)
        {
            Creation newCreation = new Creation(creationName, creationType, creation);

            mostRecentCreations.Add(newCreation);

            if (mostRecentCreations.Count > 10)
            {
                mostRecentCreations.RemoveAt(0);
            }
        }
Example #3
0
        public void Creation(Creation creation)
        {
            currentlySavedCreations.Add(creation);

            if (creation.Type == GeneratorTypesEnum.NPC)
            {
                savedNpcNames.Add(creation.Name);
            }
            else if (creation.Type == GeneratorTypesEnum.Location)
            {
                savedLocationNames.Add(creation.Name);
            }
            else
            {
                savedEncounterNames.Add(creation.Name);
            }

            string description = string.Empty;

            if (creation.Type == GeneratorTypesEnum.Encounter)
            {
                description = createEncounterDescription(creation.Generation);
            }
            else
            {
                description = creation.Generation["description"];
            }


            string insert = "INSERT INTO SavedCreationsTbl (CreationName, CreationDescription, CreationType)" +
                            "VALUES " +
                            "(\"" + creation.Name + "\", \"" + description + "\", \"" + creation.Type + "\");";

            string temp = "Data Source=";

            temp += "..\\..\\sqlDatabase\\MasterDB.db";
            temp += ";Version=3;New=False;Compress=False";

            SQLiteConnection db = new SQLiteConnection(temp);

            db.Open();
            var cmd = new SQLiteCommand(db);

            cmd.CommandText = insert;
            cmd.ExecuteNonQuery();
            db.Close();
        }