예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public static void Condition(object sender, IEventInput input)
        {
            if (!(input is ConditionInput))
            {
                ConsoleWindow.WriteLine("Invalid input passed to Condition method");
            }

            var  cInput = (ConditionInput)input;
            var  v1     = cInput.InputA as Variable;
            var  v2     = cInput.InputB as Variable;
            bool path1  = false;
            bool path2;

            switch (cInput.Comparison)
            {
            case CompareType.Var_Var:
            case CompareType.Var_Gold:
                if (cInput.CheckValue == CheckValue.ValueEqual)
                {
                    if (v1.Value == v2.Value)
                    {
                        path1 = true;
                    }
                }
                else if (cInput.CheckValue == CheckValue.ValueGreater)
                {
                    if (v1.AsInt > v2.AsInt)
                    {
                        path1 = true;
                    }
                }
                else if (cInput.CheckValue == CheckValue.ValueGreaterEqual)
                {
                    if (v1.AsInt >= v2.AsInt)
                    {
                        path1 = true;
                    }
                }
                else if (cInput.CheckValue == CheckValue.ValueLess)
                {
                    if (v1.AsInt < v2.AsInt)
                    {
                        path1 = true;
                    }
                }
                else if (cInput.CheckValue == CheckValue.ValueLessEqual)
                {
                    if (v1.AsInt <= v2.AsInt)
                    {
                        path1 = true;
                    }
                }
                break;

            case CompareType.Var_String:
                if (cInput.CheckValue == CheckValue.ValueEqual)
                {
                    if (v1.Value == v2.Value)
                    {
                        path1 = true;
                    }
                }
                break;

            case CompareType.Switch_Val:
                break;
            }
            path2 = !path1 && cInput.HasElse;
            if (path1)      //Conditional complete route
            {
                //cInput.Path1.OldList = Current_ActionList;
                Current_ActionList.ExecuteList(cInput.Path1);
            }
            else if (path2) //Else route
            {
                Current_ActionList.ExecuteList(cInput.Path2);
            }
        }