-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution.php
185 lines (161 loc) · 6.38 KB
/
solution.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
<?php
session_start();
// List of valid solutions
$valid_solutions = [
'murderer' => 'Clara Pierce',
'room' => 'The Living Room', // based on where the murder might have occurred
'weapon' => 'Candlestick' // based on your weapons list
];
// Predefined dropdown options
$murderer_options = ['Select Murderer', 'Clara Pierce', 'George Walker', 'Maya Fields', 'Harrison Drake'];
$room_options = ['Select Room', 'The Living Room', 'The Study', 'The Music Room', 'The Library'];
$weapon_options = ['Select Weapon', 'Candlestick', 'Knife', 'Rope', 'Revolver'];
// Check if all rooms have been visited
$can_submit_solution = isset($_SESSION['living_room_visited']) &&
isset($_SESSION['study_visited']) &&
isset($_SESSION['music_room_visited']) &&
isset($_SESSION['library_visited']);
// Handle solution submission
$solution_result = null;
if($_SERVER['REQUEST_METHOD'] == 'POST' && $can_submit_solution) {
$murderer = isset($_POST['murderer']) ? trim(strtolower($_POST['murderer'])) : '';
$room = isset($_POST['room']) ? trim(strtolower($_POST['room'])) : '';
$weapon = isset($_POST['weapon']) ? trim(strtolower($_POST['weapon'])) : '';
// Check each solution component separately
if ($murderer !== strtolower($valid_solutions['murderer'])) {
$error_details[] = "Murderer: The killer is not who you think.";
}
if ($room !== strtolower($valid_solutions['room'])) {
$error_details[] = "Crime Scene: The murder did not occur in the room you selected.";
}
if ($weapon !== strtolower($valid_solutions['weapon'])) {
$error_details[] = "Murder Weapon: The weapon you chose was not used in the crime.";
}
// Check if all solution components are correct
$solution_correct =
$murderer === strtolower($valid_solutions['murderer']) &&
$room === strtolower($valid_solutions['room']) &&
$weapon === strtolower($valid_solutions['weapon']);
if($solution_correct) {
$solution_result = true;
$_SESSION['solution_solved'] = true;
} else {
$solution_result = false;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solve the Murder Mystery</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #2c3e50;
color: #ecf0f1;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 0;
}
.solution-container {
background-color: rgba(44, 62, 80, 0.9);
border-radius: 10px;
padding: 30px;
width: 100%;
max-width: 500px;
box-shadow: 0 0 20px rgba(0,0,0,0.3);
}
.solution-form {
display: flex;
flex-direction: column;
gap: 15px;
}
.solution-form select,
.solution-form textarea {
width: 100%;
padding: 10px;
background-color: rgba(52, 73, 94, 0.5);
border: 1px solid #8e44ad;
color: #ecf0f1;
border-radius: 5px;
}
.solution-form select option {
background-color: #2c3e50;
color: #ecf0f1;
}
.submit-button {
background-color: #8e44ad;
color: white;
border: none;
padding: 12px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.submit-button:hover {
background-color: #9b59b6;
}
.result-message {
margin-top: 20px;
padding: 15px;
border-radius: 5px;
text-align: center;
}
.success {
background-color: rgba(39, 174, 96, 0.3);
color: #2ecc71;
}
.failure {
background-color: rgba(231, 76, 60, 0.3);
color: #e74c3c;
}
</style>
</head>
<body>
<div class="solution-container">
<h1 style="text-align: center; color: #8e44ad;">Solve the Murder</h1>
<?php if($can_submit_solution): ?>
<form method="POST" class="solution-form">
<select name="murderer" required>
<?php foreach($murderer_options as $option): ?>
<option value="<?php echo strtolower($option); ?>"><?php echo $option; ?></option>
<?php endforeach; ?>
</select>
<select name="room" required>
<?php foreach($room_options as $option): ?>
<option value="<?php echo strtolower($option); ?>"><?php echo $option; ?></option>
<?php endforeach; ?>
</select>
<select name="weapon" required>
<?php foreach($weapon_options as $option): ?>
<option value="<?php echo strtolower($option); ?>"><?php echo $option; ?></option>
<?php endforeach; ?>
</select>
<button type="submit" class="submit-button">Submit Solution</button>
</form>
<?php if($solution_result !== null): ?>
<div class="result-message <?php echo $solution_result ? 'success' : 'failure'; ?>">
<?php echo $solution_result ? 'Congratulations! You solved the murder.' : 'Incorrect solution. Try again.'; ?>
<?php if(!$solution_result && !empty($error_details)): ?>
<div class="error-details">
<p>Here are some clues about where your deduction went wrong:</p>
<ul>
<?php foreach($error_details as $error): ?>
<li><?php echo htmlspecialchars($error); ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php else: ?>
<p style="text-align: center;">You must explore all rooms before submitting a solution.</p>
<?php endif; ?>
</div>
</body>
</html>