function characterDamaged(damage, character, id) {
    afflictDamage(character, damage);
    alert(currentMonsters[0].hpLeft + " " + currentMonsters[1].hpLeft) //test method
    if (character.hpLeft < 0) {
        character.hpLeft = 0;
        if (character instanceof Monster) {
            giveXP(monsterXPYield(character));
        }
    }
    let hpBarWidth = 200 * character.hpLeft / character.hp;
    if (character instanceof Character) {
        let index = findRightChar(character);
        document.getElementById("player" + (index + 1) + "HPNumber").innerHTML = character.hpLeft + "/" + character.hp;
        document.getElementById("player" + (index + 1) + "curHP").style.width = hpBarWidth + "px";
        changeHpBarColour((character.hpLeft / character.hp) * 100, "player" + (index + 1) + "curHP");
        if (areAllDead(currentCharacters) === true) {
            alert("All Players are dead");
            //toMenu();
        }
    }
    else if (character instanceof Monster) {
        let index = id;
        document.getElementById("enemy" + (index + 1) + "HPNumber").innerHTML = character.hpLeft + "/" + character.hp;
        document.getElementById("enemy" + (index + 1) + "curHP").style.width = hpBarWidth + "px";
        changeHpBarColour((character.hpLeft / character.hp) * 100, "enemy" + (index + 1) + "curHP");
        if (areAllDead(currentMonsters) === true) {
            alert("All Monsters are dead");
            //toMenu();
        }
    }
}
/**
 * Calculates the remaining HP of the targeted combatant.
 * @param {Number} damage damage taken.
 * @param {Character} character target combatant.
 */
Calculates the remaining HP of the targeted combatant.
@param {Number} damage damage taken.
@param {Character} character target combatant.
Calculates the remaining HP of the targeted combatant . @param { Number } damage damage taken . @param { Character } character target combatant .
function characterDamaged(damage, character, id) {
    afflictDamage(character, damage);
    alert(currentMonsters[0].hpLeft + " " + currentMonsters[1].hpLeft) 
    if (character.hpLeft < 0) {
        character.hpLeft = 0;
        if (character instanceof Monster) {
            giveXP(monsterXPYield(character));
        }
    }
    let hpBarWidth = 200 * character.hpLeft / character.hp;
    if (character instanceof Character) {
        let index = findRightChar(character);
        document.getElementById("player" + (index + 1) + "HPNumber").innerHTML = character.hpLeft + "/" + character.hp;
        document.getElementById("player" + (index + 1) + "curHP").style.width = hpBarWidth + "px";
        changeHpBarColour((character.hpLeft / character.hp) * 100, "player" + (index + 1) + "curHP");
        if (areAllDead(currentCharacters) === true) {
            alert("All Players are dead");
        }
    }
    else if (character instanceof Monster) {
        let index = id;
        document.getElementById("enemy" + (index + 1) + "HPNumber").innerHTML = character.hpLeft + "/" + character.hp;
        document.getElementById("enemy" + (index + 1) + "curHP").style.width = hpBarWidth + "px";
        changeHpBarColour((character.hpLeft / character.hp) * 100, "enemy" + (index + 1) + "curHP");
        if (areAllDead(currentMonsters) === true) {
            alert("All Monsters are dead");
        }
    }
}
function characterDamaged ( damage , character , id ) { afflictDamage ( character , damage ) ; alert ( currentMonsters [ 0 ] . hpLeft + " " + currentMonsters [ 1 ] . hpLeft ) if ( character . hpLeft < 0 ) { character . hpLeft = 0 ; if ( character instanceof Monster ) { giveXP ( monsterXPYield ( character ) ) ; } } let hpBarWidth = 200 * character . hpLeft / character . hp ; if ( character instanceof Character ) { let index = findRightChar ( character ) ; document . getElementById ( "player" + ( index + 1 ) + "HPNumber" ) . innerHTML = character . hpLeft + "/" + character . hp ; document . getElementById ( "player" + ( index + 1 ) + "curHP" ) . style . width = hpBarWidth + "px" ; changeHpBarColour ( ( character . hpLeft / character . hp ) * 100 , "player" + ( index + 1 ) + "curHP" ) ; if ( areAllDead ( currentCharacters ) === true ) { alert ( "All Players are dead" ) ; } } else if ( character instanceof Monster ) { let index = id ; document . getElementById ( "enemy" + ( index + 1 ) + "HPNumber" ) . innerHTML = character . hpLeft + "/" + character . hp ; document . getElementById ( "enemy" + ( index + 1 ) + "curHP" ) . style . width = hpBarWidth + "px" ; changeHpBarColour ( ( character . hpLeft / character . hp ) * 100 , "enemy" + ( index + 1 ) + "curHP" ) ; if ( areAllDead ( currentMonsters ) === true ) { alert ( "All Monsters are dead" ) ; } } }
Calculates the remaining HP of the targeted combatant.
Calculates the remaining HP of the targeted combatant .
//test method //toMenu(); //toMenu();