Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c09610

Browse files
committed
Created v2 of pokemon homework
More advanced pokemon homework
1 parent 1e4c049 commit 2c09610

File tree

5 files changed

+201
-0
lines changed

5 files changed

+201
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" href="pokemon.css" />
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
8+
<title>Pokemon Selector</title>
9+
</head>
10+
<body>
11+
<div style="margin-left:25%">
12+
<section class="section">
13+
<div id="oakSide" style="width:25%">
14+
<img id="oakImage" src="prof_oak.png" />
15+
</div>
16+
<h3>Welcome to Professor Oak's Lab</h3>
17+
18+
<br />
19+
<div id="quoteSpace"></div>
20+
21+
<div id="poke-selector"></div>
22+
<script type="text/javascript" src="./poke-sprites.js"></script>
23+
<div id="footer">Made for FooCoding Javascript 2.</div>
24+
</section>
25+
</div>
26+
</body>
27+
</html>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* eslint-disable */
2+
3+
/*
4+
Call this function to get a JSON string of the data
5+
(simulates calling a server to retrieve data)
6+
*/
7+
var name = window.prompt('Enter your name:');
8+
var color = window.prompt('Choose fire, water or grass.');
9+
10+
function fetchPokemonData(type) {
11+
if (type == 'fire') {
12+
return `{"abilities": [{"ability": {"name": "solar-power","url": "https://pokeapi.co/api/v2/ability/94/"},"is_hidden": true,"slot": 3},{"ability": {"name": "blaze","url": "https://pokeapi.co/api/v2/ability/66/" },"is_hidden": false,"slot": 1}],"base_experience": 62,"forms": [{"name": "charmander","url": "https://pokeapi.co/api/v2/pokemon-form/4/"}], "height": 6,"held_items": [],"id": 4,"is_default": true,"location_area_encounters": "https://pokeapi.co/api/v2/pokemon/4/encounters","order": 5,"species": {"name": "charmander", "url": "https://pokeapi.co/api/v2/pokemon-species/4/"},"sprites": {"back_default": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/4.png","back_female": null,"back_shiny": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/4.png","back_shiny_female": null,"front_default": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/4.png","front_female": null,"front_shiny": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/4.png","front_shiny_female": null}}`;
13+
}
14+
if (type == 'water') {
15+
return `{"abilities":[{"ability":{"name":"rain-dish","url":"https://pokeapi.co/api/v2/ability/44/"},"is_hidden":true,"slot":3},{"ability":{"name":"torrent","url":"https://pokeapi.co/api/v2/ability/67/"},"is_hidden":false,"slot":1}],"base_experience":63,"forms":[{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-form/7/"}],"height":5,"held_items":[],"id":7,"is_default":true,"location_area_encounters":"https://pokeapi.co/api/v2/pokemon/7/encounters","name":"squirtle","order":10,"species":{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-species/7/"},"sprites":{"back_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/7.png","back_female":null,"back_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/7.png","back_shiny_female":null,"front_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/7.png","front_female":null,"front_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/7.png","front_shiny_female":null},"stats":[{"base_stat":43,"effort":0,"stat":{"name":"speed","url":"https://pokeapi.co/api/v2/stat/6/"}},{"base_stat":64,"effort":0,"stat":{"name":"special-defense","url":"https://pokeapi.co/api/v2/stat/5/"}},{"base_stat":50,"effort":0,"stat":{"name":"special-attack","url":"https://pokeapi.co/api/v2/stat/4/"}},{"base_stat":65,"effort":1,"stat":{"name":"defense","url":"https://pokeapi.co/api/v2/stat/3/"}},{"base_stat":48,"effort":0,"stat":{"name":"attack","url":"https://pokeapi.co/api/v2/stat/2/"}},{"base_stat":44,"effort":0,"stat":{"name":"hp","url":"https://pokeapi.co/api/v2/stat/1/"}}],"types":[{"slot":1,"type":{"name":"water","url":"https://pokeapi.co/api/v2/type/11/"}}],"weight":90}`;
16+
}
17+
if (type == 'grass') {
18+
return `{"abilities": [{"ability": {"name": "chlorophyll","url": "https://pokeapi.co/api/v2/ability/34/"},"is_hidden": true,"slot": 3},{"ability": {"name": "overgrow","url": "https://pokeapi.co/api/v2/ability/65/"},"is_hidden": false,"slot": 1}],"base_experience": 64,"forms": [ {"name": "bulbasaur","url": "https://pokeapi.co/api/v2/pokemon-form/1/"}],"name": "bulbasaur","order": 1,"species": {"name": "bulbasaur","url": "https://pokeapi.co/api/v2/pokemon-species/1/"},"sprites": {"back_default": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/1.png","back_female": null,"back_shiny": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/1.png","back_shiny_female": null,"front_default": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png","front_female": null,"front_shiny": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/1.png","front_shiny_female": null},"weight": 69}`;
19+
}
20+
}
21+
22+
function pokemonName(type) {
23+
if (type == 'fire') {
24+
return 'Charmander';
25+
}
26+
if (type == 'water') {
27+
return 'Squirtle';
28+
}
29+
if (type == 'grass') {
30+
return 'Bulbasaur';
31+
}
32+
}
33+
34+
let pokeName = pokemonName(color);
35+
/*Code goes below */
36+
37+
function parsemon() {
38+
let pokeProperties = JSON.parse(fetchPokemonData(color));
39+
let justSprites = Object.keys(pokeProperties.sprites)
40+
.map(key => pokeProperties.sprites[key])
41+
.filter(sprite => sprite);
42+
return justSprites;
43+
}
44+
let unorderedSprites = parsemon();
45+
let sprites = unorderedSprites.reverse();
46+
47+
const mySpriteSpot = document.querySelector('#poke-selector');
48+
49+
const intro = document.createElement('div');
50+
intro.setAttribute('class', 'oakText');
51+
intro.innerText = `Well, well. If it isn't young ${name}. Finally ready to become a Pokemon trainer! Why it seems only yesterday you were toddling around the garden with the Butterfrees and Bellsprouts.
52+
Well it looks like you've made a great choice with your first Pokemon. I'm sure this ${pokeName} will serve you well.`;
53+
mySpriteSpot.appendChild(intro);
54+
55+
const div = document.createElement('div');
56+
div.setAttribute('class', 'wrapper');
57+
58+
for (sprite in sprites) {
59+
const eachSpriteDiv = document.createElement('div');
60+
eachSpriteDiv.id = sprite;
61+
eachSpriteDiv.setAttribute('class', 'box');
62+
63+
// const name = document.createElement('h4');
64+
// name.innerText = `This is sprite ${sprite}`;
65+
// eachSpriteDiv.appendChild(name);
66+
// console.log(name);
67+
68+
const picture = document.createElement('IMG');
69+
picture.src = sprites[sprite];
70+
eachSpriteDiv.appendChild(picture);
71+
72+
div.appendChild(eachSpriteDiv);
73+
74+
mySpriteSpot.appendChild(div);
75+
76+
console.log('Name is' + name + 'sprite is' + sprites[sprite]);
77+
}
1.31 MB
Loading

