-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokemon.php
145 lines (117 loc) · 5.85 KB
/
pokemon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
// Includes
include './includes/config.php';
$urlPokemonsList = 'https://pokeapi.co/api/v2/pokemon/?offset=0&limit=30';
$urlPokemon = 'https://pokeapi.co/api/v2/pokemon/' . strtolower($pokemon);
$urlSpecies = 'https://pokeapi.co/api/v2/pokemon-species/' . strtolower($pokemon);
$resultJsonPokemon = apiCall($urlPokemon);
$resultJsonSpecies = apiCall($urlSpecies);
include './includes/pokemonConfig.php';
$hpStat = $resultJsonPokemon->stats[0]->base_stat / 2.55;
$attackStat = $resultJsonPokemon->stats[1]->base_stat / 2.55;
$defenseStat = $resultJsonPokemon->stats[2]->base_stat / 2.55;
$specialAttackStat = $resultJsonPokemon->stats[3]->base_stat / 2.55;
$specialDefenseStat = $resultJsonPokemon->stats[4]->base_stat / 2.55;
$speedStat = $resultJsonPokemon->stats[5]->base_stat / 2.55;
?>
<!-- HEADER -->
<?php include './chunks/header.php' ?>
<!-- CSS -->
<link rel="stylesheet" href="../assets/styles/style.css">
<link rel="stylesheet" href="../assets/styles/stylePokedex.css">
<link rel="stylesheet" href="../assets/styles/stylePokemon.css">
</head>
<body>
<div class="grid">
<div class="header">
<a class="previousIcon" href="./pokemon.php?pokemon=<?= $pokemon - 1?>">
<img src="./assets/images/previous-icon.svg">
</a>
<div class="title">
<div class="namePokemon"><?= ucfirst($resultJsonPokemon->name) ?></div>
<div class="idPokemon"><?= str_pad($resultJsonPokemon->id, 3, "00", STR_PAD_LEFT) ?></div>
</div>
<a class="nextIcon" href="./pokemon.php?pokemon=<?= $pokemon + 1?>">
<img src="./assets/images/next-icon.svg">
</a>
</div>
<div class="cardPokemon" style="background-color:<?= $colorBackground ?>">
<img src="<?= $resultJsonPokemon->sprites->other->{'official-artwork'}->front_default ?>">
</div>
<div class="categoriesButtons">
<div class="infosButton buttonActive">Infos</div>
<div class="formsButton">Forms</div>
<div class="typesButton">Types</div>
<div class="statsButton">Stats</div>
</div>
<div class="categoriesContent">
<div class="infosContent contentActive">
<div class="heightPokemon"><span>Height</span> - <?= $resultJsonPokemon->height / 10 ?> m</div>
<div class="weightPokemon"><span>Weight</span> - <?= $resultJsonPokemon->weight / 10 ?> kg</div>
<div class="bioPokemon"><span>Bio</span><?= str_replace("", " ", $resultJsonSpecies->flavor_text_entries[0]->flavor_text) ?></div>
</div>
<div class="formsContent">
<div class="cardsList">
<?php
include './includes/pokemonChainArray.php';
foreach ($evolutionChainArray as $key => $evolution)
{
$urlPokemonFromEvolution = 'https://pokeapi.co/api/v2/pokemon/' . $evolution;
$resultJsonPokemonFromEvolution = apiCall($urlPokemonFromEvolution);
?>
<a class="miniCardPokemon" href="./pokemon.php?pokemon=<?= $resultJsonPokemonFromEvolution->id ?>" style="background-color:<?= $colorBackground ?>">
<img src="<?= $resultJsonPokemonFromEvolution->sprites->other->{'official-artwork'}->front_default ?>">
</a>
<?php } ?>
</div>
</div>
<div class="typesContent">
<?php
foreach ($resultJsonPokemon->types as $key => $typeOfPokemon)
{
?>
<div class="typePokemon">
<img src="./assets/images/types/type-<?= $typeOfPokemon->type->name ?>.svg" alt="Type <?= $typeOfPokemon->type->name ?>" width="80px" height="80px">
<h3><?= ucfirst($typeOfPokemon->type->name) ?></h3>
</div>
<?php } ?>
</div>
<div class="statsContent">
<div class="listStats">
<!-- HP -->
<p>HP</p>
<div class="barStat">
<div class="hpStat" style="background-color: #90ee90; width: <?= $hpStat ?>%;"></div>
</div>
<!-- Attack -->
<p>Attack</p>
<div class="barStat">
<div class="attackStat" style="background-color: #f08080; width: <?= $attackStat ?>%;"></div>
</div>
<!-- Defense -->
<p>Defense</p>
<div class="barStat">
<div class="defenseStat" style="background-color: #add8e6; width: <?= $defenseStat ?>%;"></div>
</div>
<!-- Special attack -->
<p>Special attack</p>
<div class="barStat">
<div class="specialAttackStat" style="background-color: #ffa07a; width: <?= $specialAttackStat ?>%;"></div>
</div>
<!-- Special defense -->
<p>Special defense</p>
<div class="barStat">
<div class="specialDefenseStat" style="background-color: #b0c4de; width: <?= $specialDefenseStat ?>%;"></div>
</div>
<!-- Speed -->
<p>Speed</p>
<div class="barStat">
<div class="speedStat" style="background-color: #87cefa; width: <?= $speedStat ?>%;"></div>
</div>
</div>
</div>
</div>
</div>
<script src="./assets/js/script.js"></script>
<!-- FOOTER -->
<?php include './chunks/footer.php' ?>