foreach ($user->getValue('cities') as $city) { if ($city->getValue('id') == $data || @preg_match('/^' . $data . '$/i', $city->getValue('name'))) { $close_upper_bound = intval($city->getValue('id')) + 30000; $dbcities = mysql_query("SELECT city_id FROM server_cities WHERE server_id=" . $server->getID() . " AND city_id < {$close_upper_bound} ORDER BY city_id DESC LIMIT 10", $db) or die(mysql_error()); $reply = 'On ' . $server->getName() . ' near ' . $city->getValue('name') . '@' . $city->getValue('id') . ' : '; while ($icity = mysql_fetch_assoc($dbcities)) { $cityo = new city($icity['city_id']); $reply .= $cityo->getValue('name') . '@' . $cityo->getValue('id') . ' '; } break; } } } else { foreach ($user->getValue('cities') as $city) { if ($city->getValue('id') == $data || @preg_match('/^' . $data . '$/i', $city->getValue('name'))) { $reply = $city->getValue('name') . '@' . $city->getValue('id') . ' Population: ' . $city->getValue('population') . ' / Defense: ' . ($city->getValue('defense') + 1) . ' / Units: ' . $city->unit_count(); break; } } //end foreach } } break; case 'attack': case 'move': preg_match('/^([^\\s]+)[\\s]+from[\\s]+([^\\s]+)[\\s]+with[\\s]+([\\d]+)[\\s]+([^\\s]+)$/', trim($data), $data); var_dump($data); if (!count($data)) { $reply = 'I do not understand your troop movement request.'; } else { foreach ($user->getValue('cities') as $city) {
} //end while cities echo '</ul>'; } //end if ! tocity if (!$fromcity) { echo '<h2>Select a City to Attack/Move From</h2><ul>'; foreach ($current_user->getValue('cities') as $city) { echo '<li>'; echo '<a href="/server/' . $server->getID() . '/attack/' . $cities[0] . '+' . $city->getValue('id') . '">'; if ($city->getValue('name')) { echo htmlentities($city->getValue('name')) . ' / '; } echo 'Location: ' . $city->getValue('id'); echo '</a> / Population: ' . $city->getValue('population') . ' / Defense: ' . (intval($city->getValue('defense')) + 1); echo ' / Units: ' . intval($city->unit_count()); echo '</li>'; } //end foreach cities echo '</ul>'; } //end if ! fromcity if ($fromcity && $tocity) { $units = mysql_query("SELECT unit_id,name,cost FROM units WHERE server_id=" . $server->getID(), $db) or die(mysql_query()); while ($unit = mysql_fetch_assoc($units)) { $unit_list .= "\t\t\t<li>"; $unit_list .= htmlentities($unit['name']); $unit_list .= ' (' . intval($fromcity->getValue('unit_' . $unit['unit_id'])) . ')'; $unit_list .= '<form method="post" action="">'; $unit_list .= ' <input type="hidden" name="attack_id" value="' . $unit['unit_id'] . '" />'; $unit_list .= ' <input type="text" name="attack_count" value="Number to attack with" onclick="this.value=\'\'" />';
} if (!$can_access) { $can_access = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access'); if ($can_access !== true && intval($can_access) > time()) { $can_access_time = ceil(($can_access - time()) / 60); } $can_access = $can_access === true || intval($can_access) > time(); } //end if ! can_access if ($can_access) { if (!$server) { $server = new server($_REQUEST['server_id']); } $units = mysql_query("SELECT unit_id,name,description,cost FROM units WHERE server_id=" . $server->getID(), $db) or die(mysql_query()); while ($unit = mysql_fetch_assoc($units)) { $unit_options .= "\t\t\t" . '<option value="' . $unit['unit_id'] . '">' . htmlentities($unit['name']) . ' (' . $unit['cost'] . ' Gold)</option>' . "\n"; $unit_list .= "\t\t\t<li>"; $unit_list .= htmlentities($unit['name']); $unit_list .= ' (' . intval($this_city->getValue('unit_' . $unit['unit_id'])) . ')'; if ($unit['description']) { $unit_list .= ' - ' . htmlentities($unit['description']); } $unit_list .= "</li>\n"; } //end while unit echo '<h3>Units (' . $this_city->unit_count() . ')</h3>'; echo '<ul>'; echo $unit_list; echo '</ul>'; } //end if can_access