示例#1
0
        private static void ExecuteActions(ActionPhase phase, IEnumerable<ITestAction> actions, ITest test)
        {
            if (actions == null)
                return;

            foreach (ITestAction action in GetFilteredAndSortedActions(actions, phase))
            {
                if(phase == ActionPhase.Before)
                    action.BeforeTest(test);
                else
                    action.AfterTest(test);
            }
        }
示例#2
0
        public static void ExecuteActions(ActionPhase phase, IEnumerable<TestAction> actions, ITest test)
        {
            if (actions == null)
                return;

            TestAction[] filteredActions = GetFilteredAndSortedActions(actions, phase);

            foreach (TestAction action in filteredActions)
            {
                if(phase == ActionPhase.Before)
                    action.ExecuteBefore(test);
                else
                    action.ExecuteAfter(test);
            }
        }
示例#3
0
        protected override void ExecuteActions(ActionPhase phase)
        {
            List <TestAction> targetActions = new List <TestAction>();

            if (this.actions != null)
            {
                foreach (var action in this.actions)
                {
                    if (action.DoesTarget(TestAction.TargetsSuite))
                    {
                        targetActions.Add(action);
                    }
                }
            }

            ActionsHelper.ExecuteActions(phase, targetActions, this);
        }
示例#4
0
        protected virtual void ExecuteMethod(ActionArgs args, ActionResult result, ActionPhase phase)
        {
            bool match = InternalExecuteMethod(args, result, phase, true, true);

            if (!(match))
            {
                match = InternalExecuteMethod(args, result, phase, true, false);
            }
            if (!(match))
            {
                match = InternalExecuteMethod(args, result, phase, false, true);
            }
            if (!(match))
            {
                InternalExecuteMethod(args, result, phase, false, false);
            }
        }
        public void AttackMissTest()
        {
            Player p1 = mocks.Stub <Player>(0);
            Player p2 = mocks.Stub <Player>(1);

            IGame game = mocks.Stub <IGame>();

            Card attack = new Attack(CardSuit.Spade, 1);
            Miss miss   = new Miss(CardSuit.Diamond, 2);
            // ActionPhase produces attackPhase
            Phase     a   = new ActionPhase(p1);
            PhaseList ret = a.advance(new UseCardAction(attack, p2), game);
            Phase     b   = ret.pop();

            Assert.IsInstanceOfType(b, typeof(AttackPhase));
            AttackPhase b2 = b as AttackPhase;

            Assert.AreEqual(attack, b2.attack);
            Assert.AreEqual(a, b2.actionPhase);
            Assert.AreEqual(p1, b2.player);
            Assert.AreEqual(p2, b2.targets[0]);
            Assert.AreEqual(a, ret.pop());
            Assert.IsTrue(ret.isEmpty());
            // AttackPhase produces responsePhase
            ret = b.advance(null, game);
            Phase c = ret.pop();

            Assert.IsInstanceOfType(c, typeof(ResponsePhase));
            ResponsePhase c_ = c as ResponsePhase;

            Assert.AreEqual(p2, c_.player);
            Phase c2 = ret.pop();

            Assert.IsInstanceOfType(c2, typeof(AttackPhase));
            Assert.AreEqual(b, c2);
            Assert.IsTrue(ret.isEmpty());

            // response with cancel
            ret = c.advance(new CardAction(miss), game);
            Assert.IsTrue(ret.isEmpty());

            // attackPhase produces nothing
            ret = c2.advance(null, game);
            Assert.IsTrue(ret.isEmpty());
        }
        public void autoAdvanceTest2()
        {
            ZhangFei p1     = new ZhangFei(0);
            Card     attack = new Attack(CardSuit.Spade, 1);
            Miss     miss   = new Miss(CardSuit.Diamond, 2);

            p1.handCards.Add(attack);
            p1.handCards.Add(miss);
            p1.health = 1;

            IGame game = mocks.Stub <IGame>();


            // ActionPhase produces attackPhase
            UserActionPhase a = new ActionPhase(p1);

            Assert.AreEqual(a.autoAdvance(game), null);
        }
        private static void ExecuteActions(ActionPhase phase, IEnumerable <ITestAction> actions, ITest test)
        {
            if (actions == null)
            {
                return;
            }

            foreach (ITestAction action in GetFilteredAndSortedActions(actions, phase))
            {
                if (phase == ActionPhase.Before)
                {
                    action.BeforeTest(test);
                }
                else
                {
                    action.AfterTest(test);
                }
            }
        }
        private Phase randomPhase()
        {
            Phase phase;
            int   r = random.Next();

            switch (r % 10)
            {
            case 1:
                phase = new JudgePhase(randomPlayer());
                break;

            case 2:
                phase = new DrawingPhase(randomPlayer());
                break;

            case 3:
                phase = new ActionPhase(randomPlayer());
                break;

            case 4:
                phase = new DiscardPhase(randomPlayer());
                break;

            case 5:
                phase = new HarmPhase(randomPlayer(), randomPlayer(), random.Next(), randomAttack());
                break;

            case 6:
                phase = new AskForHelpPhase(randomPlayer(), new HarmPhase(randomPlayer(), randomPlayer(), random.Next(), randomAttack()));
                break;

            case 7:
                phase = new RecoverPhase(randomPlayer(), random.Next());
                break;

            default:
                phase = new DeadPhase(randomPlayer(), new HarmPhase(randomPlayer(), randomPlayer(), random.Next(), randomAttack()));
                break;
            }

            return(phase);
        }
        public void resAdvanceTest3()
        {
            ZhangFei p1     = new ZhangFei(0);
            Card     attack = new Attack(CardSuit.Spade, 1);
            Miss     miss   = new Miss(CardSuit.Diamond, 2);

            p1.handCards.Add(attack);
            p1.handCards.Add(miss);
            p1.health = 1;

            IGame game = mocks.Stub <IGame>();


            // ActionPhase produces attackPhase
            UserActionPhase a  = new ActionPhase(p1);
            PhaseList       ls = a.timeOutAdvance(game);

            Assert.IsInstanceOfType(ls.pop(), typeof(DiscardPhase));
            Assert.IsTrue(ls.isEmpty());
        }
        public void resAdvanceTest6()
        {
            Player p1     = new Player(0);
            Card   attack = new Attack(CardSuit.Spade, 1);
            Miss   miss   = new Miss(CardSuit.Diamond, 2);

            p1.handCards.Add(attack);
            p1.handCards.Add(miss);
            p1.health = 1;

            IGame game = mocks.Stub <IGame>();


            // ActionPhase produces attackPhase
            UserActionPhase a = new ActionPhase(p1);

            Player[] p = new Player[1];
            p[0] = p1;
            Assert.AreEqual(a.responseCardAction(miss, game), null);
        }