Week2/homework/pokemon/pokemon.css

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
@import url('https://fonts.googleapis.com/css?family=Abel');
2+
@import url('https://fonts.googleapis.com/css?family=Karla');
3+
body {
4+
background-image: url('pokeball-background.png');
5+
font-family: Karla;
6+
margin: 40px;
7+
color: #f4f4ed;
8+
font-size: 30px;
9+
}
10+
11+
h4 {
12+
text-decoration: underline;
13+
}
14+
15+
a:visited {
16+
color: turquoise;
17+
}
18+
19+
section {
20+
position: absolute;
21+
left: 0;
22+
right: 0;
23+
margin-left: auto;
24+
margin-right: auto;
25+
width: 85%;
26+
height: auto;
27+
background-color: wheat;
28+
text-align: center;
29+
}
30+
31+
.oakText {
32+
font-family: Abel;
33+
color: #444;
34+
font-size: 20px;
35+
text-align: center;
36+
}
37+
38+
#oakSide {
39+
float: left;
40+
}
41+
42+
#oakImage {
43+
float: left;
44+
min-height: 500px;
45+
width: auto;
46+
}
47+
48+
.wrapper {
49+
font-family: Abel;
50+
text-align: left;
51+
padding-top: 25px;
52+
padding-bottom: 25px;
53+
font-size: 20px;
54+
display: grid;
55+
align-items: center;
56+
grid-template-columns: 1fr 1fr 1fr 1fr;
57+
grid-gap: 10px;
58+
background-color: wheat;
59+
color: #444;
60+
}
61+
62+
.box {
63+
background-color: wheat;
64+
color: #c6c5b9;
65+
border-radius: 5px;
66+
font-size: 100%;
67+
max-width: 400px;
68+
min-height: 200px;
69+
}
70+
71+
img {
72+
width: auto;
73+
height: 150px;
74+
padding: 10px;
75+
margin: 10px;
76+
}
77+
78+
#footer {
79+
font-size: 20px;
80+
padding: 20px;
81+
}
82+
83+
@media screen and (max-width: 600px) {
84+
img {
85+
display: none;
86+
}
87+
@media only screen and (max-width: 800px) {
88+
.wrapper {
89+
display: grid;
90+
align-items: center;
91+
grid-template-columns: 1fr 1fr;
92+
}
93+
.box {
94+
height: 400px;
95+
}
96+
}
97+
}

Week2/homework/pokemon/prof_oak.png

162 KB
Loading

0 commit comments

Comments
 (0)