Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Deck
- {
- private readonly string[] CARDS = new string[] {
- "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "Th", "Jh", "Qh", "Kh", "Ah",
- "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "Ts", "Js", "Qs", "Ks", "As",
- "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "Td", "Jd", "Qd", "Kd", "Ad",
- "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "Tc", "Jc", "Qc", "Kc", "Ac"};
- private static readonly int NUM_CARDS = 52;
- private Card[] deck = new Card[NUM_CARDS];
- public void getNewDeck()
- {
- Card tempCard;
- string tempString;
- for (int i = 0; i < NUM_CARDS; i++)
- {
- tempString = CARDS[i];
- tempCard = new Card(tempString[0], tempString[1]);
- deck[i] = tempCard;
- }
- }
- public Card[] shuffle()
- {
- System.Random r = new System.Random();
- for (int i = NUM_CARDS - 1; i > 0; i--)
- {
- int j = r.Next(0, NUM_CARDS);
- Card temp = deck[i];
- deck[i] = deck[j];
- deck[j] = temp;
- }
- return deck;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement