| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Travel to other locations and magic portals. |
| 5 |
* |
| 6 |
* @name : travel.php |
| 7 |
* @copyright : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : thindil <thindil@users.sourceforge.net> |
| 9 |
* @author : eyescream <tduda@users.sourceforge.net> |
| 10 |
* @version : 1.4 |
| 11 |
* @since : 28.03.2007 |
| 12 |
* |
| 13 |
*/ |
| 14 |
|
| 15 |
// |
| 16 |
// |
| 17 |
// This program is free software; you can redistribute it and/or modify |
| 18 |
// it under the terms of the GNU General Public License as published by |
| 19 |
// the Free Software Foundation; either version 2 of the License, or |
| 20 |
// (at your option) any later version. |
| 21 |
// |
| 22 |
// This program is distributed in the hope that it will be useful, |
| 23 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
// GNU General Public License for more details. |
| 26 |
// |
| 27 |
// You should have received a copy of the GNU General Public License |
| 28 |
// along with this program; if not, write to the Free Software |
| 29 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 |
// |
| 31 |
// $Id$ |
| 32 |
|
| 33 |
$title='Stajnie'; |
| 34 |
require_once ('includes/head.php'); |
| 35 |
require_once ('includes/funkcje.php'); |
| 36 |
require_once ('includes/turnfight.php'); |
| 37 |
|
| 38 |
require_once('class/monster_class.php'); |
| 39 |
require_once('class/fight_class.php'); |
| 40 |
|
| 41 |
/** |
| 42 |
* Initialization of variable |
| 43 |
*/ |
| 44 |
if (!isset($_GET['akcja'])) |
| 45 |
{ |
| 46 |
$_GET['akcja'] = ''; |
| 47 |
} |
| 48 |
if (!isset($_GET['action'])) |
| 49 |
{ |
| 50 |
$_GET['action'] = ''; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Get the localization for game |
| 55 |
*/ |
| 56 |
require_once ('languages/'.$player -> lang.'/travel.php'); |
| 57 |
|
| 58 |
if ($player -> location == L_DUNGEON) |
| 59 |
{ |
| 60 |
error (ERROR); |
| 61 |
} |
| 62 |
if ($player -> hp == 0) |
| 63 |
{ |
| 64 |
error (YOU_DEAD); |
| 65 |
} |
| 66 |
/** |
| 67 |
* Assign variables to template |
| 68 |
*/ |
| 69 |
$smarty -> assign(array('Portal' => '', |
| 70 |
'Maps' => '')); |
| 71 |
|
| 72 |
|
| 73 |
/** |
| 74 |
* Function to start travel (walk or caravan), fight in random encounter and arrive on place. |
| 75 |
* $intEnergyCost - cost of travel in energy. |
| 76 |
* $intGoldCost - cost of travel in gold. |
| 77 |
* $strDestination - where should player be after succesful travel. |
| 78 |
*/ |
| 79 |
|
| 80 |
/** |
| 81 |
* Check if player have not traveled yet (needed in card.php) |
| 82 |
*/ |
| 83 |
if ($_GET['akcja'] != '' && $_GET['step'] != '') |
| 84 |
{ |
| 85 |
$Query = $db -> Execute('SELECT `changed_loc` FROM `players` WHERE `id`='.$player -> id); |
| 86 |
if ($Query -> fields['changed_loc'] == "N" || $Query -> fields['changed_loc'] == "") |
| 87 |
{ |
| 88 |
$db -> Execute('UPDATE `players` SET `changed_loc`="Y" WHERE `id`='.$player -> id); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
function travel ($intEnergyCost, $intGoldCost, $strDestination) |
| 93 |
{ |
| 94 |
global $player; |
| 95 |
global $smarty; |
| 96 |
global $enemy; |
| 97 |
global $db; |
| 98 |
|
| 99 |
$fight = $db -> Execute('SELECT `fight` FROM `players` WHERE `id`='.$player -> id); |
| 100 |
if ((rand(1,5) < 5 && $fight -> fields['fight'] == 0)) // No bandits. |
| 101 |
{ |
| 102 |
$db -> Execute('UPDATE `players` SET `energy`=`energy`-'.$intEnergyCost.', `credits`=`credits`-'.$intGoldCost.', `miejsce`=\''.$strDestination.'\' WHERE `id`='.$player -> id); //Pay and finish travel. |
| 103 |
$smarty -> assign('Message', '<p>'.MESSAGE1.'</p><p>'.YOU_REACH.'</p>'); |
| 104 |
$smarty -> display('error1.tpl'); |
| 105 |
} |
| 106 |
else |
| 107 |
{ |
| 108 |
if ($player -> energy < $intEnergyCost + 1) // Too exhausted to both fight the bandit and arrive on place. |
| 109 |
{ |
| 110 |
banditrobbery (MESSAGE2, $player -> location); // Instant death. |
| 111 |
} |
| 112 |
else // Begin fight. |
| 113 |
{ |
| 114 |
$smarty -> assign ('Message', MESSAGE3); |
| 115 |
$smarty -> display ('error1.tpl'); |
| 116 |
/* $arrbandit = array (); |
| 117 |
for ($i=0;$i<8;$i++) |
| 118 |
{ |
| 119 |
$arrbandit[$i] = rand(1,500); |
| 120 |
}*/ |
| 121 |
if (!isset($_SESSION['amount'])) { |
| 122 |
$db -> Execute('UPDATE `players` SET `fight`=99999, `miejsce`=\''.L_TRAVEL.'\' WHERE `id`='.$player -> id); |
| 123 |
|
| 124 |
$_SESSION['amount'] = 1; |
| 125 |
$_SESSION['mon0']['id'] = 99999; |
| 126 |
$_SESSION['mon0']['user'] = 'Bandyta'; |
| 127 |
$_SESSION['mon0']['level'] = 1; |
| 128 |
$_SESSION['mon0']['credits'] = rand(1,500); |
| 129 |
$_SESSION['mon0']['exp'] = rand(rand(1,500),rand(1,500)); |
| 130 |
$_SESSION['mon0']['actionpoints'] = rand(1,500); |
| 131 |
$_SESSION['mon0']['defence'] = $_SESSION['mon0']['actionpoints']; |
| 132 |
$_SESSION['mon0']['hp'] = $_SESSION['mon0']['actionpoints']; |
| 133 |
$_SESSION['mon0']['damage'] = rand(1,500); |
| 134 |
$_SESSION['mon0']['hitmodificator'] = rand(1,500); |
| 135 |
$_SESSION['mon0']['missmodificator'] = $_SESSION['mon0']['hitmodificator']; |
| 136 |
$_SESSION['mon0']['attackspeed'] = rand(1,500); |
| 137 |
|
| 138 |
$monster = new Monster($player -> fight,1,0); |
| 139 |
$attacker = new Fighter($player -> id); |
| 140 |
|
| 141 |
for ($k = 0; $k < $_SESSION['amount']; $k++) { |
| 142 |
//each monster identifier |
| 143 |
$strIndex = 'mon'.$k; |
| 144 |
$_SESSION[$strIndex]['id'] = $monster -> id; |
| 145 |
//each monster hit points |
| 146 |
// $strIndex = 'monhp'.$k; |
| 147 |
$_SESSION[$strIndex]['hp'] = $monster -> hp; |
| 148 |
//each monster action points |
| 149 |
// $strIndex = 'monap'.$k; |
| 150 |
if ($attacker -> speed > $monster -> attackspeed) { |
| 151 |
$_SESSION[$strIndex]['ap'] = 1; |
| 152 |
} |
| 153 |
else { |
| 154 |
$_SESSION[$strIndex]['ap'] = floor($monster -> attackspeed / $attacker -> speed); |
| 155 |
if ($_SESSION[$strIndex]['ap'] > 5) { |
| 156 |
$_SESSION[$strIndex]['ap'] = 5; |
| 157 |
} |
| 158 |
} |
| 159 |
$tmpActionArr[$k][0] = $monster -> attackspeed; |
| 160 |
$tmpActionArr[$k][1] = $k; |
| 161 |
} |
| 162 |
$tmpActionArr[$k][0] = $attacker -> speed; |
| 163 |
$tmpActionArr[$k][1] = -1; |
| 164 |
|
| 165 |
/** |
| 166 |
* function to compare elements of actionArr |
| 167 |
*/ |
| 168 |
function aacmp($a,$b) { |
| 169 |
if ($a[0] == $b[0]) return 0; |
| 170 |
return ($a[0] > $b[0]) ? -1 : 1; |
| 171 |
} |
| 172 |
|
| 173 |
usort($tmpActionArr,"aacmp"); |
| 174 |
for ($k = 0; $k <= $_SESSION['amount']; $k++) { |
| 175 |
$actionArr[$k] = $tmpActionArr[$k][1]; |
| 176 |
} |
| 177 |
$_SESSION['actionArr'] = $actionArr; |
| 178 |
$_SESSION['exhaust']=0; |
| 179 |
if ($attacker -> speed > $monster -> attackspeed) { |
| 180 |
$_SESSION['points'] = floor($attacker -> speed / $monster -> attackspeed); |
| 181 |
if ($_SESSION['points'] > 5) { |
| 182 |
$_SESSION['points'] = 5; |
| 183 |
} |
| 184 |
} |
| 185 |
else { |
| 186 |
$_SESSION['points'] = 1; |
| 187 |
} |
| 188 |
$_SESSION['round']=0; |
| 189 |
|
| 190 |
|
| 191 |
} |
| 192 |
// $enemy = array('name' => 'Bandyta', |
| 193 |
// 'strength' => $arrbandit[0], |
| 194 |
// 'agility' => $arrbandit[1], |
| 195 |
// 'hp' => $arrbandit[2], |
| 196 |
// 'level' => $arrbandit[3], |
| 197 |
// 'endurance' => $arrbandit[6], |
| 198 |
// 'speed' => $arrbandit[7], |
| 199 |
// 'exp1' => $arrbandit[4], |
| 200 |
// 'exp2' => $arrbandit[5]); |
| 201 |
|
| 202 |
/** |
| 203 |
* Secure the fight (player will eventually meet the monster, and his location prevents him from cheating). |
| 204 |
* Store the backup of original location (if player dies in fight, he will be transported back). |
| 205 |
* Results: player won the fight and logged out before clicking the final link - all is ok. |
| 206 |
* Player met the bandit and logged out - after log in he's dead and in location "TRAVEL". After next reset he can continue. |
| 207 |
*/ |
| 208 |
if (!isset ($_SESSION['originalLocation']) && $player -> location != L_TRAVEL) |
| 209 |
{ |
| 210 |
$_SESSION['originalLocation'] = $player -> location; |
| 211 |
} |
| 212 |
|
| 213 |
turnfight ('travel.php?'.$_SERVER['QUERY_STRING']); |
| 214 |
/* if (!isset ($_POST['action'])) |
| 215 |
{ |
| 216 |
turnfight ($arrbandit[4],$arrbandit[5],'','travel.php?'.$_SERVER['QUERY_STRING']); |
| 217 |
} |
| 218 |
else |
| 219 |
{ |
| 220 |
turnfight ($arrbandit[4],$arrbandit[5],$_POST['action'],'travel.php?'.$_SERVER['QUERY_STRING']); |
| 221 |
}*/ |
| 222 |
$myhp = $db -> Execute('SELECT `hp`, `fight` FROM `players` WHERE `id`='.$player -> id); // After each fight turn get current info about player. |
| 223 |
if ($myhp -> fields['fight'] == 0) |
| 224 |
{ |
| 225 |
if ($myhp -> fields['hp'] == 0) // Lost fight. |
| 226 |
{ |
| 227 |
banditrobbery (MESSAGE4, $_SESSION['originalLocation']); |
| 228 |
$_SESSION['originalLocation'] = NULL; |
| 229 |
unset($_SESSION['originalLocation']); |
| 230 |
// $db -> Execute('UPDATE `players` SET `miejsce`=\'Altara\''); |
| 231 |
} |
| 232 |
else |
| 233 |
{ |
| 234 |
$db -> Execute('UPDATE `players` SET `energy`=`energy`-'.($intEnergyCost+1).', `credits`=`credits`-'.$intGoldCost.', `miejsce`=\''.$strDestination.'\' WHERE `id`='.$player -> id); //Pay for travel (-fight energy) and finish. |
| 235 |
$smarty -> assign('Message', '<p>'.MESSAGE5.'</p><p>'.YOU_REACH.'</p>'); |
| 236 |
$smarty -> display('error1.tpl'); |
| 237 |
} |
| 238 |
} |
| 239 |
$myhp -> Close(); |
| 240 |
} |
| 241 |
} |
| 242 |
$fight -> Close(); |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* Compute amount of lost gold and platinum. Take them from player and kill him. Show him a way to resurrect. |
| 247 |
* $strBeginningText - text saying whether we are dead because of not having enough energy, or because we lost fight. |
| 248 |
* $strReturnLocation - where dead player should be going to (back where he came from). |
| 249 |
*/ |
| 250 |
function banditrobbery ($strBeginningText, $strReturnLocation) |
| 251 |
{ |
| 252 |
global $player; |
| 253 |
global $db; |
| 254 |
global $smarty; |
| 255 |
|
| 256 |
if (!isset($strReturnLocation)) $strReturnLocation='Altara'; |
| 257 |
|
| 258 |
$intLostGold = max(ceil($player -> credits * rand(5,15) / 100), 0); |
| 259 |
$intLostPlatinum = ceil($player -> platinum * rand(5,15) / 100); |
| 260 |
$db -> Execute('UPDATE `players` SET `miejsce`=\''.$strReturnLocation.'\', `hp`=0, `energy`=`energy`-1, `credits`=`credits` -'.$intLostGold.', `platinum`=`platinum` - '.$intLostPlatinum.' WHERE `id`='.$player -> id); |
| 261 |
$strHospital = '<p>'.A_HOSPITAL1; |
| 262 |
switch ($strReturnLocation) |
| 263 |
{ |
| 264 |
case L_FOREST: |
| 265 |
$strHospital .= '<a href="las.php?action=hermit">'.A_HOSPITAL2.'</a>'; |
| 266 |
break; |
| 267 |
case L_MOUNTAINS: |
| 268 |
$strHospital .= '<a href="gory.php?action=hermit">'.A_HOSPITAL2.'</a>'; |
| 269 |
break; |
| 270 |
default: |
| 271 |
$strHospital .= '<a href="hospital.php">'.A_HOSPITAL2.'</a>'; |
| 272 |
} |
| 273 |
$smarty -> assign('Message', $strBeginningText.$intLostGold.G_COINS.$intLostPlatinum.PLATINUM.$strHospital.'</p>'); |
| 274 |
$smarty -> display('error1.tpl'); |
| 275 |
} |
| 276 |
|
| 277 |
// Check if hero's reward item was already given. |
| 278 |
$objItem = $db -> Execute('SELECT `value` FROM `settings` WHERE `setting`=\'item\''); |
| 279 |
|
| 280 |
if ($_GET['akcja'] == '' && $_GET['action'] == '') // Display 'Stables' links. |
| 281 |
{ |
| 282 |
switch ($player -> location) |
| 283 |
{ |
| 284 |
case L_CAPITOL: // Capitol city - able to go through Portal or to Astral Plans. |
| 285 |
if ($player -> maps > 9 && !$objItem -> fields['value'] && $player -> rank != RANK_HERO) |
| 286 |
{ |
| 287 |
$smarty -> assign(array('Maps' => 1, |
| 288 |
'Portal1' => PORTAL1, |
| 289 |
'Ayes' => YES, |
| 290 |
'Ano' => NO)); |
| 291 |
} |
| 292 |
/** |
| 293 |
* Portals to astral plans |
| 294 |
*/ |
| 295 |
$arrPlans = array(MAP1, MAP2, MAP3, MAP4, MAP5, MAP6, MAP7); |
| 296 |
$objPlans = $db -> Execute('SELECT `name` FROM `astral_plans` WHERE `owner`='.$player -> id.' AND `name` LIKE \'M%\' AND `location`=\'V\''); |
| 297 |
$arrName = array(''); |
| 298 |
$arrLink = array(); |
| 299 |
$i = 0; |
| 300 |
while (!$objPlans -> EOF) |
| 301 |
{ |
| 302 |
$intNumber = (int)str_replace('M', '', $objPlans -> fields['name']) -1; |
| 303 |
$arrName[$i] = $arrPlans[$intNumber]; |
| 304 |
$arrLink[$i] = $intNumber; |
| 305 |
$i++; |
| 306 |
$objPlans -> MoveNext(); |
| 307 |
} |
| 308 |
$objPlans -> Close(); |
| 309 |
|
| 310 |
$smarty -> assign(array('Stablesinfo' => STABLES_INFO, |
| 311 |
'Amountains' => A_MOUNTAINS, |
| 312 |
'Aforest' => A_FOREST, |
| 313 |
'Tportals' => $arrName, |
| 314 |
'Tporlink' => $arrLink, |
| 315 |
'Tporinfo' => T_PORTALS, |
| 316 |
'Aelfcity' => A_ELFCITY)); |
| 317 |
break; |
| 318 |
case L_ELVEN_CITY: |
| 319 |
$smarty -> assign(array('Stablesinfo' => STABLES_INFO, |
| 320 |
'Aforest' => A_FOREST)); |
| 321 |
break; |
| 322 |
case L_FOREST: |
| 323 |
$smarty -> assign(array('Outside' => OUTSIDE, |
| 324 |
'Aelfcity' => A_ELFCITY, |
| 325 |
'Amountains' => A_MOUNTAINS)); |
| 326 |
break; |
| 327 |
case L_MOUNTAINS: |
| 328 |
$smarty -> assign(array('Outside' => OUTSIDE, |
| 329 |
'Aforest' => A_FOREST, |
| 330 |
'Aelfcity' => A_ELFCITY)); |
| 331 |
break; |
| 332 |
} |
| 333 |
$smarty -> assign('ACapitol', A_CAPITOL); |
| 334 |
} |
| 335 |
|
| 336 |
if ($_GET['action'] != '') |
| 337 |
{ |
| 338 |
switch ($player -> location) |
| 339 |
{ |
| 340 |
case L_CAPITOL: |
| 341 |
if ($_GET['action'] == 'powrot') |
| 342 |
{ |
| 343 |
error(YOU_IN); |
| 344 |
} |
| 345 |
break; |
| 346 |
case L_ELVEN_CITY: |
| 347 |
if ($_GET['action'] == 'city2') |
| 348 |
{ |
| 349 |
error(YOU_IN); |
| 350 |
} |
| 351 |
if ($_GET['action'] == 'gory') |
| 352 |
{ |
| 353 |
error(MNT_FREE); |
| 354 |
} |
| 355 |
break; |
| 356 |
case L_FOREST: |
| 357 |
if ($_GET['action'] == 'las') |
| 358 |
{ |
| 359 |
error(YOU_IN); |
| 360 |
} |
| 361 |
break; |
| 362 |
case L_MOUNTAINS: |
| 363 |
if ($_GET['action'] == 'gory') |
| 364 |
{ |
| 365 |
error(YOU_IN); |
| 366 |
} |
| 367 |
if ($_GET['action'] == 'city2') |
| 368 |
{ |
| 369 |
error(CITY_FREE); |
| 370 |
} |
| 371 |
break; |
| 372 |
} |
| 373 |
|
| 374 |
$baseEnergyCosts = array('walk' => 5, |
| 375 |
'caravan' => 1, |
| 376 |
'teleport' => 0); |
| 377 |
$baseGoldCosts = array('walk' => 0, |
| 378 |
'caravan' => 1000, |
| 379 |
'teleport' => 5000); |
| 380 |
|
| 381 |
if ($_GET['akcja'] == '') |
| 382 |
{ |
| 383 |
switch ($_GET['action']) |
| 384 |
{ |
| 385 |
case 'gory': |
| 386 |
if ($player -> location == L_CAPITOL) |
| 387 |
{ |
| 388 |
$baseEnergyCosts = array('walk' => 4, |
| 389 |
'caravan' => 1, |
| 390 |
'teleport' => 0); |
| 391 |
$baseGoldCosts = array('walk' => 0, |
| 392 |
'caravan' => 800, |
| 393 |
'teleport' => 5000); |
| 394 |
} |
| 395 |
break; |
| 396 |
|
| 397 |
case 'las': |
| 398 |
if ($player -> location == L_CAPITOL) |
| 399 |
{ |
| 400 |
$baseEnergyCosts = array('walk' => 2.5, |
| 401 |
'caravan' => 1, |
| 402 |
'teleport' => 0); |
| 403 |
$baseGoldCosts = array('walk' => 0, |
| 404 |
'caravan' => 500, |
| 405 |
'teleport' => 5000); |
| 406 |
} |
| 407 |
if ($player -> location == L_ELVEN_CITY) |
| 408 |
{ |
| 409 |
$baseEnergyCosts = array('walk' => 6, |
| 410 |
'caravan' => 1, |
| 411 |
'teleport' => 0); |
| 412 |
$baseGoldCosts = array('walk' => 0, |
| 413 |
'caravan' => 1200, |
| 414 |
'teleport' => 5000); |
| 415 |
} |
| 416 |
break; |
| 417 |
|
| 418 |
case 'city2': |
| 419 |
if ($player -> location == L_FOREST) |
| 420 |
{ |
| 421 |
$baseEnergyCosts = array('walk' => 6, |
| 422 |
'caravan' => 1, |
| 423 |
'teleport' => 0); |
| 424 |
$baseGoldCosts = array('walk' => 0, |
| 425 |
'caravan' => 1200, |
| 426 |
'teleport' => 5000); |
| 427 |
} |
| 428 |
break; |
| 429 |
|
| 430 |
case 'powrot': |
| 431 |
if ($player -> location == L_FOREST) |
| 432 |
{ |
| 433 |
$baseEnergyCosts = array('walk' => 2.5, |
| 434 |
'caravan' => 1, |
| 435 |
'teleport' => 0); |
| 436 |
$baseGoldCosts = array('walk' => 0, |
| 437 |
'caravan' => 500, |
| 438 |
'teleport' => 5000); |
| 439 |
} |
| 440 |
if ($player -> location == L_MOUNTAINS) |
| 441 |
{ |
| 442 |
$baseEnergyCosts = array('walk' => 4, |
| 443 |
'caravan' => 1, |
| 444 |
'teleport' => 0); |
| 445 |
$baseGoldCosts = array('walk' => 0, |
| 446 |
'caravan' => 800, |
| 447 |
'teleport' => 5000); |
| 448 |
} |
| 449 |
break; |
| 450 |
} |
| 451 |
|
| 452 |
$smarty -> assign(array('Acaravan' => A_CARAVAN." (".$baseGoldCosts['caravan']." ".A_COST.", ".$baseEnergyCosts['caravan']." ".A_ENERGY1.")", |
| 453 |
'Awalk' => A_WALK." (".$baseEnergyCosts['walk']." ".A_ENERGY2.")", |
| 454 |
'Ateleport' => A_TELEPORT." (".$baseGoldCosts['teleport']." ".A_COST.")", |
| 455 |
'Aback' => A_BACK)); |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
if ($_GET['akcja'] != '' && $player -> location == L_CAPITOL && !$objItem -> fields['value'] && $player -> maps >= 10 && $player -> rank != RANK_HERO) |
| 460 |
{ |
| 461 |
if ($_GET['akcja'] == 'tak' ) |
| 462 |
{ |
| 463 |
$db -> Execute('UPDATE `players` SET `miejsce`=\''.L_PORTAL.'\', `maps` = `maps` - 10 WHERE `id`='.$player -> id); |
| 464 |
$smarty -> assign(array('Portal' => 'Y', |
| 465 |
'Portal2' => PORTAL2)); |
| 466 |
} |
| 467 |
if ($_GET['akcja'] == 'nie') |
| 468 |
{ |
| 469 |
$smarty -> assign(array('Portal' => 'N', |
| 470 |
'Portal3' => PORTAL3)); |
| 471 |
} |
| 472 |
} |
| 473 |
$objItem -> Close(); |
| 474 |
|
| 475 |
if ($_GET['akcja'] != '' && $_GET['akcja'] !== 'tak' && $_GET['akcja'] !== 'nie') |
| 476 |
{ |
| 477 |
/** |
| 478 |
* Travel to places other than portals - error checking. |
| 479 |
*/ |
| 480 |
if ( $_GET['step'] !=='walk' && $_GET['step'] !=='caravan' && $_GET['step'] !=='teleport') |
| 481 |
{ |
| 482 |
error (ERROR); |
| 483 |
} |
| 484 |
$arrLocation = array(L_CAPITOL, L_ELVEN_CITY, L_TRAVEL, L_MOUNTAINS, L_FOREST); |
| 485 |
if (!in_array($player -> location, $arrLocation)) |
| 486 |
{ |
| 487 |
error (ERROR); |
| 488 |
} |
| 489 |
$arrEnergyCosts = array('walk' => 5, |
| 490 |
'caravan' => 1, |
| 491 |
'teleport' => 0); |
| 492 |
$arrGoldCosts = array('walk' => 0, |
| 493 |
'caravan' => 1000, |
| 494 |
'teleport' => 5000); |
| 495 |
$intEnergy = $arrEnergyCosts[$_GET['step']]; // Assign basic travel costs. |
| 496 |
$intGold = $arrGoldCosts[$_GET['step']]; |
| 497 |
|
| 498 |
/** |
| 499 |
* Set travel cost based on current place, destination and travel method. |
| 500 |
*/ |
| 501 |
switch ($_GET['akcja']) |
| 502 |
{ |
| 503 |
/** |
| 504 |
* Travel to mountains. |
| 505 |
*/ |
| 506 |
case 'gory': |
| 507 |
if ($player -> location == L_ELVEN_CITY) |
| 508 |
{ |
| 509 |
error (ERROR); |
| 510 |
} |
| 511 |
if( $_GET['step'] == 'teleport') |
| 512 |
{ |
| 513 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`-'.$arrGoldCosts['teleport'].', `miejsce`=\''.L_MOUNTAINS.'\' WHERE `id`='.$player -> id); |
| 514 |
error (YOU_REACH); |
| 515 |
} |
| 516 |
else |
| 517 |
{ |
| 518 |
if ($player -> location == L_CAPITOL) |
| 519 |
{ |
| 520 |
$intEnergy *= 0.8; |
| 521 |
$intGold *= 0.8; |
| 522 |
if ($_GET['step'] == 'caravan') |
| 523 |
{ |
| 524 |
$intEnergy = 1; |
| 525 |
} |
| 526 |
} |
| 527 |
if ($player -> energy < $intEnergy) |
| 528 |
{ |
| 529 |
error (NO_ENERGY); |
| 530 |
} |
| 531 |
if ($player -> credits < $intGold && $_GET['step'] != 'walk') // Criminals with fines still can walk. |
| 532 |
{ |
| 533 |
error (NO_MONEY); |
| 534 |
} |
| 535 |
travel ($intEnergy, $intGold, L_MOUNTAINS); |
| 536 |
} |
| 537 |
break; |
| 538 |
/** |
| 539 |
* Travel to forest. |
| 540 |
*/ |
| 541 |
case 'las': |
| 542 |
if( $_GET['step'] == 'teleport') |
| 543 |
{ |
| 544 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`-'.$arrGoldCosts['teleport'].', `miejsce`=\''.L_FOREST.'\' WHERE `id`='.$player -> id); |
| 545 |
error (YOU_REACH); |
| 546 |
} |
| 547 |
else |
| 548 |
{ |
| 549 |
if ($player -> location == L_CAPITOL) |
| 550 |
{ |
| 551 |
$intEnergy *= 0.5; |
| 552 |
$intGold *= 0.5; |
| 553 |
if ($_GET['step'] == 'caravan') |
| 554 |
{ |
| 555 |
$intEnergy = 1; |
| 556 |
} |
| 557 |
} |
| 558 |
if ($player -> location == L_ELVEN_CITY) |
| 559 |
{ |
| 560 |
$intEnergy *= 1.2; |
| 561 |
$intGold *= 1.2; |
| 562 |
if ($_GET['step'] == 'caravan') |
| 563 |
{ |
| 564 |
$intEnergy = 1; |
| 565 |
} |
| 566 |
} |
| 567 |
if ($player -> energy < $intEnergy) |
| 568 |
{ |
| 569 |
error (NO_ENERGY); |
| 570 |
} |
| 571 |
if ($player -> credits < $intGold && $_GET['step'] != 'walk') // Criminals with fines still can walk. |
| 572 |
{ |
| 573 |
error (NO_MONEY); |
| 574 |
} |
| 575 |
travel ($intEnergy, $intGold, L_FOREST); |
| 576 |
} |
| 577 |
break; |
| 578 |
/** |
| 579 |
* Travel to Agarakar (in code marked as Elven City). |
| 580 |
*/ |
| 581 |
case 'city2': |
| 582 |
if ($player -> location == L_MOUNTAINS) |
| 583 |
{ |
| 584 |
error (ERROR); |
| 585 |
} |
| 586 |
if ( $_GET['step'] == 'teleport') |
| 587 |
{ |
| 588 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`-'.$arrGoldCosts['teleport'].', `miejsce`=\''.L_ELVEN_CITY.'\' WHERE `id`='.$player -> id); |
| 589 |
error (YOU_REACH); |
| 590 |
} |
| 591 |
else |
| 592 |
{ |
| 593 |
if ($player -> location == L_FOREST) |
| 594 |
{ |
| 595 |
$intEnergy *= 1.2; |
| 596 |
$intGold *= 1.2; |
| 597 |
if ($_GET['step'] == 'caravan') |
| 598 |
{ |
| 599 |
$intEnergy = 1; |
| 600 |
} |
| 601 |
} |
| 602 |
if ($player -> energy < $intEnergy) |
| 603 |
{ |
| 604 |
error (NO_ENERGY); |
| 605 |
} |
| 606 |
if ($player -> credits < $intGold && $_GET['step'] != 'walk') // Criminals with fines still can walk. |
| 607 |
{ |
| 608 |
error (NO_MONEY); |
| 609 |
} |
| 610 |
travel ($intEnergy, $intGold, L_ELVEN_CITY); |
| 611 |
} |
| 612 |
break; |
| 613 |
/** |
| 614 |
* Travel to Capitol, general 'back' action. |
| 615 |
*/ |
| 616 |
case 'powrot': |
| 617 |
if( $_GET['step'] == 'teleport') |
| 618 |
{ |
| 619 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`-'.$arrGoldCosts['teleport'].', `miejsce`=\''. |
| 620 |
L_CAPITOL.'\' WHERE `id`='.$player -> id); |
| 621 |
error (YOU_REACH); |
| 622 |
} |
| 623 |
else |
| 624 |
{ |
| 625 |
if ($player -> location == L_FOREST) |
| 626 |
{ |
| 627 |
$intEnergy *= 0.5; |
| 628 |
$intGold *= 0.5; |
| 629 |
if ($_GET['step'] == 'caravan') |
| 630 |
{ |
| 631 |
$intEnergy = 1; |
| 632 |
} |
| 633 |
} |
| 634 |
if ($player -> location == L_MOUNTAINS) |
| 635 |
{ |
| 636 |
$intEnergy *= 0.8; |
| 637 |
$intGold *= 0.8; |
| 638 |
if ($_GET['step'] == 'caravan') |
| 639 |
{ |
| 640 |
$intEnergy = 1; |
| 641 |
} |
| 642 |
} |
| 643 |
if ($player -> energy < $intEnergy) |
| 644 |
{ |
| 645 |
error (NO_ENERGY); |
| 646 |
} |
| 647 |
if ($player -> credits < $intGold && $_GET['step'] != 'walk') // Criminals with fines still can walk. |
| 648 |
{ |
| 649 |
error (NO_MONEY); |
| 650 |
} |
| 651 |
travel ($intEnergy, $intGold, L_CAPITOL); |
| 652 |
} |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
/** |
| 658 |
* Assign variables to template and display page |
| 659 |
*/ |
| 660 |
$smarty -> assign ( array('Action' => $_GET['akcja'], |
| 661 |
'Action2' => $_GET['action'], |
| 662 |
'Location' => $player -> location, |
| 663 |
'LCapitol' => L_CAPITOL, |
| 664 |
'LElvenCity' => L_ELVEN_CITY, |
| 665 |
'LMountains' => L_MOUNTAINS, |
| 666 |
'LForest' => L_FOREST, |
| 667 |
'LTravel' => L_TRAVEL)); |
| 668 |
$smarty -> display('travel.tpl'); |
| 669 |
|
| 670 |
require_once("includes/foot.php"); |
| 671 |
?> |