-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoors.ps1
65 lines (62 loc) · 1.6 KB
/
doors.ps1
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
$inputNum
$switch1 = $true
$switch2 = $true
$check = $true
$sw = [Diagnostics.Stopwatch]::StartNew()
$r = 1
Clear-Host
while ($check) {
#clear-host
[System.Console]::SetCursorPosition(0,0)
if($sw.elapsed.totalseconds -gt 1) {
$r = Get-Random -Minimum 1 -Maximum 4
$sw = [Diagnostics.Stopwatch]::StartNew()
}
"There are three doors and you only have one key. Behind one of them is a murderer. Use your key wisely!"
""
if ($switch1) {
" --------- --------- --------- "
$switch1 = !$switch1
}
else {
" ^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^ "
$switch1 = !$switch1
}
"| | | | | |"
switch($r) {
1 {"| ^ ^ | | | | |"}
2 {"| | | ^ ^ | | |"}
3 {"| | | | | ^ ^ |"}
}
"| | | | | |"
"| | | | | |"
"| | | | | |"
"| | | | | |"
if ($switch2) {
" --------- --------- --------- "
$switch2 = !$switch2
}
else {
" ^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^ "
$switch2 = !$switch2
}
$inputNum = 4
if ([console]::KeyAvailable) {
$inputRead = [System.Console]::ReadKey()
switch ($inputRead.Key) {
D1 {$inputNum = 1}
D2 {$inputNum = 2}
D3 {$inputNum = 3}
Enter {$check = $false}
}
}
if($inputNum -eq $r) {break}
start-sleep -Milliseconds 50
}
if($check)
{
"YOU WON!!"
}
else {
"no..."
}