-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathleft_dynamite.php
98 lines (58 loc) · 1.9 KB
/
left_dynamite.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
<?php
require_once 'includes.php';
global $DB;
//require_once 'header.php';
redirect_to_index_if_not($user, "left_dynamite");
$type = get_team($user);
update_action($user, "NULL");
//print_r($user);
$user_in_db = is_user_in_db($user);
if($user_in_db ==0) {
$facebook->redirect("$facebook_canvas_url/install.php");
}
$to_user = $_REQUEST['to'];
$dynamite_total = get_dynamite_count($user);
$monkey_total = get_monkey_count($user);
$level = get_level($user);
//print "bomb is $bomb_total";
//print "gold is $gold";
//threw_dynamite.php?sent=1&auth_token=85000cdeb643344d058a1ab7e85f842f
//check for existance of sent=1 and auth_token, and number of bombs, then increment users level
//and decrement the users bomb count
//take the gold from the $to and add it to the current user
$sent = $_REQUEST['sent'];
//$auth_token = $_REQUEST['auth_token'];
if($dynamite_total < 1 || $monkey_total < 1 || !$sent) {
$facebook->redirect("index.php");
}
else {
set_dynamite_total($user, $dynamite_total - 1);
set_monkey_total($user, $monkey_total - 1);
$gold = get_coin_total($to_user);
if($gold < 1) {
$gold = rand(1,50);
}
if($gold > 50) {
$gold = 50;
}
$to_id_team = get_team($to_user);
if(empty($to_id_team)) {
$level_up = lower_level_up($user);
if($level_up) {
log_levels($user, 'dynamite level up', $to_user);
}
$gold = rand(1,50);
set_coins($user, get_coin_total($user) + $gold); //landlubber give em coins now
log_coins($user, $gold, 'dynamited landlubber', $to_user);
$facebook->redirect("index.php?msg=left-dynamite&gold=$gold&to=$to_user&level_up=$level_up");
}
else {
//pirate, wait for dynamite to blow up
$facebook->redirect("index.php?msg=left-dynamite-for-pirate&to=$to_user");
}
}
//$to_id = $_REQUEST['to'];
//print_r($_REQUEST);
$facebook->redirect("index.php?msg=left-dynamite&gold=$gold&to=$to_user&level_up=$level_up");
//print $friend_selector_id;
?>