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
上一篇:[洛谷P2482][题解][SDOI2010]猪国杀


下一篇:智象运维干货 | HP iLo4 Smash CLP命令行参考