Esempio n. 1
0
        protected async override void ModifierRecognized(object sender, SpeechRecognizedEventDetails args)
        {
            SpeechRecognitionHelper.ModifierWords current = SpeechRecognitionHelper.reverseModifierDict[args.text];
            switch (current)
            {
            case SpeechRecognitionHelper.ModifierWords.UNDO: {
                ItemInsertion peeked = stack.Peek();
                if (peeked.address == null)
                {
                    Console.WriteLine("Nothing else to undo...");
                    return;
                }
                Console.WriteLine("Undoing... " + Program.interaction.currentSheet.Cells[peeked.address.Row, peeked.address.Column - 2].GetValue <string>() + " with " + peeked.count + " items");
                if (await Confirmation.AskForBooleanConfirmation("'Confirm'/'Refuse'"))
                {
                    Console.Write("Confirming");
                    ItemInsertion poped = stack.Pop();
                    Program.interaction.AddNumberTo(poped.address, -poped.count);
                }
                else
                {
                    Console.Write("Refusing");
                }
                return;
            }

            default: {
                Console.WriteLine("Unsupported word " + args.text);
                return;
            }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Event fired after a modifier word was said
        /// </summary>
        /// <param name="keyWord">"NEW_TARGET" // "UNDO" // "REMOVE_TARGET" // TARGET_KILLED</param>
        /// <param name="args">Always supply at least string.Empty as args!</param>
        private async void EnemyTargetingModifierRecognized(object sender, ModiferRecognizedEventArgs args)
        {
            if (args.modifier == ModifierWords.NEW_TARGET)
            {
                switch (state)
                {
                case EnemyState.NO_ENEMY: {
                    string enemy = GetEnemy();
                    evnt.Reset();
                    if (enemy == Program.controlCommands.getRemoveTargetCommand)
                    {
                        Console.WriteLine("Targetting calcelled!");
                        return;
                    }
                    string actualEnemyName = DefinitionParser.instance.currentMobGrammarFile.GetMainPronounciation(enemy);
                    state = EnemyState.FIGHTING;
                    Program.interaction.OpenWorksheet(actualEnemyName);
                    currentEnemy = actualEnemyName;
                    Console.WriteLine("Acquired target: " + currentEnemy);
                    stack.Clear();
                    return;
                }

                case EnemyState.FIGHTING: {
                    state = EnemyState.NO_ENEMY;
                    Console.WriteLine("Killed " + currentEnemy + ", the death count increased");
                    Program.interaction.AddNumberTo(new ExcelCellAddress(1, 5), 1);
                    currentEnemy = "";
                    stack.Clear();
                    EnemyTargetingModifierRecognized(this, args);
                    return;
                }
                }
            }
            else if (args.modifier == ModifierWords.TARGET_KILLED)
            {
                Console.WriteLine("Killed " + currentEnemy + ", the death count increased");
                Program.interaction.AddNumberTo(new ExcelCellAddress(1, 5), 1);
                EnemyTargetingModifierRecognized(this, new ModiferRecognizedEventArgs()
                {
                    modifier = ModifierWords.REMOVE_TARGET
                });
            }
            else if (args.modifier == ModifierWords.REMOVE_TARGET)
            {
                Program.interaction.OpenWorksheet(DefinitionParser.instance.currentGrammarFile.ID);
                currentEnemy = "";
                currentItem  = "";
                state        = EnemyState.NO_ENEMY;
                stack.Clear();
                Console.WriteLine("Reset current target to 'None', switching to " + DefinitionParser.instance.currentGrammarFile.ID + " sheet.");
            }
            else if (args.modifier == ModifierWords.UNDO)
            {
                ItemInsertion action = stack.Peek();
                if (action.address == null)
                {
                    Console.WriteLine("Nothing else to undo!");
                    return;
                }
                Console.WriteLine("Would remove " + action.count + " items from " + Program.interaction.currentSheet.Cells[action.address.Row, action.address.Column - 2].Value);

                bool resultUndo = await Confirmation.AskForBooleanConfirmation("'Confirm'/'Refuse'?");

                if (resultUndo)
                {
                    action = stack.Pop();
                    Program.interaction.AddNumberTo(action.address, -action.count);
                    if (Program.interaction.currentSheet.Cells[action.address.Row, action.address.Column].GetValue <int>() == 0 && currentEnemy != "")
                    {
                        string itemName = Program.interaction.currentSheet.Cells[action.address.Row, action.address.Column - 2].Value.ToString();
                        Console.WriteLine("Remove " + currentItem + " from current enemy's (" + currentEnemy + ") item list?");
                        bool resultRemoveFromFile = await Confirmation.AskForBooleanConfirmation("'Confirm'/'Refuse'?");

                        if (resultRemoveFromFile)
                        {
                            currentItem = itemName;
                            mobDrops.RemoveItemEntry(currentEnemy, currentItem, true);
                        }
                        else
                        {
                            Console.WriteLine("Enemy file NOT modified!");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Undo refused!");
                }
            }
        }