-
Notifications
You must be signed in to change notification settings - Fork 0
/
pokemon.php
131 lines (111 loc) · 4.87 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
<?php
include('header.php');
$pokemon = new Pokemon(get('id'), $database);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$level = $_POST['level'];
$ability = $_POST['ability'];
$nickname = $_POST['nickname'];
$stat_hp = $_POST['stat_hp'];
$stat_attack = $_POST['stat_attack'];
$stat_defense = $_POST['stat_defense'];
$stat_spattack = $_POST['stat_spattack'];
$stat_spdefense = $_POST['stat_spdefense'];
$stat_speed = $_POST['stat_speed'];
if(isset($_POST['is_shiny'])) {
$is_shiny = 1;
}
else {
$is_shiny = 0;
}
$params = array(
'user_id' => $user['id'],
'pokemon_id' => get('id'),
'id' => implode($pokemon->getnewid()),
'level' => $level,
'ability' => $ability,
'nickname' => $nickname,
'stat_hp' => $stat_hp,
'stat_attack' => $stat_attack,
'stat_defense' => $stat_defense,
'stat_spattack' => $stat_spattack,
'stat_spdefense' => $stat_spdefense,
'stat_speed' => $stat_speed,
'is_shiny' => $is_shiny
);
$sql = file_get_contents('sql/addpokemon.sql');
$statement = $database->prepare($sql);
$statement->execute($params);
}
?>
<div class="container" style="margin-top: 50px;">
<h1 style="text-transform: capitalize;"><div class="pokedex-number" <?php if($pokemon->getPokemon()['species_id']>99) {echo "style='width:70px; height:70px; padding: 15px 0;'"; } ?>><?php echo $pokemon->getPokemon()['species_id']; ?></div> <?php echo $pokemon->getPokemon()['identifier']; ?></h1>
<img src="https://veekun.com/dex/media/pokemon/main-sprites/omegaruby-alphasapphire/<?php echo $pokemon->getPokemon()['id']; ?>.png">
<img src="https://veekun.com/dex/media/pokemon/main-sprites/omegaruby-alphasapphire/shiny/<?php echo $pokemon->getPokemon()['id']; ?>.png"><br>
<div class="row">
<div class="col-md-6">
<h3>Information</h3>
<strong>Height</strong>: <?php echo $pokemon->getPokemon()['height']; ?><br>
<strong>Weight</strong>: <?php echo $pokemon->getPokemon()['weight']; ?><br>
<strong>Base Experience</strong>: <?php echo $pokemon->getPokemon()['base_experience']; ?><br>
<strong>Order</strong>: <?php echo $pokemon->getPokemon()['order']; ?><br>
<strong>Default</strong>: <?php echo $pokemon->getPokemon()['is_default']; ?><br>
<h3>Base Statistics</h3>
<?php foreach($pokemon->getStatistics() as $stat) : ?>
<p><?php echo $stat['identifier'].": ".$stat['base_stat']; ?></p>
<?php endforeach; ?>
</div>
<div class="col-md-6">
<h3>Abilities</h3>
<?php foreach($pokemon->getAbilities() as $ability) : ?>
<?php echo $ability['ability_id'] ?>
<?php endforeach; ?>
<br><br>
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
<i class="fa fa-plus" aria-hidden="true"></i>
Add Pokemon
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Caught a Pokemon</h4>
</div>
<form method="post">
<div class="modal-body">
<p>What are the following: </p>
<input type="number" class="form-control" name="level" placeholder="level" min="1" max="100">
<br>
<p>Select the ability: </p>
<?php foreach ($pokemon->getAbilities() as $ability) : ?>
<input type="radio" name="ability" value="<?php echo $ability['ability_id']; ?>"> <?php echo $ability['ability_id']; ?><br>
<?php endforeach; ?>
<br>
<input type="text" class="form-control" name="nickname" placeholder="nickname" maxlength="12">
<br>
<input type="number" class="form-control" name="stat_hp" placeholder="HP" min="1">
<br>
<input type="number" class="form-control" name="stat_attack" placeholder="Attack" min="1">
<br>
<input type="number" class="form-control" name="stat_defense" placeholder="Defense" min="1">
<br>
<input type="number" class="form-control" name="stat_spattack" placeholder="Special Attack" min="1">
<br>
<input type="number" class="form-control" name="stat_spdefense" placeholder="Special Defense" min="1">
<br>
<input type="number" class="form-control" name="stat_speed" placeholder="Speed" min="1">
<br>
<input type="checkbox" name="is_shiny" value="1"> <label>Shiny</label>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" value="Add" class="btn btn-primary">Add Pokemon</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>