Advertisement
Guest User

Untitled

a guest
Feb 27th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.99 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. int x;
  33. int y;
  34. int main() {
  35.     card PlayerDeck[6];
  36.     card EnemyDeck[6];
  37.     card board[3][3];
  38.     int input;
  39.  
  40.     // Remember to srand() before using rand()!
  41.     srand(time(0));
  42.  
  43.     // Creating cards individually
  44.     card PlayerCards[11];
  45.     PlayerCards[0] = card("Grdl", 2, 6, 4, 3, true);
  46.     PlayerCards[1] = card("Tmbry", 3, 6, 6, 2, true);
  47.     PlayerCards[2] = card("Edea", 3, 1, 7, 9, true);
  48.     PlayerCards[3] = card("Shva", 3, 6, 3, 9, true);
  49.     PlayerCards[4] = card("Ifrt", 4, 8, 2, 6, true);
  50.     PlayerCards[5] = card("King", 7, 3, 5, 1, true);
  51.     PlayerCards[6] = card("Jinn", 9, 8, 3, 2, true);
  52.     PlayerCards[7] = card("Kiro", 2, 4, 9, 2, true);
  53.     PlayerCards[8] = card("Ward", 6, 4, 9, 6, true);
  54.     PlayerCards[9] = card("Alex", 9, 6, 4, 8, true);
  55.     PlayerCards[10] = card("Ulma", 9, 9, 9, 9, true);
  56.  
  57.     // Simpler way to do it
  58.     card EnemyCards[11] = {
  59.         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),
  60.         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),
  61.         card("Ulma", 9, 9, 9, 9, true)
  62.     };
  63.  
  64.     // Initialize board to blank
  65.     for(int x = 0; x < 3; x++)
  66.     {
  67.         for(int y = 0; y < 3; y++)
  68.             board[x][y].CardName = "    ";
  69.     }
  70.        
  71.     cout << "Select your cards: \n";
  72.     for(int i = 0; i < 11; i++)
  73.         cout << i << ": " << PlayerCards[i].CardName << endl;
  74.    
  75.     for(int i = 0; i < 6; i++)
  76.     {
  77.         cin >> input;
  78.         PlayerDeck[i] = PlayerCards[input];
  79.     }
  80.  
  81.     for(int i = 0; i < 6; i++)
  82.         EnemyDeck[i] = EnemyCards[rand() % 11]; // Random from 0 to 10
  83.  
  84.     while(true)
  85.     {
  86.         for(int i = 0; i <= 40; i++)
  87.             cout << endl;
  88.  
  89.         // Will never make it past this if-else
  90.         if((numberofcardsally >= numberofcardsenemy) && fullboard) {
  91.             cout << "You won!\n";
  92.             cin.get();
  93.             cin.get();
  94.             exit(0);
  95.         }
  96.         if((numberofcardsally <= numberofcardsenemy) && fullboard) {
  97.             cout << "You lost!\n";
  98.             cin.get();
  99.             cin.get();
  100.             exit(0);
  101.         }
  102.         for(int i = 0; i < 6; i++) {
  103.             cout << PlayerDeck[i].CardName << endl;
  104.             cout << setw(300) << EnemyDeck[i].CardName << endl;
  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.         cout << "Position: X Y ";
  114.         cin >> x >> y;
  115.         board[x][y] = PlayerDeck[input];
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement