-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrainer.cpp
92 lines (82 loc) · 2.67 KB
/
Trainer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include ".\Trainer.hpp"
Trainer::Trainer(std::string name,Pokemon a,Pokemon b,Pokemon c){
TrainerName = name;
myPoke[0] = a;
myPoke[1] = b;
myPoke[2] = c;
}
std::string Trainer::getTrainerName(){
return TrainerName;
}
Pokemon* Trainer::getpPokemon(int num){
return &myPoke[num-1];
}
Pokemon Trainer::getPokemon(int num){
return myPoke[num-1];
}
Pokemon* Trainer::getpPokemon(){
return myPoke;
}
Move Trainer::getPokeMove(int p,int m){
return getPokemon(p).getMove(m);
}
void Trainer::PokeDie(){
numArivePoke--;
}
void Trainer::showmyPoke(){
for(int i=0;i<3;i++){
std::cout <<i<<myPoke[i].getPokeName()<<std::endl;
}
}
void Trainer::setTrainer(std::string name,Pokemon* poke3){
TrainerName = name;
for(int i=0;i<3;i++){
myPoke[i].setPokemon(poke3[i]);
}
}
void Trainer::setMe(Pokemon* all,int numPokemons){
std::cout << "What your name?"<<std::endl;
std::string name;
std::cin >> name;
std::cout<<std::endl;
std::cout << "Your name is "<<name<<'!'<<std::endl;
enter();//enterキーの要求
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');// バッファをクリアする
std::cout<<"You have to choose 3 Pokemon!"<<std::endl;
enter();//enterキーの要求
for(int i=0;i<3;i++){
bool still=true;
while(still){
myPoke[i] = checkPokemon( all[selectPokemon(all,numPokemons)] , &still);
}
}
}
//ヘルパー
int Trainer::selectPokemon(Pokemon* pokemons, int numPokemons) {
int selection;
//二週目からはバッファをクリアする
std::cout << "Choose your Pokemon" << std::endl;
enter();//enterキーの要求
for (int i = 0; i < numPokemons; i++) {
std::cout << i + 1 << ". " << pokemons[i].getPokeName() << std::endl;
}
std::cin >> selection;
std::cout<<std::endl;
return selection - 1;
}
Pokemon Trainer::checkPokemon(Pokemon pokemon, bool* isConfirmed) {
Pokemon tmp;
std::cout << "Show the status of " << pokemon.getPokeName() << std::endl;
enter();//enterキーの要求
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');// バッファをクリアする
pokemon.showAllST();
enter();//enterキーの要求
std::cout << "OK?" << std::endl;
if (isYESorNO()) {
std::cout << "You choose " << pokemon.getPokeName() <<"!"<< std::endl;
enter();//enterキーの要求
tmp = pokemon;
*isConfirmed = false;
}
return tmp;
}