-
Notifications
You must be signed in to change notification settings - Fork 3
/
adr_temple.php
288 lines (238 loc) · 10.5 KB
/
adr_temple.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php
/***************************************************************************
* adr_Temple.php
* ------------------------
* begin : 19/11/2004
* copyright : One_Piece
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
define('IN_PHPBB', true);
define('IN_ADR_TEMPLE', true);
define('IN_ADR_TOWNMAP', true);
define('IN_TOWNMAP_INFOBOX', true);
define('IN_TOWNMAP_TEMPLE', true);
define('IN_TOWNMAP_COPYRIGHT', true);
define('IN_ADR_BATTLE', true);
define('IN_ADR_CHARACTER', true);
define('IN_ADR_SHOPS', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'adr/includes/adr_global.'.$phpEx);
$loc = 'town';
$sub_loc = 'adr_temple';
//
// Start session management
$userdata = session_pagestart($user_ip, PAGE_ADR);
init_userprefs($userdata);
// End session management
//
$user_id = $userdata['user_id'];
// Sorry , only logged users ...
if ( !$userdata['session_logged_in'] )
{
$redirect = "adr_temple.$phpEx";
$redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
}
// Includes the tpl and the header
adr_template_file('adr_temple_body.tpl');
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
//
//BEGIN zone Temple Restriction
//
$zone_user = adr_get_user_infos($user_id);
$actual_zone = $zone_user['character_area'];
$sql = " SELECT * FROM " . ADR_ZONES_TABLE . "
WHERE zone_id = $actual_zone ";
if( !($result = $db->sql_query($sql)) )
message_die(GENERAL_ERROR, 'Could not query area list', '', __LINE__, __FILE__, $sql);
$info = $db->sql_fetchrow($result);
$access = $info['zone_temple'];
if ( $access == '0' )
adr_previous( Adr_zone_building_noaccess , adr_zones , '' );
//
//END zone Temple Restriction
//
// Deny access if the user is into a battle or is imprisoned
adr_battle_cell_check($user_id, $userdata);
// Get the general config
$adr_general = adr_get_general_config();
if ( !$adr_general['Adr_disable_rpg'] && $userdata['user_level'] != ADMIN )
{
adr_previous ( Adr_disable_rpg , 'index' , '' );
}
// Get the user infos
$adr_char = adr_get_user_infos($user_id);
//get guild info
// V: why??
$sql = "SELECT g.guild_heal_pec, g.guild_id FROM " . ADR_GUILDS_TABLE . " g
LEFT JOIN " . ADR_GUILD_MEMBER_TABLE . " gm ON ( g.guild_id = gm.guild_member_guild_id )
WHERE gm.guild_member_user_id = $user_id";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query guild info', '', __LINE__, __FILE__, $sql);
}
$guild = $db->sql_fetchrow($result);
// Fix the values
$InfoTemple = $HTTP_POST_VARS['InfoTemple'];
if ( $InfoTemple )
{
adr_previous( Adr_TownMap_Temple_Infos , adr_temple , '' );
}
$heal_price = ceil( $adr_general['temple_heal_cost'] * ( $adr_char['character_hp_max'] - $adr_char['character_hp'] ) );
$resurrect_price = ceil( $adr_general['temple_resurrect_cost'] * ( $adr_char['character_hp_max'] ) );
$heal = $HTTP_POST_VARS['heal'];
$resurrect = $HTTP_POST_VARS['resurrect'];
$donation_amount = $HTTP_POST_VARS['donation_amount'];
$donate = $HTTP_POST_VARS['donation'];
if ( $heal )
{
if ( $adr_char['character_hp'] < 1 )
{
adr_previous( TownMap_Temple_BesoinResurrection , adr_temple , '' );
}
if ( ( $adr_char['character_hp'] == $adr_char['character_hp_max'] ) && ( $adr_char['character_mp'] == $adr_char['character_mp_max'] ) )
{
adr_previous( TownMap_Temple_PasSoin , adr_temple , '' );
}
adr_substract_points( $user_id , $heal_price , adr_temple , '' );
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_hp = character_hp_max ,
character_mp = character_mp_max
WHERE character_id = $user_id ";
if ( !($result=$db->sql_query($sql)))
{
message_die(GENERAL_ERROR , 'Can not update the user characteristics');
}
adr_previous( TownMap_Temple_Soin , adr_temple , '' );
}
else if ( $resurrect )
{
if ( $adr_char['character_hp'] > 0 )
{
adr_previous( TownMap_Temple_PasResurrection , adr_temple , '' );
}
adr_substract_points( $user_id , $resurrect_price , adr_temple , '' );
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_hp = character_hp_max ,
character_mp = character_mp_max
WHERE character_id = $user_id ";
if ( !($result=$db->sql_query($sql)))
{
message_die(GENERAL_ERROR , 'Can not update the user characteristics');
}
adr_previous( TownMap_Temple_Resurrection , adr_temple , '' );
}
elseif($donate)
{
if ($adr_char['character_hp'] < '1') adr_previous(Adr_temple_donation_dead, adr_temple, '');
if (empty($donation_amount) || !is_numeric($donation_amount)) adr_previous(Adr_temple_donation_none, adr_temple, '');
if ($userdata['user_points'] < $donation_amount) adr_previous(Adr_temple_donation_not_enough, adr_temple, '');
// Remove donation from user
subtract_reward($user_id, $donation_amount);
// Update total donations to temple
$total_donations = ($adr_general['temple_total_donations'] + $donation_amount);
$sql= "UPDATE " . ADR_GENERAL_TABLE . " SET config_value = $total_donations WHERE config_name = 'temple_total_donations'";
if ( !($result = $db->sql_query($sql)) )
{
adr_previous( Adr_character_general_update_error, adr_temple , '' );
}
$message = '<img src="adr/images/misc/priestess.gif"><br /><br />';
$message .= sprintf($lang['Adr_temple_donation_successful'], number_format($donation_amount), $board_config['points_name']).'<br />';
if($donation_amount >= $adr_general['temple_min_donation'])
{
$min_chance = round($donation_amount / $adr_general['temple_chance_increase']);
// Min chance cannot be more than 40%
$min_chance = $min_chance > 40 ? 40: $min_chance;
$chance = rand($min_chance,100);
// Work out value for user to reach to win any type of item
$win_chance = (100 - $adr_general['temple_win_chance']);
if($chance >= $win_chance)
{
$item_rand = rand(1,100);
if($item_rand > '0' && $item_rand < '65')
{
$item_id = adr_temple_donation($user_id, 0, $donation_amount);
$temple_info = adr_temple_infos($user_id, $item_id);
$message .= $temple_info['item_icon'] != '' ? '<br /><img src="adr/images/items/'.$temple_info['item_icon'].'"><br />' : '<br />';
$message .= sprintf($lang['Adr_temple_donation_won_common'], adr_get_lang($temple_info['item_name']));
}
elseif($item_rand > '64' && $item_rand < '94')
{
$item_id = adr_temple_donation($user_id, 1, $donation_amount);
$temple_info = adr_temple_infos($user_id, $item_id);
$message .= $temple_info['item_icon'] != '' ? '<br /><img src="adr/images/items/'.$temple_info['item_icon'].'"><br />' : '<br />';
$message .= sprintf($lang['Adr_temple_donation_won_uncommon'], adr_get_lang($temple_info['item_name']));
}
elseif($item_rand > '93' && $item_rand < '100')
{
$item_id = adr_temple_donation($user_id, 2, $donation_amount);
$temple_info = adr_temple_infos($user_id, $item_id);
$message .= $temple_info['item_icon'] != '' ? '<br /><img src="adr/images/items/'.$temple_info['item_icon'].'"><br />' : '<br />';
$message .= sprintf($lang['Adr_temple_donation_won_rare'], adr_get_lang($temple_info['item_name']));
}
elseif($item_rand > '95' && $item_rand < '101' && $donation_amount < $adr_general['temple_super_rare_amount'])
{
$item_id = adr_temple_donation($user_id, 3, $donation_amount);
$temple_info = adr_temple_infos($user_id, $item_id);
$message .= $temple_info['item_icon'] != '' ? '<br /><img src="adr/images/items/'.$temple_info['item_icon'].'"><br />' : '<br />';
$message .= sprintf($lang['Adr_temple_donation_won_very_rare'], adr_get_lang($temple_info['item_name']));
}
elseif($item_rand > '95' && $item_rand < '101' && $donation_amount >= $adr_general['temple_super_rare_amount'])
{
$item_id = adr_temple_donation($user_id, 4, $donation_amount);
$temple_info = adr_temple_infos($user_id, $item_id);
$message .= $temple_info['item_icon'] != '' ? '<br /><img src="adr/images/items/'.$temple_info['item_icon'].'"><br />' : '<br />';
$message .= sprintf($lang['Adr_temple_donation_won_very_rare'], adr_get_lang($temple_info['item_name']));
}
}
}
$message .= '<br /><br />'.sprintf($lang['Adr_return'],"<a href=\"" . $direction . "\">", "</a>");
message_die( GENERAL_MESSAGE,$message);
}
else
{
$template->assign_vars(array(
'HEAL_COST' => $heal_price,
'RESURRECT_COST' => $resurrect_price,
'L_TOWNMAP_TEMPLE' => $lang['TownMap_Temple'],
'L_TEMPLE_PRIXGUERISON' => $lang['TownMap_Temple_PrixGuerison'],
'L_TEMPLE_PRIXRESURRECTION' => $lang['TownMap_Temple_PrixResurrection'],
'L_GUERIR' => $lang['TownMap_Temple_Guerir'],
'L_RESUSSITER' => $lang['TownMap_Temple_Resussiter'],
'L_PRETRESSE1' => $lang['TownMap_Temple_NomPretresse1'],
'L_PRETRESSE2' => $lang['TownMap_Temple_NomPretresse2'],
'L_TOWNMAP_PRETRESSE1' => $lang['TownMap_Temple_Pretresse1'],
'L_TOWNMAP_PRETRESSE2' => $lang['TownMap_Temple_Pretresse2'],
'L_TEMPLEENTREE' => $lang['TownMap_Temple_Entree'],
'L_TOWNBOUTONINFO' => $lang['Adr_TownMap_Bouton_Infos'],
'L_TOWNBOUTONRETOUR' => $lang['Adr_TownMap_Bouton_Retour'],
'L_TEMPLEPRESENTATION' => $lang['Adr_TownMap_Temple_Presentation'],
'L_COPYRIGHT' => $lang['Adr_copyright'],
'L_TOWNMAPCOPYRIGHT' => $lang['TownMap_Copyright'],
'U_TOWNBOUTONRETOUR' => append_sid("adr_TownMap.$phpEx"),
'U_TOWNMAP_TEMPLE' => append_sid("adr_temple.$phpEx"),
'U_COPYRIGHT' => append_sid("adr_copyright.$phpEx"),
'U_TOWNMAPCOPYRIGHT' => append_sid("TownMap_Copyright.$phpEx"),
'L_POINTS' => $board_config['points_name'],
'L_DONATION_TITLE' => $lang['Adr_temple_donation_title'],
'L_DONATION' => $lang['Adr_temple_donation_amount'],
'L_DONATE' => $lang['Adr_temple_donation_submit'],
'S_CHARACTER_ACTION' => append_sid("adr_temple.$phpEx"),
));
}
include($phpbb_root_path . 'adr/includes/adr_header.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>