Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- using namespace std;
- void die(string s = "INVALID INPUT!") {
- cout << s << endl;
- exit(EXIT_FAILURE);
- }
- //Make a couple classes here to describe pokemon and moves
- class pokemon {
- public:
- string name;
- int hp = 0;
- int attack = 0;
- int defense = 0;
- int speed = 0;
- int special = 0;
- string type;
- string type2;
- };
- class moves {
- public:
- int index = 0;
- string name;
- string type;
- string category;
- int pp = 0;
- int power = 0;
- int accuracy = 0;
- };
- //Write functions to load from pokemon.txt and moves.txt
- int read(vector<pokemon> pokemen) {
- int index;
- ifstream pokemon;
- ifstream types;
- pokemon.open("pokemon.txt");
- types.open("types.txt");
- //char output[100];
- if (pokemon.is_open()) {
- while (!pokemon.eof()) {
- //pokemon >> output;
- //cout << output << endl;
- if ((pokemon >> index)
- && (pokemon >> pokemen[index - 1].name)
- && (pokemon >> pokemen[index - 1].hp)
- && (pokemon >> pokemen[index - 1].attack)
- && (pokemon >> pokemen[index - 1].defense)
- && (pokemon >> pokemen[index - 1].speed)
- && (pokemon >> pokemen[index - 1].special)
- && (types >> pokemen[index - 1].type)
- && (types >> pokemen[index - 1].type2)) {
- 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;
- }
- }
- }
- pokemon.close();
- types.close();
- return 0;
- }
- int read2(vector<moves> moves2) {
- int index;
- ifstream moves;
- moves.open("moves.txt");
- //char output[100];
- if (moves.is_open()) {
- while (!moves.eof()) {
- //pokemon >> output;
- //cout << output << endl;
- if ((moves >> index)
- && (moves >> moves2[index - 1].name)
- && (moves >> moves2[index - 1].type)
- && (moves >> moves2[index - 1].category)
- && (moves >> moves2[index - 1].pp)
- && (moves >> moves2[index - 1].power)
- && (moves >> moves2[index - 1].accuracy)) {
- 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;
- }
- }
- }
- moves.close();
- return 0;
- }
- /*int read3() {
- ifstream types;
- types.open("types.txt");
- char output[100];
- if (types.is_open()) {
- while (!types.eof()) {
- types >> output;
- cout << output << endl;
- }
- }
- types.close();
- return 0;
- }
- */
- //Then write code to do Pokemon battles
- int main() {
- vector<pokemon> pokemen(151);
- read(pokemen);
- vector<moves> moves2(165);
- read2(moves2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement