Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

C++ Snippet that automaticly creates the Experience.ini file


Minikloon
 Share

Recommended Posts

If you are the kind of *cough* lazy *person*, here's a pre-coded mix that may help you out :

```
#include #include int main(int argc, char** argv) {
char filename[81];
// Algo variables
int exp = 0, diff = 0, oexp = 0;
// --
std::cout << "Enter a file name and press ENTER: ";
std::cin.getline(filename, 80);
std::ofstream file_out(filename);
if(! file_out) { // Verify if the file can be opened/created.
std::cout << "File " << filename;
std::cout << " could not be opened.";
return -1;
}
std::cout << "File " << filename << " was opened." << std::endl;
std::cout << "Writing hardcoded algo... ";
file_out << "[EXPERIENCE]" << std::endl;
for(int i = 1; i < 501; i++) {
oexp=exp;
exp = (diff + 10) + exp; // Algorythm.
file_out << "Exp" << i << "=" << exp << std::endl;
diff = exp - oexp;
}
std::cout << "Done!" << std::endl << "Press ENTER to exit the console.";
std::cin.get();
return 0;
}

```
This isn't user-friendly btw.
The current algorythm is :
Current EXP = (Difference between two other Exps + 10) + Previous EXP.
Link to comment
Share on other sites

I don't know how to put in a code box, so here:

>! #include #include #include int main(int argc, char** argv) {
  char filename[81];
  //declares the variables
  int exp = 0, diff = 0, oexp = 0, diffmod = 0, loopval =0;
  // Declares the file name
  std::cout << "Enter a file name and press ENTER: ";
  std::cin.getline(filename, 80);//gets the filename
  std::ofstream file_out(filename);
  if(! file_out) { // Verify if the file can be opened/created.
      std::cout << "File " << filename;
      std::cout << " could not be opened.";
      return -1;
  }
  std::cout << "File " << filename << " was opened." << std::endl;
  std::cout << "Declare a modifier for the algorithm";
  std::cin.getline(diffmod, 10);
  std::cout << "Declare the amount of exp values to generate";
  stc::cin.getline(loopval, 500);
  std::cout << "Generating data ";
  file_out << "[EXPERIENCE]" << std::endl; //titles the file
  for(int I = 1; I < loopval; I++) { //declares the amount of times to generate exp values
      oexp=exp; //Declares the variable to compare the new exp to
      exp = (diff + diffmod) + exp; // Algorithm that generates the new exp
      file_out << "Exp" << I << "=" << exp << std::endl; //adds the stream data to the file
      diff = exp - oexp; //Declares the diffrence
  }
  std::cout << "Done!" << std::endl << "Press ENTER to exit the console.";
  std::cin.get();
  return 0;
}

I think I n00bed it up some (added some comments), and added some additional functions. My C++ is rusty, so I apologize if I broke it, because I can't test it right now.
Link to comment
Share on other sites

Thanks Fabio and Thanks Vash.

I think your edit is better. I realized my software was only adding 10 to the difference between lvls, making a strange experience trail. Also the diff variable wasn't needed the way it was. (The i loop could have done the job.)

TODO:
- Ask for the formula and analyze the input. (Headache.)
- GUI.

I will not do it tho, because I need to continue my learning and will maybe someday come back on this topic and see how much of a noob I was.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...