Unnecessary spin

I think this is fixed in the next lecture, but if you click the spin icon and then the move icon, you will spin.

Might be me, of course, so will update when I’ve checked further on.

:slight_smile:

You mean it takes an action if you click on the button and there’s a valid grid position under the button? Yes this is fixed later.

1 Like

Ah yes, I see. Because the (my) code for checking “IsValidActionGridPosition” is in the “case MoveAction moveAction”, then the behaviour you describe is correct - ie if I have Move selected and click on Spin when over a valid grid position, I will move.

However, because I don’t have that validation check code in the “case SpinAction spinAction”, if I select Spin and then click Move, even if NOT over a valid grid position, then I will spin.

EDIT Can confirm that in the next lecture we apply the validation to all movements. Just bear in mind, if you prefer the switch method, to apply grid validation appropriately.

            switch (selectedAction)
            {
                case MoveAction moveAction:
                    if (moveAction.IsValidActionGridPosition(mouseGridPosition))
                    {
                        SetBusy();
                        moveAction.Move(mouseGridPosition, ClearBusy);
                    }

                    break;

                case SpinAction spinAction:

                    SetBusy();
                    spinAction.Spin(ClearBusy);

                    break;
            }
2 Likes

Privacy & Terms