Advertisement
BeamNG_IRC

Card generator

Aug 17th, 2015
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. // functions
  5.  
  6. void listCards();
  7. void randomHand(int numberOfCards);
  8.  
  9.  
  10. // cards array
  11.  
  12. char *Spades[13] = {
  13.  
  14.     "🂡", "🂢",
  15.     "🂣", "🂤",
  16.     "🂥", "🂦",
  17.     "🂧", "🂨",
  18.     "🂩", "🂪",
  19.     "🂫", "🂭",
  20.     "🂮",
  21.  
  22. };
  23.  
  24. char *Hearts[13] = {
  25.  
  26.     "🂱", "🂲",
  27.     "🂳", "🂴",
  28.     "🂵", "🂶",
  29.     "🂷", "🂸",
  30.     "🂹", "🂺",
  31.     "🂻", "🂽",
  32.     "🂾"
  33.  
  34.     };
  35.  
  36. char *Diamonds[13] = {
  37.  
  38.     "🃁", "🃂",
  39.     "🃃", "🃄",
  40.     "🃅", "🃆",
  41.     "🃇", "🃈",
  42.     "🃉", "🃊",
  43.     "🃋", "🃍",
  44.     "🃎",
  45.  
  46. };
  47.  
  48. char *Clubs[13] = {
  49.  
  50.     "🃑", "🃒",
  51.     "🃓", "🃔",
  52.     "🃕", "🃖",
  53.     "🃗", "🃘",
  54.     "🃙", "🃚",
  55.     "🃛", "🃝",
  56.     "🃞",
  57.  
  58. };
  59.  
  60. char *Deck[52] = {
  61.  
  62.     "🂡", "🂢",
  63.     "🂣", "🂤",
  64.     "🂥", "🂦",
  65.     "🂧", "🂨",
  66.     "🂩", "🂪",
  67.     "🂫", "🂭",
  68.     "🂱", "🂲",
  69.     "🂳", "🂴",
  70.     "🂵", "🂶",
  71.     "🂷", "🂸",
  72.     "🂹", "🂺",
  73.     "🂻", "🂽",
  74.     "🂾", "🃁",
  75.     "🃃", "🃄",
  76.     "🃅", "🃆",
  77.     "🃇", "🃈",
  78.     "🃉", "🃊",
  79.     "🃋", "🃍",
  80.     "🃎", "🃑",
  81.     "🃓", "🃔",
  82.     "🃕", "🃖",
  83.     "🃗", "🃘",
  84.     "🃙", "🃚",
  85.     "🃛", "🃝",
  86.     "🃞", "🂮",
  87.     "🃂", "🃒"
  88.  
  89. };
  90.  
  91. int main (int argc, char **argv) {
  92.  
  93.     time_t t;
  94.     srand((unsigned)time(&t));
  95.     if (argc < 2) {
  96.  
  97.         printf("\nThis program will generate a field of cards.\commands:\nlist - lists all 52 cards in a deck\n");
  98.         return 0;
  99.  
  100.     }
  101.  
  102.     if (strcmp(argv[1], "list") == 0)
  103.         listCards();
  104.  
  105.     if (strcmp(argv[1], "hand") == 0)
  106.         randomHand(atoi(argv[2]));
  107.  
  108.     return 0;
  109.  
  110. }
  111.  
  112. void listCards() {
  113.  
  114.     int x = 0;
  115.     for (x; x < 13; x++) {
  116.  
  117.         printf("%s", Spades[x]);
  118.         printf("%s", Hearts[x]);
  119.         printf("%s", Diamonds[x]);
  120.         printf("%s\n", Clubs[x]);
  121.  
  122.     }
  123.  
  124. }
  125.  
  126. void randomHand(int numberOfCards) {
  127.  
  128.     int x = 0;
  129.     for (x; x < numberOfCards; x++) {
  130.  
  131.         printf("%s", Deck[rand() % 52]);
  132.  
  133.     }
  134.     printf("\n");
  135.  
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement