-3

私のアプリが「ランダムな」カードを選択するときはいつでも、常に同じ奇妙なパターンに従います: クラブのみ 1 ~ 3、ダイヤモンド 4 ~ 6、ハート 7 ~ 9、スペード 10 ~ 12。スーツは常にその数の範囲内にあり、変化することはありません。各スイートは 13 まで許可されるはずです。複雑な問題を解決するのを手伝ってください、ありがとう!

ソース:

    Random Suite = new Random();
    Random Value = new Random();
    int sprod;
    int vprod;

     public Card RandomCardDraw()
     {
        sprod = Suite.Next(1, 5);

        Card newc = new Card();

        newc.x = sprod;

        vprod = Value.Next(1, 13);

        if (sprod == 1)
        {
            newc.suite = CardSuites.Club;

            newc.y = vprod;

            switch (vprod)
            {
                case 1:
                    newc.cardval = CardValues.Ace;
                    return newc;
                case 2:
                    newc.cardval = CardValues.Two;
                    return newc;
                case 3:
                    newc.cardval = CardValues.Three;
                    return newc;
                case 4:
                    newc.cardval = CardValues.Four;
                    return newc;
                case 5:
                    newc.cardval = CardValues.Five;
                    return newc;
                case 6:
                    newc.cardval = CardValues.Six;
                    return newc;
                case 7:
                    newc.cardval = CardValues.Seven;
                    return newc;
                case 8:
                    newc.cardval = CardValues.Eight;
                    return newc;
                case 9:
                    newc.cardval = CardValues.Nine;
                    return newc;
                case 10:
                    newc.cardval = CardValues.Ten;
                    return newc;
                case 11:
                    newc.cardval = CardValues.Jack;
                    return newc;
                case 12:
                    newc.cardval = CardValues.Queen;
                    return newc;
                case 13:
                    newc.cardval = CardValues.King;
                    return newc;
            }
        }
        if (sprod == 2)
        {
            newc.suite = CardSuites.Diamond;

            newc.y = vprod;

            switch (vprod)
            {
                case 1:
                    newc.cardval = CardValues.Ace;
                    return newc;
                case 2:
                    newc.cardval = CardValues.Two;
                    return newc;
                case 3:
                    newc.cardval = CardValues.Three;
                    return newc;
                case 4:
                    newc.cardval = CardValues.Four;
                    return newc;
                case 5:
                    newc.cardval = CardValues.Five;
                    return newc;
                case 6:
                    newc.cardval = CardValues.Six;
                    return newc;
                case 7:
                    newc.cardval = CardValues.Seven;
                    return newc;
                case 8:
                    newc.cardval = CardValues.Eight;
                    return newc;
                case 9:
                    newc.cardval = CardValues.Nine;
                    return newc;
                case 10:
                    newc.cardval = CardValues.Ten;
                    return newc;
                case 11:
                    newc.cardval = CardValues.Jack;
                    return newc;
                case 12:
                    newc.cardval = CardValues.Queen;
                    return newc;
                case 13:
                    newc.cardval = CardValues.King;
                    return newc;
            }
        }
        if (sprod == 3)
        {
            newc.suite = CardSuites.Heart;

            newc.y = vprod;

            switch (vprod)
            {
                case 1:
                    newc.cardval = CardValues.Ace;
                    return newc;
                case 2:
                    newc.cardval = CardValues.Two;
                    return newc;
                case 3:
                    newc.cardval = CardValues.Three;
                    return newc;
                case 4:
                    newc.cardval = CardValues.Four;
                    return newc;
                case 5:
                    newc.cardval = CardValues.Five;
                    return newc;
                case 6:
                    newc.cardval = CardValues.Six;
                    return newc;
                case 7:
                    newc.cardval = CardValues.Seven;
                    return newc;
                case 8:
                    newc.cardval = CardValues.Eight;
                    return newc;
                case 9:
                    newc.cardval = CardValues.Nine;
                    return newc;
                case 10:
                    newc.cardval = CardValues.Ten;
                    return newc;
                case 11:
                    newc.cardval = CardValues.Jack;
                    return newc;
                case 12:
                    newc.cardval = CardValues.Queen;
                    return newc;
                case 13:
                    newc.cardval = CardValues.King;
                    return newc;
            }
        }
        if (sprod == 4)
        {
            newc.suite = CardSuites.Spade;

            newc.y = vprod;

            switch (vprod)
            {
                case 1:
                    newc.cardval = CardValues.Ace;
                    return newc;
                case 2:
                    newc.cardval = CardValues.Two;
                    return newc;
                case 3:
                    newc.cardval = CardValues.Three;
                    return newc;
                case 4:
                    newc.cardval = CardValues.Four;
                    return newc;
                case 5:
                    newc.cardval = CardValues.Five;
                    return newc;
                case 6:
                    newc.cardval = CardValues.Six;
                    return newc;
                case 7:
                    newc.cardval = CardValues.Seven;
                    return newc;
                case 8:
                    newc.cardval = CardValues.Eight;
                    return newc;
                case 9:
                    newc.cardval = CardValues.Nine;
                    return newc;
                case 10:
                    newc.cardval = CardValues.Ten;
                    return newc;
                case 11:
                    newc.cardval = CardValues.Jack;
                    return newc;
                case 12:
                    newc.cardval = CardValues.Queen;
                    return newc;
                case 13:
                    newc.cardval = CardValues.King;
                    return newc;
            }
        }
        else
        {
            return newc;
        }
        return newc;
    }
4

2 に答える 2