half done pokemon

This commit is contained in:
Geir Okkenhaug Jerstad 2024-09-20 14:51:30 +02:00
parent 25072921a7
commit 8ca92f7373
2 changed files with 31 additions and 15 deletions

View file

@ -28,19 +28,23 @@ let drowzee = {
level: 33,
};
let bjarne = {
name: "Bjarne",
image: "Images/pokemonTrainerIdle.png",
pokemon: [],
}
let possiblePokemon = [pikachu, bulbasaur, oranguru, drowzee];
let randomPokemon = null;
let playerName = "Bjarne";
let playerImage = "/Images/pokemonTrainerIdle.png";
let playerPokemon = [];
let app = document.getElementById("app");
updateView();
function updateView() {
getRandomPokemon()
// randomPokemon.level = Math.floor(Math.random() * 100)
// randomPokemon.health = Math.floor(Math.random() * 100)
// console.log(randomPokemon.level, randomPokemon.health);
app.innerHTML = /*HTML*/ `
<div class="container">
<div class="opposingPokemon">
@ -51,8 +55,8 @@ function updateView() {
<div class="bottomScreen">
<div class="player">
<img src="${playerImage}">
<div>${playerName}</div>
<img src="${bjarne.image}">
<div>${bjarne.name}</div>
</div>
<div class="buttonContainer">
@ -69,7 +73,7 @@ function updateView() {
function caughtPokemonView() {
app.innerHTML = /*HTML*/`
<div class="caughtContainer">
<h1>Du fanget ${playerPokemon[playerPokemon.length - 1].name}</h1>
<h1>Du fanget ${bjarne.pokemon[bjarne.pokemon.length - 1].name}</h1>
<div class="buttonContainer">
<button onclick="updateView()">Finn en annen</button>
<button onclick="showPokemon()">Vis dine pokemon</button>
@ -79,12 +83,26 @@ function caughtPokemonView(){
}
function catchPokemon() {
playerPokemon.push(randomPokemon);
bjarne.pokemon.push(randomPokemon);
caughtPokemonView();
}
function showPokemon() {
console.log(playerPokemon);
app.classList = '';
app.innerHTML = '';
for (i = 0; i < bjarne.pokemon.length; i++){
app.innerHTML += /*HTML*/ `
<table><tr><th>Navn</th><th>Level</th></tr>
<td>${bjarne.pokemon[i].name}</td><td>${bjarne.pokemon[i].level}</td></tr>
</table>
`;
}
app.innerHTML += /*HTML*/`
<div>
<button onclick="updateView()">Finn en annen</button>
</div>
`;
}
function getRandomPokemon() {

View file

@ -6,8 +6,6 @@ function Header({ title }) {
export default function HomePage() {
const names = ['Ada Lovlace', 'Grace Hopper', 'Margaret Hamilton'];
return (
<div>
<Header title="Develop. Preview. Ship." />