示例#11
0
 public override RoboAction OnRobotEnter(ActionPhase actionPhase, RoboMovement movement, RoboPosition position)
 {
     switch (actionPhase)
     {
     case ActionPhase.ActionConveyor:
         return(new RoboRotation
                (
                    (movement.Direction == Direction.Up && (FieldType & FieldType.ConveyorLeft) == FieldType.ConveyorLeft) ||
                    (movement.Direction == Direction.Right && (FieldType & FieldType.ConveyorUp) == FieldType.ConveyorUp) ||
                    (movement.Direction == Direction.Down && (FieldType & FieldType.ConveyorRight) == FieldType.ConveyorRight) ||
                    (movement.Direction == Direction.Left && (FieldType & FieldType.ConveyorDown) == FieldType.ConveyorDown) ?
                    Rotation.Left :
                    ((movement.Direction == Direction.Up && (FieldType & FieldType.ConveyorRight) == FieldType.ConveyorRight) ||
                     (movement.Direction == Direction.Right && (FieldType & FieldType.ConveyorDown) == FieldType.ConveyorDown) ||
                     (movement.Direction == Direction.Down && (FieldType & FieldType.ConveyorLeft) == FieldType.ConveyorLeft) ||
                     (movement.Direction == Direction.Left && (FieldType & FieldType.ConveyorUp) == FieldType.ConveyorUp) ?
                     Rotation.Right : Rotation.None)
                ));
     }
     return(base.OnRobotEnter(actionPhase, movement, position));
 }
