-
Notifications
You must be signed in to change notification settings - Fork 2
/
gameplay.php
executable file
·63 lines (55 loc) · 1.5 KB
/
gameplay.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
<?php
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$currentpage="account";
include "pages.php";
?>
<?php include 'header.php';?>
<html>
<head>
<link rel="stylesheet" href="index.css">
</head>
<body>
<?php
include 'connectvars.php';
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
$battle = array();
$queryIn = "SELECT * FROM Arena";
$arenas = mysqli_query($conn, $queryIn);
while($arena = mysqli_fetch_assoc($arenas)){
$queryIn = "SELECT * FROM Champions WHERE arena = '".$arena["name"]."'";
$champions = mysqli_query($conn, $queryIn);
$tempc = array();
$tempa = array();
if(mysqli_num_rows($champions)){
while($champion = mysqli_fetch_assoc($champions)){
array_push($tempc, $champion);
}
$tempa["arena"] = $arena['name'];
$tempa["weather"] = $arena['weather'];
$tempa["champions"] = $tempc;
array_push($battle, $tempa);
}
}
foreach($battle as $arena){
$count = 30;
while($count--){
$swap1 = rand() % count($arena["champions"]);
$swap2 = rand() % count($arena["champions"]);
$temp = $arena["champions"][$swap1];
$arena["champions"][$swap1] = $arena["champions"][$swap2];
$arena["champions"][$swap2] = $temp;
}
}
foreach($battle as $arena){
for(int i = 0; i < count($arena["champions"]) - 1;i+=2){
$champion1 = $arena["champions"][i];
$champion2 = $arena["champions"][i+1];
}
}
?>