0

how do i get the card type to loop with the round?

i have to create a card game where the players use a different card each round however it just uses the same card name. here is my code; #include "stdafx.h" #include <iostream> #include <string> #include <fstream> #include "MagiMania.h" using namespace std; const int ARRAYROW = 30; const int ARRAYCOL = 4; const int SIZE = 30; class sorCard { public: int sType; string sName; int sAttk; int sDef; }; class wizCard { public: int wType; string wName; int wAttk; int wDef; }; int main(){ ifstream sorceresscards; sorceresscards.open("sorceress.txt");//opens sorceress cards file// if (!sorceresscards) { cout << "Unable to open file"; system("pause"); } else { cout << "Sorceress file opened successfully" << endl; } sorCard sorDeck[SIZE];//creates deck for sorceress// for (int x = 0; x <= ARRAYROW; x++) { sorceresscards >> sorDeck[x].sType >> sorDeck[x].sName >> sorDeck[x].sAttk >> sorDeck[x].sDef;//loads file into array } ifstream wizardcards; wizardcards.open("wizard.txt");//opens sorceress cards file// if (!wizardcards) { cout << "Unable to open file"; system("pause"); } else { cout << "Wizard file opened successfully" << endl; } wizCard wizDeck[SIZE];//creates deck for sorceress// for (int x = 0; x <= ARRAYROW; x++) { wizardcards >> wizDeck[x].wType >> wizDeck[x].wName >> wizDeck[x].wAttk >> wizDeck[x].wDef;//loads file into array } cout << "Welcome To MAGIMANIA!" << wizDeck[6].wName<< endl<<"Created by M Gibson-Storey"<<endl<<endl; int round; for (int round = 1; round < 30; round++) // loops until round is equal to 30 { int sorceressHealth = 30; int wizardHealth = 30; int x = 0; x++; //Round begins cout << endl << "Round " << round << " fight!" << endl; system("pause"); //Sorceress draws card cout << "Sorceress draws " << sorDeck[x].sName << endl; //Card attacks Wizard cout << sorDeck[x].sName << " deals " << sorDeck[x].sAtt

12th Aug 2018, 8:40 PM
Matthew Gibson-storey
Matthew Gibson-storey - avatar
1 Antwort
0
Matthew Gibson-storey please post link for your code so that we can directly check out for you
13th Aug 2018, 4:18 AM
Ketan Lalcheta
Ketan Lalcheta - avatar