scrimba
Build an RPG
Build a role-playing game part 3 - The gameplay
Inflicting damage 2
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Inflicting damage 2
Expand for more info
index.js
run
preview
console
import characterData from './data.js'
import Character from './Character.js'


/*CHALLENGE
1. Think what data we need to pass to our new
takeDamage method.
2. Add that data as an argument each time we call
takeDamage below.
3. In the takeDamage method, take in the data as a
parameter called 'attackScoreArray' and log it out.
**hint.md for help!**
*/

function attack() {
wizard.getDiceHtml()
orc.getDiceHtml()
wizard.takeDamage()
orc.takeDamage()
render()
}


function render() {
document.getElementById('hero').innerHTML = wizard.getCharacterHtml();
document.getElementById('monster').innerHTML = orc.getCharacterHtml();
}

document.getElementById("attack-button").addEventListener('click', attack)

const wizard = new Character(characterData.hero)
const orc = new Character(characterData.monster)
render()
Console
/index.html
-2:54