Esempio n. 1
0
    private void AttemptAutoMove(int rollsLeft, int rolledAmount)
    {
        int            possibleMoves = 0;
        int            staged        = 0;
        PawnController stagedPawn    = null;
        int            index         = -1;

        for (int i = 0; i < pawns.Count; ++i)
        {
            PawnController pawn = pawns[i];
            if (pawn.SetCanSelect(rolledAmount))
            {
                possibleMoves++;

                if (pawn.IsStaged)
                {
                    staged++;
                    stagedPawn = pawn;
                }

                index = i;
            }
        }

        if (possibleMoves == staged && possibleMoves != 0)           // TEST
        {
            possibleMoves = 1;
        }

        switch (possibleMoves)
        {
        case 0:
            this.rollsLeft = this.rolledAmount = 0;
            break;

        case 1:
            PawnController pawn = (staged > 0) ? stagedPawn : pawns[index];
            this.rolledAmount = rolledAmount;
            this.rollsLeft    = rollsLeft;
            pawn.isSelected   = true;
            // Must be done here, otherwise in loop will skip players turn
            pawn.ServerMove(rolledAmount);
            break;

        default:
            this.rollsLeft    = rollsLeft;
            this.rolledAmount = rolledAmount;
            break;
        }
    }