其他分享
首页 > 其他分享> > 2020-12-21

2020-12-21

作者:互联网

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

标签:FP,Warrior,12,21,int,HP,Magician,2020,include
来源: https://blog.csdn.net/qq_33890670/article/details/111470816