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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
Battle.cpp
#include "Battle.h"
#include "SetUp.h"
Battle::Battle(){
SetUp _setUp;
p1 = _setUp.getPlayer(1);
p2 = _setUp.getPlayer(2);
cur_player = p1;
p1.setChoosenMove(p1.getPokeman().getMoves()[0]);
p2.setChoosenMove(p2.getPokeman().getMoves()[0]);
system("cls");
cout << "\n**********LET THE BATTLE BEGIN************\n\n\n";
system("PAUSE");
system("cls");
while (p1.getPokeman().getHealth() > 0 && p2.getPokeman().getHealth() > 0){
printBattle();
}
cout << "Fight has ended";
return;
}
void Battle::printBattle(){
system("cls");
Moves move;
cout << p1.getName() << " with " << p1.getPokemanName() << "...................................................." << "hp:" << p1.getPokeman().getHealth() << endl << endl << endl << endl << " [" << move.getName(p1.getChoosenMove()) << "]" << endl << "" << move.getName(p1.getOtherMoves(p1)[0]) << " " << move.getName(p1.getOtherMoves(p1)[1]) << " " << move.getName(p1.getOtherMoves(p1)[2]) << endl << endl << endl << endl << endl << endl << endl << endl << p2.getName() << " with " << p2.getPokemanName() << "...................................................." << "hp:" << p2.getPokeman().getHealth() << endl << endl << endl << endl << " [" << move.getName(p2.getChoosenMove()) << "]" << endl << "" << move.getName(p2.getOtherMoves(p2)[0]) << " " << move.getName(p2.getOtherMoves(p2)[1]) << " " << move.getName(p2.getOtherMoves(p2)[2]);;
//setChoosenMove(cur_player);
setChoosenMove(p1);
system("cls");
return;
}
void Battle::setChoosenMove(Player& pl){
Moves move;
string input;
cin >> input;
if (input == "d" || input == "a" || input == "s"){
if (input == "s"){
pl.setChoosenMove(pl.getOtherMoves(pl)[1]);
pl.getOtherMoves(pl).erase(pl.getOtherMoves(pl).begin() + pl.getChoosenMoveNum(pl.getChoosenMove()));
input = "";
}
if (input == "a"){
pl.setChoosenMove(pl.getOtherMoves(pl)[0]);
pl.getOtherMoves(pl).erase(pl.getOtherMoves(pl).begin() + pl.getChoosenMoveNum(pl.getChoosenMove()));
input = "";
}
if (input == "d"){
pl.setChoosenMove(pl.getOtherMoves(pl)[2]);
pl.getOtherMoves(pl).erase(pl.getOtherMoves(pl).begin() + pl.getChoosenMoveNum(pl.getChoosenMove()));
input = "";
}
}
else{
cout << "bad Input";
}
return;
}
Moves.cpp
#include "Moves.h"
Moves::Moves(string name, float acu, int damage)
{
_name = name;
}
Moves::Moves(){
}
void Moves::setMoves(vector <Moves> moves){
_moves = moves;
}
vector<Moves> Moves::getMoves (){
return _moves;
}
Moves Moves::movesList(int index){
vector <Moves> movesList;
Moves WaterBlast("WaterBlast", 100, 50);
movesList.push_back(WaterBlast);
Moves Scratch("Scratch", 100, 50);
movesList.push_back(Scratch);
Moves Fireball("Fireball", 100, 50);
movesList.push_back(Fireball);
Moves Ram("Ram", 100, 50);
movesList.push_back(Ram);
Moves SC("Scare", 100, 50);
movesList.push_back(SC);
Moves PK("Peck", 100, 50);
movesList.push_back(PK);
Moves CnTrT("Consentrate", 100, 50);
movesList.push_back(CnTrT);
Moves SA("SandAttack", 100, 50);
movesList.push_back(SA);
Moves DdG("Dodge", 100, 50);
movesList.push_back(DdG);
Moves LW("LeafWind", 100, 50);
movesList.push_back(LW);
Moves ShK("Shock", 100, 50);
movesList.push_back(ShK);
Moves Blst("Blast", 100, 50);
movesList.push_back(Blst);
return movesList[index - 1];
}
string Moves::getName(Moves move){
return move._name;
}
bool Moves::areNotMovesEqual(Moves move1, Moves move2){
if (move1.getName(move1) == move2.getName(move2)){
return false;
}
else{
return true;
}
}
Player.cpp
#include "Player.h"
Player::Player(string name)
{
_name = name;
}
Player::Player(){
}
void Player::setPokeman(Pokemans pokeman){
_pokeman = pokeman;
}
Pokemans Player::getPokeman(){
return _pokeman;
}
string Player::getPokemanName(){
return _pokeman.getName();
}
string Player::getName(){
return _name;
}
void Player::setPlayerName(string name){
return;
}
Moves Player::getChoosenMove(){
return _choosenMove;
}
vector <Moves> Player::getOtherMoves(Player player){
string name = _choosenMove.getName(_choosenMove);
Moves move;
if (name == move.getName(player.getPokeman().getMoves()[0])){
_otherMoves.push_back(player.getPokeman().getMoves()[1]);
_otherMoves.push_back(player.getPokeman().getMoves()[2]);
_otherMoves.push_back(player.getPokeman().getMoves()[3]);
}
if (name == move.getName(player.getPokeman().getMoves()[1])){
_otherMoves.push_back(player.getPokeman().getMoves()[0]);
_otherMoves.push_back(player.getPokeman().getMoves()[2]);
_otherMoves.push_back(player.getPokeman().getMoves()[3]);
}
if (name == move.getName(player.getPokeman().getMoves()[2])){
_otherMoves.push_back(player.getPokeman().getMoves()[0]);
_otherMoves.push_back(player.getPokeman().getMoves()[1]);
_otherMoves.push_back(player.getPokeman().getMoves()[3]);
}
if (name == move.getName(player.getPokeman().getMoves()[3])){
_otherMoves.push_back(player.getPokeman().getMoves()[0]);
_otherMoves.push_back(player.getPokeman().getMoves()[1]);
_otherMoves.push_back(player.getPokeman().getMoves()[2]);
}
return _otherMoves;
}
void Player::setChoosenMove(Moves move){
_choosenMove = move;
return;
}
int Player::getChoosenMoveNum(Moves move){
int in = 0;
for (int i = 0; move.areNotMovesEqual(move, _otherMoves[i]); i++){
in = i;
}
return in;
}
|