示例#12
0
        public static void ExecuteActions(ActionPhase phase, IEnumerable <TestAction> actions, ITest test)
        {
            if (actions == null)
            {
                return;
            }

            TestAction[] filteredActions = GetFilteredAndSortedActions(actions, phase);

            foreach (TestAction action in filteredActions)
            {
                if (phase == ActionPhase.Before)
                {
                    action.ExecuteBefore(test);
                }
                else
                {
                    action.ExecuteAfter(test);
                }
            }
        }
        // UnBind Action
        internal void UnBindAxes(AxesEventHandler m_Handler, ActionPhase actionPhase)
        {
            switch (actionPhase)
            {
            case ActionPhase.Down:
                if (downHandler == m_Handler)
                {
                    downHandler -= m_Handler;
                    useDown      = (downHandler != null);
                }
                break;

            case ActionPhase.Pressed:
                if (pressHandler == m_Handler)
                {
                    pressHandler -= m_Handler;
                    usePress      = (pressHandler != null);
                }
                break;

            case ActionPhase.Up:
                if (upHandler == m_Handler)
                {
                    upHandler -= m_Handler;
                    useUp      = (upHandler != null);
                }
                break;

            case ActionPhase.Click:
                if (clickHandler == m_Handler)
                {
                    clickHandler -= m_Handler;
                    useClick      = (clickHandler != null);
                }
                break;
            }
        }
        // Bind Action
        internal void BindAxes(AxesEventHandler m_Handler, ActionPhase actionPhase)
        {
            switch (actionPhase)
            {
            case ActionPhase.Down:
                useDown = true;
                if (downHandler != m_Handler)
                {
                    downHandler += m_Handler;
                }
                break;

            case ActionPhase.Pressed:
                usePress = true;
                if (pressHandler != m_Handler)
                {
                    pressHandler += m_Handler;
                }
                break;

            case ActionPhase.Up:
                useUp = true;
                if (upHandler != m_Handler)
                {
                    upHandler += m_Handler;
                }
                break;

            case ActionPhase.Click:
                useClick = true;
                if (clickHandler != m_Handler)
                {
                    clickHandler += m_Handler;
                }
                break;
            }
        }
