Untitled
unknown
plain_text
3 years ago
2.6 kB
14
Indexable
let stats = {
Goku: {
str: 6,
dex: 7,
crit: 7,
vit: 30,
damage: 12,
defence: 10,
health: 260,
level: 1,
},
Vegeta: {
str: 20,
dex: 5,
crit: 5,
vit: 10,
damage: 40,
defence: 10,
health: 100,
level: 1,
},
Piccolo: {
str: 5,
dex: 20,
crit: 20,
vit: 5,
damage: 12,
defence: 10,
health: 165,
level: 1,
},
Chimichuri: {
str: 10,
dex: 10,
crit: 10,
vit: 10,
damage: 10,
defence: 10,
health: 100,
level: 1,
},
};
let characterName = localStorage["currentHero"];
let char = new Character(characterName, stats[characterName]);
// Run on click
let statIncreaseButtons = document.querySelectorAll(".increaseStat");
statIncreaseButtons.forEach((button) => {
button.addEventListener("click", () => {
let statName = button.dataset.stat;
char.changeStatValue(statName);
char.calculateStats();
char.displayAllStats();
});
});
let counter = 0;
function incrementLevel() {
counter++;
document.getElementById("counter").innerHTML = counter;
console.log(counter);
}
let i = 0;
// function move() {
// if (i == 0) {
// i = 1;
// let elem = document.getElementById("my-bar");
// let width = 5;
// let id = setInterval(frame, 10);
// function frame() {
// if (width >= 100) {
// clearInterval(id);
// i = 0;
// incrementLevel();
// } else {
// width++;
// elem.style.width = width + "%";
// elem.innerHTML = width + "%";
// }
// }
// }
// }
function move() {
let elem = document.getElementById("my-bar");
if (i == 0) {
i = 1;
let width = 1;
let id = setInterval({
if (width >= 100) {
clearInterval(id);
i = 0;
incrementLevel();
} else {
width++;
elem.style.width = width + "%";
elem.innerHTML = width + "%";
}
}, 10);
}
}
document.getElementById("mainHero").src = "images/" + char.name + ".png";
document.getElementById("hero").innerText = char.name;
document
.getElementById("saveData")
.addEventListener("click", () => char.saveData());
document
.getElementById("loadData")
.addEventListener("click", () => char.loadData());
document
.getElementById("deleteData")
.addEventListener("click", () => char.clearSavedData());
char.calculateStats();
char.displayAllStats();
Editor is loading...