示例#1
0
        /// <summary>
        /// Dynamically append new entries to the current sheet
        /// </summary>
        public void AddItemEntryToCurrentSheet(DefinitionParserData.Item entry)
        {
            ExcelCellAddress current = new ExcelCellAddress(2, 1 + Program.gameRecognizer.enemyHandling.mobDrops.GetGroupNumberForEnemy(_currentSheet.Name, entry.group) * 4);
            int maxDetph             = 10;

            //Add the group if it does't exist
            if (!_currentSheet.Cells[current.Row, current.Column, current.Row, current.Column + 2].Merge)
            {
                _currentSheet.Cells[current.Row, current.Column, current.Row, current.Column + 2].Merge = true;
            }
            _currentSheet.Cells[current.Row, current.Column, current.Row, current.Column + 2].Value = entry.group;
            _currentSheet.Cells[current.Row, current.Column, current.Row, current.Column + 2].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;

            //Find free spot in the group
            while (_currentSheet.Cells[current.Address].Value != null)
            {
                current = new ExcelCellAddress(current.Row + 1, current.Column);
                if (current.Row >= maxDetph)
                {
                    current = new ExcelCellAddress(2, current.Column + 4);
                }
            }

            //Insert
            InsertValue(current, entry.mainPronounciation);
            InsertValue(new ExcelCellAddress(current.Row, current.Column + 1), entry.yangValue);
            InsertValue(new ExcelCellAddress(current.Row, current.Column + 2), 0);
            sheetToAdresses[_currentSheet.Name].Add(entry.mainPronounciation, new ExcelCellAddress(current.Row, current.Column + 2));
            Save();
        }
        private void AddMobEntry(string mobName, DefinitionParserData.Item item)
        {
            List <string> modified = new List <string>(getAllDropsFile);

            modified.Add(mobName + "{");
            modified.Add("\t-" + item.group + ":" + item.mainPronounciation);
            modified.Add("}");
            getAllDropsFile = modified.ToArray();
        }
示例#3
0
 protected override void SpeechRecognized(object sender, SpeechRecognizedEventDetails args)
 {
     if (SpeechRecognitionHelper.reverseModifierDict.ContainsKey(args.text))
     {
         ModifierRecognized(this, args);
         return;
     }
     Console.WriteLine(args.text + " -- " + args.confidence);
     DefinitionParserData.Item item = DefinitionParser.instance.currentGrammarFile.GetItemEntry(DefinitionParser.instance.currentGrammarFile.GetMainPronounciation(args.text));
     enemyHandling.ItemDropped(item);
 }
示例#4
0
        /// <summary>
        /// Increases number count to 'item' in current speadsheet
        /// </summary>
        public void ItemDropped(DefinitionParserData.Item item, int amount = 1)
        {
            if (!string.IsNullOrWhiteSpace(currentEnemy))
            {
                mobDrops.UpdateDrops(currentEnemy, item);
            }
            ExcelCellAddress address = Program.interaction.GetAddress(item.mainPronounciation);

            Program.interaction.AddNumberTo(address, amount);
            stack.Push(new ItemInsertion(address, amount));
        }
        public void UpdateDrops(string mobName, DefinitionParserData.Item item)
        {
            bool          mobEntryExists = false;
            List <string> list;

            for (int i = 0; i < getAllDropsFile.Length; i++)
            {
                if (getAllDropsFile[i].Contains("{"))
                {
                    string[] splt = getAllDropsFile[i].Split('{');
                    if (splt[0] == mobName)
                    {
                        mobEntryExists = true;
                        if (!CheckGroupExists(i + 1, item.group))
                        {
                            list = new List <string>(getAllDropsFile);
                            list.Insert(i + 1, "\t-" + item.group + ":");

                            list[i + 1]     = list[i + 1] + item.mainPronounciation;
                            getAllDropsFile = list.ToArray();
                            Program.interaction.AddItemEntryToCurrentSheet(item);
                            SaveChanges();
                            return;
                        }

                        int  line = GetGroupLine(i + 1, item.group);
                        bool edit = !CheckItemExists(getAllDropsFile[line], item.mainPronounciation);
                        if (edit)
                        {
                            getAllDropsFile[line] = getAllDropsFile[line] + "," + item.mainPronounciation;
                            Program.interaction.AddItemEntryToCurrentSheet(item);
                            SaveChanges();
                        }

                        return;
                    }
                }
            }
            if (!mobEntryExists)
            {
                AddMobEntry(mobName, item);
                Program.interaction.AddItemEntryToCurrentSheet(item);
                SaveChanges();
            }
        }
示例#6
0
        /// <summary>
        /// Dynamically remove new entries from the current sheet
        /// </summary>
        public void RemoveItemEntryFromCurrentSheet(DefinitionParserData.Item entry)
        {
            ExcelCellAddress current = new ExcelCellAddress("A2");
            int maxDetph             = 10;

            while (_currentSheet.Cells[current.Address].GetValue <string>() != entry.mainPronounciation)
            {
                current = new ExcelCellAddress(current.Row + 1, current.Column);
                if (current.Row >= maxDetph)
                {
                    current = new ExcelCellAddress(2, current.Column + 4);
                }
            }
            //Found the cell
            InsertValue <object>(current, null);
            InsertValue <object>(new ExcelCellAddress(current.Row, current.Column + 1), null);
            InsertValue <object>(new ExcelCellAddress(current.Row, current.Column + 2), null);
            sheetToAdresses[_currentSheet.Name].Remove(entry.mainPronounciation);
        }
 /// <summary>
 /// Prompts user to remove item from mob asociations, used when Undoing
 /// </summary>
 public bool RemoveItemEntry(string mobName, string itemName, bool yes)
 {
     DefinitionParserData.Item item = DefinitionParser.instance.currentGrammarFile.GetItemEntry(itemName);
     if (yes)
     {
         List <string> AllDropsFileList = new List <string>(getAllDropsFile);
         for (int i = 0; i < getAllDropsFile.Length; i++)
         {
             if (getAllDropsFile[i].Contains(mobName))
             {
                 string   targetGroup   = DefinitionParser.instance.currentGrammarFile.GetGroup(itemName);
                 int      itemLineIndex = GetGroupLine(i + 1, targetGroup);
                 string[] split         = getAllDropsFile[itemLineIndex].Split(':')[1].Split(',');
                 if (split.Length != 1)
                 {
                     split[split.Length - 1]        = "";
                     getAllDropsFile[itemLineIndex] = "\t-" + targetGroup + ":" + string.Join(",", split.Where(str => str != ""));
                     Console.WriteLine("Entry removed!");
                 }
                 else
                 {
                     AllDropsFileList.RemoveAt(itemLineIndex);
                     getAllDropsFile = AllDropsFileList.ToArray();
                 }
                 SaveChanges();
                 Program.interaction.RemoveItemEntryFromCurrentSheet(item);
                 return(true);
             }
         }
         Console.WriteLine("Entry not found?!");
         return(false);
     }
     else
     {
         Console.WriteLine("Entry not removed!");
         return(false);
     }
 }