示例#1
0
void Battle::doBattle(Pokemon& attacking, Pokemon& defending, Move& move)
{
    // print the pokemon and move involved in this battle
    println_debug("Running Battle");
    cout << attacking.getNickname() << " used " << move.getName() << "."
        << endl;

    // determine if move will hit
    bool moveHit = willMoveHit(attacking, defending, move);

    if(moveHit)
    {
        // do the actual move
        if(move.getCategory() == STATUS)
        {
            // status moves just use a hook
            move.doEffect(attacking, defending);
        }
        else
        {
            // physical and special moves do damage
            int damage = getDamage(attacking, defending, move);
            defending.changeHp(-damage);
        }

        // hook for post-move effect
        move.onMoveEnd(attacking, defending, moveHit);
    }
    else
    {
        // print miss  statement
        cout << attacking.getNickname() << "'s attack missed." << endl;
    }
}