| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Magic portal - special location |
| 5 |
* |
| 6 |
* @name : portal.php |
| 7 |
* @copyright : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : thindil <thindil@users.sourceforge.net> |
| 9 |
* @version : 1.2 |
| 10 |
* @since : 29.07.2006 |
| 11 |
* |
| 12 |
*/ |
| 13 |
|
| 14 |
// |
| 15 |
// |
| 16 |
// This program is free software; you can redistribute it and/or modify |
| 17 |
// it under the terms of the GNU General Public License as published by |
| 18 |
// the Free Software Foundation; either version 2 of the License, or |
| 19 |
// (at your option) any later version. |
| 20 |
// |
| 21 |
// This program is distributed in the hope that it will be useful, |
| 22 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
// GNU General Public License for more details. |
| 25 |
// |
| 26 |
// You should have received a copy of the GNU General Public License |
| 27 |
// along with this program; if not, write to the Free Software |
| 28 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 29 |
// |
| 30 |
// $Id: portal.php 544 2006-07-29 08:35:11Z thindil $ |
| 31 |
|
| 32 |
$title = "Portal"; |
| 33 |
require_once("includes/head.php"); |
| 34 |
require_once ("includes/funkcje.php"); |
| 35 |
require_once("includes/turnfight.php"); |
| 36 |
|
| 37 |
require_once('class/monster_class.php'); |
| 38 |
require_once('class/fight_class.php'); |
| 39 |
|
| 40 |
/** |
| 41 |
* Get the localization for game |
| 42 |
*/ |
| 43 |
require_once("languages/".$player -> lang."/portal.php"); |
| 44 |
|
| 45 |
if ($player -> location != 'Portal') |
| 46 |
{ |
| 47 |
error (ERROR); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Assign variable to template |
| 52 |
*/ |
| 53 |
$smarty -> assign("Win", ''); |
| 54 |
|
| 55 |
if ($player -> hp <= 0 && !isset($_GET['action1'])) |
| 56 |
{ |
| 57 |
$db -> Execute("UPDATE players SET miejsce='Altara' WHERE id=".$player -> id); |
| 58 |
error (YOU_DEAD); |
| 59 |
} |
| 60 |
|
| 61 |
if (!isset ($_GET['action1'])) |
| 62 |
{ |
| 63 |
$smarty -> assign(array("Portaltext" => PORTAL_TEXT, |
| 64 |
"Afight2" => A_FIGHT2, |
| 65 |
"Aretreat" => A_RETREAT)); |
| 66 |
} |
| 67 |
|
| 68 |
if (isset ($_GET['action1']) && $_GET['action1'] == 'retreat' && $player -> hp > 0) |
| 69 |
{ |
| 70 |
$db -> Execute("UPDATE players SET miejsce='Altara' WHERE id=".$player -> id); |
| 71 |
$db -> Execute("UPDATE players SET energy=0 WHERE id=".$player -> id); |
| 72 |
$smarty -> assign(array("Portaltext" => PORTAL_TEXT, |
| 73 |
"Ahere" => A_HERE)); |
| 74 |
} |
| 75 |
|
| 76 |
if (isset ($_GET['action1']) && $_GET['action1'] == 'fight' && $player -> hp > 0) |
| 77 |
{ |
| 78 |
global $arrehp; |
| 79 |
if (!isset ($_GET['step'])) |
| 80 |
{ |
| 81 |
$smarty -> assign ("Message", START_FIGHT); |
| 82 |
$smarty -> display ('error1.tpl'); |
| 83 |
// $enemy = array ('name' => MONSTER_NAME, |
| 84 |
// 'strength' => 15000, |
| 85 |
// 'agility' => 15000, |
| 86 |
// 'hp' => 50000, |
| 87 |
// 'level' => 1, |
| 88 |
// 'endurance' => 15000, |
| 89 |
// 'speed' => 15000); |
| 90 |
|
| 91 |
if (!isset($_SESSION['amount'])) { |
| 92 |
$_SESSION['amount'] = 1; |
| 93 |
$_SESSION['mon0']['id'] = 999; |
| 94 |
$_SESSION['mon0']['user'] = MONSTER_NAME; |
| 95 |
$_SESSION['mon0']['level'] = 1; |
| 96 |
$_SESSION['mon0']['credits'] = 5000000; |
| 97 |
$_SESSION['mon0']['exp'] = 1000000; |
| 98 |
$_SESSION['mon0']['actionpoints'] = 15000; |
| 99 |
$_SESSION['mon0']['defence'] = 15000; |
| 100 |
$_SESSION['mon0']['hp'] = 100000; |
| 101 |
$_SESSION['mon0']['damage'] = 15000; |
| 102 |
$_SESSION['mon0']['hitmodificator'] = 15000; |
| 103 |
$_SESSION['mon0']['missmodificator'] = 15000; |
| 104 |
$_SESSION['mon0']['attackspeed'] = 15000; |
| 105 |
|
| 106 |
$monster = new Monster(999,1,0); |
| 107 |
$attacker = new Fighter($player -> id); |
| 108 |
|
| 109 |
for ($k = 0; $k < $_SESSION['amount']; $k++) { |
| 110 |
//each monster identifier |
| 111 |
$strIndex = 'mon'.$k; |
| 112 |
$_SESSION[$strIndex]['id'] = $monster -> id; |
| 113 |
//each monster hit points |
| 114 |
// $strIndex = 'monhp'.$k; |
| 115 |
$_SESSION[$strIndex]['hp'] = $monster -> hp; |
| 116 |
//each monster action points |
| 117 |
// $strIndex = 'monap'.$k; |
| 118 |
if ($attacker -> speed > $monster -> attackspeed) { |
| 119 |
$_SESSION[$strIndex]['ap'] = 1; |
| 120 |
} |
| 121 |
else { |
| 122 |
$_SESSION[$strIndex]['ap'] = floor($monster -> attackspeed / $attacker -> speed); |
| 123 |
if ($_SESSION[$strIndex]['ap'] > 5) { |
| 124 |
$_SESSION[$strIndex]['ap'] = 5; |
| 125 |
} |
| 126 |
} |
| 127 |
$tmpActionArr[$k][0] = $monster -> attackspeed; |
| 128 |
$tmpActionArr[$k][1] = $k; |
| 129 |
} |
| 130 |
$tmpActionArr[$k][0] = $attacker -> speed; |
| 131 |
$tmpActionArr[$k][1] = -1; |
| 132 |
|
| 133 |
/** |
| 134 |
* function to compare elements of actionArr |
| 135 |
*/ |
| 136 |
function aacmp($a,$b) { |
| 137 |
if ($a[0] == $b[0]) return 0; |
| 138 |
return ($a[0] > $b[0]) ? -1 : 1; |
| 139 |
} |
| 140 |
|
| 141 |
usort($tmpActionArr,"aacmp"); |
| 142 |
for ($k = 0; $k <= $_SESSION['amount']; $k++) { |
| 143 |
$actionArr[$k] = $tmpActionArr[$k][1]; |
| 144 |
} |
| 145 |
$_SESSION['actionArr'] = $actionArr; |
| 146 |
$_SESSION['exhaust']=0; |
| 147 |
if ($attacker -> speed > $monster -> attackspeed) { |
| 148 |
$_SESSION['points'] = floor($attacker -> speed / $monster -> attackspeed); |
| 149 |
if ($_SESSION['points'] > 5) { |
| 150 |
$_SESSION['points'] = 5; |
| 151 |
} |
| 152 |
} |
| 153 |
else { |
| 154 |
$_SESSION['points'] = 1; |
| 155 |
} |
| 156 |
$_SESSION['round']=0; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
if ($player -> hp <= 0) |
| 162 |
{ |
| 163 |
error (NO_HP); |
| 164 |
} |
| 165 |
if ($player -> energy <= 0) |
| 166 |
{ |
| 167 |
error (NO_ENERGY); |
| 168 |
} |
| 169 |
$db -> Execute("UPDATE players SET fight=999 WHERE id=".$player -> id); |
| 170 |
$arrehp = array (); |
| 171 |
turnfight ('portal.php?action1=fight'); |
| 172 |
/* if (!isset ($_POST['action'])) |
| 173 |
{ |
| 174 |
turnfight (1000000, 1000000, '', 'portal.php?action1=fight'); |
| 175 |
} |
| 176 |
else |
| 177 |
{ |
| 178 |
turnfight (1000000, 1000000, $_POST['action'], 'portal.php?action1=fight'); |
| 179 |
}*/ |
| 180 |
$myhp = $db -> Execute("SELECT hp, fight FROM players WHERE id=".$player -> id); |
| 181 |
$item = $db -> Execute("SELECT value FROM settings WHERE setting='item'"); |
| 182 |
if ($myhp -> fields['hp'] <= 0) |
| 183 |
{ |
| 184 |
$db -> Execute("UPDATE players SET energy=0, miejsce='Altara' WHERE id=".$player -> id); |
| 185 |
error (LOST_FIGHT2); |
| 186 |
} |
| 187 |
elseif (!$item -> fields['value'] && $myhp -> fields['hp'] > 0 && $myhp -> fields['fight'] == 0 && $_SESSION['result'] == 'win') |
| 188 |
{ |
| 189 |
$db -> Execute("UPDATE players SET energy=0 WHERE id=".$player -> id); |
| 190 |
$smarty -> assign(array("Win" => 1, |
| 191 |
"Portaltext" => PORTAL_TEXT, |
| 192 |
"Sword" => SWORD, |
| 193 |
"Armor" => ARMOR, |
| 194 |
"Istaff" => I_STAFF, |
| 195 |
"Cape" => CAPE)); |
| 196 |
} |
| 197 |
$myhp -> Close(); |
| 198 |
$item -> Close(); |
| 199 |
if (isset($_SESSION['result'])) unset($_SESSION['result']); |
| 200 |
} |
| 201 |
if (isset ($_GET['step'])) |
| 202 |
{ |
| 203 |
if ($_GET['step'] != 'sword' && $_GET['step'] != 'armor' && $_GET['step'] != 'staff' && $_GET['step'] != 'cape') |
| 204 |
{ |
| 205 |
error (ERROR); |
| 206 |
} |
| 207 |
$winner = $db -> Execute("SELECT value FROM settings WHERE setting='player'"); |
| 208 |
if ($winner -> fields['value'] > 0) |
| 209 |
{ |
| 210 |
error(ITEM_TAKE); |
| 211 |
} |
| 212 |
$winner -> Close(); |
| 213 |
if ($_GET['step'] == 'sword') |
| 214 |
{ |
| 215 |
$smarty -> assign ("Item", SWORD); |
| 216 |
$db -> Execute("INSERT INTO equipment (owner, name, power, type, cost, zr, wt, minlev, maxwt, amount, magic, poison, szyb, twohand) VALUES(".$player -> id.",'".SWORD."',500,'W',1,0,5000,1,5000,1,'Y',0,100,'Y')"); |
| 217 |
$db -> Execute("UPDATE settings SET value='sword' WHERE setting='item'"); |
| 218 |
} |
| 219 |
if ($_GET['step'] == 'armor') |
| 220 |
{ |
| 221 |
$smarty -> assign ("Item", ARMOR); |
| 222 |
$db -> Execute("INSERT INTO equipment (owner, name, power, type, cost, zr, wt, minlev, maxwt, amount, magic, poison, szyb, twohand) VALUES(".$player -> id.",'".ARMOR."',2000,'A',1,-100,20000,1,20000,1,'Y',0,100,'N')"); |
| 223 |
$db -> Execute("UPDATE settings SET value='armor' WHERE setting='item'"); |
| 224 |
} |
| 225 |
if ($_GET['step'] == 'staff') |
| 226 |
{ |
| 227 |
$smarty -> assign ("Item", I_STAFF); |
| 228 |
$db -> Execute("INSERT INTO equipment (owner, name, power, type, cost, zr, wt, minlev, maxwt, amount, magic, poison, szyb, twohand) VALUES(".$player -> id.",'".I_STAFF."',500,'S',1,0,0,1,0,1,'Y',0,0,'N')"); |
| 229 |
$db -> Execute("UPDATE settings SET value='staff' WHERE setting='item'"); |
| 230 |
} |
| 231 |
if ($_GET['step'] == 'cape') |
| 232 |
{ |
| 233 |
$smarty -> assign ("Item", CAPE); |
| 234 |
$db -> Execute("INSERT INTO equipment (owner, name, power, type, cost, zr, wt, minlev, maxwt, amount, magic, poison, szyb, twohand) VALUES(".$player -> id.",'".CAPE."',500,'Z',1,0,0,1,0,1,'Y',0,0,'N')"); |
| 235 |
$db -> Execute("UPDATE settings SET value='cape' WHERE setting='item'"); |
| 236 |
} |
| 237 |
$db -> Execute("UPDATE players SET miejsce='Altara', rank='Bohater' WHERE id=".$player -> id); |
| 238 |
$db -> Execute("UPDATE settings SET value=".$player -> id." WHERE setting='player'"); |
| 239 |
$db -> Execute("INSERT INTO halloffame (heroid, oldname, herorace, newid) VALUES(".$player -> id.", '".$player -> user."', '".$player -> race." ".$player -> clas."', ".$player -> id.")"); |
| 240 |
$db -> Execute("INSERT INTO updates (starter, title, updates, lang) VALUES('(Herold)','".U_TITLE."','".U_TEXT.$gamename.U_TEXT2.$gamename.U_TEXT3.$newdate.U_TEXT4.$player -> user.U_TEXT5.$player -> id.U_TEXT6."','".$player -> lang."')"); |
| 241 |
$smarty -> assign(array("Steptext" => STEP_TEXT, |
| 242 |
"Tgo" => T_GO, |
| 243 |
"Ahere" => A_HERE)); |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
/** |
| 248 |
* Initialization of variables |
| 249 |
*/ |
| 250 |
if (!isset($_GET['action1'])) |
| 251 |
{ |
| 252 |
$_GET['action1'] = ''; |
| 253 |
} |
| 254 |
if (!isset($_GET['step'])) |
| 255 |
{ |
| 256 |
$_GET['step'] = ''; |
| 257 |
} |
| 258 |
|
| 259 |
/** |
| 260 |
* Assign variables to template and display page |
| 261 |
*/ |
| 262 |
$smarty -> assign(array("Action" => $_GET['action1'], |
| 263 |
"Step" => $_GET['step'])); |
| 264 |
$smarty -> display('portal.tpl'); |
| 265 |
|
| 266 |
require_once("includes/foot.php"); |
| 267 |
?> |