function giveLoot() { //rename to be more accurate global $partyfighters, $totalgold, $totalloot, $reportintro; $totalgold *= 1 + rand(-15, 15) / 100; $eachgold = floor($totalgold / count($partyfighters)); foreach ($partyfighters as $fighter) { $id = $fighter['id']; $conn = mysqli_connect("ucfsh.ucfilespace.uc.edu", "piattjd", "curtis1", "piattjd"); mysqli_query($conn, "UPDATE Hero SET gold = gold + {$eachgold} WHERE id = '{$id}'"); mysqli_query($conn, "UPDATE Hero SET maxgold = maxgold + {$eachgold} WHERE id = '{$id}'"); mysqli_close($conn); $reportintro .= $fighter['name'] . " gets " . $eachgold . " gold<br>"; } $reportintro .= "<br>"; foreach ($totalloot as $lootdrop) { $loottaker = rand(1, count($partyfighters)) - 1; $lootstats = explode(",", $lootdrop); giveItem($partyfighters[$loottaker]['id'], 0, $lootstats[0], $lootstats[1], $lootstats[2], $lootstats[3], $lootstats[4], $lootstats[5]); $reportintro .= $partyfighters[$loottaker]['name'] . " picks up " . getItemName(0, 0, 0, $lootstats[0], $lootstats[1], $lootstats[2], $lootstats[3], $lootstats[4], $lootstats[5]) . "<br>"; } }
giveItem($hero['id'], 2, 9, 1, 0, 0, 0, 0); giveItem($hero['id'], 1, 6, 1, 0, 0, 0, 0); break; case "Archer": giveItem($hero['id'], 1, 15, 1, 17, 1, 0, 0); giveItem($hero['id'], 1, 4, 1, 0, 0, 0, 0); break; case "Priest": giveItem($hero['id'], 1, 21, 1, 22, 1, 0, 0); giveItem($hero['id'], 2, 20, 1, 0, 0, 0, 0); giveItem($hero['id'], 1, 6, 1, 0, 0, 0, 0); break; case "Knight": giveItem($hero['id'], 1, 11, 1, 15, 1, 0, 0); giveItem($hero['id'], 2, 14, 1, 0, 0, 0, 0); giveItem($hero['id'], 1, 2, 1, 0, 0, 0, 0); break; } mysqli_query($conn, "INSERT INTO HeroSkills (heroid, abilityid, skilllevel) VALUES ('{$hero['id']}', '7', '1')") or die(mysqli_error($conn)); setcookie("DungeonsOfEld", $hero['id'] . "||" . $pw, time() + 60 * 60 * 24 * 365); echo "<META http-equiv='refresh' content='0;URL=profile.php'>"; mysqli_close($conn); exit; } } else { if (isset($_POST['name'], $_POST['pw'])) { $conn = mysqli_connect("ucfsh.ucfilespace.uc.edu", "piattjd", "curtis1", "piattjd") or die("#2013 - Lost connection to MySQL server at 'reading authorization packet', system error: 0<br>" . mysqli_error($conn)); $name = mysqli_real_escape_string($conn, $_POST['name']); $pw = sha1(mysqli_real_escape_string($conn, $_POST['pw'])); $hero = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM Hero WHERE name = '{$name}' AND pw = '{$pw}'")); if (is_null($hero)) {