Warrior.cpp
#include "Warrior.h"
#include <vector>
#include <bits/stdc++.h>
Warrior::Warrior(int HP, int FP):Piece("W",HP){
this->FP = FP;
}
void Warrior::attack(vector<Piece*> &opponents){
int len = opponents.size();
for(int i=0;i<len;++i){
Piece* one = opponents[i];
if(one==NULL) continue;
int newHp = one->getHP()-this->FP;
if(newHp <=0) {
opponents.erase(find(opponents.begin(),opponents.end(),one));
//one=NULL;
}else{
one->setHP(one->getHP()-this->FP);
}
}
}
Magician.cpp
#include "Magician.h"
#include <bits/stdc++.h>
Magician::Magician(int HP, int MP):Piece("M",HP){
this->MP = MP;
}
void Magician::attack(vector<Piece*> &opponents){
int len = oppo