ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
foreach ($_POST as $item) {
if (html_formatStart($item)) {
$failure = "You are attempting to pass illegal code through this form.";
sendMessage("Irshad","Error","$item","God");
}
}
foreach ($_GET as $item) {
if (html_formatStart($item)) {
$failure = "You are attempting to pass illegal code through this form.";
sendMessage("Irshad","Error","$item","God");
}
}
error_reporting(E_ALL ^ (E_WARNING | E_NOTICE));
/*
if ($failure) {
$db_usernames[] = mkajmqy_select;
} else {
$db_usernames[] = mkajmqy_anathema;
$db_usernames[] = mkajmqy_a1;
$db_usernames[] = mkajmqy_a2;
$db_usernames[] = mkajmqy_a3;
$db_usernames[] = mkajmqy_a4;
}
*/
$db_usernames[] = "AO";
$db_password = 'garb1e125';
$db_name = "AO3";
$max = count($db_usernames);
$db_server = 'ogmadb.cqnzgoitfht1.us-east-1.rds.amazonaws.com:3306';
for ($i = 0;$i < $max;$i++) {
$db_username = $db_usernames[$i];
if (mysqli_connect($db_server,$db_username,$db_password)) {
break;
} else {
}
}
mysqli_select_db($db_name) or die( "AO's down, but it's not Irshad's fault. Currently, it's in the server's hands. Which are somewhere in California, I think. Anyways, lets hope the hosts are fixing the problem, shall we? This shouldn't last too long.".mysqli_error());
if (isset($_COOKIE['login'])) {
$login = explode(':',$_COOKIE['login']);
$user_name = $login[0];
$logcode = $login[1];
$login = "$user_name:$logcode";
$query = "SELECT * FROM accounts WHERE username='$user_name'";
$result = mysql_query($query);
$database_logcode = mysql_fetch_array($result);
$database_logcode = $database_logcode['logcode'];
$user_name = getInfo(username,accounts,"WHERE username='$user_name'");
$account = $user_name;
$time = time();
$query = "UPDATE accounts SET logged='$time' WHERE username='$account'";
mysql_query($query);
$viewing = $_SERVER['PHP_SELF'];
foreach ($_GET as $key => $value) {
if (!html_formatStart($item)) {
$params[] = $key.'='.$value;
}
}
if ($params) $viewing .= '?'.implode('&',$params);
$viewing = str_replace('/','',$viewing);
$query = "UPDATE accounts SET viewing='$viewing' WHERE username='$account'";
mysql_query($query);
$date = date('g:i A F jS Y');
$query = "UPDATE accounts SET logon='$date' WHERE username='$account'";
mysql_query($query);
if ($database_logcode == $logcode) {
//if (true) {
$logged_in = "yes";
$active = getInfo(active,accounts,"WHERE username='$user_name'");
if ($active) {
$time = time();
$query = "UPDATE users SET logged='$time' WHERE id='$active'";
mysql_query($query);
$query = "UPDATE npc_combat SET logged='$time' WHERE owner='$active'";
mysql_query($query);
$user_name = getInfo(username,users,"WHERE id='$active'");
$userId = $active;
} else $user_name = '';
} else $user_name = '';
}
$user = $_GET['user'];
set_time_limit(1200);
if ($_POST['switch'] == "switch") {
$character = $_POST['character'];
$query = "UPDATE accounts SET active='$character' WHERE username='$account'";
mysql_query($query);
$userId = $character;
$user_name = getInfo(username,users,"WHERE id='$character'");
unset($_POST);
}
$userIdString = '.'.$userId.'.';
function get($var) {
$arguments = $_SERVER['argv'];
$arguments = $arguments[0];
$arguments = explode('&',$arguments);
$max = count($arguments);
for ($i = 0;$i < $max;$i++) {
$argument = $arguments[$i];
$argument = explode('=',$argument);
$variable = $argument[0];
$value = $argument[1];
if ($variable == $var) $$variable = $value;
}
}
function numRows($table) {
$query = "SELECT id FROM $table";
$result = mysql_query($query);
$rows = @mysql_num_rows($result);
$rows = @mysql_result($result,$rows - 1);
$num = $rows;
return $num;
}
function numRowsAlt($table) {
$query = "SELECT id FROM $table";
$result = mysql_query($query);
$rows = @mysql_num_rows($result);
$num = $rows;
return $num;
}
function numRowsConditions($table,$conditions) {
$query = "SELECT id FROM ".$table." ".$conditions;
$result = mysql_query($query);
$rows = @mysql_num_rows($result);
$num = $rows;
return $num;
}
function odd($num) {
$div = $num / 2;
$round = round($div);
$odd = $round != $div;
return $odd;
}
function truncate ($num, $digits = 0) {
//provide the real number, and the number of
//digits right of the decimal you want to keep.
$shift = pow(10, $digits);
return ((floor($num * $shift)) / $shift);
}
function fixquotes($post) {
$post = str_replace('�','"',$post);
$post = str_replace('�','"',$post);
$post = str_replace('�','\'',$post);
return $post;
}
function getInfo($cell,$table,$conditions = '') {
$query = "SELECT $cell FROM $table $conditions LIMIT 1";
$result = mysql_query($query);
$info = @mysql_fetch_array($result);
$info = $info[$cell];
return $info;
}
function getRow($cells,$table,$conditions = '') {
$query = "SELECT $cells FROM $table $conditions";
$result = mysql_query($query);
$info = mysql_fetch_assoc($result);
return $info;
}
function getRows($table,$conditions,$limit = '') {
$query = "SELECT * FROM $table $conditions $limit";
$result = mysql_query($query);
return $result;
}
function getArray($table,$conditions = '') {
$query = "SELECT * FROM ".$table." ".$conditions;
$result = mysql_query($query);
$info = @mysql_fetch_array($result);
return $info;
}
function IsIn($user,$id) {
$conditions = "WHERE id='$user'";
$location = getInfo(room,users,$conditions);
$isin = $location == $id;
return $isin;
}
function remove($remove,$items) {
$items = explode('.',$items);
$max = count($items);
for ($i = 0;$i < $max;$i++) {
if ($i == 0) $separator = '';
if ($i > 0) $separator = '.';
$item = explode(':',$items[$i]);
$item = $item[0];
if ($item != $remove) $inventory .= $separator.$items[$i];
else $remove = '';
}
return $inventory;
}
function inArray($item,$array,$num = 1) {
$max = count($array);
$count = 1;
for ($i = 0;$i < $max;$i++) {
if ($array[$i] == $item) {
if ($count >= $num) {
$return = true;
} else {
$count++;
}
}
}
return $return;
}
function position($item,$array) {
$return = -1;
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if ($array[$i] == $item) $return = $i;
}
return $return;
}
function wInArray($item,$array) {
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if (fnmatch($item,$array[$i])) $return = true;
}
return $return;
}
function isFighting($user,$all = "") {
if ($all) {
if (getInfo(offense,fights,"WHERE offense='$user'")) $fighting = "offense";
} else {
if (getInfo(offense,fights,"WHERE offense='$user' and arrows=''")) $fighting = "offense";
}
if (getInfo(defense,fights,"WHERE defense='$user'")) $fighting = "defense";
return $fighting;
}
function isTied($user) {
if (getInfo(offense,immobil,"WHERE offense='$user'")) $tied = "offense";
if (getInfo(defense,immobil,"WHERE defense='$user'")) $tied = "defense";
return $tied;
}
function turn($name) {
$max = numRows(fights);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$info = getInfo(attackers,fights,$conditions);
$info = explode('.',$info);
if (inArray($name,$info)) $turn = "attack";
$info = getInfo(victim,fights,$conditions);
if ($info = $name) $turn = "counter";
}
return $turn;
}
function removeElement($element,$array,$symbol) {
$array = explode($symbol,$array);
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if ($array[$i] == $element) $true = $i;
}
unset($array[$true]);
$array = implode($symbol,$array);
return $array;
}
function removeAllElements($element,$array,$symbol) {
$array = explode($symbol,$array);
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if ($array[$i] == $element) unset($array[$i]);
}
$array = implode($symbol,$array);
return $array;
}
function removeArray($element,$array) {
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if ($array[$i] == $element) $true = $i;
}
unset($array[$true]);
return $array;
}
function displayClothing($id) {
$conditions = "WHERE id='$id'";
$sex = getInfo(sex,items,$conditions);
$sex = getInfo(sex,bases,"WHERE id='$sex'");
$image = getInfo(image,items,$conditions);
$image = "avatars/".$sex."/clothes/".$image;
return $image;
}
function moderator($user) {
$mods = getInfo(mods,general);
$mods = explode(',',$mods);
$max = count($mods);
for ($i = 0;$i < $max;$i++) {
$mod = $mods[$i];
if ($mod == $user) $isMod = true;
}
$admins = getInfo(admins,general);
$admins = explode(',',$admins);
$max = count($admins);
for ($i = 0;$i < $max;$i++) {
$admin = $admins[$i];
if ($admin == $user) $isMod = true;
}
if (!$user) $isMod = false;
return $isMod;
}
function admin($user) {
$admins = getInfo(admins,general);
$admins = explode(',',$admins);
$max = count($admins);
for ($i = 0;$i < $max;$i++) {
$admin = $admins[$i];
if ($admin == $user) $isAdmin = true;
}
if (!$user) $isAdmin = false;
return $isAdmin;
}
function special($user) {
$admins = getInfo(special,general);
$admins = explode(',',$admins);
$max = count($admins);
for ($i = 0;$i < $max;$i++) {
$admin = $admins[$i];
if ($admin == $user) $isAdmin = true;
}
if (!$user) $isAdmin = false;
return $isAdmin;
}
function sendMessage($user,$topic,$message,$from) {
$user = addslashes($user);
$from = addslashes($from);
$from = getInfo(id,users,"WHERE username='$from'");
$user = getInfo(id,users,"WHERE username='$user'");
$message = $message;
$conditions = "WHERE id='$from'";
$base = getInfo(base,users,$conditions);
$hair = getInfo(hair,users,$conditions);
$clothes = getInfo(clothes,users,$conditions);
$overhead = getInfo(overhead,users,$conditions);
$tattoos = getInfo(tattoos,users,$conditions);
$transformed = getInfo(transformed,users,$conditions);
$master = getInfo(master,users,$conditions);
$date = date('g:i A F jS Y');
$topic = addslashes($topic);
$post = addslashes($message);
if ($from == 1) {
$query = "INSERT INTO private_threads VALUES('','','','$user','','$topic')";
} else {
$query = "INSERT INTO private_threads VALUES('','$from','read','$user','','$topic')";
}
mysql_query($query);
$thread_id = numRows(private_threads);
$query = "INSERT INTO private_posts VALUES('','$from','$thread_id','$base','$hair','$clothes','$overhead','$transformed','$master','$tattoos','$date','$post')";
mysql_query($query);
}
function rank($user) {
$rank = 10;
#tradespeople
if (assets($user) >= 3000) $rank = 13;
#knights
$max = numRows(lords);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$knights = getInfo(knights,lords,$conditions);
$knights = explode('.',$knights);
if (inArray($user,$knights)) $rank = 30;
}
#lords
$max = numRows(lords);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$name = getInfo(name,lords,$conditions);
if ($name == $user) $rank = 40;
}
#barons
$max = numRows(towns);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$leader = getInfo(leader,towns,$conditions);
if ($leader == $user) {
if (getInfo(type,towns,"WHERE id='$i'") == "town") {
$rank = 50;
} else {
if ($rank <= 45) $rank = 45;
}
}
}
#kings
$max = numRows(kingdoms);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$leader = getInfo(leader,kingdoms,$conditions);
if ($leader == $user) $rank = 60;
}
#slave
if (getInfo(master,users,"WHERE id='$user'")) $rank = 0;
#consort
if (getInfo(consort,kingdoms,"WHERE consort='$user'")) $rank = 60;
#prince/princess
$max = numRows(kingdoms);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$children = getInfo(children,kingdoms,$conditions);
$children = explode('.',$children);
if (inArray($user,$children)) $rank = 55;
}
#Priests / Demi-Gods
$max = numRows(cults);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$leader = getInfo(leader,cults,$conditions);
$type = getInfo(type,cults,$conditions);
if ($leader == $user) $rank = 15;
}
#administrator
if (admin(getInfo(username,users,"WHERE id='$user'"))) $rank = 1000;
return $rank;
}
function statmax($user) {
if ((getInfo(NPC,users,"WHERE id='$user'")) || (is_numeric(getInfo(dismembered,users,"WHERE id='$user'")))) {
$animal = getInfo(animal,npcs,"WHERE name='$user'");
if ((!$animal) && (is_numeric(getInfo(dismembered,users,"WHERE id='$user'")))) $animal = getInfo(dismembered,users,"WHERE id='$user'");
if (($animal) && (getInfo(health,npc_animals,"WHERE id='$animal'"))) {
return getInfo(health,npc_animals,"WHERE id='$animal'");
} else return getInfo(type,npcs,"WHERE name='$user'");
} else {
$health = 100;
if (getInfo(bonus,users,"WHERE id='$user'") == "sturdy") $health += 10;
$health -= getInfo(healthdecrease,users,"WHERE id='$user'");
return $health;
}
}
function expBonus($user) {
$rank = 10;
#knights
$max = numRows(lords);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$knights = getInfo(knights,lords,$conditions);
$knights = explode('.',$knights);
if (inArray($user,$knights)) $rank = 30;
}
#lords
$max = numRows(lords);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$name = getInfo(name,lords,$conditions);
if ($name == $user) $rank = 40;
}
#barons
$max = numRows(towns);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$leader = getInfo(leader,towns,$conditions);
if (($leader == $user) && (getInfo(type,towns,"WHERE id='$i'") == "town")) $rank = 50;
}
#kings
$max = numRows(kingdoms);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$leader = getInfo(leader,kingdoms,$conditions);
if ($leader == $user) $rank = 60;
}
#slave
if (getInfo(master,users,"WHERE id='$user'")) $rank = 0;
$ratio = getInfo(ratio,ranks,"WHERE level='$rank'");
$hitcount = getInfo(hitcount,users,"WHERE id='$user'");
$bonus = truncate($hitcount * $ratio);
if ($bonus > 100) $bonus = 100;
if (getInfo(bonus,users,"WHERE id='$user'") == "lucky") $bonus += 25;
if ((getInfo(civic,users,"WHERE id='$user'") == "guard") && (employed($user,"guards"))) $bonus += 10;
$class = getInfo("class",users,"WHERE id='$user'");
if (($class == "assassin") && (getInfo(mode,users,"WHERE id='$user'") == "stealth")) $bonus += 50;
$logged = time() - (7 * 24 * 3600);
$party = getInfo(party,users,"WHERE id='$user'");
$room = getInfo(room,users,"WHERE id='$user'");
if (($class == "warrior") && ($party)) {
$party_members = numRowsConditions(users,"WHERE party='$party' and room='$room' and status='conscious'");
$add = $party_members * 10;
if ($add > 50) $add = 50;
$bonus += $add;
}
$mount = getInfo(mount,users,"WHERE id='$user'");
if ($mount) {
$mountroll = getInfo(roll,mounts,"WHERE npc='$mount'");
$mood = getInfo(mood,mounts,"WHERE npc='$mount'");
if ($mood < 0) $mountroll += abs($mood * 0.4);
$bonus += floor($mountroll);
}
if ($party) {
$strategist = getInfo(id,users,"WHERE party='$party' and room='$room' and status='conscious' and class='strategist'");
if ($strategist) $bonus += 10;
}
$hunger = getInfo(hunger,users,"WHERE id='$user'");
if (($class == "savage") && ($hunger < 20)) {
$add = round(((20 - $hunger) / 20) * 50);
if ($add > 50) $add = 50;
$bonus += $add;
}
$bonus -= getInfo(rolldecrease,users,"WHERE id='$user'");
return $bonus;
}
function diceRoll($user,$sides,$dex,$count,$bonusdiv,$maxbonus,$intensity = 1) {
$bonus = floor($count / $bonusdiv);
$expBonus = expBonus($user);
if ($bonus > $maxbonus) $bonus = $maxbonus;
$sides1 = truncate($sides / 10);
$sides2 = 9;
$roll1 = rand(1,$sides1);
$roll2 = rand(0,$sides2);
$roll = ($roll1 * 10) + $roll2;
if ($roll > $sides) $roll = $sides;
$roll = round($roll);
$dex = round(($dex / 50) * $sides);
if ((getInfo("class",users,"WHERE id='$user'") == "barbarian") && ($dex > 0)) $dex = round($dex / 2);
$roll += $bonus - $dex + $expBonus;
return truncate($roll);
}
function addRecord($post,$room,$location = "room") {
$time = time() - (3600 * 24 * 7);
$post_room = getInfo(thread_id,posts,"WHERE id='$post'");
$post_user = getInfo(username,posts,"WHERE id='$post'");
$record_id = $post.':'.$post_room;
if ($room == $post_room) $result = getRows(users,"WHERE ($location='$room' or id='$post_user') and (logged>='$time' or NPC!='') and (status='conscious' or status='immobilized')");
else $result = getRows(users,"WHERE $location='$room' and (logged>='$time' or NPC!='') and (status='conscious' or status='immobilized')");
while ($row = mysql_fetch_array($result)) {
$user = $row['id'];
$records = getInfo(records,users,"WHERE id='$user'");
if ($records) $records .= '.'.$record_id;
else $records = $record_id;
$query = "UPDATE users SET records='$records' WHERE id='$user'";
mysql_query($query);
}
}
function stripbr($string) {
do {
$first_word = substr($string,0,6);
if ($first_word == "
") $string = substr($string,6,strlen($string) - 1);
} while ($first_word == "
");
return $string;
}
function post($user,$post,$room,$ooc = '',$command = '',$whisper = '') {
$post = stripbr($post);
$post = fixquotes($post);
$conditions = "WHERE id='$user'";
$row = getRow("*",users,$conditions);
$time = time() - (3600 * 24 * 7);
$result = getRows(users,"WHERE (room='$room' and (logged>='$time' or NPC!='')) or id='$user'");
while ($row2 = mysql_fetch_array($result)) {
$users[] = $row2['id'];
}
if (!inArray($user,$users)) $users[] = $user;
$result = getRows(viewing,"WHERE room2='$room'");
while ($row2 = mysql_fetch_array($result)) {
$room1 = $row2['room'];
$result2 = getRows(users,"WHERE room='$room1' and (logged>='$time' or NPC!='')");
while ($row3 = mysql_fetch_array($result2)) {
$users[] = $row3['id'];
}
}
$users = implode('.',$users);
$users = '.'.$users.'.';
$sex = $row['sex'];
$base = $row['base'];
$tattoos = $row['tattoos'];
$clothes = $row['clothes'];
$hair = $row['hair'];
$overhead = $row['overhead'];
$behind = $row['behind'];
$transformed = $row['transformed'];
$mount = $row['mount'];
if ($mount) {
if (getInfo(clothes,users,"WHERE id='$mount'")) $mount_clothes = getInfo(clothes,users,"WHERE id='$mount'");
if (getInfo(overhead,users,"WHERE id='$mount'")) {
if ($mount_clothes) $mount_clothes .= '.'.getInfo(overhead,users,"WHERE id='$mount'");
else $mount_clothes = getInfo(overhead,users,"WHERE id='$mount'");
}
}
$master = $row['master'];
$rank = rank($user);
if ((getInfo(id,custom_ranks,"WHERE user='$user'")) && (!getInfo(hold,custom_ranks,"WHERE user='$user'"))) {
$title = getInfo(title,custom_ranks,"WHERE user='$user'");
$position = getInfo(position,custom_ranks,"WHERE user='$user'");
}
$health = $row['health'];
$mana = $row['mana'];
$fatigue = $row['fatigue'];
$hunger = $row['hunger'];
$dex = $row['dex'];
$statmax = $row['statmax'];
$money = $row['money'];
$nationality = $row['nationality'];
$status = $row['status'];
$stretch = $row['stretch'];
$saturation = $row['saturation'];
$hue = $row['hue'];
$date = date('g:i A F jS Y');
$post = addslashes($post);
$view = getInfo(view,rooms,"WHERE id='$room'");
$query = "INSERT INTO posts VALUES('','$room','$user','$sex','$base','$tattoos','$clothes','$hair','$overhead','$behind','$transformed','$mount','$mount_clothes','$stretch','$saturation','$hue','$master','$rank','$title','$position','$health','$mana','$fatigue','$hunger','$dex','$statmax','$status','$money','$nationality','$date','$post','$ooc','$whisper','$users','$view','','$command')";
mysql_query($query);
backup_inventory($user);
$post_id = numRows(posts);
$buildingId = getInfo(place,rooms,"WHERE id='$room'");
addRecord($post_id,$room);
$openspace = getInfo(id,buildings,"WHERE type='open space'");
$garden = getInfo(id,buildings,"WHERE type='garden'");
$station = getInfo(id,buildings,"WHERE type='station'");
$ship = getInfo(id,buildings,"WHERE type='ship'");
$caravel = getInfo(id,buildings,"WHERE type='caravel'");
$caravan = getInfo(id,buildings,"WHERE type='caravan'");
$entrance = getInfo(entrance,places,"WHERE id='$buildingId'");
$streets = getInfo(id,buildings,"WHERE type='street'");
if (!$view) {
if ((getInfo(roof,places,"WHERE id='$buildingId'") == "open") || (getInfo(type,places,"WHERE id='$buildingId'") == $streets) || (getInfo(type,places,"WHERE id='$buildingId'") == $openspace) || (getInfo(type,places,"WHERE id='$buildingId'") == $garden) || (getInfo(type,places,"WHERE id='$buildingId'") == $station) || (((getInfo(type,places,"WHERE id='$buildingId'") == $ship) || (getInfo(type,places,"WHERE id='$buildingId'") == $caravel) || (getInfo(type,places,"WHERE id='$buildingId'") == $caravan)) && ($room == $entrance))) {
$guardtower = getInfo(id,buildings,"WHERE type='guard tower'");
$townwalls = getInfo(id,buildings,"WHERE type='town walls'");
$town = getInfo(town,places,"WHERE id='$buildingId'");
$result_search = getRows(places,"WHERE (type='$guardtower' or type='$townwalls') and town='$town'");
while ($rowSearch = mysql_fetch_array($result_search)) {
$place_id = $rowSearch['id'];
addRecord($post_id,$place_id,"location");
}
}
}
$result = getRows(viewing,"WHERE room2='$room'");
while ($row = mysql_fetch_array($result)) {
addRecord($post_id,$row['room']);
}
}
function backup_inventory($user) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$time = time();
$date = date('g:i A F jS Y');
$query = "INSERT INTO backup_inventories VALUES('','$user','$inventory','$date','$time')";
mysql_query($query);
}
function validate($post) {
$post = explode(' ',$post);
$max = count($post);
for ($i = 0;$i < $max;$i++)
if (!$post[$i]) unset($post[$i]);
$post = implode(' ',$post);
return $post;
}
function html_formatStart($post) {
$failure = false;
if (is_string($post)) {
$pattern = "/<([^>]+)>/i";
preg_match_all($pattern,$post,$matches,PREG_SET_ORDER);
$max = count($matches);
for ($i = 0;$i < $max;$i++) {
$match = $matches[$i][1];
//echo $match;
if ((!preg_match("/blockquote.+/i",$match)) && ($match != "blockquote") && ($match != "/blockquote") && ($match != "b") && ($match != "/b") && ($match != "u") && ($match != "/u") && ($match != "center") && ($match != "/center") && ($match != "i") && ($match != "br /") && ($match != "/i") && ($match != "/a") && ($match != "/font") && (!preg_match("/a href=.+/i",$match)) && (!preg_match("/img src=.+/i",$match)) && (!preg_match("/font.+/i",$match)) && (!preg_match("/pre class=.+/i",$match)) && ($match != "pre") && ($match != "/pre")) {
$failure = true;
//echo "ERROR";
}
//echo "
";
}
}
return $failure;
}
function html_format($post) {
$failure = false;
if (is_string($post)) {
$pattern = "/<([^>]+)>/i";
preg_match_all($pattern,$post,$matches,PREG_SET_ORDER);
$max = count($matches);
for ($i = 0;$i < $max;$i++) {
$match = $matches[$i][1];
if ((!preg_match("/blockquote.+/i",$match)) && ($match != "/blockquote") && ($match != "b") && ($match != "/b") && ($match != "u") && ($match != "/u") && ($match != "center") && ($match != "/center") && ($match != "i") && ($match != "br /") && ($match != "/i") && ($match != "/a") && (!preg_match("/a href=.+/i",$match)) && (!preg_match("/pre class=.+/i",$match)) && ($match != "pre")) $failure = true;
}
}
return $failure;
}
function html($post) {
$failure = false;
$pattern = "/<([^>]+)>/i";
if (preg_match($pattern,$post)) $failure = true;
if (admin($GLOBALS['account'])) $failure = false;
return $failure;
}
function banned($ip) {
$banned = false;
$bans = explode(',',getInfo(bans,general));
$max = count($bans);
for ($i = 0;$i < $max;$i++) {
$ban = $bans[$i];
if (($ban == $ip) || (fnmatch($ban,$ip))) $banned = true;
$ban_array = explode('.',$ban);
if (!is_numeric($ban_array[count($ban_array) - 1])) {
if (fnmatch($ban,gethostbyaddr($ip))) $banned = true;
}
}
return $banned;
}
function capitalize($string) {
if ($string) {
$string = explode(' ',$string);
$max = count($string);
for ($i = 0;$i < $max;$i++) $string[$i][0] = strtoupper($string[$i][0]);
$string = implode(' ',$string);
}
return $string;
}
function br2n($string) {
$string = str_replace("
","",$string);
$string = str_replace("\n","",$string);
return $string;
}
function doublePost($user,$post) {
$double = false;
$result = getRows(posts,"WHERE username='$user' ORDER BY id DESC LIMIT 10");
while ($row = mysql_fetch_array($result)) {
$message = $row['post'];
$message = explode('
',$message);
$message = $message[0];
if ($message == $post) $double = true;
}
if (!$post) $double = false;
return $double;
}
function fixArray($array) {
$array = explode('.',$array);
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if (!$array[$i]) unset($array[$i]);
}
$array = implode('.',$array);
return $array;
}
function clearRepeat($array) {
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if (!inArray($array[$i],$store)) $store[] = $array[$i];
}
return $store;
}
function fixInventory($user) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) {
$inventory = explode('.',$inventory);
$inventory = clearRepeat($inventory);
if ($inventory) $inventory = implode('.',$inventory);
else $inventory = '';
}
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
function drawCards($table,$num = 1) {
$deck = getInfo(deck,card_tables,"WHERE id='$table'");
$deck = explode('.',$deck);
for ($i = 1;$i <= $num;$i++) {
$cards[] = array_shift($deck);
if (!$deck) break;
}
if ($deck) $deck = implode('.',$deck);
else $deck = "";
$query = "UPDATE card_tables SET deck='$deck' WHERE id='$table'";
mysql_query($query);
return implode('.',$cards);
}
function cardHistory($table,$statement) {
$date = date('g:i A F jS Y');
$query = "INSERT INTO card_history VALUES('','$table','$date','$statement')";
mysql_query($query);
}
function changeTurn($table) {
$current = getInfo(turn,card_tables,"WHERE id='$table'");
$round = getInfo("round",card_tables,"WHERE id='$table'");
$dealer = getInfo(dealer,card_tables,"WHERE id='$table'");
$result = getRows(card_hands,"WHERE cardtable='$table' and user!='$dealer' and status='play'");
while ($row = mysql_fetch_array($result)) {
$players[] = $row['user'];
}
$players[] = $dealer;
$position = position($current,$players);
$max = count($players);
if (($position >= $max - 1) || ($position < 0)) {
$turn = 0;
$round += 1;
$query = "UPDATE card_tables SET round='$round' WHERE id='$table'";
mysql_query($query);
} else $turn = $position + 1;
$turn = $players[$turn];
if (($round >= getInfo(max_turns,card_tables,"WHERE id='$table'")) && (getInfo(max_turns,card_tables,"WHERE id='$table'"))) $turn = 0;
$query = "UPDATE card_tables SET turn='$turn' WHERE id='$table'";
mysql_query($query);
}
function clearArray($array,$symbol,$noitem = "") {
$array = explode($symbol,$array);
$max = count($array);
for ($i = 0;$i < $max;$i++) {
if (!$array[$i]) unset($array[$i]);
$item = $array[$i];
$item = getInfo(item,user_items,"WHERE id='$item'");
if (!$noitem) if (!getInfo(name,items,"WHERE id='$item'")) unset($array[$i]);
}
$array = implode($symbol,$array);
return $array;
}
function doublePostOOC($user,$post) {
$double = false;
$max = numRows(ooc);
$count = 0;
for ($i = $max;($i > 0) && ($counter <= 5);$i--) {
$conditions = "WHERE id='$i'";
$poster = getInfo(user,ooc,$conditions);
if ($poster == $user) {
$count++;
$message = addslashes(getInfo(post,ooc,$conditions));
if ($message == $post) $double = true;
}
}
return $double;
}
function last($post,$room,$user) {
$max = numRows(posts);
$result = false;
$search = getRows(posts,"WHERE thread_id='$room' and username!='1' ORDER BY id desc LIMIT 1");
while ($row = mysql_fetch_array($search)) {
$last = $row['id'];
$command = $row['command'];
}
if ($last == $post) if (($user == getInfo(username,posts,"WHERE id='$last'")) && ($command != "attack") && ($command != "consume") && ($command != "counter") && ($command != "counterattack") && ($command != "takeblow") && ($command != "takeblowother") && ($command != "loot") && ($command != "move") && ($command != "attack") && ($command != "steal") && ($command != "carry") && ($command != "heal") && ($command != "slay") && ($command != "sacrifice") && ($command != "drag") && ($command != "pickpocket") && ($command != "escort") && ($command != "take") && ($command != "immobilize") && ($command != "free") && ($command != "resist") && ($command != "breakfree") && ($command != "free") && ($command != "arrowlong") && ($command != "dismember") && ($command != "sendletter") && ($command != "stealstock") && ($command != "pickup") && ($command != "bribe") && ($command != "createpot") && ($command != "joinpot") && ($command != "strip") && ($command != "block") && ($command != "unblock") && ($command != "give") && ($command != "callpot") && ($command != "raisepot") && ($command != "foldpot")) $result = true;
return $result;
}
function bannedNum() {
$max = numRows(users);
$count = 0;
for ($i = 1;$i <= $max;$i++) {
if (getInfo(status,users,"WHERE id='$i'") == "banned") $count++;
}
return $count;
}
function dismember($user,$name,$description) {
$description = addslashes($description);
$query = "INSERT INTO items VALUES('','$name','','$description','','$user','relic','','','','','','','','','')";
mysql_query($query);
$item = numRows(items);
$query = "INSERT INTO user_items VALUES('','$name','relic','$item','','','','','','')";
mysql_query($query);
return numRows(user_items);
}
function createItem($item,$amount = 1) {
$conditions = "WHERE id='$item'";
$name = addslashes(getInfo(name,items,$conditions));
if ($name) {
$type = getInfo(type,items,$conditions);
if ($type == "other") $written = addslashes(getInfo(description,items,$conditions));
$portions = getInfo(portions,items,$conditions);
$stat = getInfo(stat,items,$conditions);
$enchantment = getInfo(enchantment,items,$conditions);
$spell = getInfo(spell,enchantments,"WHERE id='$enchantment'");
$mana = getInfo(mana,enchantments,"WHERE id='$enchantment'");
$var1 = getInfo(var1,enchantments,"WHERE id='$enchantment'");
$var2 = getInfo(var2,enchantments,"WHERE id='$enchantment'");
$var3 = getInfo(var3,enchantments,"WHERE id='$enchantment'");
$extra = getInfo(extra,items,$conditions);
for ($i = 1;$i <= $amount;$i++) {
if ($enchantment) {
$query = "INSERT INTO enchantments VALUES('','$spell','$mana','$var1','$var2','$var3')";
mysql_query($query);
$new_enchantment = numRows(enchantments);
} else $new_enchantment = "";
$query = "INSERT INTO user_items VALUES('','$name','$type','$item','$portions','$stat','','$written','$new_enchantment','$extra')";
mysql_query($query);
if ($items) $items .= '.'.numRows(user_items);
else $items = numRows(user_items);
}
}
return $items;
}
function sidesStatmax($user,$nobonus = false) {
#rank
$rank = 10;
#slave
if (getInfo(master,users,"WHERE id='$user'")) $rank = 0;
#knights
$max = numRows(lords);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$knights = getInfo(knights,lords,$conditions);
$knights = explode('.',$knights);
if (inArray($user,$knights)) {
$lord = getInfo(name,lords,$conditions);
if (numRowsConditions(places,"WHERE abandoned='' and owner='$lord' and type='30'") > 0) $rank = 30;
}
}
#lords
$max = numRows(lords);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$name = getInfo(name,lords,$conditions);
if ($name == $user) {
if (numRowsConditions(places,"WHERE abandoned='' and owner='$name' and type='30'") > 0) $rank = 40;
}
}
#barons
$max = numRows(towns);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i' and type='town'";
$leader = getInfo(leader,towns,$conditions);
if ($leader == $user) {
$rank = 50;
}
}
#kings
$max = numRows(kingdoms);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$leader = getInfo(leader,kingdoms,$conditions);
if ($leader == $user) {
$rank = 60;
if (numRowsConditions(towns,"WHERE kingdom='$i'") > 1) $rank = 70;
}
}
#administrator
if (admin($user)) $rank = 1000;
$rankStatmax = getInfo(maxstat,ranks,"WHERE level='$rank'");
#statmax via kills
$statmax = 0;
$max = numRows(murders);
for ($i = 1;$i <= $max;$i++) {
$conditions = "WHERE id='$i'";
$murderer = getInfo(murderer,murders,$conditions);
if ($murderer == $user) {
$deadstatmax = getInfo(statmax,murders,$conditions);
if ($deadstatmax > $statmax) $statmax = $deadstatmax;
}
}
if (getInfo(NPC,users,"WHERE id='$user'")) $statmax = 100;
if ((getInfo(personal,users,"WHERE id='$user'") == "jester") || (getInfo(personal,users,"WHERE id='$user'") == "bard")) {
$statmax = round($statmax / 2);
$rankStatmax = round($rankStatmax / 2);
}
if ((getInfo(bonus,users,"WHERE id='$user'") == "archer") && (!$nobonus)) {
$statmax = round($statmax * 0.75);
$rankStatmax = round($rankStatmax * 0.75);
}
if ((getInfo("class",users,"WHERE id='$user'") == "assassin") && (getInfo(mode,users,"WHERE id='$user'") != "stealth")) {
$statmax = round($statmax * 0.5);
$rankStatmax = round($rankStatmax * 0.5);
}
if (getInfo("class",users,"WHERE id='$user'") == "thief") {
$statmax = round($statmax * 0.75);
$rankStatmax = round($rankStatmax * 0.75);
}
if ($statmax > $rankStatmax) return $statmax;
else return $rankStatmax;
}
function sides($user) {
$statmax = sidesStatmax($user);
$health = getInfo(health,users,"WHERE id='$user'");
$sides = $statmax - round((statmax($user) - $health) / 2);
return $sides;
}
function sameUser($user1,$user2) {
$return = false;
$max = numRows(accounts);
for ($i = 1;$i <= $max;$i++) {
$characters = getInfo(characters,accounts,"WHERE id='$i'");
$characters = explode('.',$characters);
if (inArray($user1,$characters)) {
if (inArray($user2,$characters)) {
$return = true;
}
}
}
return $return;
}
function getCharacters($user) {
$user = strtolower($user);
$return = false;
$max = numRows(accounts);
for ($i = 1;$i <= $max;$i++) {
$characters = getInfo(characters,accounts,"WHERE id='$i'");
$characters_array = explode('.',strtolower($characters));
if (inArray($user,$characters_array)) {
$return = $characters;
}
}
return $return;
}
function getAccount($user) {
$user = strtolower($user);
$return = false;
$result = getRows(accounts,"WHERE characters like '%$user%' or dead like '%$user%'");
while ($row = mysql_fetch_array($result)) {
$characters = $row['characters'].'.'.$row['dead'];
$characters_array = explode('.',strtolower($characters));
if (inArray($user,$characters_array)) {
$return = $row['id'];
}
}
return $return;
}
function getDead($user) {
$user = strtolower($user);
$return = false;
$max = numRows(accounts);
for ($i = 1;$i <= $max;$i++) {
$characters = getInfo(dead,accounts,"WHERE id='$i'");
$characters_array = explode('.',strtolower($characters));
if (inArray($user,$characters_array)) {
$return = $characters;
}
}
return $return;
}
function employee($user,$place) {
$employees = getInfo(employees,places,"WHERE id='$place'");
$employees = explode('.',$employees);
if (inArray($user,$employees)) return true;
elseif (getInfo(owner,places,"WHERE id='$place'") == $user) return true;
else return false;
}
function items($user,$type) {
$inventory = getInfo(overhead,users,"WHERE id='$user'").'.'.getInfo(clothes,users,"WHERE id='$user'").'.'.getInfo(behind,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if ((getInfo(type,user_items,"WHERE id='$item'") == $type) && (getInfo(portions,user_items,"WHERE id='$item'") > 0)) {
$items[$item] = getInfo("stat",user_items,"WHERE id='$item'");
}
}
arsort($items);
foreach ($items as $key => $value) {
$objects[] = $key;
}
$object1 = $objects[0];
$object2 = $objects[1];
$stat1 = getInfo("stat",user_items,"WHERE id='$object1'");
$stat2 = getInfo("stat",user_items,"WHERE id='$object2'");
if ($stat1 != $stat2) {
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if ((getInfo("stat",user_items,"WHERE id='$item'") == $stat1) && (getInfo(type,user_items,"WHERE id='$item'") == $type)) $objects1[$item] = getInfo(portions,user_items,"WHERE id='$item'");
if ((getInfo("stat",user_items,"WHERE id='$item'") == $stat2) && (getInfo(type,user_items,"WHERE id='$item'") == $type)) $objects2[$item] = getInfo(portions,user_items,"WHERE id='$item'");
}
arsort($objects1);
foreach ($objects1 as $key => $value) {
$item1 = $key;
break;
}
arsort($objects2);
foreach ($objects2 as $key => $value) {
$item2 = $key;
break;
}
} else {
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if ((getInfo("stat",user_items,"WHERE id='$item'") == $stat1) && (getInfo(type,user_items,"WHERE id='$item'") == $type)) $objects1[$item] = getInfo(portions,user_items,"WHERE id='$item'");
}
arsort($objects1);
$count = 1;
foreach ($objects1 as $key => $value) {
if ($count == 1) $item1 = $key;
if ($count == 2) $item2 = $key;
$count++;
if ($count == 3) break;
}
}
if ($type == "weapon") $return = $item1;
if ($type == "epic") $return = $item1;
if ($type == "armour") $return = $item1.'.'.$item2;
return $return;
}
function poisonStat($user) {
$item = items($user,"weapon");
if (getInfo(poison,user_items,"WHERE id='$item'")) $poison = explode(':',getInfo(poison,user_items,"WHERE id='$item'"));
else $poison = 0;
return $poison;
}
function itemStat($user,$type,$damage = 0) {
$damageBonus = 0;
if (!getInfo(id,punishments,"WHERE user='$user' and type='arms'")) {
$inventory = explode('.',items($user,$type));
$count = 0;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
$record = getInfo(item,user_items,"WHERE id='$item'");
if ((getInfo(type,user_items,"WHERE id='$item'") == $type) || (getInfo(type,user_items,"WHERE id='$item'") == "epic")) {
$count++;
if ($type != "epic") {
$weaponHealth = getInfo(portions,user_items,"WHERE id='$item'");
$weaponStat = getInfo(stat,user_items,"WHERE id='$item'");
if (getInfo(type,user_items,"WHERE id='$item'") == "epic") {
if ($type == "weapon") $mult = 9;
if ($type == "armour") $mult = 13;
$weaponStat = round(($weaponStat / 10) * $mult);
}
if ($type == "armour") {
if ($damage < $damageBonus) $weaponDamage = $damage;
else $weaponDamage = $weaponStat;
} else $weaponDamage = $weaponStat;
if ($weaponHealth < $weaponDamage) {
$damageBonus += $weaponHealth;
$weaponHealth = 0;
$remWeapon = true;
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$overhead = removeElement($item,$overhead,'.');
$underhead = getInfo(clothes,users,"WHERE id='$user'");
$underhead = removeElement($item,$underhead,'.');
$behind = getInfo(behind,users,"WHERE id='$user'");
$behind = removeElement($item,$behind,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET clothes='$underhead' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET behind='$behind' WHERE id='$user'";
mysql_query($query);
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
} else {
$damageBonus += $weaponStat;
if ($type == "armour") {
if ($damage < $damageBonus) $weaponHealth -= $damage;
else $weaponHealth -= $weaponStat;
} else {
$weaponHealth -= $weaponStat;
}
}
$query = "UPDATE user_items SET portions='$weaponHealth' WHERE id='$item'";
mysql_query($query);
} else {
if (getInfo(type,user_items,"WHERE id='$item'") == "epic") {
return (getInfo(stat,user_items,"WHERE id='$item'") * 2);
break;
}
}
if ($type == "armour") {
if ($count >= 2) break;
}
if ($type == "weapon") {
if ($count >= 1) break;
}
if ($type == "epic") {
if ($count >= 1) break;
}
}
}
if ($type == "armour") {
if (getInfo(bonus,users,"WHERE id='$user'") == "sturdy") $damageBonus += 10;
}
if ($type == "weapon") {
if (getInfo(bonus,users,"WHERE id='$user'") == "strong") $damageBonus += 5;
}
if ($type == "weapon") {
$mount = getInfo(mount,users,"WHERE id='$user'");
if ($mount) {
$mountdamage = getInfo(damage,mounts,"WHERE npc='$mount'");
$mood = getInfo(mood,mounts,"WHERE npc='$mount'");
if ($mood < 0) $mountdamage += abs($mood * 0.12);
$damageBonus += floor($mountdamage);
}
}
}
$animal = getInfo(animal,npcs,"WHERE name='$user'");
if ($animal) {
if ($type == "armour") {
$damageBonus = getInfo(armour,npc_animals,"WHERE id='$animal'");
$ahealth = getInfo(ahealth,loot_animals,"WHERE npc='$user'");
if ($damage > $damageBonus) $damage = $damageBonus;
$ahealth -= $damage;
if ($ahealth <= 0) {
$ahealth = 0;
$query = "UPDATE loot_animals SET armour='0' WHERE npc='$user'";
mysql_query($query);
}
$query = "UPDATE loot_animals SET ahealth='$ahealth' WHERE npc='$user'";
mysql_query($query);
}
if ($type == "weapon") {
$damageBonus = getInfo(weapon,npc_animals,"WHERE id='$animal'");
$whealth = getInfo(whealth,loot_animals,"WHERE npc='$user'");
$whealth -= $damageBonus;
if ($whealth <= 0) {
$whealth = 0;
$query = "UPDATE loot_animals SET weapon='0' WHERE npc='$user'";
mysql_query($query);
}
$query = "UPDATE loot_animals SET whealth='$whealth' WHERE npc='$user'";
mysql_query($query);
}
}
return $damageBonus;
}
function assets($user) {
$money = getInfo(money,users,"WHERE id='$user'");
$money += getInfo(money,banks,"WHERE username='$user'");
$result = getRows(places,"WHERE owner='$user' and money>'0' and abandoned=''");
while ($row = mysql_fetch_array($result)) {
$money += $row['money'];
}
$amount = round($money * ($amount * 0.01));
$result = getRows(towns,"WHERE leader='$user'");
while ($row = mysql_fetch_array($result)) {
if ($row['seaside']) $money += 6000;
else $money += 5000;
}
$result = getRows(users,"WHERE master='$user'");
while ($row = mysql_fetch_array($result)) {
$money += 300;
}
return $money;
}
function clearDoubles($string) {
return str_replace("
","
",$string);
}
function nextId($tablename) {
$next_increment = 0;
$qShowStatus = "SHOW TABLE STATUS LIKE '$tablename'";
$qShowStatusResult = mysql_query($qShowStatus) or die ( "Query failed: ".mysql_error()."
" .$qShowStatus);
$row = mysql_fetch_assoc($qShowStatusResult);
$next_increment = $row['Auto_increment'];
return $next_increment;
}
function clearInventory($user) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) {
$inventory = explode('.',$inventory);
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
if (($inventory[$i] == "Item") || (!$inventory[$i]) || (!getInfo(id,user_items,"WHERE id='".$inventory[$i]."'"))) unset($inventory[$i]);
}
$inventory = implode('.',$inventory);
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
return $inventory;
}
function npclimit($user) {
$rank = rank($user);
$npcs = getInfo(npcs,ranks,"WHERE level='$rank'");
$count = 0;
$result = getRows(users,"WHERE NPC='$user' and status!='dead'");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (!getInfo(animal,npcs,"WHERE name='$npc'")) $count++;
}
if ($count >= $npcs) $return = false;
else $return = true;
if ($npcs == 0) $return = true;
if ($rank == 0) $return = false;
return $return;
}
function cityGuards($town) {
$guards = numRowsConditions(users,"WHERE guard='$town' and status='conscious' and town='$town'");
$leader = getInfo(leader,towns,"WHERE id='$town'");
if (($guards > 0) || (getInfo(town,users,"WHERE id='$leader'") == $town)) $return = true;
else $return = false;
return $return;
}
function counter($user,$rolls,$damages,$destination = 0) {
$userId = $GLOBALS['userId'];
if ($destination) {
if ($destination == "archery") {
$archery = "archery";
$destination = 0;
}
}
$npc = $user;
$npcname = getInfo(username,users,"WHERE id='$npc'");
$rolls = explode('.',$rolls);
$damages = explode('.',$damages);
$max = count($rolls);
$i = -1;
$god = '';
do {
$i++;
$roll = $rolls[$i];
$counterRoll = rand(1,getInfo(type,npcs,"WHERE name='$npc'") - round((getInfo(type,npcs,"WHERE name='$npc'") - getInfo(health,users,"WHERE id='$npc'")) / 2)) + rand(1,100);
if ($roll <= $counterRoll) {
$god .= "$npcname successfully countered attack ".($i + 1).". $npcname rolled $counterRoll and ".$GLOBALS['user_name']." rolled $roll.
";
} else {
$absorb = itemStat($npc,"armour",$damages[$i]);
if ($damages[$i] - $absorb < 0) $absorb = $damages[$i];
$god .= "$npcname failed to counter attack ".($i + 1).". $npcname rolled $counterRoll and ".$GLOBALS['user_name']." rolled $roll. ".($damages[$i] - $absorb)." damage was dealt.";
$failed = true;
}
} while (($i < $max - 1) && (!$failed));
if ($failed) {
$hitcount = 1;
$totalDamage = $damages[$i];
$totalDamage -= $absorb;
if ($absorb) $god .= " ".$absorb." damage was absorbed by the armour.";
$god .= '
';
if ($i < $max - 1) {
for ($i = $i + 1;$i < $max;$i++) {
$hitcount++;
$totalDamage += $damages[$i];
$absorb = itemStat($npc,"armour",$damages[$i]);
if ($damages[$i] - $absorb < 0) $absorb = $damages[$i];
$god .= "$npcname subsequently failed to counter attack ".($i + 1).". ".($damages[$i] - $absorb)." damage was dealt.";
$totalDamage -= $absorb;
if ($absorb) $god .= " [".$absorb." damage was absorbed by the armour]";
$god .= '
';
}
}
$userId = $GLOBALS['userId'];
if ($archery) {
$archery = getInfo(archery,users,"WHERE id='$userId'");
$archery++;
if ($archery > 450) $archery = 450;
$query = "UPDATE users SET archery='$archery' WHERE id='$userId'";
mysql_query($query);
} else {
if (($damages[$i] >= 10) && (getInfo(animal,npcs,"WHERE name='$npc'"))) {
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
//sendMessage("Irshad","Hitcount","NPC : $npc $npcname
$animal
".getInfo(aggressive,npc_animals,"WHERE id='$animal'"),"God");
if (getInfo(aggressive,npc_animals,"WHERE id='$animal'")) {
$hitcount += getInfo(hitcount,users,"WHERE id='$userId'");
$query = "UPDATE users SET hitcount='$hitcount' WHERE id='$userId'";
mysql_query($query);
}
}
}
$health = getInfo(health,users,"WHERE id='$npc'");
$health -= $totalDamage;
if ($health <= 0) {
$health = 0;
if ((rand(1,100) <= 80) && (!getInfo(id,npc_citizens,"WHERE npc='$npc'"))) {
$query = "UPDATE users SET NPC='*' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='dead' WHERE id='$npc'";
mysql_query($query);
$status = "dead";
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
$query = "UPDATE users SET dismembered='$animal' WHERE id='$npc'";
mysql_query($query);
} else {
$query = "UPDATE users SET dismembered='dismembered' WHERE id='$npc'";
mysql_query($query);
}
$npcname = getInfo(username,users,"WHERE id='$npc'");
$query = "UPDATE creature_names SET used='' WHERE name='$npcname'";
mysql_query($query);
$query = "UPDATE citizen_names SET used='' WHERE name='$npcname'";
mysql_query($query);
$query = "DELETE FROM npcs WHERE name='$npc'";
mysql_query($query);
} else {
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='unconscious' WHERE id='$npc'";
$status = "unconscious";
}
mysql_query($query);
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$npc'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='".$GLOBALS['user_name']."' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$GLOBALS['user_name'].", by knocking out your last present guard.","God");
sendMessage($GLOBALS['user_name'],"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$npc'";
mysql_query($query);
if ($status == "unconscious") $god .= $npcname." was knocked out.";
if ($status == "dead") {
$god .= $npcname." was killed.";
}
if (getInfo(id,users,"WHERE mount='$npc'")) {
$mountuser = getInfo(id,users,"WHERE mount='$npc'");
$mountusername = getInfo(username,users,"WHERE id='$mountuser'");
if ($health <= 0) {
$mountdamage = rand(40,60);
$absorb = itemStat($userId,"armour",$damage);
$mountdamage -= $absorb;
$god .= " $mountusername fell to the ground, losing $mountdamage health ($absorb damage absorbed by armour).";
if (damage($mountuser,$mountdamage) == "unconscious") $god .= " $mountusername is now unconscious.";
} else {
if (rand(1,$totalDamage) > getInfo(pain,mounts,"WHERE npc='$npc'")) {
$roll = rand(1,$totalDamage) + 50;
$query = "INSERT INTO mount_throw VALUES('','$mountuser','$npc','$roll')";
mysql_query($query);
$god .= "$npcname panicked and attempted to throw $mountusername from its back.";
}
}
}
$id = getInfo(room,users,"WHERE id='$npc'");
$buildingId = getInfo(place,rooms,"WHERE id='$id'");
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (($destination) && (!getInfo(guardin,rooms,"WHERE id='$room_id'"))) {
if ($destination == "overboard") {
move($npc,"overboard");
$god .= "
".$npcname." was thrown overboard.";
} else {
$destPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationRoomName = getInfo(name,rooms,"WHERE id='$destination'");
$destinationPlaceName = getInfo(name,places,"WHERE id='$destPlace'");
move($npc,$destination);
$god .= "
".$npcname." was thrown into ".$destinationRoomName." in ".$destinationPlaceName.".";
}
$query = "UPDATE users SET chained='' WHERE id='$npc'";
mysql_query($query);
}
}
return $god;
}
function animalcounter($user,$rolls,$damages,$offense) {
$npc = $user;
$npcname = getInfo(username,users,"WHERE id='$npc'");
$offensename = getInfo(username,users,"WHERE id='$offense'");
$rolls = explode('.',$rolls);
$damages = explode('.',$damages);
$max = count($rolls);
$i = -1;
$god = '';
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
do {
$i++;
$roll = $rolls[$i];
$maxRoll = getInfo(roll,animals,"WHERE id='$animal'");
if (!$maxRoll) $maxRoll = 100;
$counterRoll = rand(1,$maxRoll - round((getInfo(type,npcs,"WHERE name='$npc'") - getInfo(health,users,"WHERE id='$npc'")) / 2)) + rand(1,100) - getInfo(vulnerability,users,"WHERE id='$npc'");
if ($roll <= $counterRoll) {
$god .= "$npcname successfully countered attack ".($i + 1).". $npcname rolled $counterRoll and ".$offensename." rolled $roll.
";
} else {
$absorb = itemStat($npc,"armour",$damages[$i]);
if ($damages[$i] - $absorb < 0) $absorb = $damages[$i];
$god .= "$npcname failed to counter attack ".($i + 1).". $npcname rolled $counterRoll and ".$offensename." rolled $roll. ".($damages[$i] - $absorb)." damage was dealt.";
$failed = true;
}
} while (($i < $max - 1) && (!$failed));
if ($failed) {
$totalDamage = $damages[$i];
$totalDamage -= $absorb;
if ($absorb) $god .= " ".$absorb." damage was absorbed by the armour.";
$god .= '
';
if ($i < $max - 1) {
for ($i = $i + 1;$i < $max;$i++) {
$totalDamage += $damages[$i];
$absorb = itemStat($npc,"armour",$damages[$i]);
if ($damages[$i] - $absorb < 0) $absorb = $damages[$i];
$god .= "$npcname subsequently failed to counter attack ".($i + 1).". ".($damages[$i] - $absorb)." damage was dealt.";
$totalDamage -= $absorb;
if ($absorb) $god .= " [".$absorb." damage was absorbed by the armour]";
$god .= '
';
}
}
$health = getInfo(health,users,"WHERE id='$npc'");
$health -= $totalDamage;
if ($health <= 0) {
$health = 0;
if (rand(1,100) <= 80) {
$query = "UPDATE users SET NPC='*' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='dead' WHERE id='$npc'";
mysql_query($query);
$status = "dead";
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
$query = "UPDATE users SET dismembered='$animal' WHERE id='$npc'";
mysql_query($query);
} else {
$query = "UPDATE users SET dismembered='dismembered' WHERE id='$npc'";
mysql_query($query);
}
$npcname = getInfo(username,users,"WHERE id='$npc'");
$query = "UPDATE creature_names SET used='' WHERE name='$npcname'";
mysql_query($query);
$query = "UPDATE citizen_names SET used='' WHERE name='$npcname'";
mysql_query($query);
$query = "DELETE FROM npcs WHERE name='$npc'";
mysql_query($query);
} else {
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='unconscious' WHERE id='$npc'";
$status = "unconscious";
}
mysql_query($query);
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$npc'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='".$offensename."' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$offensename.", by knocking out your last present guard.","God");
sendMessage($GLOBALS['user_name'],"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$npc'";
mysql_query($query);
if ($status == "unconscious") $god .= $npcname." was knocked out.";
if ($status == "dead") {
$god .= $npcname." was killed.";
$query = "UPDATE users SET NPC='*' WHERE id='$npc'";
mysql_query($query);
}
if (getInfo(id,users,"WHERE mount='$npc'")) {
$mountuser = getInfo(id,users,"WHERE mount='$npc'");
$mountusername = getInfo(username,users,"WHERE id='$mountuser'");
if ($health <= 0) {
$mountdamage = rand(40,60);
$absorb = itemStat($userId,"armour",$damage);
$mountdamage -= $absorb;
$god .= " $mountusername fell to the ground, losing $mountdamage health ($absorb damage absorbed by armour).";
if (damage($mountuser,$mountdamage) == "unconscious") $god .= " $mountusername is now unconscious.";
} else {
if (rand(1,$totalDamage) > getInfo(pain,mounts,"WHERE npc='$npc'")) {
$roll = rand(1,$totalDamage) + 50;
$query = "INSERT INTO mount_throw VALUES('','$mountuser','$npc','$roll')";
mysql_query($query);
$god .= "$npcname panicked and attempted to throw $mountusername from its back.";
}
}
}
}
return $god;
}
function takeblow($user,$damages) {
$npc = $user;
$npcname = getInfo(username,users,"WHERE id='$npc'");
$damages = explode('.',$damages);
$max = count($damages);
$damageTotal = 0;
$absorbTotal = 0;
for ($i = 0;$i < $max;$i++) {
$damage = $damages[$i];
$absorb = itemStat($user,"armour",$damage);
$damage -= $absorb;
$absorbTotal += $absorb;
$damageTotal += $damage;
}
if ($damageTotal < 0) $damageTotal = 0;
$health = getInfo(health,users,"WHERE id='$npc'");
$health -= $damageTotal;
if ($health <= 0) {
$health = 0;
if (rand(1,100) <= 80) {
$query = "UPDATE users SET NPC='*' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='dead' WHERE id='$npc'";
mysql_query($query);
$status = "dead";
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
$query = "UPDATE users SET dismembered='$animal' WHERE id='$npc'";
mysql_query($query);
} else {
$query = "UPDATE users SET dismembered='dismembered' WHERE id='$npc'";
mysql_query($query);
}
$npcname = getInfo(username,users,"WHERE id='$npc'");
$query = "UPDATE creature_names SET used='' WHERE name='$npcname'";
mysql_query($query);
$query = "UPDATE citizen_names SET used='' WHERE name='$npcname'";
mysql_query($query);
$query = "DELETE FROM npcs WHERE name='$npc'";
mysql_query($query);
} else {
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='unconscious' WHERE id='$npc'";
$status = "unconscious";
}
mysql_query($query);
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$npc'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='".$GLOBALS['user_name']."' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$GLOBALS['user_name'].", by knocking out your last present guard.","God");
sendMessage($GLOBALS['user_name'],"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$npc'";
mysql_query($query);
$god = "$damageTotal damage was dealt ($absorbTotal damage was absorbed by armour)";
if ($status == "unconscious") $god .= "
".$npcname." was knocked out.";
if ($status == "dead") {
$god .= "
".$npcname." was killed.";
$query = "UPDATE users SET NPC='*' WHERE id='$npc'";
mysql_query($query);
}
return $god;
}
function react($npc,$victim) {
$victimname = getInfo(username,users,"WHERE id='$victim'");
$npcname = getInfo(username,users,"WHERE id='$npc'");
$room = getInfo(room,users,"WHERE id='$npc'");
if ((getInfo(counter,npcs,"WHERE name='$npc'") == "fight") && (getInfo(room,users,"WHERE id='$victim'") == $room) && (!getInfo(id,users,"WHERE mount='$npc'"))) {
$intensity = rand(1,3);
$roll = rand(1,getInfo(type,npcs,"WHERE name='$npc'") - round((getInfo(type,npcs,"WHERE name='$npc'") - getInfo(health,users,"WHERE id='$npc'")) / 2)) + rand(1,50);
switch ($intensity) {
case 1:
$damage = rand(1,40);
break;
case 2:
$damage = rand(31,70);
break;
case 3:
$damage = rand(71,100);
$roll = round($roll * 0.6);
break;
}
switch ($intensity) {
case 1:
$intense = "minor";
break;
case 2:
$intense = "moderate";
break;
case 3:
$intense = "major";
break;
}
$damageBonus = itemStat($npc,"weapon");
$damage += $damageBonus;
$party = getInfo(party,users,"WHERE id='$victim'");
if ($party) {
$result = getRows(users,"WHERE party='$party' and room='$room'");
while ($row = mysql_fetch_array($result)) {
$party_members[] = $row['id'];
}
$party_members = implode('.',$party_members);
} else $party_members = "";
$query = "INSERT INTO fights VALUES('','$npc','$victim','$roll','$damage','$intensity','','','1','','','$party_members','')";
mysql_query($query);
$god = "
$npcname $intense attacked $victimname.";
if ($damageBonus > 0) $post .= " - ".$damageBonus." damage bonus from weaponry";
}
if (getInfo(counter,npcs,"WHERE name='$npc'") == "run") {
$npctown = getInfo(town,users,"WHERE id='$npc'");
$npcroom = getInfo(room,users,"WHERE id='$npc'");
$destinations = destinations($npcroom,$npc);
$npcroom = $destinations[rand(0,count($destinations) - 1)];
$npcplace = getInfo(place,rooms,"WHERE id='$npcroom'");
if (($npcroom) && (($npcroom != "travel") || (rand(1,100) <= 20)) && (($npcroom != "overboard") || (rand(1,100) <= 10))) {
move($npc,$npcroom);
$god = "
$npcname ran away.";
}
}
return $god;
}
function npcattack($npc,$victim) {
$victimname = getInfo(username,users,"WHERE id='$victim'");
$npcname = getInfo(username,users,"WHERE id='$npc'");
$room = getInfo(room,users,"WHERE id='$npc'");
$intensity = rand(1,3);
$roll = rand(1,100 - round((getInfo(type,npcs,"WHERE name='$npc'") - getInfo(health,users,"WHERE id='$npc'")) / 2)) + rand(1,50) + 50;
switch ($intensity) {
case 1:
$damage = rand(1,30);
break;
case 2:
$damage = rand(31,70);
break;
case 3:
$damage = rand(71,100);
$roll = round($roll * 0.6);
break;
}
switch ($intensity) {
case 1:
$intense = "minor";
break;
case 2:
$intense = "moderate";
break;
case 3:
$intense = "major";
break;
}
$damageBonus = itemStat($npc,"weapon");
$damage += $damageBonus;
$party = getInfo(party,users,"WHERE id='$victim'");
if ($party) {
$result = getRows(users,"WHERE party='$party' and room='$room'");
while ($row = mysql_fetch_array($result)) {
$party_members[] = $row['id'];
}
$party_members = implode('.',$party_members);
} else $party_members = "";
$query = "INSERT INTO fights VALUES('','$npc','$victim','$roll','$damage','$intensity','','','1','','','$party_members','')";
mysql_query($query);
$god = "
$npcname $intense attacked $victimname.";
if ($damageBonus > 0) $god .= " - ".$damageBonus." damage bonus from weaponry";
if (getInfo(NPC,users,"WHERE id='$victim'")) {
$time = time() + (60 * 15);
$query = "INSERT INTO npc_fights VALUES('','$npc','$victim','$fight','$attackType','$target','$time')";
mysql_query($query);
}
return $god;
}
function translate($post,$user) {
$username = getInfo(username,users,"WHERE id='$user'");
$sex = getInfo(sex,users,"WHERE id='$user'");
if ($sex == "f") {
$he = "she";
$his = "her";
$him = "her";
} else {
$he = "he";
$his = "his";
$him = "him";
}
$post = str_replace("username",$username,$post);
$post = str_replace(" he ",' '.$he.' ',$post);
$post = str_replace(" his ",' '.$his.' ',$post);
$post = str_replace(" him ",' '.$him.' ',$post);
$post = str_replace(" he.",' '.$he.'.',$post);
$post = str_replace(" his.",' '.$his.'.',$post);
$post = str_replace(" him.",' '.$him.'.',$post);
$post = str_replace(" he,",' '.$he.',',$post);
$post = str_replace(" his,",' '.$his.',',$post);
$post = str_replace(" him,",' '.$him.',',$post);
return $post;
}
function translate2($post,$user) {
$username = " %username";
$sex = getInfo(sex,users,"WHERE id='$user'");
if ($sex == "f") {
$he = "%he";
$his = "%his";
$him = "%him";
} else {
$he = "%he";
$his = "%his";
$him = "%him";
}
$post = str_replace(" username",$username,$post);
$post = str_replace(" he ",' '.$he.' ',$post);
$post = str_replace(" his ",' '.$his.' ',$post);
$post = str_replace(" him ",' '.$him.' ',$post);
$post = str_replace(" he.",' '.$he.'.',$post);
$post = str_replace(" his.",' '.$his.'.',$post);
$post = str_replace(" him.",' '.$him.'.',$post);
$post = str_replace(" he,",' '.$he.',',$post);
$post = str_replace(" his,",' '.$his.',',$post);
$post = str_replace(" him,",' '.$him.',',$post);
return $post;
}
function gridtocoord($x,$y) {
$x *= 53.21;
$y *= 53.21;
return "$x,$y";
}
//x - 53.5
//y + 10 / 49.6
function coordtogrid($x,$y) {
$x = floor(($x / 53.5) + 1);
$y = floor((($y) / 51.18) + 0.5 + (1200 / (($y * $y * ($y - 66)))));
return "$x,$y";
}
function translateNPC($post,$user,$npc) {
$npcgroup = getInfo(npcgroup,npcs,"WHERE name='$npc'");
$tribe = getInfo(id,tribes,"WHERE hunters='$npcgroup' or villagers='$npcgroup'");
if (!$tribe) {
$tribe = getInfo(tribe,npcs,"WHERE name='$npc'");
}
if ($tribe) {
$village = getInfo(village,tribes,"WHERE id='$tribe'");
$town = getInfo(town,users,"WHERE id='$user'");
if ($town) {
$place = getInfo(location,users,"WHERE id='$user'");
$x = getInfo(x,transport,"WHERE place='$place'");
$y = getInfo(y,transport,"WHERE place='$place'");
} else {
$x = getInfo(x,towns,"WHERE id='$town'");
$y = getInfo(y,towns,"WHERE id='$town'");
}
$vx = getInfo(x,towns,"WHERE id='$village'");
$vy = getInfo(y,towns,"WHERE id='$village'");
$dx = $vx - $x;
$dy = $vy - $y;
$angle = abs(rad2deg(atan($dy/$dx)));
if ($angle < 30) {
if ($dx > 0) $direction = "east";
else $direction = "west";
} elseif ($angle > 60) {
if ($dy > 0) $direction = "south";
else $direction = "north";
} else {
if ($dx > 0) {
if ($dy > 0) $direction = "southeast";
else $direction = "northeast";
} else {
if ($dy > 0) $direction = "southwest";
else $direction = "northwest";
}
}
}
$npcname = getInfo(username,users,"WHERE id='$npc'");
$username = getInfo(username,users,"WHERE id='$user'");
$sex = getInfo(sex,users,"WHERE id='$user'");
if ($sex == "f") {
$he = "she";
$his = "her";
$him = "her";
} elseif ($sex == "m") {
$he = "he";
$his = "his";
$him = "him";
} else {
$he = "it";
$his = "its";
$him = "it";
}
$post = str_replace("%direction",$direction,$post);
$post = str_replace("%npcname",$npcname,$post);
$post = str_replace("%username",$username,$post);
$post = str_replace("%he",$he,$post);
$post = str_replace("%his",$his,$post);
$post = str_replace("%him",$him,$post);
return $post;
}
function translateRumour($post,$npc,$user,$rumour) {
$rumour = getInfo(rumour,npc_rumours,"WHERE id='$rumour'");
$username = getInfo(username,users,"WHERE id='$user'");
$sex = getInfo(sex,users,"WHERE id='$user'");
if ($sex == "f") {
$he = "she";
$his = "her";
$him = "her";
$himself = "herself";
} elseif ($sex == "m") {
$he = "he";
$his = "his";
$him = "him";
$himself = "himself";
} else {
$he = "it";
$his = "its";
$him = "it";
$himself = "itself";
}
$npcname = getInfo(username,users,"WHERE id='$npc'");
$sex = getInfo(sex,users,"WHERE id='$npc'");
if ($sex == "f") {
$npche = "she";
$npchis = "her";
$npchim = "her";
$npchimself = "herself";
} elseif ($sex == "m") {
$npche = "he";
$npchis = "his";
$npchim = "him";
$npchimself = "himself";
} else {
$npche = "it";
$npchis = "its";
$npchim = "it";
$npchimself = "itself";
}
$post = str_replace("%username",$username,$post);
$post = str_replace("%npcname",$npcname,$post);
$post = str_replace("%rumour",$rumour,$post);
$post = str_replace("%he",' '.$he.' ',$post);
$post = str_replace("%his",' '.$his.' ',$post);
$post = str_replace("%himself",' '.$himself.' ',$post);
$post = str_replace("%him",' '.$him.' ',$post);
$post = str_replace("%He",' '.capitalize($he).' ',$post);
$post = str_replace("%His",' '.capitalize($his).' ',$post);
$post = str_replace("%Himself",' '.capitalize($himself).' ',$post);
$post = str_replace("%Him",' '.capitalize($him).' ',$post);
$post = str_replace("%npche",' '.$npche.' ',$post);
$post = str_replace("%npchis",' '.$npchis.' ',$post);
$post = str_replace("%npchimself",' '.$npchimself.' ',$post);
$post = str_replace("%npchim",' '.$npchim.' ',$post);
$post = str_replace("%npcHe",' '.capitalize($npche).' ',$post);
$post = str_replace("%npcHis",' '.capitalize($npchis).' ',$post);
$post = str_replace("%npcHimself",' '.capitalize($npchimself).' ',$post);
$post = str_replace("%npcHim",' '.capitalize($npchim).' ',$post);
return $post;
}
function translateCitizen($post,$user,$item) {
$username = getInfo(username,users,"WHERE id='$user'");
$sex = getInfo(sex,users,"WHERE id='$user'");
if ($sex == "f") {
$he = "she";
$his = "her";
$him = "her";
$himself = "herself";
} elseif ($sex == "m") {
$he = "he";
$his = "his";
$him = "him";
$himself = "himself";
} else {
$he = "it";
$his = "its";
$him = "it";
$himself = "itself";
}
$post = str_replace("%username",$username,$post);
$post = str_replace("%item",$item,$post);
$post = str_replace("%he",' '.$he.' ',$post);
$post = str_replace("%his",' '.$his.' ',$post);
$post = str_replace("%himself",' '.$himself.' ',$post);
$post = str_replace("%him",' '.$him.' ',$post);
$post = str_replace("%He",' '.capitalize($he).' ',$post);
$post = str_replace("%His",' '.capitalize($his).' ',$post);
$post = str_replace("%Himself",' '.capitalize($himself).' ',$post);
$post = str_replace("%Him",' '.capitalize($him).' ',$post);
return $post;
}
function animalattack($npc,$victim) {
$victimname = getInfo(username,users,"WHERE id='$victim'");
$npcname = getInfo(username,users,"WHERE id='$npc'");
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
$maxRoll = getInfo(roll,npc_animals,"WHERE id='$animal'");
$roll = rand(1,$maxRoll - round((getInfo(type,npcs,"WHERE name='$npc'") - getInfo(health,users,"WHERE id='$npc'")) / 2)) + rand(0,50);
$result = getRows(npc_actions,"WHERE animal='$animal' and type='attack'");
while ($row = mysql_fetch_array($result)) {
$attacks[] = $row['id'];
}
$attack = $attacks[rand(0,count($attacks) - 1)];
$post[0] = getInfo(post,npc_actions,"WHERE id='$attack'");
$post[0] = translateNPC($post[0],$victim,$npc);
$intensity = getInfo(intensity,npc_actions,"WHERE id='$attack'");
if ($intensity == "minor") $intensity = 1;
if ($intensity == "moderate") $intensity = 2;
if ($intensity == "major") $intensity = 3;
if (!$post[0]) {
$post[1] = "ooc";
$intensity = rand(1,3);
}
switch ($intensity) {
case 1:
$damage = rand(1,40);
$vuln = 25;
break;
case 2:
$damage = rand(31,70);
$vuln = 50;
break;
case 3:
$damage = rand(71,100);
$vuln = 100;
$roll = round($roll * 0.6);
break;
}
switch ($intensity) {
case 1:
$intense = "minor";
break;
case 2:
$intense = "moderate";
break;
case 3:
$intense = "major";
break;
}
$query = "UPDATE users SET vulnerability='$vuln' WHERE id='$npc'";
mysql_query($query);
$party = getInfo(party,users,"WHERE id='$victim'");
if ($party) {
$result = getRows(users,"WHERE party='$party' and room='$room'");
while ($row = mysql_fetch_array($result)) {
$party_members[] = $row['id'];
}
$party_members = implode('.',$party_members);
} else $party_members = "";
$damageBonus = itemStat($npc,"weapon");
$damage += $damageBonus;
$query = "INSERT INTO fights VALUES('','$npc','$victim','$roll','$damage','$intensity','','','1','','','$party_members','')";
mysql_query($query);
$fight = numRows(fights);
if (!$post[1]) {
$post[0] .= "
[$npcname $intense attacked $victimname";
if ($damageBonus > 0) $post[0] .= " - ".$damageBonus." damage bonus from weaponry";
$post[0] .= "]";
} else {
$post[0] .= "$npcname $intense attacked $victimname";
if ($damageBonus > 0) $post[0] .= " - ".$damageBonus." damage bonus from weaponry";
}
if (getInfo(NPC,users,"WHERE id='$victim'")) {
$attackType = getInfo(attack,npc_actions,"WHERE id='$attack'");
$target = getInfo(target,npc_actions,"WHERE id='$attack'");
$time = time() + (60 * 15);
$query = "INSERT INTO npc_fights VALUES('','$npc','$victim','$fight','$attackType','$target','$time')";
mysql_query($query);
}
return $post;
}
function createAnimal($animal,$group = 0,$owner = 1) {
$sex = getInfo(sex,npc_animals,"WHERE id='$animal'");
if (!$sex) {
$sex = rand(1,2);
if ($sex == 1) $sex = "m";
if ($sex == 2) $sex = "f";
}
$age = rand(2,5);
$species = getInfo(species,npc_animals,"WHERE id='$animal'");
$result = getRows(creature_names,"WHERE type='$species' and (sex='$sex' or sex='') and used=''");
while ($row = mysql_fetch_array($result)) $names[] = $row['name'];
if (!$names) {
$result = getRows(creature_names,"WHERE type='$species' and (sex='$sex' or sex='')");
while ($row = mysql_fetch_array($result)) $names[] = $row['name'];
}
$name = $names[rand(0,count($names) - 1)];
$species = capitalize($species);
if (!$name) $name = capitalize(getInfo(label,npc_animals,"WHERE id='$animal'"));
else {
$query = "UPDATE creature_names SET used='used' WHERE name='$name'";
mysql_query($query);
}
$weapon = getInfo(weapon,npc_animals,"WHERE id='$animal'");
$armour = getInfo(armour,npc_animals,"WHERE id='$animal'");
$whealth = getInfo(whealth,npc_animals,"WHERE id='$animal'");
$ahealth = getInfo(ahealth,npc_animals,"WHERE id='$animal'");
$health = getInfo(health,npc_animals,"WHERE id='$animal'");
$transformation = getInfo(transformation,npc_animals,"WHERE id='$animal'");
$transformation = explode('.',$transformation);
$rand = rand(0,count($transformation) - 1);
$transformation = $transformation[$rand];
$mounts = getInfo(mount,npc_animals,"WHERE id='$animal'");
$counter = getInfo(counter,npc_animals,"WHERE id='$animal'");
$protect = getInfo(protect,npc_animals,"WHERE id='$animal'");
$query = "INSERT INTO users VALUES('','$name','','','','','','$owner','','','','','','','$transformation','$transformation','','','','$age','$sex','$species','','10','conscious','','','','','','','','','','','','','','','','','$health','','150','','0','','','0','','','','','$animal','','','','','','','','','','','','','','','','','','','','','','')";
mysql_query($query);
$user_id = numRows(users);
$query = "INSERT INTO npcs VALUES('','$user_id','','','$group','$health','','','','wander','$counter','','$protect','$animal','','','','','','','','','')";
mysql_query($query);
$query = "INSERT INTO loot_animals VALUES('','$user_id','$weapon','$whealth','$armour','$ahealth','')";
mysql_query($query);
if ($mounts) {
$mounts = explode('.',$mounts);
$mount = $mounts[$rand];
$temper = getInfo(temper,npc_animals,"WHERE id='$animal'");
$temper = explode(',',$temper);
$temper = rand($temper[0],$temper[1]);
$riding = getInfo(riding,npc_animals,"WHERE id='$animal'");
$pain = getInfo(pain,npc_animals,"WHERE id='$animal'");
$speed = getInfo(speed,npc_animals,"WHERE id='$animal'");
$roll = getInfo(rollbonus,npc_animals,"WHERE id='$animal'");
$damage = getInfo(damage,npc_animals,"WHERE id='$animal'");
$query = "INSERT INTO mounts VALUES('','$user_id','$mount','$temper','$temper','','','$riding','$pain','$speed','$roll','$damage')";
mysql_query($query);
}
}
function employed($user,$type) {
if ($type == "miners") $type_id = 32;
if ($type == "builders") $type_id = 33;
if ($type == "smiths") $type_id = 34;
if ($type == "guards") $type_id = 35;
if ($type == "medics") $type_id = 36;
if ($type == "cooks") $type_id = 9;
if ($type == "shopkeepers") $type_id = 14;
$employed = 0;
$result = getRows(places,"WHERE type='$type_id' and (employees like '%$user%' or owner='$user')");
while ($row = mysql_fetch_array($result)) {
$employees = explode('.',$row['employees']);
if (inArray($user,$employees)) $employed = $row['id'];
}
return $employed;
}
function isEmployed($user) {
$employed = 0;
if (employed($user,"miners")) $employed = employed($user,"miners");
if (employed($user,"builders")) $employed = employed($user,"builders");
if (employed($user,"smiths")) $employed = employed($user,"smiths");
if (employed($user,"guards")) $employed = employed($user,"guards");
if (employed($user,"medics")) $employed = employed($user,"medics");
if (employed($user,"cooks")) $employed = employed($user,"cooks");
if (employed($user,"shopkeepers")) $employed = employed($user,"shopkeepers");
return $employed;
}
function chargeItem($user,$check,$amount = 1,$protect = "") {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$count = 0;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if ($item != $protect) {
$record = getInfo(item,user_items,"WHERE id='$item'");
if ($record == $check) {
if ($count < $amount) {
$count++;
unset($inventory[$i]);
$deletes[] = $item;
}
}
}
}
if ($count >= $amount) {
$inventory = implode('.',$inventory);
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
$max = count($deletes);
for ($i = 0;$i < $max;$i++) {
$item = $deletes[$i];
$query = "DELETE FROM user_items WHERE id='$item'";
mysql_query($query);
}
}
}
function hasItem($user,$check,$amount = 1,$protect = "") {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$count = 0;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if ($item != $protect) {
$record = getInfo(item,user_items,"WHERE id='$item'");
if ($record == $check) {
if ($count < $amount) {
$count++;
unset($inventory[$i]);
}
}
}
}
if ($count >= $amount) {
return true;
} else {
return false;
}
}
function countItem($user,$check) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$count = 0;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if ($item != $protect) {
$record = getInfo(item,user_items,"WHERE id='$item'");
if ($record == $check) {
$count++;
}
}
}
return $count;
}
function chargeRes($user,$wood,$stone) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$woodCount = 0;
$stoneCount = 0;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
$record = getInfo(item,user_items,"WHERE id='$item'");
if ($record == 109) { #WOOD
if ($woodCount < $wood) {
$woodCount++;
unset($inventory[$i]);
}
}
if ($record == 113) { #STONE
if ($stoneCount < $stone) {
$stoneCount++;
unset($inventory[$i]);
}
}
}
if (($stoneCount >= $stone) && ($woodCount >= $wood)) {
$inventory = implode('.',$inventory);
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
}
function hasRes($user,$wood,$stone) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$woodCount = 0;
$stoneCount = 0;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
$record = getInfo(item,user_items,"WHERE id='$item'");
if ($record == 109) { #WOOD
if ($woodCount < $wood) {
$woodCount++;
unset($inventory[$i]);
}
}
if ($record == 113) { #STONE
if ($stoneCount < $stone) {
$stoneCount++;
unset($inventory[$i]);
}
}
}
if (($stoneCount >= $stone) && ($woodCount >= $wood)) {
return true;
} else {
return false;
}
}
function giveCrate($user,$crateName,$crateDescription,$items) {
$query = "INSERT INTO items VALUES('','$crateName','','$crateDescription','','$userId','crate','$items','','','','','','','','')";
mysql_query($query);
$crate_id = numRows(items);
$query = "INSERT INTO user_items VALUES('','$crateName','crate','$crate_id','0','$items','0','','','')";
mysql_query($query);
$crate_id = numRows(user_items);
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) $inventory .= '.'.$crate_id;
else $inventory = $crate_id;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
function stripWhitespace($string) {
$string = explode(' ',$string);
$max = count($string);
for ($i = 0;$i < $max;$i++) {
if (!$string[$i]) unset($string[$i]);
}
$string = implode(' ',$string);
return $string;
}
function inPot($user) {
$inPot = false;
$result = getRows(pots,"WHERE users like '%$user%'");
while ($row = mysql_fetch_array($result)) {
$users = explode('.',$row['users']);
if (inArray($user,$users)) $inPot = true;
}
return $inPot;
}
function buildings($town) {
$count = 0;
$result = getRows(places,"WHERE town='$town' and type!='21' and type!='23' and type!='29' and type!='37'");
while ($row = mysql_fetch_array($result)) {
if ((!inArray($row['owner'],$owners)) && (!sameUser($row['owner'],getInfo(leader,towns,"WHERE id='$town'")))) {
$owners[] = $row['owner'];
$count++;
}
}
return $count;
}
function destinationPlaces($id,$user = 0) {
$buildingId = getInfo(place,rooms,"WHERE id='$id'");
if (getInfo(id,places,"WHERE entrance='$id'")) {
$town = getInfo(town,places,"WHERE id='$buildingId'");
$entrance = getInfo(entrance,places,"WHERE id='$buildingId'");
if (!getInfo(locked,doors,"WHERE room='$entrance' && room2='out'")) {
if ($town) {
$locked = getInfo(locked,towns,"WHERE id='$town'");
if (!$locked) {
$result = getRows(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' ORDER BY type");
} else {
$outskirts = getInfo(outskirts,places,"WHERE id='$buildingId'");
$result = getRows(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' and outskirts='$outskirts'");
}
while ($row = mysql_fetch_array($result)) {
$entrance = $row['entrance'];
$place = $row['id'];
$place_name = $row['name'];
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
$destinations[] = $place;
}
} else {
$x = getInfo(x,transport,"WHERE place='$buildingId'");
$y = getInfo(y,transport,"WHERE place='$buildingId'");
$result = getRows(transport,"WHERE x='$x' and y='$y' and place!='$buildingId'");
$destinations[] = "overboard";
while ($row = mysql_fetch_array($result)) {
$place = $row['place'];
$entrance = getInfo(entrance,places,"WHERE id='$place'");
$place_name = getInfo(name,places,"WHERE id='$place'");
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
$destinations[] = $entrance;
}
}
}
}
return $destinations;
}
function destinations($id,$user = 0,$goOutside = true,$otherUser = '') {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if (getInfo(type,user_items,"WHERE id='$item'") == "key") {
$keys[] = $item;
$key_doors[] = getInfo(stat,user_items,"WHERE id='$item'");
}
}
$max = count($keys);
unset($placeKeys);
$hasKeys = false;
if ($user != "*") {
$conditions = "WHERE (room='$id' or room2='$id') and ((locked='') or (";
for ($i = 0;$i < $max;$i++) {
$key = $keys[$i];
$hasKeys = true;
$passage = getInfo("stat",user_items,"WHERE id='$key'");
$passage_place = getInfo(place,doors,"WHERE id='$passage'");
if (getInfo(room2,doors,"WHERE id='$passage'") == "out") $placeKeys[] = getInfo(entrance,places,"WHERE id='$passage_place'");
if ($i != 0) $conditions .= " or ";
$conditions .= "id='$passage'";
}
$conditions .= "))";
} else {
$conditions = "WHERE room='$id' or room2='$id'";
}
$buildingId = getInfo(place,rooms,"WHERE id='$id'");
$building_name = getInfo(name,places,"WHERE id='$buildingId'");
if (getInfo(id,travel_routes,"WHERE station='$buildingId' or station2='$buildingId'")) {
$result = getRows(travel_routes,"WHERE station='$buildingId' or station2='$buildingId'");
while ($row = mysql_fetch_array($result)) {
$route = $row['id'];
if ($row['station'] == $buildingId) {
$station = $row['station2'];
$toll = $row['toll'];
}
if ($row['station2'] == $buildingId) {
$station = $row['station'];
$toll = $row['toll2'];
}
if ((!getInfo(abandoned,places,"WHERE id='$station'")) && ($station)) {
$stationTown = getInfo(town,places,"WHERE id='$station'");
$stationTown = getInfo(name,towns,"WHERE id='$stationTown'");
$currentTown = getInfo(town,places,"WHERE id='$buildingId'");
$stationdistrict = getInfo(district,places,"WHERE id='$station'");
$currentdistrict = getInfo(district,places,"WHERE id='$buildingId'");
if ($currentTown == $stationTown) {
$stationdistrictName = getInfo(name,districts,"WHERE id='$stationdistrict'");
}
if (((getInfo(locked,towns,"WHERE id='$stationTown'") != "locked") && (getInfo(locked,towns,"WHERE id='$currentTown'") != "locked")) || (($stationTown == $currentTown) && (getInfo(outskirts,districts,"WHERE id='$stationdistrict'") == getInfo(outskirts,districts,"WHERE id='$currentdistrict'"))) || (($stationTown != $currentTown) && ((getInfo(outskirts,districts,"WHERE id='$stationdistrict'")) || (getInfo(locked,towns,"WHERE id='$stationTown'") != "locked")))) $destinations[] = "travel_$route";
}
}
}
if (numRowsConditions(doors,"WHERE (room='$id' or room2='$id') and room2!='out'") >= 1) {
if (!$hasKeys) $result = getRows(doors,"WHERE (room='$id' or room2='$id') and locked=''");
else {
$result = getRows(doors,$conditions);
}
while ($row = mysql_fetch_array($result)) {
$door = $row['id'];
if ($row['room'] == $id) {
$room_id = $row['room2'];
$block = $row['block'];
$side = 1;
}
if ($row['room2'] == $id) {
$room_id = $row['room'];
$block = $row['block2'];
$side = 2;
}
if (!getInfo(id,secret_doors,"WHERE door='$door' and side='$side' and open=''")) {
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if ($row['room'] == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if ($row['room2'] == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
$room_name = getInfo(name,rooms,"WHERE id='$room_id'");
if ((!$block) || ($otherUser == $block)) $destinations[] = $room_id;
}
}
}
if (numRowsConditions(doors,"WHERE room='$id' or room2='$id'") <= 0) {
$entrance = getInfo(entrance,places,"WHERE id='$buildingId'");
if ($entrance != $id) {
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
$destinations[] = $entrance;
}
}
if ((getInfo(id,places,"WHERE entrance='$id'")) && ((!getInfo(block,doors,"WHERE room='$id' and room2='out'")) || ($otherUser == getInfo(block,doors,"WHERE room='$id' and room2='out'")) )) {
$result = getRows(rooms,"WHERE place='$buildingId' and id!='$id'");
while ($row = mysql_fetch_array($result)) {
$room_id = $row['id'];
$room_name = getInfo(name,rooms,"WHERE id='$room_id'");
if (numRowsConditions(doors,"WHERE room='$room_id' or room2='$room_id'") <= 0) $destinations[] = $room_id;
}
$town = getInfo(town,places,"WHERE id='$buildingId'");
$entrance = getInfo(entrance,places,"WHERE id='$buildingId'");
$front_door = getInfo(id,doors,"WHERE room='$entrance' && room2='out' && place='$buildingId'");
if (((!getInfo(locked,doors,"WHERE room='$entrance' && room2='out'")) || (inArray($front_door,$key_doors))) && ($front_door) && ($goOutside)) {
if ($town) {
$locked = getInfo(locked,towns,"WHERE id='$town'");
if (!$locked) {
$result = getRows(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' ORDER BY type");
} else {
$district = getInfo(district,places,"WHERE id='$buildingId'");
$result = getRows(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' and district='$district'");
}
while ($row = mysql_fetch_array($result)) {
$entrance = $row['entrance'];
$place = $row['id'];
if (getInfo(id,doors,"WHERE place='$place' and room2='out'")) {
$place_name = $row['name'];
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
if (((!getInfo(locked,doors,"WHERE room='$entrance' && room2='out'")) || (inArray($entrance,$placeKeys))) && (!getInfo(locked,places,"WHERE id='$place'"))) $destinations[] = $entrance;
}
}
} else {
$x = getInfo(x,transport,"WHERE place='$buildingId'");
$y = getInfo(y,transport,"WHERE place='$buildingId'");
$result = getRows(transport,"WHERE x='$x' and y='$y' and place!='$buildingId'");
$destinations[] = "overboard";
while ($row = mysql_fetch_array($result)) {
$place = $row['place'];
if (getInfo(id,doors,"WHERE place='$place' and room2='out'")) {
$entrance = getInfo(entrance,places,"WHERE id='$place'");
$place_name = getInfo(name,places,"WHERE id='$place'");
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
if ($row['room'] == $id) $block = $row['block'];
if ($row['room2'] == $id) $block = $row['block2'];
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if ($row['room'] == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if ($row['room2'] == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
if (((!$block) || ($otherUser == $block)) && (!getInfo(abandoned,places,"WHERE id='$place'")) && ((!getInfo(locked,doors,"WHERE room='$entrance' && room2='out'")) || (inArray($entrance,$placeKeys))) && (!getInfo(locked,places,"WHERE id='$place'"))) $destinations[] = $entrance;
}
}
}
}
}
return $destinations;
}
function destinationDisplay($id,$user = 0,$otherUser = '') {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if (getInfo(type,user_items,"WHERE id='$item'") == "key") {
$keys[] = $item;
$key_doors[] = getInfo(stat,user_items,"WHERE id='$item'");
}
}
$buildingId = getInfo(place,rooms,"WHERE id='$id'");
$building_name = getInfo(name,places,"WHERE id='$buildingId'");
echo "";
if (getInfo(id,travel_routes,"WHERE station='$buildingId' or station2='$buildingId'")) {
$currentTown = getInfo(town,places,"WHERE id='$buildingId'");
$currentTownName = getInfo(name,towns,"WHERE id='$currentTown'");
$currentdistrict = getInfo(district,places,"WHERE id='$buildingId'");
if ((getInfo(locked,towns,"WHERE id='$currentTown'") == "locked") && (!getInfo(outskirts,districts,"WHERE id='$currentdistrict'"))) echo "";
else {
$result = getRows(travel_routes,"WHERE station='$buildingId' or station2='$buildingId'");
while ($row = mysql_fetch_array($result)) {
$route = $row['id'];
if ($row['station'] == $buildingId) {
$station = $row['station2'];
$toll = $row['toll'];
}
if ($row['station2'] == $buildingId) {
$station = $row['station'];
$toll = $row['toll2'];
}
if ((!getInfo(abandoned,places,"WHERE id='$station'")) && ($station)) {
$stationTown = getInfo(town,places,"WHERE id='$station'");
$stationTownName = getInfo(name,towns,"WHERE id='$stationTown'");
$stationdistrict = getInfo(district,places,"WHERE id='$station'");
$currentdistrict = getInfo(district,places,"WHERE id='$buildingId'");
$stationdistrictName = getInfo(name,districts,"WHERE id='$stationdistrict'");
if ($currentTown == $stationTown) {
$stationTownName = $stationdistrictName;
}
if (($stationTown != $currentTown) || (getInfo(outskirts,districts,"WHERE id='$stationdistrict'") != getInfo(outskirts,districts,"WHERE id='$currentdistrict'"))) {
if ($stationTown != $currentTown) {
if ((getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") && (!getInfo(outskirts,districts,"WHERE id='$stationdistrict'")) && (getInfo(locked,towns,"WHERE id='$stationTown'") == "locked")) echo "";
else echo "";
} else {
if (getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") echo "";
else echo "";
}
} else echo "";
}
}
}
echo "";
}
if (numRowsConditions(doors,"WHERE (room='$id' or room2='$id') and room2!='out'") >= 1) {
$result = getRows(doors,"WHERE (room='$id' or room2='$id') and room2!='out'");
while ($row = mysql_fetch_array($result)) {
$door = $row['id'];
if ($row['room'] == $id) {
$room_id = $row['room2'];
$block = $row['block'];
$side = 1;
}
if ($row['room2'] == $id) {
$room_id = $row['room'];
$block = $row['block2'];
$side = 2;
}
if (!getInfo(id,secret_doors,"WHERE door='$door' and side='$side' and open=''")) {
$room_name = getInfo(name,rooms,"WHERE id='$room_id'");
echo "";
unset($block);
}
}
}
if (numRowsConditions(doors,"WHERE room='$id' or room2='$id'") <= 0) {
$entrance = getInfo(entrance,places,"WHERE id='$buildingId'");
if ($entrance != $id) {
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
echo "";
}
}
if ((getInfo(id,places,"WHERE entrance='$id'")) && ((!getInfo(block,doors,"WHERE room='$id' and room2='out'")) || ($otherUser == getInfo(block,doors,"WHERE room='$id' and room2='out'")) || ($otherUser == "*"))) {
$result = getRows(rooms,"WHERE place='$buildingId' and id!='$id'");
while ($row = mysql_fetch_array($result)) {
$room_id = $row['id'];
$room_name = getInfo(name,rooms,"WHERE id='$room_id'");
if (numRowsConditions(doors,"WHERE room='$room_id' or room2='$room_id'") <= 0) echo "";
}
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (numRowsConditions(places,"WHERE town='$town'") > 1) echo "";
$entrance = getInfo(entrance,places,"WHERE id='$buildingId'");
$front_door = getInfo(id,doors,"WHERE room='$entrance' && room2='out' && place='$buildingId'");
if (((!getInfo(locked,doors,"WHERE room='$entrance' && room2='out'")) || (inArray($front_door,$key_doors))) && ($front_door)) {
if ($town) {
echo "";
$locked = getInfo(locked,towns,"WHERE id='$town'");
if (!$locked) {
$result = getRows(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' ORDER BY name");
} else {
$district = getInfo(district,places,"WHERE id='$buildingId'");
$result = getRows(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' and district='$district' ORDER BY name");
}
while ($row = mysql_fetch_array($result)) {
$entrance = $row['entrance'];
$place = $row['id'];
if (getInfo(id,doors,"WHERE place='$place' and room2='out'")) {
$place_name = $row['name'];
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
echo "";
unset($block);
}
}
} else {
$x = getInfo(x,transport,"WHERE place='$buildingId'");
$y = getInfo(y,transport,"WHERE place='$buildingId'");
echo "";
echo "";
$result = getRows(transport,"WHERE x='$x' and y='$y' and place!='$buildingId' ORDER BY id");
while ($row = mysql_fetch_array($result)) {
$place = $row['place'];
if (getInfo(id,doors,"WHERE place='$place' and room2='out'")) {
$entrance = getInfo(entrance,places,"WHERE id='$place'");
$place_name = getInfo(name,places,"WHERE id='$place'");
$entrance_name = getInfo(name,rooms,"WHERE id='$entrance'");
if (!getInfo(abandoned,places,"WHERE id='$place'")) {
echo "";
}
}
}
}
} else echo "";
} elseif (getInfo(block,doors,"WHERE room='$id' and room2='out'")) {
echo "";
echo "";
}
}
function sameDistrict($place1,$place2) {
$return = true;
if (getInfo(district,places,"WHERE id='$place1'") != getInfo(district,places,"WHERE id='$place2'")) $return = false;
if (getInfo(town,places,"WHERE id='$place1'") != getInfo(town,places,"WHERE id='$place2'")) $return = false;
return $return;
}
function sameArea($place1,$place2) {
$return = true;
$town = getInfo(town,places,"WHERE id='$place1'");
$district1 = getInfo(district,places,"WHERE id='$place1'");
$district2 = getInfo(district,places,"WHERE id='$place2'");
if (getInfo(outskirts,districts,"WHERE id='$district1'") != getInfo(outskirts,districts,"WHERE id='$district2'")) $return = false;
$walls = getInfo(walls,towns,"WHERE id='$town'");
if (!$walls) $return = true;
if (getInfo(burn,places,"WHERE id='$walls'") <= 0) $return = true;
if (($place1 == $walls) || ($place2 == $walls)) $return = true;
if (getInfo(town,places,"WHERE id='$place1'") != getInfo(town,places,"WHERE id='$place2'")) $return = false;
return $return;
}
function districtBuildings($district) {
$town = getInfo(town,districts,"WHERE id='$district'");
if (!getInfo(developed,towns,"WHERE id='$town'")) {
if ((getInfo(district_out,towns,"WHERE id='$town'") == $district) || ((!getInfo(district_out,towns,"WHERE id='$town'")) && (getInfo(district_in,towns,"WHERE id='$town'") == $district))) $types = Array(10,15,22,28,21,23,29,37);
else $types = Array(10,15,22,28);
$buildings = getInfo(buildings,districts,"WHERE id='$district'");
if ($buildings) {
$buildings = explode('.',$buildings);
$max = count($buildings);
for ($i = 0;$i < $max;$i++) {
$types[] = $buildings[$i];
}
}
} else {
$result = getRows(buildings,"WHERE restrictions!='2'");
while ($row = mysql_fetch_array($result)) $types[] = $row['id'];
}
return $types;
}
function districtCentre($place) {
$district = getInfo(district,places,"WHERE id='$place'");
$town = getInfo(town,places,"WHERE id='$place'");
if ($town) {
$destination = getInfo(streets,districts,"WHERE id='$district'");
if ($destination) {
$return = getInfo(id,rooms,"WHERE place='$destination' ORDER BY id ASC");
}
} else $return = "overboard";
return $return;
}
function spreadRumours($room) {
$result = getRows(users,"WHERE NPC!='' and room='$room' and (status='conscious' or status='immobilized')");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (getInfo(id,npc_citizens,"WHERE npc='$npc'")) {
if (getInfo(rumours,npc_citizens,"WHERE npc='$npc'")) {
if ($rumours) $rumours .= '.'.getInfo(rumours,npc_citizens,"WHERE npc='$npc'");
else $rumours = getInfo(rumours,npc_citizens,"WHERE npc='$npc'");
}
$npcs[] = $npc;
}
}
$rumours = explode('.',$rumours);
$max = count($rumours);
for ($i = 0;$i < $max;$i++) {
$rumour = $rumours[$i];
if (!inArray($rumour,$valid)) {
$valid[] = $rumour;
}
}
$rumours = implode('.',$valid);
$max = count($npcs);
for ($i = 0;$i < $max;$i++) {
$npc = $npcs[$i];
$query = "UPDATE npc_citizens SET rumours='$rumours' WHERE npc='$npc'";
mysql_query($query);
}
}
function move($user,$destination) {
$temp = $destination;
if (!admin($user_name)) {
if ((((is_numeric($destination)) || ($destination == "overboard") || (fnmatch("travel_*",$destination)))) && ((!getInfo(mount,rooms,"WHERE id='$destination'")) || (!getInfo(id,mounts,"WHERE npc='$user'")))) {
$room = getInfo(room,users,"WHERE id='$user'");
$date = date('g:i A F jS Y');
$NPC = getInfo(NPC,users,"WHERE id='$user'");
$query = "INSERT INTO moves VALUES('','$user','$NPC','$room','$destination','$date')";
mysql_query($query);
$result = getRows(npc_bribes,"WHERE user='$user' or npc='$user'");
while ($row = mysql_fetch_array($result)) {
$bribe = $row['id'];
$current = $row['current'];
$total = $row['total'];
$total += $current;
$query = "UPDATE npc_bribes SET total='$total' WHERE id='$bribe'";
mysql_query($query);
$query = "UPDATE npc_bribes SET current='0' WHERE id='$bribe'";
mysql_query($query);
}
$buildingId = getInfo(location,users,"WHERE id='$user'");
$id = getInfo(room,users,"WHERE id='$user'");
$result = getRows(npcs,"WHERE (movement='follow' or mode='protect') and var='$userId'");
while ($row = mysql_fetch_array($result)) {
$npcs[] = "npc!='".$row['name']."'";
}
$conditions = implode(' and ',$npcs);
$query = "DELETE FROM interactions WHERE user='$user' and permanent='' $conditions";
mysql_query($query);
$query = "UPDATE doors SET block='' WHERE block='$user'";
mysql_query($query);
$query = "UPDATE doors SET block2='' wHERE block2='$user'";
mysql_query($query);
if (fnmatch("travel_*",$destination)) {
$travel = explode("_",$destination);
$route = $travel[1];
$query = "DELETE FROM npc_mining WHERE npc='$user'";
mysql_query($query);
if (getInfo(id,travel_routes,"WHERE station='$buildingId' and id='$route'")) {
$station = getInfo(station2,travel_routes,"WHERE station='$buildingId' and id='$route'");
$time = getInfo("time",travel_routes,"WHERE station='$buildingId' and id='$route'");
}
if (getInfo(id,travel_routes,"WHERE station2='$buildingId' and id='$route'")) {
$station = getInfo(station,travel_routes,"WHERE station2='$buildingId' and id='$route'");
$time = getInfo("time",travel_routes,"WHERE station2='$buildingId' and id='$route'");
}
if (getInfo(personal,users,"WHERE id='$userId'") == "traveler") $time = round($time / 2);
$destination = getInfo(town,places,"WHERE id='$station'");
$query = "UPDATE users SET town='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET location='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET room='' WHERE id='$user'";
mysql_query($query);
$mount = getInfo(mount,users,"WHERE id='$user'");
if ($mount) {
$speed = getInfo(speed,mounts,"WHERE npc='$mount'");
$mood = getInfo(mood,mounts,"WHERE npc='$mount'");
if ($mood < 0) $speed -= abs($mood * 0.4);
$time = ceil($time * ((100 - $speed) / 100));
}
$arrival = time() + $time;
$query = "INSERT INTO travels VALUES('','$user','$arrival','$destination','','$station')";
mysql_query($query);
$result = getRows(users,"WHERE room='$id' and npc!=''");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (($npc != getInfo(mount,users,"WHERE id='$user'")) && ((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") || (getInfo(movement,npcs,"WHERE name='$npc'") == "follow")) && (getInfo("var",npcs,"WHERE name='$npc'") == $user) && (getInfo(status,users,"WHERE id='$npc'") == "conscious") && (!isFighting($npc)) && (!isTied($npc)) && (weigh($npc) <= maxWeight($npc))) {
move($npc,"travel_$route");
}
}
} elseif ($destination == "overboard") {
$query = "DELETE FROM npc_mining WHERE npc='$user'";
mysql_query($query);
$type = getInfo(type,places,"WHERE id='$buildingId'");
$type = getInfo(label,buildings,"WHERE id='$type'");
$zone = getInfo(zone,towns,"WHERE id='$town'");
$found = false;
if (($type == "ship")) $result = getRows(towns,"WHERE seaside!='' and developed!='' and name!=''");
if (($type == "caravan")) $result = getRows(towns,"WHERE zone='$zone' and name!=''");
while ($row = mysql_fetch_array($result)) {
$areas[] = $row['id'];
$found = true;
}
if (!$found) {
if (($type == "ship")) $result = getRows(towns,"WHERE seaside!='' and developed!='' and name!=''");
if (($type == "caravan")) $result = getRows(towns,"WHERE name!=''");
while ($row = mysql_fetch_array($result)) {
$areas[] = $row['id'];
}
}
$area = $areas[rand(0,(count($areas) - 1))];
$health = getInfo(health,users,"WHERE id='$user'");
$health = round($health * 0.25);
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET town='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET location='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET room='' WHERE id='$user'";
mysql_query($query);
$arrival = time() + (3600 * 2);
$query = "INSERT INTO travels VALUES('','$user','$arrival','$area','','')";
mysql_query($query);
$result = getRows(users,"WHERE room='$id' and npc!=''");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (($npc != getInfo(mount,users,"WHERE id='$user'")) && ((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") || (getInfo(movement,npcs,"WHERE name='$npc'") == "follow")) && (getInfo("var",npcs,"WHERE name='$npc'") == $user) && (getInfo(status,users,"WHERE id='$npc'") == "conscious") && (weigh($npc) <= maxWeight($npc))) {
move($npc,"overboard");
}
}
} else {
$query = "UPDATE npc_mining SET room='$destination' WHERE npc='$user'";
mysql_query($query);
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
$query = "UPDATE users SET room='$destination' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET location='$destinationPlace' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET town='$destinationTown' WHERE id='$user'";
mysql_query($query);
$result = getRows(users,"WHERE room='$id' and npc!=''");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (($npc != getInfo(mount,users,"WHERE id='$user'")) && ((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") || (getInfo(movement,npcs,"WHERE name='$npc'") == "follow")) && (getInfo("var",npcs,"WHERE name='$npc'") == $user) && (getInfo(status,users,"WHERE id='$npc'") == "conscious") && (!isFighting($npc)) && (!isTied($npc)) && (weigh($npc) <= maxWeight($npc))) {
move($npc,$destination);
}
}
}
$room = getInfo(room,users,"WHERE id='$user'");
if (($room) && (getInfo(NPC,users,"WHERE id='$user'")) && (getInfo(id,npc_citizens,"WHERE npc='$user'"))) {
spreadRumours($room);
}
} else sendMessage("Irshad","MOVE","Destination: $destination, User: $user","God");
$destination = $temp;
if (getInfo(mount,users,"WHERE id='$user'")) {
$mount = getInfo(mount,users,"WHERE id='$user'");
if (!getInfo(mount,rooms,"WHERE id='$destination'")) {
move($mount,$destination);
} else {
$query = "UPDATE users SET mount='' WHERE id='$user'";
mysql_query($query);
}
}
}
}
function maxWeight($user) {
if (!getInfo(NPC,users,"WHERE id='$user'")) {
$weightMax = 60;
if (getInfo(bonus,users,"WHERE id='$user'") == "strong") $weightMax += 20;
$mount = getInfo(mount,users,"WHERE id='$user'");
if ($mount) {
$weightMax += maxWeight($mount);
}
} elseif (getInfo(animal,npcs,"WHERE name='$user'")) {
$animal = getInfo(animal,npcs,"WHERE name='$user'");
$carry = getInfo(carry,npc_animals,"WHERE id='$animal'");
if ($carry) $weightMax = $carry;
else $weightMax = 60;
} else {
$weightMax = 60;
}
return $weightMax;
}
function outside($room,$exception = 0) {
$return = false;
if (numRowsConditions(doors,"WHERE room='$room' or room2='$room'") > 0) {
$result = getRows(doors,"WHERE (room='$room' or room2='$room') and id!='$exception'");
while ($row = mysql_fetch_array($result)) {
$passage = $row['id'];
if ($room == $row['room']) $newRoom = $row['room2'];
else $newRoom = $row['room'];
if ($newRoom != "out") {
$return = outside($newRoom,$passage);
if ($return) break;
} else {
return true;
}
}
} else {
$return = true;
}
return $return;
}
function vuln($effort) {
if ($effort >= 70) {
$vuln = (($effort - 70) * 3) + (30 * 2) + (40);
} else if ($effort >= 40) {
$vuln = (($effort - 40) * 2) + (40);
} else {
$vuln = $effort;
}
return $vuln;
}
function count_items($inventory) {
$inventory = explode('.',$inventory);
$max = count($inventory);
$count = 0;
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if (getInfo(type,user_items,"WHERE id='$item'")) {
$type = getInfo(type,user_items,"WHERE id='$item'");
if ($type == "crate") {
$stat = getInfo(stat,user_items,"WHERE id='$item'");
$count += count_items($stat);
} else {
if (($type == "food") || ($type == "drink") || ($type == "alcohol") || ($type == "poison")) $count += 0.2;
if (($type == "weapon") || ($type == "armour")) $count += (getInfo(stat,user_items,"WHERE id='$item'") * 0.5);
if ($type == "clothing") $count += 0.3;
if ($type == "other") $count += 0.05;
if ($type == "misc") $count += 0.05;
if ($type == "relic") $count += 1;
if ($type == "resource") $count += 1;
if ($type == "material") $count += 1;
if ($type == "door") $count += getInfo(portions,user_items,"WHERE id='$item'") / 12;
if ($type == "arrows") $count += getInfo(portions,user_items,"WHERE id='$item'") * getInfo(stat,user_items,"WHERE id='$item'") * 0.03;
if ($type == "money") $count += getInfo(stat,user_items,"WHERE id='$item'") * 0.005;
}
}
}
$count = round($count,2);
return $count;
}
function damage($user,$damage) {
$username = getInfo(username,users,"WHERE id='$user'");
$health = getInfo(health,users,"WHERE id='$user'");
$health -= $damage;
if ($health <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$user'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$user'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$user'";
mysql_query($query);
$status = "unconscious";
} else $status = "conscious";
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
return $status;
}
function weigh_item($item) {
if (getInfo(name,items,"WHERE id='$item'")) {
$type = getInfo(type,items,"WHERE id='$item'");
if ($type == "crate") {
$stat = getInfo(stat,items,"WHERE id='$item'");
$count += count_items($stat);
} else {
if (($type == "food") || ($type == "drink") || ($type == "alcohol") || ($type == "poison")) $count += 0.2;
if (($type == "weapon") || ($type == "armour")) $count += (getInfo(stat,items,"WHERE id='$item'") * 0.5);
if ($type == "clothing") $count += 0.3;
if ($type == "other") $count += 0.05;
if ($type == "misc") $count += 0.05;
if ($type == "relic") $count += 1;
if ($type == "resource") $count += 1;
if ($type == "material") $count += 1;
if ($type == "door") $count += getInfo(portions,items,"WHERE id='$item'") / 12;
if ($type == "arrows") $count += getInfo(portions,items,"WHERE id='$item'") * getInfo(stat,items,"WHERE id='$item'") * 0.03;
if ($type == "money") $count += getInfo(stat,items,"WHERE id='$item'") * 0.005;
}
}
$count = round($count,2);
return $count;
}
function weigh($user) {
$inventory = getInfo(inventory,users,"WHERE id='$user'").'.'.getInfo(overhead,users,"WHERE id='$user'").'.'.getInfo(clothes,users,"WHERE id='$user'").'.'.getInfo(behind,users,"WHERE id='$user'");
$weight = count_items($inventory);
$weight += getInfo(money,users,"WHERE id='$user'") * 0.005;
$weight = floor($weight);
return $weight;
}
function wordcount($user) {
$count = 0;
$total = 0;
$result = getRows(posts,"WHERE username='$user' and (ooc='' or ooc='failed counter') ORDER BY id DESC LIMIT 50");
while ($row = mysql_fetch_array($result)) {
$count = count(explode(' ',$row['post']));
$posts[] = $count;
}
rsort($posts);
$posts = array_slice($posts,0,40);
$average = round(average($posts));
return $average;
}
function average($array) {
$max = count($array);
$total = 0;
$average = 0;
if ($array) {
for ($i = 0;$i < $max;$i++) {
$total += $array[$i];
}
$average = $total / $max;
}
return $average;
}
function remember_avatar($user) {
$base = getInfo(base,users,"WHERE id='$user'");
$tattoos = getInfo(tattoos,users,"WHERE id='$user'");
$clothes = getInfo(clothes,users,"WHERE id='$user'");
$hair = getInfo(hair,users,"WHERE id='$user'");
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$user'");
$transformed = getInfo(transformed,users,"WHERE id='$user'");
$master = getInfo(master,users,"WHERE id='$user'");
$health = getInfo(health,users,"WHERE id='$user'");
$saturation = getInfo(saturation,users,"WHERE id='$user'");
$hue = getInfo(hue,users,"WHERE id='$user'");
$statmax = statmax($user);
$query = "INSERT INTO memory_avatars VALUES('','$user','$base','$tattoos','$clothes','$hair','$overhead','$behind','$saturation','$hue','$transformed','$mount','$mount_clothes','$master','$health','$statmax')";
mysql_query($query);
return numRows(memory_avatars);
}
function remember_action($npc,$user1,$var,$command) {
$avatar1 = remember_avatar($user1);
$invalid = array("startfire","breakdown","lockpick","suicide");
if ((!inArray($command,$invalid)) && ($var)) $avatar2 = remember_avatar($var);
$time = time();
$query = "INSERT INTO npc_memories VALUES('','$npc','$user1','$avatar1','$var','$avatar2','$command','$time')";
mysql_query($query);
}
function hasIngredients($user,$spell,$item) {
if ($spell == "revitalize") $ingredients = array(1814,2401,1802);
if ($spell == "calmAnimals") $ingredients = array(2391,2395,1818);
if ($spell == "divineIntervention") $ingredients = array(2395,2398,2392,1818);
if ($spell == "protection") $ingredients = array(2399,2392,2398,2391,2401);
if ($spell == "trace") $ingredients = array(2402,2398,2392);
if ($spell == "insomniac") $ingredients = array(1810,2400,1821,1802);
if ($spell == "enrageBeasts") $ingredients = array(2387,2399,2397,2400,1821);
if ($spell == "demonicPossession") $ingredients = array(2399,2397,1809,121);
if ($spell == "raiseTheDead") $ingredients = array(1819,2387,121,2400,2392,2403);
if ($ingredients) {
$return = true;
$max = count($ingredients);
for ($i = 0;$i < $max;$i++) {
$ingredient = $ingredients[$i];
if (!hasItem($user,$ingredient,1,$item)) {
$return = false;
}
}
} else $return = false;
return $return;
}
function chargeIngredients($user,$spell,$item) {
if ($spell == "revitalize") $ingredients = array(1814,2401,1820);
if ($spell == "calmAnimals") $ingredients = array(2391,2395,1818);
if ($spell == "divineIntervention") $ingredients = array(2395,2398,2392,1818);
if ($spell == "protection") $ingredients = array(2399,2392,2398,2391,2401);
if ($spell == "trace") $ingredients = array(2402,2398,2392);
if ($spell == "insomniac") $ingredients = array(1810,2400,1821,1802);
if ($spell == "enrageBeasts") $ingredients = array(2387,2399,2397,2400,1821);
if ($spell == "demonicPossession") $ingredients = array(2399,2397,1809,121);
if ($spell == "raiseTheDead") $ingredients = array(1819,2387,121,2400,2392,2403);
if ($ingredients) {
$return = true;
$max = count($ingredients);
for ($i = 0;$i < $max;$i++) {
$ingredient = $ingredients[$i];
if (!hasItem($user,$ingredient,1,$item)) {
$return = false;
}
}
if ($return) {
$max = count($ingredients);
for ($i = 0;$i < $max;$i++) {
$ingredient = $ingredients[$i];
chargeItem($user,$ingredient,1,$item);
}
}
} else $return = false;
return $return;
}
function hasHair($user,$user2) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$return = false;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if (getInfo(item,user_items,"WHERE id='$item'") == 2390) {
if (getInfo(stat,user_items,"WHERE id='$item'") == $user2) {
$return = true;
break;
}
}
}
return $return;
}
function chargeHair($user,$user2) {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$inventory = explode('.',$inventory);
$return = false;
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
if (getInfo(item,user_items,"WHERE id='$item'") == 2390) {
if (getInfo(stat,user_items,"WHERE id='$item'") == $user2) {
$return = true;
unset($inventory[$i]);
break;
}
}
}
if ($return) {
$inventory = implode('.',$inventory);
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
return $return;
}
$day = getInfo(day,general);
if (($day + (3600 * 24)) <= time()) {
$time = time();
$query = "UPDATE general SET day='$time'";
mysql_query($query);
$query = "UPDATE general SET visits=''";
mysql_query($query);
}
$IP = $_SERVER['REMOTE_ADDR'];
$IPs = explode(',',getInfo(visits,general));
if (!inArray($IP,$IPs)) {
$IPs[] = $IP;
$IPs = implode(',',$IPs);
$query = "UPDATE general SET visits='$IPs'";
mysql_query($query);
$pageviews = getInfo(pageviews,general);
$pageviews++;
$query = "UPDATE general SET pageviews='$pageviews'";
mysql_query($query);
}
$rank = rank($user_name);
$statmax = statmax($user_name);
$query = "UPDATE users SET rank='$rank' WHERE username='$user_name'";
mysql_query($query);
$query = "UPDATE users SET statmax='$statmax' WHERE username='$user_name'";
mysql_query($query);
if ((!getInfo(base,users,"WHERE id='$userId'")) && ($_SERVER['PHP_SELF'] != "/avatarsetup.php") && ($_SERVER['PHP_SELF'] != "/logout.php") && ($user_name) && (!admin($user_name)) && ($user_name != "God")) echo '';
unset($failure);
?>
if (!$title) $title = "Anathema Online";
?>
![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (getInfo(id,card_hands,"WHERE user='$userId'")) {
$table = getInfo(cardtable,card_hands,"WHERE user='$userId'");
if ($_POST['mode'] == "discard") {
$discard = $_POST['cards'];
$cards = fixArray(getInfo(hand_show,card_hands,"WHERE user='$userId'").'.'.getInfo(hand_hide,card_hands,"WHERE user='$userId'"));
$cards_array = explode('.',$cards);
if (!$discard) $failure = "You have not selected any cards to discard.";
$discard = clearRepeat(explode('.',$discard));
$hand_show = getInfo(hand_show,card_hands,"WHERE user='$userId'");
$hand_hide = getInfo(hand_hide,card_hands,"WHERE user='$userId'");
$discard_mode = getInfo(discard,card_tables,"WHERE id='$table'");
if (!$discard_mode) $failure = "This table does not allow you to discard your cards, as it is not needed for the game being played.";
$max = count($discard);
$hand = $discard;
if (($max > count(explode('.',getInfo(deck,card_tables,"WHERE id='$table'")))) && ($discard_mode == "switch")) $failure = "There are not enough cards in the deck to switch all the cards you selected.";
for ($i = 0;$i < $max;$i++) {
if (!inArray($discard[$i],$cards_array)) $failure = "At least one of the cards you are trying to discard is not in your hand.";
else {
$hand_show = removeElement($discard[$i],$hand_show,'.');
$hand_hide = removeElement($discard[$i],$hand_hide,'.');
}
}
if (getInfo(turn,card_tables,"WHERE id='$table'") != $userId) $failure = "It is not your turn.";
if (!getInfo(id,card_hands,"WHERE user='$userId'")) $failure = "You are not sitting at this table.";
$discards = getInfo(discards,card_hands,"WHERE user='$userId'");
$max_discard = getInfo(max_discard,card_tables,"WHERE id='$table'");
if (($max_discard) && ($discards >= $max_discard)) $failure = "You have already reached the maximum number of times you may discard any cards from your hand.";
if (!$failure) {
changeTurn($table);
$discard = implode('.',$discard);
$discards++;
$discard_action = getInfo(discard_action,card_tables,"WHERE id='$table'");
unset($cards);
if ($discard_mode == "switch") {
if ($hand_hide) $hand_hide .= '.'.drawCards($table,$max);
else $hand_hide = drawCards($table,$max);
$success = "You have successfully discarded the selected cards and drawn $max new ones.";
if ($discard_action == "show") {
$max = count($hand);
for ($i = 0;$i < $max;$i++) {
$card = $hand[$i];
if ($card) $cards[] = "the ".getInfo(name,cards,"WHERE id='$card'");
}
if ($cards) {
$cards = implode(', ',$cards);
}
$statement = "$user_name discarded $cards, and drew $max new ones.";
} else $statement = "$user_name discarded $max cards and drew $max new ones.";
} else {
$success = "You have successfully discarded the selected cards.";
if ($discard_action == "show") {
$max = count($hand);
for ($i = 0;$i < $max;$i++) {
$card = $hand[$i];
if ($card) $cards[] = "the ".getInfo(name,cards,"WHERE id='$card'");
}
if ($cards) {
$cards = implode(', ',$cards);
}
$statement = "$user_name discarded $cards.";
} else $statement = "$user_name discarded $max cards.";
}
$query = "UPDATE card_hands SET hand_show='$hand_show', hand_hide='$hand_hide', discards='$discards' WHERE user='$userId'";
mysql_query($query);
$discard = fixArray(getInfo(discarded,card_tables,"WHERE id='$table'").'.'.$discard);
$query = "UPDATE card_tables SET discarded='$discard' WHERE id='$table'";
mysql_query($query);
cardHistory($table,$statement);
echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "switchface") { $cards = $_POST['cards']; $hand_hide = getInfo(hand_hide,card_hands,"WHERE user='$userId'"); $hand_show = getInfo(hand_show,card_hands,"WHERE user='$userId'"); $hand_hide = explode('.',$hand_hide); $cards = explode('.',$cards); $max = count($cards); for ($i = 0;$i < $max;$i++) { $card = $cards[$i]; if (!inArray($card,$hand_hide)) { $failure = "At least one of the cards you selected is not among the HIDDEN cards in your hands."; } else { $hand_hide = implode('.',$hand_hide); $hand_hide = removeElement($card,$hand_hide,'.'); $hand_hide = explode('.',$hand_hide); } } $hand_hide = implode('.',$hand_hide); $hand_show = fixArray($hand_show.'.'.implode('.',$cards)); if (!$_POST['cards']) $failure = "You did not select any cards."; if ((!getInfo(allowshow,card_tables,"WHERE id='$table'")) && (getInfo(dealer,card_tables,"WHERE id='$table'") != $userId)) $failure = "The dealer has disabled the players' ability to flip their face-down cards."; if (!getInfo(id,card_hands,"WHERE user='$userId'")) $failure = "You are not sitting at this table."; if (!$failure) { $hand = $cards; unset($cards); $max = count($hand); for ($i = 0;$i < $max;$i++) { $card = $hand[$i]; if ($card) $cards[] = "the ".getInfo(name,cards,"WHERE id='$card'"); } if ($cards) { $cards = implode(', ',$cards); } $statement = "$user_name revealed the following cards in their hand: $cards."; $query = "UPDATE card_hands SET hand_show='$hand_show', hand_hide='$hand_hide' WHERE user='$userId'"; mysql_query($query); cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "fold") { $hand = fixArray(getInfo(hand_show,card_hands,"WHERE user='$userId'").'.'.getInfo(hand_show,card_hands,"WHERE user='$userId'")); $discarded = fixArray(getInfo(discarded,card_tables,"WHERE id='$table'").'.'.$hand); if (getInfo(status,card_hands,"WHERE user='$userId'") != "play") $failure = "You cannot fold, because you are currently not playing in this round."; if (!$failure) { if (getInfo(turn,card_tables,"WHERE id='$table'") == $userId) changeTurn($table); $query = "UPDATE card_tables SET discarded='$discarded' WHERE id='$table'"; mysql_query($query); $query = "UPDATE card_hands SET hand_show='', hand_hide='', status='fold' WHERE user='$userId'"; mysql_query($query); $statement = "$user_name folded their hand."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "endturn") { if (getInfo(turn,card_tables,"WHERE id='$table'") != $userId) $failure = "You cannot end your turn, because it is not your turn."; if (getInfo(status,card_hands,"WHERE user='$userId'") != "play") $failure = "You cannot end your turn, because you are currently not playing in this round."; if (!$failure) { changeTurn($table); $statement = "$user_name passed on their turn."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "sitin") { if ((getInfo(status,card_hands,"WHERE user='$userId'") == "play") || (getInfo(status,card_hands,"WHERE user='$userId'") == "fold")) $failure = "You cannot sit in because you are already playing."; if (!$failure) { $query = "UPDATE card_hands SET status='fold' WHERE user='$userId'"; mysql_query($query); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "sitout") { $hand = fixArray(getInfo(hand_show,card_hands,"WHERE user='$userId'").'.'.getInfo(hand_show,card_hands,"WHERE user='$userId'")); $discarded = fixArray(getInfo(discarded,card_tables,"WHERE id='$table'").'.'.$hand); $status = getInfo(status,card_hands,"WHERE user='$userId'"); if (($status != "play") && ($status != "fold")) $failure = "You cannot fold, because you are currently not playing in this round."; if (!$failure) { if (getInfo(turn,card_tables,"WHERE id='$table'") == $userId) changeTurn($table); $query = "UPDATE card_tables SET discarded='$discarded' WHERE id='$table'"; mysql_query($query); $query = "UPDATE card_hands SET hand_show='', hand_hide='', status='out' WHERE user='$userId'"; mysql_query($query); $statement = "$user_name folded their hand and decided to sit out."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if (getInfo(dealer,card_tables,"WHERE id='$table'") == $userId) { if ($_POST['mode'] == "dealer_deal") { $amount = $_POST['amount']; $max_cards = getInfo(max_cards,card_tables,"WHERE id='$table'"); if ($amount > $max_cards) $failure = "You are trying to deal more cards than the set maximum of the table."; $user = $_POST['user']; $type = $_POST['type']; $type = "hand_".$type; if ((is_numeric($user)) && (getInfo(cardtable,card_hands,"WHERE user='$user'") != $table)) $failure = "That user is not sitting at this table."; if ((is_numeric($user)) && (count(explode('.',fixArray(getInfo(hand_show,card_hands,"WHERE user='$userId'").'.'.getInfo(hand_hide,card_hands,"WHERE user='$userId'")))) + $amount > $max_cards)) $failure = "You are trying to deal more cards than your set maximum will allow."; if (($user == "_") && (count(explode('.',fixArray(getInfo(hand_show,card_tables,"WHERE id='$table'").'.'.getInfo(hand_hide,card_tables,"WHERE id='$table'")))) + $amount > $max_cards)) $failure = "You are trying to deal more cards than your set maximum will allow."; if (!$type) $failure = "You have not selected whether you wish to deal the cards out face up or face down."; if (!$failure) { if ($user == "*") { unset($drawn); $max = numRowsConditions(card_hands,"WHERE cardtable='$table' and status='play'"); for ($i = 1;$i <= $amount;$i++) { for ($ii = 0; $ii < $max;$ii++) { if (getInfo(deck,card_tables,"WHERE id='$table'")) $drawn[$ii][] = drawCards($table); else break 2; } } $counter = 0; $result = getRows(card_hands,"WHERE cardtable='$table' and status='play'"); while ($row = mysql_fetch_array($result)) { $hand_id = $row['id']; $hand = $row[$type]; $cards = implode('.',$drawn[$counter]); if ($hand) $hand .= '.'.$cards; else $hand = $cards; $query = "UPDATE card_hands SET $type='$hand' WHERE id='$hand_id'"; mysql_query($query); $counter++; } $success = "You have dealt out cards to all the players sitting at the table."; $statement = "The dealer dealt out $amount cards to all the players sitting at the table."; } elseif ($user == "_") { $hand = getInfo($type,card_tables,"WHERE id='$table'"); $cards = drawCards($table,$amount); if ($hand) $hand .= '.'.$cards; else $hand = $cards; $query = "UPDATE card_tables SET $type='$hand' WHERE id='$table'"; mysql_query($query); $success = "You have dealt out cards to the table."; $statement = "The dealer dealt $amount cards onto the table."; } else { $username = getInfo(username,users,"WHERE id='$user'"); $hand = getInfo($type,card_hands,"WHERE user='$user'"); $cards = drawCards($table,$amount); if ($hand) $hand .= '.'.$cards; else $hand = $cards; $query = "UPDATE card_hands SET $type='$hand' WHERE user='$user'"; mysql_query($query); $success = "You have dealt out cards to $username."; $statement = "The dealer dealt $amount cards to $username."; } cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_discard") { $amount = $_POST['amount']; $user = $_POST['user']; $type = $_POST['type']; if (!$type) $failure = "You have not selected whether you wish to deal the cards out face up or face down."; $type = "hand_".$type; if ((is_numeric($user)) && (getInfo(cardtable,card_hands,"WHERE user='$user'") != $table)) $failure = "That user is not sitting at this table."; if (!$failure) { if ($user == "*") { $result = getRows(card_hands,"WHERE cardtable='$table' and status='play'"); while ($row = mysql_fetch_array($result)) { $hand_id = $row['id']; $hand = $row[$type]; if ($hand) { $hand = explode('.',$hand); for ($i = 1;$i <= $amount;$i++) { $position = rand(0,count($hand) - 1); $discarded[] = $hand[$position]; unset($hand[$position]); if (!$hand) break; $hand = array_values($hand); } if ($hand) $hand = implode('.',$hand); else $hand = ''; $query = "UPDATE card_hands SET $type='$hand' WHERE id='$hand_id'"; echo $query; mysql_query($query); } } $success = "You have discarded cards from all the players sitting at the table."; $statement = "The dealer discarded $amount cards from all the players sitting at the table."; } elseif ($user == "_") { $hand = getInfo($type,card_tables,"WHERE id='$table'"); if ($hand) { $hand = explode('.',$hand); for ($i = 1;$i <= $amount;$i++) { $position = rand(0,count($hand) - 1); $discarded[] = $hand[$position]; unset($hand[$position]); if (!$hand) break; $hand = array_values($hand); } if ($hand) $hand = implode('.',$hand); else $hand = ''; $query = "UPDATE card_tables SET $type='$hand' WHERE id='$table'"; mysql_query($query); } $success = "You have discarded cards from the table."; $statement = "The dealer discarded $amount cards from the table hand."; } else { $username = getInfo(username,users,"WHERE id='$user'"); $hand = getInfo($type,card_hands,"WHERE user='$user'"); if ($hand) { $hand = explode('.',$hand); for ($i = 1;$i <= $amount;$i++) { $position = rand(0,count($hand) - 1); $discarded[] = $hand[$position]; unset($hand[$position]); if (!$hand) break; $hand = array_values($hand); } if ($hand) $hand = implode('.',$hand); else $hand = ''; $query = "UPDATE card_hands SET $type='$hand' WHERE user='$user'"; mysql_query($query); } $success = "You have discarded cards from $username."; $statement = "The dealer discarded $amount cards from $username."; } $discarded = implode('.',$discarded); $discarded = fixArray(getInfo(discarded,card_tables,"WHERE id='$table'").'.'.$discarded); $query = "UPDATE card_tables SET discarded='$discarded' WHERE id='$table'"; mysql_query($query); cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_openclose") { $status = getInfo(status,card_tables,"WHERE id='$table'"); if (($status == "closed") && (!getInfo(id,card_hands,"WHERE user='$userId' and cardtable='$table'"))) $failure = "You may only open the table if you are sitting at it."; if (!$failure) { if ($status == "open") { $success = "You have successfully temporarily closed the table. The players have been removed and will not be able to sit down here once again until you have reopened it."; $query = "UPDATE card_tables SET status='closed' WHERE id='$table'"; mysql_query($query); $query = "DELETE FROM card_hands WHERE cardtable='$table'"; mysql_query($query); } if ($status == "closed") { $success = "You have successfully opened the table. Players will now be able to sit down."; $query = "UPDATE card_tables SET status='open' WHERE id='$table'"; mysql_query($query); } echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_burn") { drawCards($table); if (!$failure) { $statement = "The dealer removed the card at the top of the deck and discarded it."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_settings") { $max_users = $_POST['max_users']; $max_cards = $_POST['max_cards']; $max_turns = $_POST['max_turns']; $max_discard = $_POST['max_discard']; $discard_mode = $_POST['discard_mode']; $discard_action = $_POST['discard_action']; $allowshow = $_POST['allowshow']; if ($max_users > 8) $max_users = 8; if ($max_users < 0) $max_users = 0; if ($max_cards > 10) $max_users = 10; if ($max_cards < 0) $max_cards = 0; if ($max_turns < 0) $max_turns = 0; if ($max_discard < 0) $max_discard = 0; $query = "UPDATE card_tables SET max_users='$max_users', max_cards='$max_cards', max_turns='$max_turns', max_discard='$max_discard', discard='$discard_mode', discard_action='$discard_action', allowshow='$allowshow' WHERE id='$table'"; mysql_query($query); echo '
"; } if ($_POST['mode'] == "dealer_clearshuffle") { unset($summary); $result = getRows(cards,""); while ($row = mysql_fetch_array($result)) { $deck[] = $row['id']; } shuffle($deck); $deck = implode('.',$deck); if (!$failure) { $result = getRows(card_hands,"WHERE cardtable='$table' and status='play'"); if (getInfo(id,card_hands,"WHERE cardtable='$table' and status='play'")) { $statement = "End of round summary: "; $hand = fixArray(getInfo(hand_show,card_tables,"WHERE id='$table'").'.'.getInfo(hand_hide,card_tables,"WHERE id='$table'")); $hand = explode('.',$hand); $max = count($hand); for ($i = 0;$i < $max;$i++) { $card = $hand[$i]; if ($card) $cards[] = "the ".getInfo(name,cards,"WHERE id='$card'"); } if ($cards) { $cards = implode(', ',$cards); $summary[] = "On the table, there were $cards"; } unset($cards); while ($row = mysql_fetch_array($result)) { $user = $row['user']; $username = getInfo(username,users,"WHERE id='$user'"); $hand = fixArray($row['hand_show'].'.'.$row['hand_hide']); $hand = explode('.',$hand); $max = count($hand); for ($i = 0;$i < $max;$i++) { $card = $hand[$i]; if ($card) $cards[] = "the ".getInfo(name,cards,"WHERE id='$card'"); } if ($cards) $cards = implode(', ',$cards); else $cards = 'no cards'; $summary[] = "$username had $cards"; unset($cards); } if ($summary) $statement .= implode('The dealer has cleared the table and shuffled the deck."; } else $statement = "The dealer has cleared the table and shuffled the deck. A new round has now started."; cardHistory($table,$statement); $turn = getInfo(user,card_hands,"WHERE cardtable='$table' and user!='$userId' ORDER BY id ASC"); if (!$turn) $turn = $userId; $query = "UPDATE card_tables SET deck='$deck', discarded='', hand_hide='', hand_show='', turn='$turn', round='1' WHERE id='$table'"; mysql_query($query); $query = "UPDATE card_hands SET hand_hide='', hand_show='', discards='0' WHERE cardtable='$table'"; mysql_query($query); $query = "UPDATE card_hands SET status='play' WHERE status='fold' and cardtable='$table'"; mysql_query($query); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_discardshuffle") { $deck = explode('.',fixArray(getInfo(deck,card_tables,"WHERE id='$table'").'.'.getInfo(discarded,card_tables,"WHERE id='$table'"))); shuffle($deck); $deck = implode('.',$deck); $query = "UPDATE card_tables SET deck='$deck', discarded='' WHERE id='$table'"; mysql_query($query); if (!$failure) { $statement = "The dealer has gathered all discarded cards and shuffled them into the deck."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_remainshuffle") { $deck = explode('.',fixArray(getInfo(deck,card_tables,"WHERE id='$table'"))); shuffle($deck); $deck = implode('.',$deck); $query = "UPDATE card_tables SET deck='$deck' WHERE id='$table'"; mysql_query($query); if (!$failure) { $statement = "The dealer has shuffled the remaining cards in the deck."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } if ($_POST['mode'] == "dealer_sitout") { $user = $_POST['user']; $username = getInfo(username,users,"WHERE id='$user'"); $hand = fixArray(getInfo(hand_show,card_hands,"WHERE user='$user'").'.'.getInfo(hand_show,card_hands,"WHERE user='$user'")); $discarded = fixArray(getInfo(discarded,card_tables,"WHERE id='$table'").'.'.$hand); $status = getInfo(status,card_hands,"WHERE user='$user'"); if (($status != "play") && ($status != "fold")) $failure = "The player is already sitting out."; if (!$failure) { if (getInfo(turn,card_tables,"WHERE id='$table'") == $user) changeTurn($table); $query = "UPDATE card_tables SET discarded='$discarded' WHERE id='$table'"; mysql_query($query); $query = "UPDATE card_hands SET hand_show='', hand_hide='', status='out' WHERE user='$user'"; mysql_query($query); $statement = "The dealer forced $username to fold their hand and sit out."; cardHistory($table,$statement); echo '
"; } else { echo '
"; } } } echo ' ';
echo ' ';
if (getInfo(dealer,card_tables,"WHERE id='$table'") == $userId) {
echo '
';
echo ' ';
}
$turn = getInfo(turn,card_tables,"WHERE id='$table'");
echo '
';
echo ' ';
echo '';
}
?>
';
echo ' ';
echo ''; echo ' ';
echo '';
if ($turn) {
$turnname = getInfo(username,users,"WHERE id='$turn'");
if ($turn == $userId) echo 'Current Turn: It is your turn';
else echo "Current Turn: It is $turnname's turn";
} else echo "The round is over.";
echo ' ';
echo ' ';
echo '
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||