Classic multiplayer game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1284 lines
54 KiB

<?php
session_start();
require 'settings.php';
require 'db.php';
require 'functions.php';
require 'vendor/autoload.php';
$page_main = '';
$page_menu = '';
$page_infobar = '';
$page_notification_bad = array();
$page_notification_good = array();
$smarty = new Smarty();
$result = zoopz_query('SELECT * FROM `updates`');
while ($line = $result->fetch_assoc()) {
if ($line['name'] == 'halfhour') {
if (time() >= $line['nextrun']) {
do_updates('halfhour', $line['nextrun']);
global $update_halfhour_nextrun;
} else {
$update_halfhour_nextrun = $line['nextrun'];
}
} elseif ($line['name'] == 'day') {
if (time() >= $line['nextrun']) {
do_updates('day', $line['nextrun']);
global $update_day_nextrun;
} else {
$update_day_nextrun = $line['nextrun'];
}
}
}
if (!isset($_GET['act'])) {
$_GET['act'] = '';
}
$user_isloggedin = false;
if (isset($_SESSION['zoopzusername']) && $_GET['act'] != 'login' && $_GET['act'] != 'signup') {
$result = zoopz_query("SELECT * FROM `accounts` WHERE `username` = '".mysqli_real_escape_string($dblink, $_SESSION['zoopzusername'])."' AND `password` = '".mysqli_real_escape_string($dblink, $_SESSION['zoopzpassword'])."'");
if ($result->num_rows > 0) {
$user_isloggedin = true;
$result = zoopz_query("SELECT * FROM `accounts` WHERE `username` = '".mysqli_real_escape_string($dblink, $_SESSION['zoopzusername'])."'");
while ($line = $result->fetch_assoc()) {
$user = $line;
}
$user['zoop_maxhp'] = calculateMaxHP($user['zoop_level'], $user['zoop_stamina']);
$user['zoop_xp_nextlevel'] = (5 * 3 * (pow($user['zoop_level'], 2)) + (10 * $user['zoop_level'])) * 10;
$result = zoopz_query("SELECT `level` FROM buildings_built WHERE buildings_built.type = 1 AND buildings_built.userid = ".$user['id']."");
$row = $result->fetch_row();
if ($row[0]>0) {
$user['potatomine_built'] = true;
$result = zoopz_query('SELECT `capacity` FROM building_names WHERE type = 1 AND level = ' . $row[0]);
$row = $result->fetch_row();
$user['potatomine_capacity'] = $row[0];
} else {
$user['potatomine_built'] = false;
}
zoopz_query("UPDATE `accounts` SET `lastactive` = ".time()." WHERE `id` = ".$user['id']."");
$specialevent = rand(1,1500);
if ($specialevent==666) {
$moneygained = rand(1,1000);
$page_notification_good[] = 'It seems luck is with you! You spot a bag marked Quetzals, which had '.$moneygained.' Quetzals in it!';
$user['money'] += $moneygained;
zoopz_query("UPDATE `accounts` SET `money` = ".$user['money']." WHERE `id` = ".$user['id']."");
} elseif ($specialevent==999) {
$moneylost = rand(0,$user['money']);
$page_notification_bad[] = '<img src="/img/art/banker.png" width="150" height="150"><br>It seems luck is against you! A rough, unshaven Zoop stole your bag of Quetzals!';
if ($moneylost==0) {
$page_notification_bad[] = ' However, it appears the trick was on them, as you weren\'t holding any Quetzals at the time!';
} else {
$page_notification_bad[] = ' You check to see how much is left in various pockets, and determine he stole ' . $moneylost . ' Quetzals.';
}
$user['money'] -= $moneylost;
zoopz_query('UPDATE `accounts` SET `money` = ' . $user['money'] . ' WHERE `id` = ' . $user['id']);
}
} else {
session_destroy();
header('Location: ?');
die();
}
}
$zooplore = '<h1>Lore</h1>
<h2>The Beginning</h2>
Zoopz, small round creatures with a bit of hair, were first domesticated after their discovery in the land they called Zopz.<br>
In Zopz, they ate small round discs which they highly enjoy called Zupz.<br>
Zop<b>s</b> is the secondary Zoop hide out which has yet to be found, is often sought by explorers. It is said in ancient Zoop writing that in order to enter Zops, you must play back an audio code consisting of pig noises.<br>
Zupz are only found in the land of Zopz and Zops.<br>
When Zoopz were first found in Zopz, they attacked the explorers with their crude weapons, named Zapz. Unfortunately, Zapz simply bounced off of the explorers, causing no harm. The Zoopz were quickly captured and hauled to the U.S.A.<br><br>
<h2>Medicinal Use</h2>
Zoopz are often ground up into a powder while still alive and well, creating a snortable substance named Zipz. Zipz is shown to cure most minor ailments along with amazingly curing any form of cancer.<br><br>
<h2>Current Treatment</h2>
Zoopz are very stupid and feeble creatures. Almost all owners never feed their Zoop, nor give them proper birth control contraceptives.<br>
<h3>Birth</h3>
Zoopz reproduce asexually and when giving birth, the smaller Zoop which had grown inside of the parent Zoop will push the Zoop\'z eyeball out and crawl through the space. This is excrutiatingly painful for the parent Zoop, and Zoop owners could give their Zoop pain killers, but they don\'t. Parent Zoopz can often be identified by one or both of their eyes missing.<br>
<h3>Feeding</h3>
Zoopz normally would feed on delicious treats named Zupz. Zoop owners could buy Zupz for their Zoopz, but they don\'t.<br>
Because Zoop owners do not feed their Zoopz, they are forced to survive on the dirt which accumulates on the house\'s floor. While rolling around on the ground, they absorb lint and other types of dirt and use it for energy.
<h3>Abuse</h3>
Zoopz contribute very little to society, and thus are not treated with any respect at all. Zoopz are often beaten for the entertainment and are sometimes fed to pets alive.';
$zoopgametext = '<h1>How to Play</h1>
<h2>Starting Out</h2>
When you first make your account, you will be presented with your naked, unskilled zoop. Your job is to train them as your focus towards making yourself rich using their powers.<br>
You also use can other members of the zoop species for tasks of yours.<br>
<br><h2>Fighting</h2>
When fighting other zoopz, you can gain or lose Quetzals, depending on the nature of the fight. Also, when you attack another zoop and win, you have the chance to gain experience points.<br>
<h3>Attack Turns</h3>
In every fight you start, you choose how many attack turns to use. Attack turns are proportionate to the rewards given out at the end of the fight. For instance, if you spend 10 attack turns on one fight, and win, you\'d get the maximum amount of reward possible. However, if you were to spend 5, you\'d receive only half of what you could have won.<br>
<h3>Experience</h3>
The amount of XP you gain from a fight depends on the level of the other zoop, and the amount of attack turns being used. If you use the maximum attack turns on a level 1 zoop, you will receive 10 XP. A level 2 zoop will give 20XP, and so on. However, if you were to use only five attack turns on a level 1 zoop, you would only receive 5 XP.<br>
<h3>Leveling Up</h3>
Every time you level up, you will receive bonus training points for the Gym. The amount of points you receive goes up as you level. Also, leveling up unlocks new possible opponents, as you are only able to see/attack zoopz which are at least half your zoop\'z level up to three levels above your zoop.<br>
<br><h2>Turns</h2>
<h3>Day</h3>
Every day you will receive 10 Gym training points, regardless of your level. The maximum amount of training points which you can hold is 100, therefore you may leave your account alone for 10 days and still not waste any of the daily training points.<br>
<h3>Half Hour</h3>
Every half hour is known as a game turn. In this turn, every player is given 5 attack turns, and any zoopz not at full health are healed a small amount. The most attack turns anyone can hold at one time is 400.<br>
<br><h2>Daily Reward</h2>
All players qualify for a daily reward when clicking the Rewards link in the left menu and following the voting procedure. This adds two training points to your account, and an additional worker will be able to be hired.<br>
<br><h2>Pronunciation</h2>
Zoopz is not pronounced Zoops, though quite a few people say it that way. Try to remember that Zoopz starts and ends with the same sound, and doing so will show off your Zoopz intellect. There have been several studies showing human females respond positively to this.<br>
Quetzals, the currency of Zoopz, is pronounced KETzulz.';
$zoopart = '<h1>Artwork</h1><br>
<table width="100%" class="prettytable">
<tr>
<th>Picture</th>
<th>Information</th>
</tr>
<tr>
<td>
<img src="/img/art/birth2.png">
</td>
<td>
<b>Beautiful Zoop Birth</b><br>
Drawn by Serdar David Gümüştel
</td>
</tr>
<tr>
<td>
<img src="/img/art/worker.png">
</td>
<td>
<b>Zoop Worker</b><br>
Drawn by Serdar David Gümüştel
</td>
</tr>
<tr>
<td>
<img src="/img/art/marketman.png">
</td>
<td>
<b>Market-Man</b><br>
Drawn by Serdar David Gümüştel
</td>
</tr>
<tr>
<td>
<img src="/img/art/banker.png">
</td>
<td>
<b>Banker</b><br>
Drawn by Serdar David Gümüştel
</td>
</tr>
<tr>
<td>
<img src="/img/art/doctor.png">
</td>
<td>
<b>Doctor</b><br>
Drawn by Serdar David Gümüştel
</td>
</tr>
</table>';
if ($_GET['act']=='logout') {
session_destroy();
header("Location: ?");
die();
} elseif ($_GET['act']=='top') {
$page_main .= '<h1>Top Zoopz</h1><br>
<table width="100%" class="prettytable" cellspacing="0" cellpadding="0">
<tr>
<th width="1%">Rank</th>
<th width="150">Picture</th>
<th width="1%" style="white-space: pre;">Level</th>
<th>Zoop Name</th>
<th>Owner</th>
</tr>';
$result = zoopz_query("SELECT * FROM `accounts` ORDER BY `zoop_level` DESC, `zoop_xp` DESC LIMIT 25");
$i = 0;
$oddrow = false;
while ($line = $result->fetch_assoc()) {
$i++;
if ($oddrow) {
$page_main .= '<tr height="172" class="oddrow">';
} else {
$page_main .= '<tr height="172">';
}
$pic = '<img src="/zoop.php?id=' . $line['id'] . '" alt="' . htmlentities($line['username'], ENT_QUOTES) . '" border="0">';
$page_main .= '<td style="font-size: 2em;text-align: center;">#'.$i.'</td>
<td>'.$pic.'</td>
<td style="font-size: 2em;text-align: center;">'.$line['zoop_level'].'</td>
<td style="font-size: 2em;font-weight: bold;">'.$line['zoop_name'].'</td>
<td>'.$line['username'].'</td>
</tr>';
$oddrow = (!$oddrow);
}
$page_main .= '</table>';
do_display();
} elseif ($_GET['act']=='stats') {
$page_main .= '<h1>Ztatz</h1>
<h3>Top Zoopz by Lint Consumed</h3><br>
<table width="100%" class="prettytable">
<tr>
<th width="1%">Rank</th>
<th>Zoop Name</th>
<th>Owner</th>
<th>Lint Consumed (cc)</th>
</tr>';
$result = zoopz_query("SELECT * FROM `accounts` ORDER BY `zoop_lint` DESC, `zoop_level` DESC LIMIT 25");
$i = 0;
$oddrow = false;
while ($line = $result->fetch_assoc()) {
$i++;
if ($oddrow) {
$page_main .= '<tr class="oddrow">';
} else {
$page_main .= '<tr>';
}
$page_main .= '<td style="text-align: center;">#'.$i.'</td><td>'.$line['zoop_name'].'</td><td>'.$line['username'].'</td><td>'.calculateLint($line['zoop_lint']).'</td></tr>';
$oddrow = (!$oddrow);
}
$page_main .= '</table>';
do_display();
} elseif ($_GET['act']=='login'&&isset($_POST['username'])) {
if ($_POST['username']!=''&&$_POST['password']!='') {
$result = zoopz_query("SELECT COUNT(*) FROM `accounts` WHERE `username` = '".mysqli_real_escape_string($dblink, $_POST['username'])."' AND `password` = '".mysqli_real_escape_string($dblink, md5($_POST['password']))."'");
$user_logincorrect = $result->fetch_row();
if ($user_logincorrect[0]>0) {
$_SESSION['zoopzusername'] = $_POST['username'];
$_SESSION['zoopzpassword'] = md5($_POST['password']);
header("Location: ?");
} else {
die('Invalid username/password.');
}
} else {
die('Please enter all fields.');
}
}
if (!$user_isloggedin) {
if ($_GET['act']=='signup') {
if (isset($_POST['username'])) {
if ($_POST['username']!=''&&$_POST['password']!=''&&$_POST['password2']!=''&&$_POST['email']!=''&&$_POST['zoopname']!='') {
if ($_POST['password']==$_POST['password2']) {
if ($_POST['zoopcolor']=='white'||$_POST['zoopcolor']=='blue'||$_POST['zoopcolor']=='green'||$_POST['zoopcolor']=='orange'||$_POST['zoopcolor']=='red'||$_POST['zoopcolor']=='yellow') {
$result = zoopz_query("SELECT COUNT(*) FROM `accounts` WHERE `username` = '".mysqli_real_escape_string($dblink, $_POST['username'])."'");
$username_istaken = $result->fetch_row();
if ($username_istaken[0]==0) {
$result = zoopz_query("SELECT COUNT(*) FROM `accounts` WHERE `email` = '".mysqli_real_escape_string($dblink, $_POST['email'])."'");
$email_istaken = $result->fetch_row();
if ($email_istaken[0]==0) {
$result = zoopz_query("SELECT COUNT(*) FROM `accounts` WHERE `zoop_name` = '".mysqli_real_escape_string($dblink, $_POST['zoopname'])."'");
$zoop_istaken = $result->fetch_row();
if ($zoop_istaken[0]==0) {
if ($_POST['promo']=='toprpgames') {
$start_trainingpoints = 15;
} else {
$start_trainingpoints = 10;
}
zoopz_query("INSERT INTO `accounts` ( `username` , `password` , `email` , `registered` , `lastactive` , `zoop_name` , `zoop_color` , `trainingpoints` ) VALUES ( '".mysqli_real_escape_string($dblink, $_POST['username'])."' , '".mysqli_real_escape_string($dblink, md5($_POST['password']))."' , '".mysqli_real_escape_string($dblink, $_POST['email'])."' , '".time()."' , '".time()."' , '".mysqli_real_escape_string($dblink, $_POST['zoopname'])."' , '".mysqli_real_escape_string($dblink, $_POST['zoopcolor'])."' , '".$start_trainingpoints."' )");
$page_main .= 'Account successfully created!<br><br>Log in <a href="?act=login">here</a>.';
} else {
$page_main .= 'Sorry, someone already has a Zoop with that name.';
}
} else {
$page_main .= 'That email is already in use.';
}
} else {
$page_main .= 'Sorry, that username is already taken.';
}
} else {
$page_main .= 'Invalid Zoop color.';
}
} else {
$page_main .= 'Passwords did not match.';
}
} else {
$page_main .= 'Please enter all fields.';
}
} else {
$page_main .= '<form action="/?act=signup" method="post">';
if ($_GET['promo']=='toprpgames') {
$page_main .= '<input type="hidden" name="promo" value="toprpgames">';
}
$page_main .= '<fieldset>
<legend>Sign up</legend>
<ol>
<li>
<label for="username">Username:</label>
<input type="text" name="username" id="username">
</li>
<li>
<label for="password">Password:</label>
<input type="password" name="password" id="password">
</li>
<li>
<label for="password2">Confirm Password:</label>
<input type="password" name="password2" id="password2">
</li>
<li>
<label for="email">Email:</label>
<input type="text" name="email" id="email">
</li>
<li>
<label for="zoopname">Zoop\'z Name:</label>
<input type="text" name="zoopname" id="zoopname">
</li>
<li>
<label for="zoopcolor">Zoop\'z Color:</label>
<select name="zoopcolor" id="zoopcolor"><option value="white">White</option><option value="blue">Blue</option><option value="green">Green</option><option value="orange">Orange</option><option value="red">Red</option><option value="yellow">Yellow</option></select>&nbsp;
<a target="_blank" href="/allzoopz.html">View Zoopz</a>
</li>
<li>
<input type="submit" value="Sign Up">
</li>
</ol>
</fieldset>
</form>';
}
} elseif ($_GET['act'] == 'lore') {
$page_main .= $zooplore;
} elseif ($_GET['act'] == 'howtoplay') {
$page_main .= $zoopgametext;
} elseif ($_GET['act'] == 'art') {
$page_main .= $zoopart;
} else {
$page_main .= '<form action="/?act=login" method="post">
<fieldset>
<legend>Log in</legend>
<ol>
<li>
<label for="username">Username:</label>
<input type="text" name="username" id="username">
</li>
<li>
<label for="password">Password:</label>
<input type="password" name="password" id="password">
</li>
<li>
<input type="submit" value="I neglect my Zoop">
</li>
</ol>
</fieldset>
</form><br>
Don\'t have a Zoop yet?&nbsp;<a href="?act=signup"><b>Sign Up!</b></a><br><br>
<div style="text-align: center;">
<img src="/img/art/birth3.png" width="344" height="420" alt="BEAUTIFUL BIRTH"><br><br>
<b>Did you remember to give your Zoop their contraceptives today?</b>
</div>';
}
do_display();
}
//User is logged in
if ($_GET['act'] == 'zoop') {
$page_main .= '<h1>Your Zoop</h1><br>
' . zoopImage($user, false) . '<br>
<h3>Name: '.$user['zoop_name'].'</h3>
<h3>Level: '.$user['zoop_level'].'</h3>
<h3>XP: '.$user['zoop_xp'].'/'.$user['zoop_xp_nextlevel'].'</h3>
<h2>Attributes</h2>
<h3>Strength: '.$user['zoop_strength'].'</h3>
<h3>Defense: '.$user['zoop_defense'].'</h3>
<h3>Stamina: '.$user['zoop_stamina'].'</h3>
<h2>Battle Info</h2>
<h3>Wins: '.$user['zoop_battle_wins'].'</h3>
<h3>Losses: '.$user['zoop_battle_losses'].'</h3>
<h2>Other Info</h2>
<h3>Lint absorbed: ' . calculateLint($user['zoop_lint']) . ' cc</h3>';
} elseif ($_GET['act'] == 'inventory') {
$page_main .= '<h1>Inventory</h1><br>';
if (isset($_GET['equip']) || isset($_GET['unequip'])) {
if (isset($_GET['equip'])) {
$itemid = $_GET['equip'];
$equip = true;
} elseif (isset($_GET['unequip'])) {
$itemid = $_GET['unequip'];
$equip = false;
}
if (hasItem($user, $itemid)) {
if ($equip) {
$item = getItem($itemid);
if (!hasItemTypeEquipped($user, $item['type'])) {
itemEquip($user, $itemid);
$page_notification_good[] = 'Item successfully equipped.';
} else {
$page_notification_bad[] = 'You already have an item equipped of the type ' . $item['type'] . ', unequip it to equip this one.';
}
} else {
itemUnequip($user, $itemid);
$page_notification_good[] = 'Item successfully unequipped.';
}
} else {
$page_notification_bad[] = 'Unknown item ID.';
}
}
$useritems = getUserItems($user, false);
if (count($useritems) > 0) {
$page_main .= '<table width="100%" class="prettytable">
<tr>
<th width="1%">Item</th>
<th>Information</th>
<th>Action</th>
</tr>';
$oddrow = false;
foreach ($useritems as $useritem) {
$item = getItem($useritem['itemid']);
if ($oddrow) {
$page_main .= '<tr class="oddrow">';
} else {
$page_main .= '<tr>';
}
$page_main .= ' <td>' . itemImage($item) . '</td>
<td>' . itemInformation($item) . '</td>
<td>';
if ($useritem['equipped'] == 0) {
$page_main .= 'Not equipped.<br>
<a href="/?act=inventory&equip=' . $useritem['itemid'] . '">Equip</a>';
} else {
$page_main .= '<b>Equipped</b>.<br>
<a href="/?act=inventory&unequip=' . $useritem['itemid'] . '">Unequip</a>';
}
$page_main .= '</td>
</tr>';
$oddrow = (!$oddrow);
}
$page_main .= '</table>';
} else {
$page_main .= 'You do not currently have any items.';
}
} elseif ($_GET['act'] == 'gym') {
$page_main .= '<h1>The Gym</h1>';
if (checkCaptcha()) {
$page_main .= '<div align="center">
<img src="/img/zoop_trainer.png"><br>
Your personal trainer says:
<h3>IMMA WEARIN A HEADBAND</h3>
</div>';
if (isset($_POST['message'])) {
$message = trim(strip_tags($_POST['message']));
if ($message != '') {
zoopz_query('INSERT INTO `chat` ( `playerid`, `timestamp`, `message`, `place` ) VALUES ( ' . $user['id'] . ', ' . time() . ', \'' . mysqli_real_escape_string($dblink, $message) . '\', 1 )');
$page_notification_good[] = 'Message posted.';
} else {
$page_notification_bad[] = 'Please enter a message.';
}
}
if (isset($_POST['strength'])) {
$_POST['strength'] = floor($_POST['strength']); $_POST['defense'] = floor($_POST['defense']); $_POST['stamina'] = floor($_POST['stamina']);
if ($_POST['strength']>=0&&$_POST['defense']>=0&&$_POST['stamina']>=0) {
if ($_POST['strength']+$_POST['defense']+$_POST['stamina']>0) {
if ($_POST['strength']+$_POST['defense']+$_POST['stamina']<=$user['trainingpoints']) {
zoopz_query("UPDATE `accounts` SET `zoop_strength` = '".($user['zoop_strength']+$_POST['strength'])."' , `zoop_defense` = '".($user['zoop_defense']+$_POST['defense'])."' , `zoop_stamina` = '".($user['zoop_stamina']+$_POST['stamina'])."' , `trainingpoints` = '".($user['trainingpoints']-($_POST['strength']+$_POST['defense']+$_POST['stamina']))."' WHERE `username` = '".mysqli_real_escape_string($dblink, $_SESSION['zoopzusername'])."'");
$user['zoop_strength'] = $user['zoop_strength']+$_POST['strength'];
$user['zoop_defense'] = $user['zoop_defense']+$_POST['defense'];
$user['zoop_stamina'] = $user['zoop_stamina']+$_POST['stamina'];
$user['trainingpoints'] = $user['trainingpoints']-($_POST['strength']+$_POST['defense']+$_POST['stamina']);
$page_notification_good[] = 'Training points successfully spent!';
} else {
$page_notification_bad[] = 'You don\'t have that many points!';
}
} else {
$page_notification_bad[] = 'You need to enter a few points to train.';
}
} else {
$page_notification_bad[] = 'Please enter correct numbers.';
}
}
$page_main .= 'You currently have <b>'.$user['trainingpoints'].'</b> training points to spend.<br>
<form action="/?act=gym" method="post">
<fieldset>
<legend>Train</legend>
<ol>
<li>
<label for="strength">Strength: <b>'.$user['zoop_strength'].'</b></label>
+<input type="text" name="strength" value="0" size="4" maxlength="4">
</li>
<li>
<label for="defense">Defense: <b>'.$user['zoop_defense'].'</b></label>
+<input type="text" name="defense" value="0" size="4" maxlength="4">
</li>
<li>
<label for="stamina">Stamina: <b>'.$user['zoop_stamina'].'</b></label>
+<input type="text" name="stamina" value="0" size="4" maxlength="4"> (Each point adds to your Zoopz HP)
</li>
<li>
<input type="submit" value="I\'m not paying you to stand around">
</li>
</ol>
</fieldset>
</form>
<form action="/?act=gym" method="post">
<fieldset>
<legend>Gym Bulletin Board</legend>
<ol>
<li>
<input type="text" name="message" size="32">
<input type="submit" value="Post Message">
</li>
<li>
Messages are removed after two weeks. Abuse of this feature will result in a ban.<br>
Mouse over a player\'s username to see how long ago the message was posted.
</li>
<li>
<hr>
</li>' . "\n";
zoopz_query('DELETE FROM `chat` WHERE `timestamp` < ' . (time() - 1209600)); // Two weeks
$result = zoopz_query('SELECT * FROM `chat` WHERE `place` = 1 ORDER BY `timestamp` DESC');
while ($line = $result->fetch_assoc()) {
$userinfo = userInfo($line['playerid']);
$page_main .= '<li>
<span style="font-weight: bold;" title="' . TimeAgo($line['timestamp']) . 'ago">' . $userinfo['username'] . '</span>: ' . $line['message'] . '
</li>' . "\n";
}
$page_main .= '
</ol>
</fieldset>
</form>';
}
} elseif ($_GET['act']=='arena') {
$page_main .= '<h1>Arena</h1><br>';
if (checkCaptcha()) {
if (isset($_GET['fightuser']) && $_GET['fightuser']!='') {
$otheruser = userInfo($_GET['fightuser']);
if ($otheruser) {
$_POST['attackturns'] = floor($_POST['attackturns']);
if ($_POST['attackturns']>0) {
if ($_POST['attackturns']<=10) {
if ($_POST['attackturns']<=$user['attackturns']) {
if (canFight($user)) {
if (canFight($otheruser)) {
if (floor($user['zoop_level']/2)<=$otheruser['zoop_level']) {
$result = zoopz_query("SELECT COUNT(*) FROM `attacks` WHERE `userid` = '".$user['id']."' AND `attacked` = '".$otheruser['id']."'");
$numattacks = $result->fetch_row();
if ($numattacks[0]<5) {
$whosturn = 0;
$page_main .= '<table border="0" width="100%">' . "\n" .
'<tr>' . "\n" .
' <td>' . "\n" .
' ' . zoopImage($user, true) . '<br>' . "\n" .
' <b>' . $user['zoop_name'] . '</b><br>' . "\n" .
' Level ' . $user['zoop_level'] .
' </td>' . "\n" .
' <td align="right">' . "\n" .
' ' . zoopImage($otheruser, false) . '<br>' . "\n" .
' <b>' . $otheruser['zoop_name'] . '</b><br>' . "\n" .
' Level ' . $otheruser['zoop_level'] .
' </td>' . "\n" .
'</tr>' . "\n" .
'</table><br>' . "\n" .
'<hr>' . "\n";
/* Fight Loop */
$turn = 1;
while ($user['zoop_hp'] > 0 && $otheruser['zoop_hp'] > 0) {
if ($whosturn == 0) { // Our turn to attack
$user_buffs = handleBattleItems($user, true);
$otheruser_buffs = handleBattleItems($otheruser, false);
$attack_base = rand(max(1, $user['zoop_strength'] - ($user['zoop_level'] * 2)), $user['zoop_strength']);
$attack = $attack_base + $user_buffs['atk'];
$defense_base = rand(max(0, $otheruser['zoop_defense'] - ($otheruser['zoop_defense'] * 2)), $otheruser['zoop_defense']);
$defense = $defense_base + $otheruser_buffs['def'];
$damage = max(0,$attack-$defense);
$otheruser['zoop_hp'] -= $damage;
$page_main .= '<b>'.$user['zoop_name'].'</b> hit <b>'.$otheruser['zoop_name'].'</b> for '.$damage.' damage.';
$attack_bonus = $attack - $attack_base;
$defense_bonus = $defense - $defense_base;
if ($attack_bonus > 0) {
$page_main .= '&nbsp;&nbsp;(<b>+' . $attack_bonus . '</b> attack item bonus)';
}
$page_main .= '&nbsp;&nbsp;(New HP: '.max(0,$otheruser['zoop_hp']).')<br>';
} elseif ($whosturn == 1) { // Their turn to attack
$user_buffs = handleBattleItems($user, false);
$otheruser_buffs = handleBattleItems($otheruser, true);
$attack_base = rand(max(1, $otheruser['zoop_strength'] - ($otheruser['zoop_level'] * 2)), $otheruser['zoop_strength']);
$attack = $attack_base + $otheruser_buffs['atk'];
$defense_base = rand(max(0, $user['zoop_defense'] - ($user['zoop_defense'] * 2)), $user['zoop_defense']);
$defense = $defense_base + $user_buffs['def'];
$damage = max(0,$attack-$defense);
if ($damage == 0) {
$damage = rand(1, $otheruser['zoop_level'] * 2);
}
$user['zoop_hp'] -= $damage;
$page_main .= '<div style="background-color: #FBEFEF; layer-background-color: #FBEFEF;"><b>'.$otheruser['zoop_name'].'</b> hits <b>'.$user['zoop_name'].'</b> for '.$damage.' damage.';
$attack_bonus = $attack - $attack_base;
$defense_bonus = $defense - $defense_base;
if ($defense_bonus > 0) {
$page_main .= '&nbsp;&nbsp;(<b>+' . $defense_bonus . '</b> defense item bonus)';
}
$page_main .= '&nbsp;&nbsp;(New HP: '.max(0,$user['zoop_hp']).')</div>';
}
// Flip turn
$whosturn = ($whosturn==0) ? 1 : 0;
$turn++;
}
handleBreakableItems($user);
handleBreakableItems($otheruser);
/*$user_zoop_attackpower = floor(($user['zoop_strength'] * 100) + (pow($user['zoop_level'],3) / 2));
$otheruser['zoop_defense']power = floor(($otheruser['zoop_defense'] * 100) + (pow($otheruser['zoop_level'],3) / 2));
$page_main .= 'Your Zoop ('.$user['zoop_name'].') attacks for <b>'.$user_zoop_attackpower.'</b><br><br>'.$otheruser['username'].'\'s Zoop ('.$_GET['fight'].') defends for '.$otheruser['zoop_defense']power.'<br>';*/
if ($user['zoop_hp']<0) { $user['zoop_hp'] = 0; }
if ($otheruser['zoop_hp']<0) { $otheruser['zoop_hp'] = 0; }
if ($otheruser['zoop_hp']==0) {
$page_notification_good[] = 'You won!';
$user['moneygained'] = floor($otheruser['money'] / (12-$_POST['attackturns']));
$user['potatoesgained'] = handleBattlePotatoes($user, $otheruser);
$user_xpgained = $otheruser['zoop_level'] * $_POST['attackturns'];
$user['money'] = $user['money'] + $user['moneygained'];
$otheruser['money'] = $otheruser['money'] - $user['moneygained'];
$user['zoop_xp'] += $user_xpgained;
$user['potatoes'] += $user['potatoesgained'];
$otheruser['potatoes'] -= $user['potatoesgained'];
$user['zoop_battle_wins']++;
$otheruser['zoop_battle_losses']++;
zoopz_query("UPDATE `accounts` SET `money` = '".$user['money']."' , `potatoes` = " . $user['potatoes'] . " , `zoop_xp` = '".$user['zoop_xp']."' WHERE `id` = '".$user['id']."'");
zoopz_query("UPDATE `accounts` SET `money` = '".$otheruser['money']."' , `potatoes` = " . $otheruser['potatoes'] . " WHERE `id` = '".$otheruser['id']."'");
$page_main .= '<br>' . battleEndMessage(true, $user['moneygained'], $user['potatoesgained'], $user_xpgained);
if ($user['zoop_xp']>=$user['zoop_xp_nextlevel']) {
$user['zoop_xp'] = $user['zoop_xp'] - $user['zoop_xp_nextlevel'];
$user['zoop_level']++;
zoopz_query("UPDATE `accounts` SET `zoop_level` = '".$user['zoop_level']."' , `zoop_xp` = '".$user['zoop_xp']."' WHERE `id` = '".$user['id']."'");
rewardLevelUp();
$page_main .= '<br><br>You have gained a level! You have been rewarded ' . ($user['zoop_level'] * 10) . ' training points.';
}
insertEvent($otheruser, battleEndEvent(false, $user['username'], $user['moneygained'], $user['potatoesgained'], 0), 2);
} else {
$page_notification_bad[] = 'You lost!';
$user['moneylost'] = floor($user['money'] / (12-$_POST['attackturns']));
$user['potatoeslost'] = handleBattlePotatoes($otheruser, $user);
$user['money'] = $user['money']-$user['moneylost'];
$otheruser['money'] = $otheruser['money']+$user['moneylost'];
$user['potatoes'] -= $user['potatoeslost'];
$otheruser['potatoes'] += $user['potatoeslost'];
$user['zoop_battle_losses']++;
$otheruser['zoop_battle_wins']++;
zoopz_query("UPDATE `accounts` SET `money` = '".$user['money']."', `potatoes` = " . $user['potatoes'] . " WHERE `id` = '".$user['id']."'");
zoopz_query("UPDATE `accounts` SET `money` = '".$otheruser['money']."', `potatoes` = " . $otheruser['potatoes'] . " WHERE `id` = '".$otheruser['id']."'");
$page_main .= '<br>' . battleEndMessage(false, $user['moneylost'], $user['potatoeslost'], 0);
insertEvent($otheruser, battleEndEvent(true, $user['username'], $user['moneylost'], $user['potatoeslost'], 0), 2);
}
zoopz_query("UPDATE `accounts` SET `zoop_hp` = '".$user['zoop_hp']."' , `zoop_battle_wins` = '".$user['zoop_battle_wins']."' , `zoop_battle_losses` = '".$user['zoop_battle_losses']."' WHERE `id` = '".$user['id']."'");
zoopz_query("UPDATE `accounts` SET `zoop_hp` = '".$otheruser['zoop_hp']."' , `zoop_battle_wins` = '".$otheruser['zoop_battle_wins']."' , `zoop_battle_losses` = '".$otheruser['zoop_battle_losses']."' WHERE `id` = '".$otheruser['id']."'");
$user['attackturns'] -= $_POST['attackturns'];
zoopz_query("UPDATE `accounts` SET `attackturns` = '".$user['attackturns']."' WHERE `id` = '".$user['id']."'");
zoopz_query("INSERT INTO `attacks` ( `userid` , `attacked` ) VALUES ( '".$user['id']."' , '".$otheruser['id']."' )");
} else {
$page_notification_bad[] = 'You have already attacked this person 5 times today.';
}
} else {
$page_notification_bad[] = 'You can only attack Zoopz half your level or higher.';
}
} else {
$page_notification_bad[] = 'Your opponent\'s Zoop currently has less than half of it\'s HP. Check back later.';
}
} else {
$page_notification_bad[] = 'Your Zoop needs to have at least half of their HP to fight.';
}
} else {
$page_notification_bad[] = 'You don\'t have that many attack turns!';
}
} else {
$page_notification_bad[] = 'You can only use up to 10 attack turns!';
}
} else {
$otheruser = userInfo($_GET['fightuser']);
if ($otheruser) {
$page_main .= '<form action="/?act=arena&amp;fightuser='.$_GET['fightuser'].'" method="post">
<h3>Attacking '.$otheruser['zoop_name'].'</h3>
<label for="attackturns">Attack with: </label>
<input type="text" name="attackturns" size="2" maxlength="2" value="';
if ($user['attackturns']>=10) {
$page_main .= '10';
} elseif ($user['attackturns']>0) {
$page_main .= $user['attackturns'];
} else { //Do nothing
}
$page_main .= '"> attack turns. (Up to 10)<br>
<input type="submit" value="Attack!">
</form>';
} else {
$page_main .= 'No user with that ID found.';
}
}
} else {
$page_notification_bad[] = 'No Zoop with that name exists!';
}
} else { //if (round($user['zoop_hp'] / $user['zoop_maxhp'], 2) >= 0.25) {
$page_main .= 'Click a Zoop\'z picture to attack them.<br>
Displaying other Zoopz at least about half the level of your Zoop, up to three levels above your Zoop, with at least half of their HP:<br>';
$page_main .= '<table width="100%" class="prettytable">' . "\n" .
'<tr>' . "\n" .
' <th>Zoop</th>' . "\n" .
' <th>Picture</th>' . "\n" .
'</tr>' . "\n";
$oddrow = false;
$result = zoopz_query("SELECT * FROM `accounts` WHERE `zoop_level` <= ".($user['zoop_level']+3)." AND `zoop_level` >= ".floor($user['zoop_level']/2)." AND `id` != '".$user['id']."' AND `zoop_hp` > 0 ORDER BY `zoop_level` DESC");
while ($line = $result->fetch_assoc()) {
if (canFight($line)) {
if ($oddrow) {
$page_main .= '<tr class="oddrow">' . "\n";
} else {
$page_main .= '<tr>' . "\n";
}
$page_main .= ' <td><span style="font-size: 2em;font-weight: bold;">' . $line['zoop_name'] . '</span><br><br>
<span style="font-size: 1.5em;">Level <b>' . $line['zoop_level'] . '</b></span><br><br>
Wins / Losses: <b>' . number_format($line['zoop_battle_wins']) . '</b> / <b>' . number_format($line['zoop_battle_losses']) . '</b><br>
Owned by: <b>' . $line['username'] . '</b><br>
Quetzals on hand: <b>' . number_format($line['money']) . '</b></td>' . "\n" .
' <td style="text-align: center;"><a href="?act=arena&fightuser=' . $line['id'] . '">' . zoopImage($line, false) . '</a></td>' . "\n" .
'</tr>' . "\n";
$oddrow = (!$oddrow);
}
}
$page_main .= '</table>';
}/* else {
$page_main .= 'Your Zoop currently has less than one quarter of its HP. Heal it to enter the Arena and view other Zoopz.';
}*/
}
} elseif ($_GET['act']=='hospital') {
$page_main .= '<h1>Hospital</h1>';
if (checkCaptcha()) {
$page_main .= '<div align="center"><img src="/img/zoop_nurse.png"><br>Dr. Tesarik says:<h3>I ONLY HAVE A DEGREE IN BIOLOGY</h3></div>';
$page_main .= '<h2>Heal</h2>';
if ($user['zoop_hp']<$user['zoop_maxhp']) {
if ($user['zoop_level']==1) {
$cost = 0;
} else {
$cost = ($user['zoop_maxhp']-$user['zoop_hp'])*($user['zoop_level']*0.25);
}
if ($_GET['do']=='heal') {
if ($user['money']>=$cost) {
$user['money'] -= $cost;
$user['zoop_hp'] = $user['zoop_maxhp'];
zoopz_query("UPDATE `accounts` SET `money` = ".$user['money']." , `zoop_hp` = ".$user['zoop_hp']." WHERE `id` = ".$user['id']."");
$page_notification_good[] = 'You have been successfully healed!';
} else {
$page_notification_bad[] = 'You don\'t have enough money to pay the bill!';
}
} else {
$page_main .= 'Looks like you\'ve been hurt.<br>';
if ($cost>0) {
$page_main .= 'The total cost for healing comes to '.$cost.' Quetzals.';
} else {
$page_main .= 'Since you\'re such a young Zoop, I\'ll heal you for free.';
}
$page_main .= '<br><br><a href="?act=hospital&do=heal">Heal me!</a>';
}
}
if ($user['zoop_hp']>=$user['zoop_maxhp']) {
$page_main .= 'You\'re already full health! Come back after you\'ve taken a good beating.';
}
}
} elseif ($_GET['act']=='market') {
$page_main .= '<h1>Market</h1>
<div align="center">
<img src="/img/zoop_marketman.png"><br>
Market-man\'s moustache says:
<h3>CANDY IS DANDY BUT LIQUOR IS QUICKER</h3>
</div>';
if (isset($_GET['buy'])) {
if (!hasItem($user, $_GET['buy'])) {
$item = getItem($_GET['buy']);
if ($user['money'] >= $item['cost']) {
$user['money'] -= $item['cost'];
zoopz_query('UPDATE `accounts` SET `money` = \'' . $user['money'] . '\' WHERE `id` = \'' . $user['id'] . '\'');
giveItem($user, $item['id']);
$page_notification_good[] = 'You have successfully bought: ' . $item['name'];
} else {
$page_notification_bad[] = 'You don\'t have enough to buy that!';
}
} else {
$page_notification_bad[] = 'You already own one of those!';
}
}
$page_main .= '<table width="100%" class="prettytable" style="border: 0px none;">
<tr>
<td colspan="6" style="border: 0px none;"><h2 align="center">Offense</h2></td>
</tr>
<tr>
<th width="1%">Picture</th>
<th>Name</th>
<th>Description</th>
<th>Offense+</th>
<th>Cost</th>
<th>Buy</th>
</tr>';
$oddrow = false;
$result = zoopz_query("SELECT * FROM `items` WHERE `type` = 'offense' ORDER BY `cost` ASC");
while ($line = $result->fetch_assoc()) {
if ($oddrow) {
$page_main .= '<tr class="oddrow">';
} else {
$page_main .= '<tr>';
}
$page_main .= ' <td>' . itemImage($line) . '</td>
<td>'.$line['name'].'</td>
<td>'.$line['desc'].'</td>
<td>'.$line['offense'].'</td>
<td>'.$line['cost'].'</td>
<td><a href="?act=market&buy='.$line['id'].'">Buy!</td>
</tr>';
$oddrow = (!$oddrow);
}
//$page_main .= '</table>';
//$page_main .= '<h2>Defense</h2>';
$page_main .= '
<tr>
<td colspan="6" style="border: 0px none;"><br><h2 align="center">Defense</h2></td>
</tr>
<tr>
<th width="1%">Picture</th>
<th>Name</th>
<th>Description</th>
<th>Defense+</th>
<th>Cost</th>
<th>Buy</th>
</tr>';
$oddrow = false;
$result = zoopz_query("SELECT * FROM `items` WHERE `type` = 'defense' ORDER BY `cost` ASC");
while ($line = $result->fetch_assoc()) {
if ($oddrow) {
$page_main .= '<tr class="oddrow">';
} else {
$page_main .= '<tr>';
}
$page_main .= ' <td>' . itemImage($line) . '</td>
<td>'.$line['name'].'</td>
<td>'.$line['desc'].'</td>
<td>'.$line['defense'].'</td>
<td>'.$line['cost'].'</td>
<td><a href="?act=market&buy='.$line['id'].'">Buy!</td>
</tr>';
$oddrow = (!$oddrow);
}
//$page_main .= '</table>';
//$page_main .= '<h2>Other Items</h2>';
$page_main .= '<tr style="border: 0px none;">
<td colspan="6" style="border: 0px none;"><br><h2 align="center">Other Items</h2></td>
</tr>
<tr>
<th width="1%">Picture</th>
<th>Name</th>
<th>Description</th>
<th>Attribute</th>
<th>Cost</th>
<th>Buy</th>
</tr>';
$oddrow = false;
$result = zoopz_query("SELECT * FROM `items` WHERE `type` = 'potatosack' ORDER BY `type` ASC, `cost` ASC");
while ($line = $result->fetch_assoc()) {
if ($oddrow) {
$page_main .= '<tr class="oddrow">';
} else {
$page_main .= '<tr>';
}
$page_main .= ' <td>' . itemImage($line) . '</td>
<td>'.$line['name'].'</td>
<td>'.$line['desc'].'</td>
<td>';
if ($line['type'] == 'potatosack') {
$page_main .= 'Holds ' . $line['special'] . ' potatoes';
}
$page_main .= '</td>
<td>'.$line['cost'].'</td>
<td><a href="?act=market&buy='.$line['id'].'">Buy!</td>
</tr>';
$oddrow = (!$oddrow);
}
$page_main .= '</table>';
} elseif ($_GET['act']=='bank') {
$page_main .= '<h1>Bank</h1>';
if (checkCaptcha()) {
$page_main .= '<div align="center"><img src="/img/zoop_banker.png"><br>Scruge McMoneysworth says:<h3>I CAN\'T FIND MY TEETH</h3></div>';
if (isset($_POST['depositmoney'])||isset($_POST['withdrawmoney'])) {
$_POST['depositmoney'] = floor($_POST['depositmoney']);
$_POST['withdrawmoney'] = floor($_POST['withdrawmoney']);
if ($_POST['depositmoney']>0) {
if ($user['bank_deposits'] < 8) {
if ($_POST['depositmoney']<=$user['money']) {
$user['money'] -= $_POST['depositmoney'];
$user['money_bank'] += $_POST['depositmoney'];
$user['bank_deposits']++;
zoopz_query("UPDATE `accounts` SET `money` = '".$user['money']."' , `money_bank` = '".$user['money_bank']."' , `bank_deposits` = '".$user['bank_deposits']."' WHERE `id` = ".$user['id']."");
$page_notification_good[] = 'You successfully deposited '.$_POST['depositmoney'].' Quetzals.';
} else {
$page_notification_bad[] = 'You don\'t have that much to deposit!';
}
} else {
$page_notification_bad[] = 'You have reached your bank deposit limit for today.';
}
} elseif ($_POST['withdrawmoney']>0) {
if ($_POST['withdrawmoney']<=$user['money_bank']) {
$user['money'] += $_POST['withdrawmoney'];
$user['money_bank'] -= $_POST['withdrawmoney'];
zoopz_query("UPDATE `accounts` SET `money` = '".$user['money']."' , `money_bank` = '".$user['money_bank']."' WHERE `id` = ".$user['id']."");
$page_notification_good[] = 'You successfully withdrew '.$_POST['withdrawmoney'].' Quetzals.';
} else {
$page_notification_bad[] = 'You don\'t have that much to deposit!';
}
}
}
$page_main .= '<table width="100%">
<tr>
<td colspan="2" align="center">
Bank account balance: <b>' . number_format($user['money_bank']) . '</b> Quetzals<br>
Deposits left: '.(8-$user['bank_deposits']).' / 8
</td>
</tr>
<tr>
<td align="center">
<form method="post" action="/?act=bank">
<input type="text" name="depositmoney" size="7" value="'.$user['money'].'"><br>
<input type="submit" value="Deposit">
</form>
</td>
<td align="center">
<form method="post" action="/?act=bank">
<input type="text" name="withdrawmoney" size="7" value="0"><br>
<input type="submit" value="Withdraw">
</form>
</td>
</tr>
</table>';
}
} elseif ($_GET['act']=='buildings') {
$page_main .= '<h1>Buildings</h1><br>';
if (checkCaptcha()) {
if ($_GET['buy']>0) {
$result = zoopz_query("SELECT * FROM building_names WHERE level = 1 AND id = ".mysqli_real_escape_string($dblink, $_GET['buy']));
$rows = $result->num_rows;
if ($rows>0) {
while ($line = $result->fetch_assoc()) {
$buybuilding_id = $line['id'];
$buybuilding_type = $line['type'];
$buybuilding_cost = $line['cost'];
}
$result = zoopz_query("SELECT * FROM buildings_built WHERE type = ".$buybuilding_type." AND userid = ".$user['id']."");
$rows = $result->num_rows;
if ($rows==0) {
if ($user['money']>=$buybuilding_cost) {
$user['money'] -= $buybuilding_cost;
zoopz_query("INSERT INTO buildings_built ( `userid` , `type` , `level` ) VALUES ( ".$user['id']." , ".$buybuilding_type." , 1 )");
zoopz_query("UPDATE `accounts` SET `money` = ".$user['money']." WHERE `id` = ".$user['id']."");
$page_notification_good[] = 'Building successfully built!';
} else {
$page_notification_bad[] = 'You do not have enough Quetzals to buy that.';
}
} else {
$page_notification_bad[] .= 'You have already built that type of building!';
}
} else {
$page_notification_bad[] .= 'That building ID does not exist!';
}
} elseif ($_GET['upgrade'] > 0) {
$result = zoopz_query('SELECT * FROM building_names WHERE id = \'' . mysqli_real_escape_string($dblink, $_GET['upgrade']) . '\'');
$rows = $result->num_rows;
if ($rows > 0) {
while ($line = $result->fetch_assoc()) {
$building = $line;
}
$result = zoopz_query("SELECT * FROM buildings_built WHERE type = " . $building['type'] . " AND userid = ".$user['id']." LIMIT 1");
$rows = $result->num_rows;
if ($rows > 0) {
while ($line = $result->fetch_assoc()) {
$buildingsbuilt = $line;
}
if (($buildingsbuilt['level'] + 1) == $building['level']) {
if ($user['money'] >= $building['cost']) {
$user['money'] -= $building['cost'];
zoopz_query('UPDATE buildings_built SET `level` = ' . $building['level'] . ' WHERE `userid` = ' . $user['id'] . ' LIMIT 1');
zoopz_query('UPDATE `accounts` SET `money` = ' . $user['money'] . ' WHERE `id` = ' . $user['id']);
$page_notification_good[] = 'Building successfully upgraded!';
} else {
$page_notification_bad[] = 'You do not have enough Quetzals to buy that.';
}
} else {
$page_notification_bad[] = 'You can not upgrade to that level without upgrading to the prior level first.';
}
} else {
$page_notification_bad[] .= 'You don\'t yet own that type of building!';
}
} else {
$page_notification_bad[] .= 'That building ID does not exist!';
}
}
$page_main .= '<h3>Your current buildings</h3>';
$result = zoopz_query("SELECT * FROM buildings_built JOIN building_types ON buildings_built.type = building_types.id WHERE buildings_built.userid = ".$user['id']."");
$page_main .= mysqli_error($dblink);
$rows = $result->num_rows;
if ($rows>0) {
$page_main .= '<table width="100%" class="prettytable">
<tr>
<th>Type</th>
<th>Level</th>
<th>Description</th>
<th>Capacity</th>
<th>Upgrade Cost</th>
<th>Upgrade</th>
</tr>';
while ($line = $result->fetch_assoc()) {
$result2 = zoopz_query("SELECT `name`,`desc` FROM `building_types` WHERE `id` = ".$line['type']."");
$row = $result2->fetch_row();
$result2 = zoopz_query("SELECT * FROM building_names WHERE type = ".$line['type']." AND level = ".$line['level']."");
while ($line2 = $result2->fetch_assoc()) {
$result3 = zoopz_query("SELECT * FROM building_names WHERE type = ".$line['type']." AND level = ".($line['level']+1)."");
$rows = $result3->num_rows;
$page_main .= '<tr>
<td><b><nobr>'.$row[0].'</nobr></b></td>
<td><span style="font-size: 1.5em;">' . $line['level'] . '</span></td>
<td>'.$row[1].'</td>
<td>'.$line2['capacity'].'</td><td>';
if ($rows>0) {
while ($line3 = $result3->fetch_assoc()) {
$page_main .= $line3['cost'].'</td><td><a href="?act=buildings&upgrade='.$line3['id'].'">Upgrade</a>';
}
} else {
$page_main .= ' - </td><td> - ';
}
$page_main .= '</td>
</tr>';
}
}
$page_main .= '</table>';
} else {
$page_main .= 'No buildings have been built yet.<br>';
}
$page_main .= '<h3>Buildings you can buy</h3>';
$result = zoopz_query("SELECT * FROM buildings_built WHERE buildings_built.userid = ".$user['id']."");
$page_main .= mysqli_error($dblink);
$rows = $result->num_rows;
if ($rows>0) {
$query = "SELECT * FROM building_names WHERE building_names.level = 1";
while ($line = $result->fetch_assoc()) {
$query .= " AND building_names.type != ".$line['type'];
}
} else {
$query = "SELECT * FROM building_names WHERE building_names.level = 1";
}
$result = zoopz_query($query);
$rows = $result->num_rows;
if ($rows>0) {
$page_main .= '<table width="100%" class="prettytable">
<tr>
<th>Type</th>
<th>Description</th>
<th>Capacity</th>
<th>Cost</th>
<th>Buy</th>
</tr>';
while ($line = $result->fetch_assoc()) {
$result2 = zoopz_query("SELECT `name`,`desc` FROM `building_types` WHERE `id` = ".$line['type']."");
while ($row = $result2->fetch_assoc()) {
$page_main .= '<tr><td>' . $row[0] . '</td><td>' . $row[1] . '</td><td>' . $line['capacity'] . '</td><td>' . $line['cost'] . '</td><td><a href="?act=buildings&buy=' . $line['id'] . '">Buy</a></td></tr>';
}
}
$page_main .= '</table>';
} else {
$page_main .= 'You have already bought all buildings available.';
}
}
} elseif ($_GET['act']=='potatomine') {
$page_main .= '<h1>Potato Mine</h1><br>';
if ($user['potatomine_built']) {
if (isset($_GET['do'])) {
if ($_GET['do'] == 'sellpotatoes') {
if ($user['potatoes'] > 0) {
if ($user['potato_sells'] < 5) {
$user['potato_sells'] = $user['potato_sells'] + 1;
$user['money'] += $user['potatoes'];
$user['potatoes'] = 0;
zoopz_query('UPDATE `accounts` SET `money` = ' . $user['money'] . ' , `potatoes` = ' . $user['potatoes'] . ' , `potato_sells` = ' . $user['potato_sells'] . ' WHERE `id` = ' . $user['id'] . ' LIMIT 1');
$page_notification_good[] = 'You have successfully sold all of your potatoes.';
} else {
$page_notification_bad[] = 'You have maxed out your Potato Black Market Security Card uses for today.';
}
} else {
$page_notification_bad[] = 'You do not currently have any potatoes to sell!';
}
}
}
$page_main .= 'You currently have <b>'.$user['potatominers'].'</b> potato miners';
if (($user['potatomine_capacity'] - $user['potatominers']) > 0) {
$page_main .= ', and you have the capacity to hire <b>' . ($user['potatomine_capacity'] - $user['potatominers']) . '</b> more';
}
$page_main .= '.<br>
<div align="center"><img src="/img/zoop_worker.png"><br>Zoop Worker says:<h3>';
$rand = rand(1, 3);
if ($rand == 1) {
$page_main .= 'I\'M SO HUNGRY';
} elseif ($rand == 2) {
$page_main .= 'PLEASE... FEED ME';
} else {
$page_main .= 'WHEN WILL YOU PAY US?';
}
$page_main .= '</h3></div>
<h3>Every turn:</h3>
Potatoes mined: <b>'.$user['potatominers'].'</b><br><br>
<h3>To date:</h3>
Potatoes mined: <b>'.$user['potatoesmined'].'</b><br><br>
<h3>Potato Inventory</h3>
You currently have <b>' . $user['potatoes'] . '</b> potatoes which are able to be sold.<br><br>
Potato Black Market Security Card uses left today: ' . (5 - $user['potato_sells']) . ' / 5<br><br>';
if ($user['potatoes'] > 0) {
$page_main .= '<a href="?act=potatomine&do=sellpotatoes">Sell your potatoes 1 Quetzal each</a>';
} else {
$page_main .= 'Come back when you have some potatoes!';
}
} else {
$page_notification_bad[] = 'You do not currently have a potato mine constructed!';
}
} elseif ($_GET['act']=='hireworkers') {
$page_main .= '<h1>Hire Workers</h1>';
if (checkCaptcha()) {
if ($user['potatomine_built']) {
if (isset($_POST['hirepotatominers'])) {
$_POST['hirepotatominers'] = floor($_POST['hirepotatominers']);
if ($_POST['hirepotatominers'] > 0) {
if ($_POST['hirepotatominers'] <= $user['peopleabletobehired']) {
if ($user['potatominers'] + $_POST['hirepotatominers'] <= $user['potatomine_capacity']) {
if ($user['money']>=($_POST['hirepotatominers']*50)) {
$user['money'] -= ($_POST['hirepotatominers']*50);
$user['peopleabletobehired'] -= $_POST['hirepotatominers'];
$user['potatominers'] += $_POST['hirepotatominers'];
zoopz_query("UPDATE accounts SET money = ".$user['money']." , peopleabletobehired = ".$user['peopleabletobehired']." , potatominers = ".$user['potatominers']." WHERE id = ".$user['id']."");
$page_notification_good[] = 'You have successfully hired '.$_POST['hirepotatominers'].' potato miners!';
} else {
$page_notification_bad[] = 'You do not have enough money to hire that many workers! (Cost: '.($_POST['hirepotatominers']*50).')';
}
} else {
$page_notification_bad[] = 'Your current mine size does not allow for that many total potato miners!';
}
}
}
}
if ($user['peopleabletobehired']>0) {
$page_main .= 'You currently have <b>'.$user['peopleabletobehired'].'</b> people you can hire as workers.<br><br>';
$page_main .= '<form action="/?act=hireworkers" method="post"><label for="hirepotatominers">Potato Miners: </label><input type="text" name="hirepotatominers" value="'.$user['peopleabletobehired'].'"> (Cost: 50 Quetzals each)<br><input type="submit" value="Hire"></form>';
} else {
$page_main .= 'You do not currently have any more people able to be hired.';
}
} else {
$page_main .= 'You do not currently have any buildings to hire workers for!';
}
}
} elseif ($_GET['act']=='account') {
$page_main .= '<h1>Options</h1>';
} elseif ($_GET['act']=='upgrade') {
$page_main .= '<h1>Upgrade Your Account</h1>';
$page_main .= '<h2>30 DAY - BRONZE</h2>3 Attack turns per half hour, 600 Attack turns max, 12 Training points per day.
<h2>30 DAY - SILVER</h2>3 Attack turns per half hour, 650 Attack turns max, 14 Training points per day.
<h2>30 DAY - GOLD</h2>4 Attack turns per half hour, 800 Attack turns max, 16 Training points per day.';
$page_main .= '<br><br>Note: All packages feature removal of advertisements when you (or the person who you are ordering for) is/are logged in, no matter how long the package duration is.';
$page_main .= '<br><br>Click <a taget="_blank" href="/store/">here</a> to open the store.';
} elseif ($_GET['act']=='rewards') {
$page_main .= '<h1>Rewards</h1><br>For voting for Zoopz, a thank-you reward is given at the time of the vote.<br><br>Top RP Games: <a href=http://www.toprpgames.com/vote.php?idno=1293&userid='.$user['id'].'>Vote!</a> (+2 Training Points, +1 Hireable Worker)<br>';
} elseif ($_GET['act']=='events') {
$page_main .= '<h1>Events</h1>
<h3>New events are in bold</h3><br>
<table width="100%" class="prettytable">
<tr><th>Time</th><th>Message</th></tr>';
$result = zoopz_query('SELECT * FROM `events` WHERE `userid` = \'' . $user['id'] . '\' ORDER BY `timestamp` DESC');
$i = 0;
$oddrow = false;
while ($line = $result->fetch_assoc()) {
$i++;
if ($oddrow) {
$page_main .= '<tr class="oddrow">';
} else {
$page_main .= '<tr>';
}
if ($line['read'] == 1) {
$page_main .= '<td>' . TimeAgo($line['timestamp']) . ' ago</td><td>' . $line['message'] . '</td></tr>';
} else {
$page_main .= '<td><b>' . TimeAgo($line['timestamp']) . ' ago</b></td><td><b>' . $line['message'] . '</b></td></tr>';
}
$oddrow = (!$oddrow);
}
$page_main .= '</table>';
zoopz_query('UPDATE `events` SET `read` = 1 WHERE `userid` = ' . $user['id']);
} elseif ($_GET['act'] == 'art') {
$page_main .= $zoopart;
} elseif ($_GET['act'] == 'lore') {
$page_main .= $zooplore;
} elseif ($_GET['act'] == 'howtoplay') {
$page_main .= $zoopgametext;
} else {
$page_main .= '<br><br><br><font size="+10">Zoop zoop zoop.</font><br><br><br>Accounts are checked daily for activity.<br>
Not logging in for six months will result in your account being deleted. It\'s not like you were playing, anyway.';
}
do_display();