MZ Battle ends way too fast when using an alias.

Here is the original method:


JavaScript:
BattleManager.checkBattleEnd = function() {
    if (this._phase) {
        if (this.checkAbort()) {
            return true;
        } else if ($gameParty.isAllDead()) {
            this.processDefeat();
            return true;
        } else if ($gameTroop.isAllDead()) {
            this.processVictory();
            return true;
        }
    }
    return false;
};
When this runs and the result is of everyone being dead, you'll see a message that the party was defeated, yadda yadda, and then the screen fades and the game is closed(in the case of battle testing).

However when it's aliased, the process is sped up and you don't even see the defeat message before the game is closed. It doesn't matter if nothing else is added in the function body and just allow the game to run the original code:
JavaScript:
(function(alias) {
    BattleManager.checkBattleEnd = function() {
        alias.apply(this);
        
    };
})(BattleManager.checkBattleEnd);

I want to know how to have it end the battle at its original pace(if that makes sense) and yes I need to change the behavior of that method, preferably not having to rewrite the method.
That method should return a value, so remember to include a return statement:
JavaScript:
(function(alias) {
    BattleManager.checkBattleEnd = function() {
        return alias.apply(this);
    };
})(BattleManager.checkBattleEnd);
I'm dumb.... thanks again.
It's an easy mistake to make, no worries! 👋

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/battle-ends-way-too-fast-when-using-an-alias.140986/