Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Co PDF

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

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
<?php
session_start();
include "config.php";
$bdd = new PDO('mysql:host='.$host.';dbname='.$db, $db_user, $db_password);

if (isset($_GET['user']))
{
$req = $bdd->prepare("SELECT * FROM users WHERE username = :id");
$req->execute(array('id' => $_GET['user']));
while ($data = $req->fetch(PDO::FETCH_OBJ))
{

$req = $bdd->prepare("SELECT * FROM persos WHERE id_user = :id");


$req->execute(array('id' => $data->id));
while ($victime = $req->fetch(PDO::FETCH_OBJ))
{
$req = $bdd->prepare("SELECT * FROM persos WHERE id_user = :id");
$req->execute(array('id' => $_SESSION['id']));
while ($attaquant = $req->fetch(PDO::FETCH_OBJ))
{
$degats_a = $attaquant->foorce * rand(1,5);
$degats_v = $victime->foorce * rand(1,5);
$req = $bdd->prepare("UPDATE persos SET vie = :vie WHERE id
= :id");
$req->execute(array('vie' => -$degats_a, 'id' => $victime->id));
$req = $bdd->prepare("UPDATE persos SET vie = :vie WHERE id
= :id");
$req->execute(array('vie' => -$degats_v, 'id' => $attaquant->id));
if ($attaquant->vie < 0)
{
echo "Vous avez perdu.";
$req = $bdd->prepare("UPDATE persos SET vie = :vie WHERE id
= :id");
$req->execute(array('vie' => 200, 'id' => $attaquant->id));
$req = $bdd->prepare("UPDATE persos SET vie = :vie WHERE id
= :id");
$req->execute(array('vie' => 200, 'id' => $victime->id));
$req = $bdd->prepare("UPDATE users SET experience = :experience
WHERE id = :id");
$victime_xp = $victime->experience + 10;
$req->execute(array('experience' => $victime_xp, 'id' =>
$victime->id));
echo "<a href='profil.php?user=".
$_SESSION['pseudo']."'>Retour</a>";

}
if ($victime->vie < 0)
{
echo "Vous avez gagné.";
$req = $bdd->prepare("UPDATE persos SET vie = :vie WHERE id
= :id");
$req->execute(array('vie' => 200, 'id' => $attaquant->id));
$req = $bdd->prepare("UPDATE persos SET vie = :vie WHERE id
= :id");
$req->execute(array('vie' => 200, 'id' => $victime->id));
$req = $bdd->prepare("UPDATE users SET experience = :experience
WHERE id = :id");
$attaquant_xp = $attaquant->experience + 10;
$req->execute(array('experience' => $attaquant_xp, 'id' =>
$attaquant->id));
echo "<a href='profil.php?user=".
$_SESSION['pseudo']."'>Retour</a>";

}
}

}
}

?>

You might also like