/// <summary>Executes the command via CIL.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryIfCIL(CommandQueue queue, CommandEntry entry)
        {
            entry.SetData(queue, new IfCommandData()
            {
                Result = 0
            });
            bool success = TryIf(queue, entry, new List <Argument>(entry.Arguments));

            if (success)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "If is true, executing...");
                }
                ((IfCommandData)entry.GetData(queue)).Result = 1;
            }
            else
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "If is false, doing nothing!");
                }
            }
            return(success);
        }
        /// <summary>Executes the numbered input part of the while command, without debug.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryWhileNumberedCIL_NoDebug(CommandQueue queue, CommandEntry entry)
        {
            bool success = IfCommand.TryIf(queue, entry, new List <Argument>(entry.Arguments));

            if (!success)
            {
                return(false);
            }
            entry.SetData(queue, new WhileCommandData()
            {
                Index = 1, ComparisonArgs = entry.Arguments
            });
            return(true);
        }
Exemple #3
0
        /// <summary>Executes the numbered input part of the repeat command, without debug.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryRepeatNumberedCIL_NoDebug(CommandQueue queue, CommandEntry entry)
        {
            int target = (int)IntegerTag.TryFor(entry.GetArgumentObject(queue, 0)).Internal;

            if (target <= 0)
            {
                return(false);
            }
            entry.SetData(queue, new RepeatCommandData()
            {
                Index = 1, Total = target
            });
            return(true);
        }
        /// <summary>Executes the list input part of the foreached command, without debug.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        /// <param name="listItem">Dynamic tag to hold the item in the list.</param>
        public static bool TryForeachNumberedCIL_NoDebug(CommandQueue queue, CommandEntry entry, DynamicTag listItem)
        {
            ListTag list = ListTag.CreateFor(entry.GetArgumentObject(queue, 1));

            if (list.Internal.Count == 0)
            {
                return(false);
            }
            entry.SetData(queue, new ForeachCommandData()
            {
                Index = 0, List = list.Internal
            });
            listItem.Internal = list.Internal[0];
            return(true);
        }
        /// <summary>Executes the comparison input part of the while command.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryWhileNumberedCIL(CommandQueue queue, CommandEntry entry)
        {
            bool success = IfCommand.TryIf(queue, entry, new List <Argument>(entry.Arguments));

            if (!success)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Not looping.");
                }
                return(false);
            }
            entry.SetData(queue, new WhileCommandData()
            {
                Index = 1, ComparisonArgs = entry.Arguments
            });
            if (entry.ShouldShowGood(queue))
            {
                entry.GoodOutput(queue, "While looping...");
            }
            return(true);
        }
Exemple #6
0
        /// <summary>Executes the numbered input part of the repeat command.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryRepeatNumberedCIL(CommandQueue queue, CommandEntry entry)
        {
            int target = (int)IntegerTag.TryFor(entry.GetArgumentObject(queue, 0)).Internal;

            if (target <= 0)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Not repeating.");
                }
                return(false);
            }
            entry.SetData(queue, new RepeatCommandData()
            {
                Index = 1, Total = target
            });
            if (entry.ShouldShowGood(queue))
            {
                entry.GoodOutput(queue, "Repeating " + TextStyle.Separate + target + TextStyle.Base + " times...");
            }
            return(true);
        }
        /// <summary>Executes the list input part of the foreached command.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        /// <param name="listItem">Dynamic tag to hold the item in the list.</param>
        public static bool TryForeachNumberedCIL(CommandQueue queue, CommandEntry entry, DynamicTag listItem)
        {
            ListTag list = ListTag.CreateFor(entry.GetArgumentObject(queue, 1));

            if (list.Internal.Count == 0)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Not looping.");
                }
                return(false);
            }
            entry.SetData(queue, new ForeachCommandData()
            {
                Index = 0, List = list.Internal
            });
            listItem.Internal = list.Internal[0];
            if (entry.ShouldShowGood(queue))
            {
                entry.GoodOutput(queue, "Looping " + TextStyle.Separate + list.Internal.Count + TextStyle.Base + " times...");
            }
            return(true);
        }
Exemple #8
0
        /// <summary>Executes the command via CIL.</summary>
        /// <param name="queue">The command queue involved.</param>
        /// <param name="entry">Entry to be executed.</param>
        public static bool TryIfCIL(CommandQueue queue, CommandEntry entry)
        {
            entry.SetData(queue, new IfCommandData()
            {
                Result = 0
            });
            if (entry.Arguments.Length == 0)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Else is reached, executing block...");
                }
                ((IfCommandData)entry.GetData(queue)).Result = 1;
                return(true);
            }
            List <Argument> args = new(entry.Arguments);

            args.RemoveAt(0);
            bool success = IfCommand.TryIf(queue, entry, args);

            if (success)
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Else-If is true, executing...");
                }
                ((IfCommandData)entry.GetData(queue)).Result = 1;
            }
            else
            {
                if (entry.ShouldShowGood(queue))
                {
                    entry.GoodOutput(queue, "Else-If is false, doing nothing!");
                }
            }
            return(success);
        }