forked from zilveer/Multiplayer-PHP-Ajax-Games
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videopoker.php
167 lines (166 loc) · 4.94 KB
/
videopoker.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
<?php
include "videopoker_func.php";
include "globals.php";
print"<center><h2>Video Poker</h2><hr />";
$adst=$db->query("SELECT * FROM videopoker_stats LIMIT 1");
$adsta=$db->fetch_row($adst);
if($ir['user_level']==2)
{
$minbeta=abs(intval($_POST['minbet']));
$maxbeta=abs(intval($_POST['maxbet']));
print"<hr />
Stats:<br />
<b>House Profit:</b> $".number_format($adsta['houseProfit'])."<br />
<b>Total Plays:</b> ".number_format($adsta['totalPlays'])."<br />";
if($_GET['act']=='admin' && $minbeta && $maxbeta)
{
$db->query("UPDATE videopoker_stats SET minbet=$minbeta, maxbet=$maxbeta");
print"<br /><b>Betting info updated!</b><br />";
$adsta['minbet']=$minbeta;
$adsta['maxbet']=$maxbeta;
}
print"<br /><form method=post action=videopoker.php?act=admin>
<b>Minimum Bet:</b> <input type=text name=minbet value={$adsta['minbet']}><br />
<b>Maximum Bet:</b> <input type=text name=maxbet value={$adsta['maxbet']}>
<br /><input type=submit value='Submit Changes'></form>
<hr />";
}
print"
Minimum Bet: \$".number_format($adsta['minbet'])."<br />
Maximum Bet: \$".number_format($adsta['maxbet'])."<br /><br />
<b>Payout Multiplier:</b><br /><img src=images/scores.PNG><br /><br />";
$pcar=$db->query("SELECT * FROM videopoker WHERE userid='$userid'");
$bb=$db->fetch_row($pcar);
$playingpoker=$db->num_rows($pcar);
if(!$_GET['act'] || $_GET['act']=='admin')
{
$defaultbet = ((int)($ir['money']/1000));
if($defaultbet<=0){$defaultbet=1;}
print"<form action=videopoker.php?act=deal method=post>
Amount to risk each round:<br />
$<input type=text name=betamount value=$defaultbet size=6><br /><br />
<input type=submit value='Set Bet And Start Playing!'>
</form>";
}
else if($_GET['act']=='deal')
{
$betamt=abs(intval($_POST['betamount']));
if($betamt > $ir['money'])
{
$error='Sorry, you do not have that much money.<br />><a href=videopoker.php>Back</a>';
}
if($betamt > $adsta['maxbet'])
{
$error='Sorry, that is greater than the maximum allowed bet.<br />><a href=videopoker.php>Back</a>';
}
if($betamt < $adsta['minbet'])
{
$error='Sorry, that is lower than the minimum required bet.<br />><a href=videopoker.php>Back</a>';
}
if($betamt <= 0)
{
$error='Sorry, you must bet more than $0.<br />><a href=videopoker.php>Back</a>';
}
if(!$error)
{
$db->query("UPDATE users SET money=money-$betamt WHERE userid='$userid'");
$db->query("UPDATE videopoker_stats SET houseProfit=houseProfit+$betamt, totalPlays=totalPlays+1");
print"You bet: <b>$".number_format($betamt)."</b>.<br /><br />";
deal_cards($userid, $betamt);
$cards=show_cards($userid, 1);
print"$cards<br />";
}
else
{
print $error;
}
}
else if($_GET['act']=='newdeal')
{
$betamt=abs(intval($_GET['bet']));
if($betamt > $ir['money'])
{
$error='Sorry, you do not have that much money.<br />><a href=videopoker.php>Back</a>';
}
if($betamt > $adsta['maxbet'])
{
$error='Sorry, that is greater than the maximum allowed bet.<br />><a href=videopoker.php>Back</a>';
}
if($betamt < $adsta['minbet'])
{
$error='Sorry, that is lower than the minimum required bet.<br />><a href=videopoker.php>Back</a>';
}
if($betamt <= 0)
{
$error='Sorry, you must bet more than $0.<br />><a href=videopoker.php>Back</a>';
}
if(!$error)
{
$db->query("UPDATE users SET money=money-$betamt WHERE userid='$userid'");
$db->query("UPDATE videopoker_stats SET houseProfit=houseProfit+$betamt, totalPlays=totalPlays+1");
print"You bet: <b>$".number_format($betamt)."</b>.<br /><br />";
deal_cards($userid, $betamt);
$cards=show_cards($userid, 1);
print"$cards<br />";
}
else
{
print $error;
}
}
else if($_GET['act']=='draw')
{
if(!$playingpoker)
{
$error='Sorry, you do not have a currently active poker game.<br />><a href=videopoker.php>Back</a>';
}
if(!$error)
{
if(!$_POST['hold1'])
{
replace_card(1, $userid);
}
if(!$_POST['hold2'])
{
replace_card(2, $userid);
}
if(!$_POST['hold3'])
{
replace_card(3, $userid);
}
if(!$_POST['hold4'])
{
replace_card(4, $userid);
}
if(!$_POST['hold5'])
{
replace_card(5, $userid);
}
$cards=show_cards($userid, 2);
print"$cards<br />";
$scoreArray=calc_score($userid);
$winMultiplier = find_winnings($scoreArray[1], $scoreArray[2]);
$bet=$bb['betAmount'];
$totalwin = $bet * $winMultiplier;
if($totalwin!=0)
{
print "With your {$scoreArray[0]}, you won {$winMultiplier}x your original bet of $".number_format($bet).". <br /><br />";
print "<b>$".number_format($totalwin)." has been added to your wallet.</b>";
$db->query("UPDATE users SET money=money+$totalwin WHERE userid='$userid'");
$db->query("UPDATE videopoker_stats SET houseProfit=houseProfit-$totalwin");
}
else
{
print "<b>With your {$scoreArray[0]}, you lost your original bet of $".number_format($bet).".</b> <br /><br />";
print "(Need pair of jacks or better to win)";
}
$db->query("DELETE FROM videopoker WHERE userid='$userid'");
}
else
{
print $error;
}
}
print"</center>";
$h->endpage();
?>