-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainFile.php
More file actions
105 lines (83 loc) · 2.68 KB
/
Copy pathmainFile.php
File metadata and controls
105 lines (83 loc) · 2.68 KB
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
<?php
//////////////////////////////BGCookie/////////////////////////
$check = $_POST['checkColor'];
//SetCookie("BGColor",'');
//print_r($_POST);
if ($check == 1){
$favcolor = $_POST['favcolor'];
SetCookie("BGColor",$favcolor);
}
/////////////////////////////////////////////////////////////
$new = $_POST['new'];
$next = $_POST['next'];
$stop = $_POST['stop'];
$currentUserSum = $_POST['usr'];
$currentCPUSum = $_POST['cpu'];
$currentUserSumString = $_POST['usrStr'];
$currentCPUSumString = $_POST['cpuStr'];
function generateCard()
{
$card = rand(6, 14);
return $card;
}
if ($new == 1)
{
$currentUserSum = generateCard();
$currentCPUSum = generateCard();
$currentUserSumString = (String)$currentUserSum;
$currentCPUSumString = (String)$currentCPUSum;
}
if ($next == 1)
{
$currentUserSum += generateCard();
$usrTempStr = (String)$currentUserSum;
$currentUserSumString .= " + " . $currentUserSum;
if($currentCPUSum < 21) $currentCPUSum += generateCard();
$cpuTempStr = (String)$currentCPUSum;
$currentCPUSumString .= " + " . $currentCPUSum;
}
?>
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="background-color: <?php echo $_COOKIE['BGColor'] ?>">
<h1>Black Jack</h1>
<form method="post" action="mainFile.php">
<!-- ///////////Input Hidden///////////////-->
<input type="hidden" name="usr" value="<?php echo $currentUserSum?>" >
<input type="hidden" name="cpu" value="<?php echo $currentCPUSum?>" >
<input type="hidden" name="usrStr" value="<?php echo $currentUserSumString?>" >
<input type="hidden" name="cpuStr" value="<?php echo $currentCPUSumString?>" >
<button name="new" value="1">New Game</button>
<h2>Your cards:</h2>
<?php
echo $currentUserSumString."=".$currentUserSum;
?>
<button name="next" value="1">Take one card</button>
<button name="stop" value="1">Stop</button>
<h2>CPU cards:</h2>
<?php
echo $currentCPUSumString."=".$currentCPUSum;
?>
<h2>State:</h2>
<?php
if ($currentUserSum > 21) echo 'you lost';
if ($currentCPUSum > 21) echo 'CPU lost';
if ($stop == 1)
{
if ($currentUserSum > $currentCPUSum) echo 'you won';
if ($currentUserSum < $currentCPUSum) echo 'you lost';
if ($currentUserSum == $currentCPUSum) echo 'friendship won';
}
?>
<hr>
<!-- -->
<h3>Background color:</h3>
<input type="checkbox" name="checkColor" value="1">
<input type="color" name="favcolor">
</form>
</body>
</html>