-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_card.php
337 lines (286 loc) · 21.8 KB
/
window_card.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
require_once("global.php");
require_once("chat.php");
require_once("modules/mysql.php");
require_once("control_rule.php");
?>
<?php
if(!isset($_SESSION)){session_start();}
if ( (isset($_SESSION['id_user'])) && (isset($_SESSION['init'])) && (isset($_SESSION['id_gt'])) ){
//****Карту отправляем в сброс****
if ($_REQUEST['send_com']==0){
if (($_REQUEST['from_object']>=20)&&($_REQUEST['from_object']<=29)) {
$DBLink=connectdb();
$query="SELECT * FROM cards_of_user JOIN cards ON (cards_of_user.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM cards_of_user WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$per_str=' отправил карту из руки в сброс';
add_str($per_str,0);
}
mysql_close ($DBLink);
}elseif (($_REQUEST['from_object']>=10)&&($_REQUEST['from_object']<=19)) {
$DBLink=connectdb();
$query="SELECT * FROM cards_of_table JOIN cards ON (cards_of_table.id_card=cards.id_card) WHERE (id_gt=".$_SESSION['id_gt']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM cards_of_table WHERE (id_card=".$row['id_card']." AND id_gt=".$_SESSION['id_gt']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$per_str=' отправил карту со стола в сброс';
add_str($per_str,0);
}
mysql_close ($DBLink);
//Класс - отправляем в сброс
}elseif (($_REQUEST['from_object']>=30)&&($_REQUEST['from_object']<=32)) {
$DBLink=connectdb();
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
if ($row['c_type']=="supermunch"){
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=32)";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
$_SESSION['num_d']=$_SESSION['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=32)";
$result=mysql_query($query);
}
$per_str=' отправил в сброс свой класс';
add_str($per_str,0);
}else{
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$per_str=' отправил в сброс свой класс';
add_str($per_str,0);
}
}
mysql_close ($DBLink);
//Расу - отправляем в сброс
}elseif (($_REQUEST['from_object']>=40)&&($_REQUEST['from_object']<=42)) {
$DBLink=connectdb();
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
if ($row['c_type']=="halfbreed"){
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=42)";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
$_SESSION['num_d']=$_SESSION['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=42)";
$result=mysql_query($query);
}
$per_str=' отправил в сброс свою расу';
add_str($per_str,0);
}else{
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$per_str=' отправил в сброс свою расу';
add_str($per_str,0);
}
}
mysql_close ($DBLink);
//Шмотку - отправляем в сброс
}elseif (($_REQUEST['from_object']>=50)&&($_REQUEST['from_object']<=75)) {
$DBLink=connectdb();
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
$query="SELECT MAX(num_d) AS num_d
FROM discards
WHERE (id_gt=".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$_SESSION['num_d']=$row1['num_d']+1;
$query="INSERT INTO discards VALUES(NULL,".$_SESSION['num_d'].",".$row['id_card'].",".$_SESSION['id_gt'].")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (($_REQUEST['from_object']>=50)&&($_REQUEST['from_object']<=69)) {
$per_str=' отправил в сброс свою шмотку';
add_str($per_str,0);
}elseif (($_REQUEST['from_object']>=70)&&($_REQUEST['from_object']<=75)) {
$per_str=' отправил в сброс наложенное на него проклятие: [B]'.$row['c_name'].'[/B]';
add_str($per_str,0);
}
}
mysql_close ($DBLink);
}
//КОНЕЦ****Карту отправляем в сброс****
//****Карту устанавливаем как КЛАСС/РАСУ*****
}elseif ($_REQUEST['send_com']==1){
apply_card($_REQUEST['from_object']);//Вызываем функцию контроля правил применения карт - распологается в control_rule.php
//КОНЕЦ ****Карту устанавливаем как КЛАСС/РАСУ*****
//****ПРОДАТЬ карту*****
}elseif ($_REQUEST['send_com']==2){
//Узнаем карты лежит в руке или в шмотках
if ( (($_REQUEST['from_object']>=20)&&($_REQUEST['from_object']<=29)) || (($_REQUEST['from_object']>=50)&&($_REQUEST['from_object']<=69)) ) {
sell_card($_REQUEST['from_object']);//Вызываем функцию контроля правил продажи карт - распологается в control_rule.php
}
//КОНЕЦ ****ПРОДАТЬ карту*****
//***Карту устанавливаем как шмотку***
}elseif ($_REQUEST['send_com']==3){
if (($_REQUEST['from_object']>=20)&&($_REQUEST['from_object']<=29)) {
$DBLink=connectdb();
$query="SELECT * FROM cards_of_user JOIN cards ON (cards_of_user.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
if (($row['c_type']=="smallitem") OR ($row['c_type']=="bigitem") OR ($row['c_type']=="chit") OR ($row['c_type']=="magic") ){
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card)
WHERE (id_user=".$_SESSION['id_user']." AND place_card BETWEEN 60 AND 69) ORDER BY place_card";
$result=mysql_query($query);
unset($select_place);
if (mysql_num_rows($result)>0){
for ($i=60;$i<=69;$i++){
$row1=mysql_fetch_array($result);
if ($row1['place_card']!=$i){
$select_place=$i;
break;
}
}
}else{
$select_place=60;
}
if (isset($select_place)){
//Ложим карту в шмотки
$query="INSERT INTO carried_items VALUES(NULL,".$_SESSION['id_user'].",".$row['id_card'].",".$select_place.")";
$result=mysql_query($query);
$query="DELETE FROM cards_of_user WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$per_str=' бросил к себе в шмотки : [B]'.$row['c_name'].'[/B]';
add_str($per_str,0);
print "1";
}else{
//В шмотках нет свободного места
$per_str=' Нельзя отправить карту в неактивные шмотки там [B]НЕТ СВОБОДНОГО МЕСТА[/B]';
add_str($per_str,0);
print "0";
}
}
}else{
print "0";
}
mysql_close ($DBLink);
}elseif (($_REQUEST['from_object']>=10)&&($_REQUEST['from_object']<=19)) {
print "0";
}
//КОНЕЦ ***Карту устанавливаем как шмотку***
//***Карту из Шмоток бросаем на стол (ну конечно если есть место)****
}elseif ($_REQUEST['send_com']==4){
if (($_REQUEST['from_object']>=50)&&($_REQUEST['from_object']<=69))
{
$DBLink=connectdb();
$query="SELECT * FROM carried_items JOIN cards ON (carried_items.id_card=cards.id_card) WHERE (id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
if (mysql_num_rows($result)!=0){
$row=mysql_fetch_array($result);
if (($row['c_type']=="smallitem") OR ($row['c_type']=="bigitem") OR ($row['c_type']=="chit") OR ($row['c_type']=="magic") ){
$query="SELECT * FROM cards_of_table JOIN cards ON (cards_of_table.id_card=cards.id_card)
WHERE (id_gt=".$_SESSION['id_gt'].") ORDER BY place_card";
$result=mysql_query($query);
unset($select_place);
if (mysql_num_rows($result)!=0){
for ($i=10;$i<=19;$i++){
$row1=mysql_fetch_array($result);
if ($row1['place_card']!=$i){
$select_place=$i;
break;
}
}
}else{
$select_place=10;
}
if (isset($select_place)){
//Ложим карту на стол
$query="INSERT INTO cards_of_table VALUES(NULL,".$_SESSION['id_gt'].",".$row['id_card'].",".$select_place.")";
$result=mysql_query($query);
$query="DELETE FROM carried_items WHERE (id_card=".$row['id_card']." AND id_user=".$_SESSION['id_user']." AND place_card=".$_REQUEST['from_object'].")";
$result=mysql_query($query);
$per_str=' выбросил свою одетую шмотку : [B]'.$row['c_name'].'[/B] на стол';
add_str($per_str,0);
print "1";
}else{
//На столе нет свободного места
$per_str=' Нельзя выбросить шмотку на стол [B]НЕТ СВОБОДНОГО МЕСТА[/B]';
add_str($per_str,0);
print "0";
}
}
}
mysql_close ($DBLink);
}
//КОНЕЦ *** Карту из Шмоток бросаем на стол (ну конечно если есть место)***
}elseif ($_REQUEST['send_com']==5)
{
kill_monster($_REQUEST['place_card']);
//ОТКРЫТЬ КАРТУ
}elseif ($_REQUEST['send_com']==6)
{
open_window_card($_REQUEST['place_card']);
}
//ОТКРЫТЬ КАРТУ
}
?>