1
<?php
2
/**
3
 *   File functions:
4
 *   Rest - regenerate mana for a energy
5
 *
6
 *   @name                 : rest.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                : 11.08.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: rest.php 566 2006-09-13 09:31:08Z thindil $
31
32
$title = "Odpoczynek"; 
33
require_once("includes/head.php");
34
35
/**
36
* Get the localization for game
37
*/
38
require_once("languages/".$player -> lang."/rest.php");
39
40
41
$arrEquip = $player -> equipment();
42
$arrRings = array(R_INT, R_WIS);
43
$arrStat = array('inteli', 'wisdom');
44
if ($arrEquip[9][0])
45
{
46
    $arrRingtype = explode(" ", $arrEquip[9][1]);
47
    $intAmount = count($arrRingtype) - 1;
48
    $intKey = array_search($arrRingtype[$intAmount], $arrRings);
49
    if ($intKey != NULL)
50
    {
51
        $strStat = $arrStat[$intKey];
52
        $player -> $strStat = $player -> $strStat + $arrEquip[9][2];
53
    }
54
}
55
if ($arrEquip[10][0])
56
{
57
    $arrRingtype = explode(" ", $arrEquip[10][1]);
58
    $intAmount = count($arrRingtype) - 1;
59
    $intKey = array_search($arrRingtype[$intAmount], $arrRings);
60
    if ($intKey != NULL)
61
    {
62
        $strStat = $arrStat[$intKey];
63
        $player -> $strStat = $player -> $strStat + $arrEquip[10][2];
64
    }
65
}
66
$maxmana = ($player -> inteli + $player -> wisdom);
67
$maxmana = $maxmana + (($arrEquip[8][2] / 100) * $maxmana);
68
$manainfo = round($maxmana - $player -> mana);
69
if ($manainfo < 1)
70
{
71
	$manainfo = 0;
72
}
73
74
$manarest = 5* $player -> level ;
75
$restcount = floor($manainfo / $manarest);
76
if ($restcount <1)
77
{
78
	$restcount = 0;
79
}
80
81
$smarty -> assign(array("Manarest" => $manarest,
82
	                        "Manainfo" => $manainfo,
83
	                        "Restcount" => $restcount,
84
	                        "Trest" => T_REST,
85
                            "Restinfo" => REST_INFO,
86
                            "Restinfo1" => REST_INFO1,
87
                            "Restinfo2" => REST_INFO2,
88
                            "Iwant" => I_WANT,
89
                            "Rmana" => R_MANA,
90
                            "Arest" => A_REST,
91
                            "Aback" => A_BACK));
92
93
$smarty -> display ('rest.tpl');
94
95
if (isset($_GET['akcja']) && $_GET['akcja'] == 'all') 
96
{
97
    if (!isset($_POST['amount']))
98
    {
99
        error(HOW_MANY);
100
    }
101
    if (!ereg("^[1-9][0-9]*$", $_POST['amount'])) 
102
    {
103
        error (ERROR);
104
    }
105
    integercheck($_POST['amount']);
106
    if (!isset($_POST['amount'])) 
107
    {
108
        error(ERROR);
109
    }
110
    if ($player -> energy < $_POST['amount']*0.1) 
111
    {
112
        error (NO_ENERGY);
113
    }
114
    if ($player -> hp <= 0) 
115
    {
116
        error (YOU_DEAD);
117
    }
118
    $zpm = ($_POST['amount']*$manarest);
119
    $energia = $_POST['amount']*0.1;
120
    if ( $manainfo == 0)
121
    {
122
    	$zpm =0;
123
    	$db -> Execute("UPDATE `players` SET `energy`=`energy`-".$energia." WHERE `id`=".$player -> id);
124
    	error (YOU_REST.$zpm.YOU_REST2.$energia.YOU_REST3);
125
    }
126
    else	
127
    {
128
    	if (($zpm + $player -> mana) >= $maxmana)
129
    	{
130
    	    $db -> Execute("UPDATE `players` SET `pm`=".$maxmana.", `energy`=`energy`-".$energia." WHERE `id`=".$player -> id);
131
      	    error (YOU_REST.$manainfo.YOU_REST2.$energia.YOU_REST3);
132
    	}
133
    	else
134
    	{	
135
    	    $db -> Execute("UPDATE `players` SET `pm`=`pm`+".$zpm.", `energy`=`energy`-".$energia." WHERE `id`=".$player -> id);
136
    	}
137
    error (YOU_REST.$zpm.YOU_REST2.$energia.YOU_REST3);
138
    }
139
}
140
141
require_once("includes/foot.php");
142
?>