示例#15
0
        private void ManagePlayerTurn()
        {
            if (unitPlayer[0].GetType() != UnitType.NO_UNIT)
            {
                int winCounter = 0;

                for (int i = 0; i < elements.Length; ++i)
                {
                    if ((elements[i].GetStatus() == Status.SOCIALIZED) || (elements[i].GetStatus() == Status.CONQUERED))
                    {
                        winCounter++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (winCounter == elements.Length)
                {
                    isShowPhase = true;
                    phase       = SpacePhase.WIN;
                    return;
                }

                switch (actionPhase)
                {
                default:
                {
                    /*nothing to do*/
                }
                break;

                case ActionPhase.SELECT_UNIT:
                {
                    for (int i = 0; i < unitPlayer.Length; ++i)
                    {
                        if ((cursor.GetX() == unitPlayer[i].GetPoint().GetX()) && (cursor.GetY() == unitPlayer[i].GetPoint().GetY()))
                        {
                            selectedUnit = i;
                            actionPhase  = ActionPhase.SELECT_ACTION;
                            ActionCursor = 1;
                            break;
                        }
                    }
                }
                break;

                case ActionPhase.SELECT_ACTION:
                {
                    if (unitPlayer[selectedUnit].GetType() != UnitType.UFO)
                    {
                        switch (actionCursor)
                        {
                        default:
                        {
                            /*nothing to do*/
                        }
                        break;

                        case 1:
                        {
                            actionPhase = ActionPhase.MOVE;
                        }
                        break;


                        case 2:
                        {
                            actionPhase = ActionPhase.DEFENSE;
                        }
                        break;



                        case 3:
                        {
                            actionPhase = ActionPhase.SELECT_UNIT;
                        }
                        break;
                        }
                    }
                    else
                    {
                        switch (actionCursor)
                        {
                        default:
                        {
                            /*nothing to do*/
                        }
                        break;

                        case 1:
                        {
                            actionPhase = ActionPhase.MOVE;
                        }
                        break;


                        case 2:
                        {
                            actionPhase = ActionPhase.DEFENSE;
                        }
                        break;



                        case 3:
                        {
                            actionPhase = ActionPhase.BUILD;
                        }
                        break;

                        case 4:
                        {
                            actionPhase = ActionPhase.SELECT_UNIT;
                        }
                        break;
                        }
                    }
                }
                break;


                case ActionPhase.MOVE:
                {
                    if ((cursor.GetX() == unitPlayer[i].GetPoint().GetX()) && (cursor.GetY() == unitPlayer[i].GetPoint().GetY()))
                    {
                        selectedUnit = i;
                        actionPhase  = ActionPhase.SELECT_ACTION;
                        ActionCursor = 1;
                        break;
                    }
                }
                break;
                }
            }
            else
            {
                isShowPhase = true;
                phase       = SpacePhase.LOOSE;
                return;
            }
        }
示例#16
0
        public Space(int _levelIndex)
        {
            unitPlayer = new Unit[MAX_UNITS];
            unitEnemy  = new Unit[MAX_UNITS];

            cursor       = new Cursor(new Point(0, 0));
            isRunning    = true;
            isShowPhase  = true;
            phase        = SpacePhase.SET_UFO;
            actionPhase  = ActionPhase.SELECT_UNIT;
            selectedUnit = -1;


            turnNo         = 1;
            isPlayerTurn   = true;
            isShowTurnInfo = false;

            actionCursor = 1;

            phaseDelegate     = (string _text) => Console.WriteLine(_text);
            clsScreenDelegate = () => { Console.WriteLine("     Жми любую клавишу для продолжения"); Console.ReadKey(); Console.Clear(); };


            for (int i = 0; i < MAX_UNITS; ++i)
            {
                unitPlayer[i].SetData(UnitType.NO_UNIT, new Point(0, 0));
                unitEnemy[i].SetData(UnitType.NO_UNIT, new Point(0, 0));
            }
            elements = null;

            switch (_levelIndex)
            {
            default:
            {
                /*nothing to do*/
            }
            break;

            case 1:
            {
                elements = new Element[3];

                elements[0] = new Element(new Point(0, 0), "Зира", Type.STAR, Status.NO_STATUS);         // 40  9
                elements[1] = new Element(new Point(0, Settings.SPACE_HEIGHT - 1), "Унив", Type.PLANET, Status.OPONENT_OWNER);
                elements[2] = new Element(new Point(Settings.SPACE_WIDTH - 1, Settings.SPACE_HEIGHT - 1), "Кло", Type.PLANET, Status.OPONENT_OWNER);

                unitPlayer[0].SetData(UnitType.AVENGER, new Point(0, 3));
                unitPlayer[1].SetData(UnitType.BATTLE_WAGON, new Point(10, 3));
                unitPlayer[2].SetData(UnitType.BOMBER, new Point(20, 3));
                unitPlayer[3].SetData(UnitType.UFO, new Point(30, 3));
                unitPlayer[4].SetData(UnitType.ROBO_WARRIOR, new Point(40, 3));
                unitPlayer[5].SetData(UnitType.SOCIALIST, new Point(50, 3));

                unitEnemy[0].SetData(UnitType.AVENGER, new Point(5, 0));
                unitEnemy[1].SetData(UnitType.BATTLE_WAGON, new Point(10, 0));
                unitEnemy[2].SetData(UnitType.BOMBER, new Point(15, 0));
                unitEnemy[3].SetData(UnitType.UFO, new Point(20, 0));
            }
            break;


            case 2:
            {
                elements = new Element[3];

                elements[0] = new Element(new Point(40, 9), "Зира", Type.STAR, Status.NO_STATUS);
                elements[1] = new Element(new Point(20, 5), "Унив", Type.PLANET, Status.OPONENT_OWNER);
                elements[2] = new Element(new Point(60, 10), "Кло", Type.PLANET, Status.OPONENT_OWNER);
            }
            break;

            case 3:
            {
                elements = new Element[3];

                elements[0] = new Element(new Point(40, 10), "Зира", Type.STAR, Status.NO_STATUS);
                elements[1] = new Element(new Point(20, 5), "Унив", Type.PLANET, Status.OPONENT_OWNER);
                elements[2] = new Element(new Point(60, 15), "Кло", Type.PLANET, Status.OPONENT_OWNER);
            }
            break;
            }
        }
示例#17
0
        protected override void ExecuteActions(ActionLevel level, ActionPhase phase)
        {
            InvokeMethodsWithAttribute(typeof(GivenAttribute));

            InvokeMethodsWithAttribute(typeof(WhenAttribute));

            base.ExecuteActions(level, phase);
        }
示例#18
0
        private static ITestAction[] GetFilteredAndSortedActions(IEnumerable<ITestAction> actions, ActionPhase phase)
        {
            var filteredActions = new List<ITestAction>();
            foreach (var actionItem in actions)
            {
                if (filteredActions.Contains(actionItem) != true)
                    filteredActions.Add(actionItem);
            }

            if(phase == ActionPhase.After)
                filteredActions.Reverse();

            return filteredActions.ToArray();
        }
示例#19
0
 public void BeginActionPhase(ActionPhase phase)
 {
 }
示例#20
0
 public void PrimaryAction(ActionPhase phase)
 {
     Debug.Log("Attack");
 }
        protected override void ExecuteActions(ActionPhase phase)
        {
            List<TestAction> targetActions = new List<TestAction>();

            if (this.actions != null)
            {
                foreach (var action in this.actions)
                {
                    if (action.DoesTarget(TestAction.TargetsSuite))
                        targetActions.Add(action);
                }
            }

            ActionsHelper.ExecuteActions(phase, targetActions, this);
        }
示例#22
0
 /// <summary>
 /// Unbind your void of controller axis  action, identified by controllerName & actionPhase.
 /// </summary>
 /// <param name="controllerName"></param>
 /// <param name="m_Handler"></param>
 /// <param name="actionPhase"></param>
 public static void UnBindAxes(string controllerName, AxesEventHandler m_Handler, ActionPhase actionPhase)
 {
     foreach (AxesBasedController controller in abControllers)
     {
         if (controller.MyName == controllerName)
         {
             controller.UnBindAxes(m_Handler, actionPhase);
             return;
         }
     }
     Debug.LogError("Controller: " + controllerName + " not found!");
 }
示例#23
0
 public void SecondaryAction(ActionPhase phase)
 {
 }
示例#24
0
 public void PrimaryAction(ActionPhase phase)
 {
 }
示例#25
0
    // Update is called once per frame
    void Update()
    {
        // TODO array with phases (interface phase), set index to active phase index, if(update active phase) increment index modulo

        CalculateTeamHp();
        if (HasGameFinished())
        {
            print("game is over now");
            phase = Phase.End;
            // TODO assign ranks
        }

        else
        {
            passedGameSeconds += Time.deltaTime;

            if (phase == Phase.Decision)
            {
                passedDecisionPhaseSeconds = passedDecisionPhaseSeconds += Time.deltaTime;
                timeLeft = maxDecisionPhaseSeconds - passedDecisionPhaseSeconds;

                if (passedDecisionPhaseSeconds >= maxDecisionPhaseSeconds)
                {
                    print("its action phase now");
                    phase = Phase.Action;
                }
            }

            if (phase == Phase.Action)
            {
                passedDecisionPhaseSeconds = 0f;
                isActionPhaseFinished      = activePlayerIndex >= players.Count;

                if (isActionPhaseFinished)
                {
                    print("its decision phase now");
                    phase                      = Phase.Decision;
                    roundCount                += 1;
                    activePlayerIndex          = 0;
                    equippingPlayerIndex       = 0;
                    arePlayerActionsOver       = Enumerable.Repeat(false, players.Count).ToList();
                    havePlayersEquippedWeapons = Enumerable.Repeat(false, players.Count).ToList();
                }
                else
                {
                    // equip new weapon for each player, one time for each ActionPhase
                    foreach (PlayerProperties player in players)
                    {
                        if (equippingPlayerIndex < havePlayersEquippedWeapons.Count && !havePlayersEquippedWeapons[equippingPlayerIndex])
                        {
                            ActionPhase   actionPhase   = player.GetComponent <ActionPhase>();
                            DecisionPhase decisionPhase = player.GetComponent <DecisionPhase>();

                            actionPhase.ChangeLeftHandWeapon(player.rowPosition, player.weapon);
                            havePlayersEquippedWeapons[equippingPlayerIndex] = true;
                            equippingPlayerIndex++;
                        }
                    }

                    // each player attacks sequentially
                    // end if the last active player is finished
                    ActionPhase activePlayerActionPhase = players[activePlayerIndex].GetComponent <ActionPhase>();

                    if (!arePlayerActionsOver[activePlayerIndex])
                    {
                        activePlayerActionPhase.DoAction();
                        arePlayerActionsOver[activePlayerIndex] = true;
                    }
                }
            }
        }
    }
示例#26
0
 protected virtual void ExecuteMethod(ActionArgs args, ActionResult result, ActionPhase phase)
 {
     bool match = InternalExecuteMethod(args, result, phase, true, true);
     if (!(match))
         match = InternalExecuteMethod(args, result, phase, true, false);
     if (!(match))
         match = InternalExecuteMethod(args, result, phase, false, true);
     if (!(match))
         InternalExecuteMethod(args, result, phase, false, false);
 }
示例#27
0
        private static TestAction[] GetFilteredAndSortedActions(IEnumerable <TestAction> actions, ActionPhase phase)
        {
            List <TestAction> filteredActions = new List <TestAction>();

            foreach (TestAction actionItem in actions)
            {
                if (filteredActions.Contains(actionItem) != true)
                {
                    filteredActions.Add(actionItem);
                }
            }

            if (phase == ActionPhase.After)
            {
                filteredActions.Reverse();
            }

            return(filteredActions.ToArray());
        }
示例#28
0
 public ControllerActionAttribute(string controller, string view, string commandName, ActionPhase phase) :
     this(controller, view, commandName, String.Empty, phase)
 {
 }
示例#29
0
 public void SecondaryAction(ActionPhase phase)
 {
     throw new System.NotImplementedException();
 }
        private bool InternalExecuteMethod(ActionArgs args, ActionResult result, ActionPhase phase, bool viewMatch, bool argumentMatch)
        {
            _arguments = args;
            _result    = result;
            bool success = false;

            MethodInfo[] methods = GetType().GetMethods((BindingFlags.Public | (BindingFlags.NonPublic | BindingFlags.Instance)));
            foreach (MethodInfo method in methods)
            {
                object[] filters = method.GetCustomAttributes(typeof(ControllerActionAttribute), true);
                foreach (ControllerActionAttribute action in filters)
                {
                    if (((action.Controller == args.Controller) || (!(String.IsNullOrEmpty(args.Controller)) && Regex.IsMatch(args.Controller, action.Controller))) && ((!(viewMatch) && String.IsNullOrEmpty(action.View)) || (action.View == args.View)))
                    {
                        if ((action.CommandName == args.CommandName) && ((!(argumentMatch) && String.IsNullOrEmpty(action.CommandArgument)) || (action.CommandArgument == args.CommandArgument)))
                        {
                            if (action.Phase == phase)
                            {
                                ParameterInfo[] parameters = method.GetParameters();
                                if ((parameters.Length == 2) && ((parameters[0].ParameterType == typeof(ActionArgs)) && (parameters[1].ParameterType == typeof(ActionResult))))
                                {
                                    method.Invoke(this, new object[] {
                                        args,
                                        result
                                    });
                                }
                                else
                                {
                                    object[] arguments = new object[parameters.Length];
                                    for (int i = 0; (i < parameters.Length); i++)
                                    {
                                        ParameterInfo p = parameters[i];
                                        FieldValue    v = SelectFieldValueObject(p.Name);
                                        if (v != null)
                                        {
                                            if (p.ParameterType.Equals(typeof(FieldValue)))
                                            {
                                                arguments[i] = v;
                                            }
                                            else
                                            {
                                                try
                                                {
                                                    arguments[i] = DataControllerBase.ConvertToType(p.ParameterType, v.Value);
                                                }
                                                catch (Exception)
                                                {
                                                }
                                            }
                                        }
                                    }
                                    method.Invoke(this, arguments);
                                    success = true;
                                }
                            }
                        }
                    }
                }
            }
            return(success);
        }
示例#31
0
 public void SecondaryAction(ActionPhase phase)
 {
     Debug.Log("Defend");
 }
示例#32
0
        /// <summary>
        /// Execute the phases of the action.
        /// </summary>
        /// <param name="type">
        /// A <see cref="ActionExecuteType"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        internal bool Execute(ActionExecuteType type)
        {
            if (this.Context != null && this.Context.Request != null)
            {
                this.Writer = new StreamWriter(this.Context.Request.ResponseBody);
            }
            bool result = false;

            if (this.NextPhase == ActionPhase.Filters)
            {
                try
                {
                    this.executeFilters();
                    result = true;
                }finally
                {
                    this.NextPhase = ActionPhase.Execute;
                }
                if (!result)
                {
                    return(result);
                }
            }

            /*
             *      if(this.NextPhase == ActionPhase.Authenticate)
             *      {
             *              try
             *              {
             *                      result = this.OnAuthenticate();
             *              }finally
             *              {
             *                      this.NextPhase  = ActionPhase.Lookup;
             *              }
             *      }
             *      if(!result)return result;
             *      if(this.NextPhase == ActionPhase.Lookup)
             *      {
             *              try
             *              {
             *                      var lresult =this.OnLookup();
             *                      result = lresult == ActionLookupResult.Found || lresult == ActionLookupResult.Skipped;
             *              }finally
             *              {
             *                      this.NextPhase  = ActionPhase.Authorize;
             *              }
             *      }
             * if(!result)return result;
             *      if(this.NextPhase == ActionPhase.Authorize)
             *      {
             *              try
             *              {
             *                      result =this.OnAuthorize();
             *              }finally
             *              {
             *                      this.NextPhase  = ActionPhase.Execute;
             *              }
             *      }
             * if(!result)return result;
             */
            if (!this.Lookup)
            {
                this.OnLookup();
            }
            if (type == ActionExecuteType.Complete && this.NextPhase == ActionPhase.Execute)
            {
                try
                {
                    this.OnExecute();
                    result = true;
                }finally
                {
                    this.NextPhase = ActionPhase.Finish;
                }
            }
            return(result);
        }
示例#33
0
 private bool InternalExecuteMethod(ActionArgs args, ActionResult result, ActionPhase phase, bool viewMatch, bool argumentMatch)
 {
     _arguments = args;
     _result = result;
     bool success = false;
     MethodInfo[] methods = GetType().GetMethods((BindingFlags.Public | (BindingFlags.NonPublic | BindingFlags.Instance)));
     foreach (MethodInfo method in methods)
     {
         object[] filters = method.GetCustomAttributes(typeof(ControllerActionAttribute), true);
         foreach (ControllerActionAttribute action in filters)
             if (((action.Controller == args.Controller) || (!(String.IsNullOrEmpty(args.Controller)) && Regex.IsMatch(args.Controller, action.Controller))) && ((!(viewMatch) && String.IsNullOrEmpty(action.View)) || (action.View == args.View)))
             {
                 if ((action.CommandName == args.CommandName) && ((!(argumentMatch) && String.IsNullOrEmpty(action.CommandArgument)) || (action.CommandArgument == args.CommandArgument)))
                 {
                     if (action.Phase == phase)
                     {
                         ParameterInfo[] parameters = method.GetParameters();
                         if ((parameters.Length == 2) && ((parameters[0].ParameterType == typeof(ActionArgs)) && (parameters[1].ParameterType == typeof(ActionResult))))
                             method.Invoke(this, new object[] {
                                         args,
                                         result});
                         else
                         {
                             object[] arguments = new object[parameters.Length];
                             for (int i = 0; (i < parameters.Length); i++)
                             {
                                 ParameterInfo p = parameters[i];
                                 FieldValue v = SelectFieldValueObject(p.Name);
                                 if (v != null)
                                     if (p.ParameterType.Equals(typeof(FieldValue)))
                                         arguments[i] = v;
                                     else
                                         try
                                         {
                                             arguments[i] = DataControllerBase.ConvertToType(p.ParameterType, v.Value);
                                         }
                                         catch (Exception )
                                         {
                                         }
                             }
                             method.Invoke(this, arguments);
                             success = true;
                         }
                     }
                 }
             }
     }
     return success;
 }
示例#34
0
        public void BeginActionPhase(ActionPhase phase)
        {
            var response = _controller.HandleGameEvent(phase, phase.TurnScope);

            response.Execute();
        }
示例#35
0
 public ControllerActionAttribute(string controller, string view, string commandName, string commandArgument, ActionPhase phase)
 {
     this._controller      = controller;
     this._view            = view;
     this._commandName     = commandName;
     this._commandArgument = commandArgument;
     this._phase           = phase;
 }
示例#36
0
 /// <summary>
 /// Bind your void to button action, identified by buttonName. Called established event in actionPhase.
 /// </summary>
 /// <param name="buttonName"></param>
 /// <param name="m_Handler"></param>
 /// <param name="actionPhase"></param>
 public static void BindAction(string buttonName, ActionEventHandler m_Handler, ActionPhase actionPhase)
 {
     foreach (TCKButton button in buttons)
     {
         if (button.MyName == buttonName)
         {
             button.BindAction(m_Handler, actionPhase);
             return;
         }
     }
     Debug.LogError("Button: " + buttonName + " Not Found.");
 }
示例#37
0
        protected virtual void ExecuteActions(ActionPhase phase)
        {
            List<TestAction> targetActions = new List<TestAction>();

            if (this.suiteActions != null)
            {
                foreach (var action in this.suiteActions)
                {
                    if(action.DoesTarget(TestAction.TargetsTest))
                        targetActions.Add(action);
                }
            }

            if (this.actions != null)
            {
                foreach (var action in this.actions)
                {
#if DEFAULT_APPLIES_TO_TESTCASE
                    if (!(Parent is ParameterizedMethodSuite) && (action.DoesTarget(TestAction.TargetsDefault) || action.DoesTarget(TestAction.TargetsTest)))
#else
                    if (action.DoesTarget(TestAction.TargetsDefault) || (!(Parent is ParameterizedMethodSuite) && action.DoesTarget(TestAction.TargetsTest)))
#endif
                        targetActions.Add(action);
                }
            }

            ActionsHelper.ExecuteActions(phase, targetActions, this);
        }
示例#38
0
 public ControllerActionAttribute(string controller, string commandName, ActionPhase phase) :
     this(controller, null, commandName, phase)
 {
 }