Advertisement
Guest User

main.cc

a guest
Nov 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. void die(string s = "INVALID INPUT!") {
  9.     cout << s << endl;
  10.     exit(EXIT_FAILURE);
  11. }
  12.  
  13. //Make a couple classes here to describe pokemon and moves
  14. class pokemon {
  15.   public:
  16.     string name;
  17.     int hp = 0;
  18.     int attack = 0;
  19.     int defense = 0;
  20.     int speed = 0;
  21.     int special = 0;
  22.     string type;
  23.     string type2;
  24. };
  25.  
  26. class moves {
  27.   public:
  28.     int index = 0;
  29.     string name;
  30.     string type;
  31.     string category;
  32.     int pp = 0;
  33.     int power = 0;
  34.     int accuracy = 0;
  35. };
  36. //Write functions to load from pokemon.txt and moves.txt
  37.  
  38. int read(vector<pokemon> pokemen) {
  39.     int index;
  40.     ifstream pokemon;
  41.     ifstream types;
  42.     pokemon.open("pokemon.txt");
  43.     types.open("types.txt");
  44.     //char output[100];
  45.     if (pokemon.is_open()) {
  46.         while (!pokemon.eof()) {
  47.             //pokemon >> output;
  48.             //cout << output << endl;
  49.             if ((pokemon >> index)
  50.                     && (pokemon >> pokemen[index - 1].name)
  51.                     && (pokemon >> pokemen[index - 1].hp)
  52.                     && (pokemon >> pokemen[index - 1].attack)
  53.                     && (pokemon >> pokemen[index - 1].defense)
  54.                     && (pokemon >> pokemen[index - 1].speed)
  55.                     && (pokemon >> pokemen[index - 1].special)
  56.                     && (types >> pokemen[index - 1].type)
  57.                     && (types >> pokemen[index - 1].type2)) {
  58.                 cout << "Pokemon Entry " << index << ": " << pokemen[index - 1].name << " hp: " << pokemen[index - 1].hp << " attack: " << pokemen[index - 1].attack << " defense: " << pokemen[index - 1].defense << " speed: " << pokemen[index - 1].speed << " special: " << pokemen[index - 1].special << " type: " << pokemen[index - 1].type << " type2: " << pokemen[index - 1].type2 << endl;
  59.             }
  60.         }
  61.     }
  62.     pokemon.close();
  63.     types.close();
  64.     return 0;
  65. }
  66.  
  67.  
  68.  
  69. int read2(vector<moves> moves2) {
  70.     int index;
  71.     ifstream moves;
  72.     moves.open("moves.txt");
  73.     //char output[100];
  74.     if (moves.is_open()) {
  75.         while (!moves.eof()) {
  76.             //pokemon >> output;
  77.             //cout << output << endl;
  78.             if ((moves >> index)
  79.                     && (moves >> moves2[index - 1].name)
  80.                     && (moves >> moves2[index - 1].type)
  81.                     && (moves >> moves2[index - 1].category)
  82.                     && (moves >> moves2[index - 1].pp)
  83.                     && (moves >> moves2[index - 1].power)
  84.                     && (moves >> moves2[index - 1].accuracy)) {
  85.                 cout << "Move Index " << index << ": " << moves2[index - 1].name << " type: " << moves2[index - 1].type << " category: " << moves2[index - 1].category << " PP: " << moves2[index - 1].pp << " power: " << moves2[index - 1].power << " accuracy: " << moves2[index - 1].accuracy << "%" << endl;
  86.             }
  87.         }
  88.     }
  89.     moves.close();
  90.     return 0;
  91. }
  92.  
  93.  
  94.  
  95. /*int read3() {
  96.     ifstream types;
  97.     types.open("types.txt");
  98.     char output[100];
  99.     if (types.is_open()) {
  100.         while (!types.eof()) {
  101.  
  102.             types >> output;
  103.             cout << output << endl;
  104.         }
  105.     }
  106.     types.close();
  107.     return 0;
  108. }
  109. */
  110.  
  111. //Then write code to do Pokemon battles
  112.  
  113. int main() {
  114.     vector<pokemon> pokemen(151);
  115.     read(pokemen);
  116.     vector<moves> moves2(165);
  117.     read2(moves2);
  118.  
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement