Advertisement
Guest User

Untitled

a guest
Feb 26th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.87 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. #include<iomanip>
  5. using namespace std;
  6.  
  7. struct card {
  8.     int Top;
  9.     int Left;
  10.     int Right;
  11.     int Bottom;
  12.     bool Side;
  13.     string CardName;
  14.    
  15.     // Struct constructor to easier initialization
  16.     card(string cardName, int top, int left, int right, int bottom, bool side)
  17.     {
  18.         CardName = cardName;
  19.         Top = top;
  20.         Left = left;
  21.         Right = right;
  22.         Bottom = bottom;
  23.         Side = side;
  24.     }
  25.  
  26.     card() { } // Default constructor
  27. };
  28.  
  29. const int numberofcardsally = 6;
  30. const int numberofcardsenemy = 6;
  31. bool fullboard = false;
  32.  
  33. int main() {
  34.     card PlayerDeck[6];
  35.     card EnemyDeck[6];
  36.     card board[3][3];
  37.     int input;
  38.  
  39.     // Remember to srand() before using rand()!
  40.     srand(time(0));
  41.  
  42.     // Creating cards individually
  43.     card PlayerCards[11];
  44.     PlayerCards[0] = card("Grdl", 2, 6, 4, 3, true);
  45.     PlayerCards[1] = card("Tmbry", 3, 6, 6, 2, true);
  46.     PlayerCards[2] = card("Edea", 3, 1, 7, 9, true);
  47.     PlayerCards[3] = card("Shva", 3, 6, 3, 9, true);
  48.     PlayerCards[4] = card("Ifrt", 4, 8, 2, 6, true);
  49.     PlayerCards[5] = card("King", 7, 3, 5, 1, true);
  50.     PlayerCards[6] = card("Jinn", 9, 8, 3, 2, true);
  51.     PlayerCards[7] = card("Kiro", 2, 4, 9, 2, true);
  52.     PlayerCards[8] = card("Ward", 6, 4, 9, 6, true);
  53.     PlayerCards[9] = card("Alex", 9, 6, 4, 8, true);
  54.     PlayerCards[10] = card("Ulma", 9, 9, 9, 9, true);
  55.  
  56.     // Simpler way to do it
  57.     card EnemyCards[11] = {
  58.         card("Grdl", 2, 6, 4, 3, true), card("Tmbry", 3, 6, 6, 2, true), card("Edea", 3, 1, 7, 9, true), card("Shva", 3, 6, 3, 9, true), card("Ifrt", 4, 8, 2, 6, true),
  59.         card("King", 7, 3, 5, 1, true), card("Jinn", 9, 8, 3, 2, true), card("Kiro", 2, 4, 9, 2, true), card("Ward", 6, 4, 9, 6, true), card("Alex", 9, 6, 4, 8, true),
  60.         card("Ulma", 9, 9, 9, 9, true)
  61.     };
  62.  
  63.     // Initialize board to blank
  64.     for(int x = 0; x < 3; x++)
  65.     {
  66.         for(int y = 0; y < 3; y++)
  67.             board[x][y].CardName = "    ";
  68.     }
  69.        
  70.     cout << "Select your cards: \n";
  71.     for(int i = 0; i < 11; i++)
  72.         cout << i << ": " << PlayerCards[i].CardName << endl;
  73.    
  74.     for(int i = 0; i < 6; i++)
  75.     {
  76.         cin >> input;
  77.         PlayerDeck[i] = PlayerCards[input];
  78.     }
  79.  
  80.     for(int i = 0; i < 6; i++)
  81.         EnemyDeck[i] = EnemyCards[rand() % 11]; // Random from 0 to 10
  82.  
  83.     while(true)
  84.     {
  85.         for(int i = 0; i <= 40; i++)
  86.             cout << endl;
  87.  
  88.         // Will never make it past this if-else
  89.         if((numberofcardsally >= numberofcardsenemy) && fullboard) {
  90.             cout << "You won!\n";
  91.             cin.get();
  92.             cin.get();
  93.             exit(0);
  94.         } else {
  95.             cout << "You lost!\n";
  96.             cin.get();
  97.             cin.get();
  98.             exit(0);
  99.         }
  100.         for(int i = 0; i < 6; i++) {
  101.             cout << setw(100) << PlayerCards[i].CardName;
  102.         }
  103.         for(int i = 0; i < 6; i++) {
  104.             cout << setw(30) << EnemyCards[i].CardName;
  105.         }
  106.         for(int x = 3; x < 3; x++) {
  107.             for(int y = 3; y < 3; y++)
  108.             cout << "[" << board[x][y].CardName << "]";
  109.             cout << endl;
  110.         }
  111.         cout << "Which card do you want to use? ";
  112.         cin >> input;
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement