scrimba
Create an RPG game - Rob Sutcliffe
Name functions
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

Name functions
by
AboutCommentsNotes
Name functions
by
Expand for more info
index.js
run
preview
console
import characterData from "./data";
import Character from "./Character";

function render() {
document.getElementById(hero.elementId).innerHTML = hero.getTemplate();
document.getElementById(monster.elementId).innerHTML = monster.getTemplate();
}

const hero = new Character(characterData.hero);
const monster = new Character(characterData.monster);

render();

// 1. Seperate the function below and call it attackPhase
// 2. Assign the attackPhase fuction to the onclick method before
document.getElementById("attack-button").onclick = function() {

const heroAttackScore = hero.rollDice();
const monsterAttackScore = monster.rollDice();

hero.takeDamage(monsterAttackScore);
monster.takeDamage(heroAttackScore);

render();
}
Console
/index.html
-2:14