This commit is contained in:
Ivan Bushchik 2021-10-26 20:27:30 +03:00
parent 1f84830c17
commit 92f26a666f

View file

@ -3,19 +3,19 @@
Module Program Module Program
'https://github.com/BushchikIvan/roulette 'https://github.com/BushchikIvan/roulette
Dim ReadOnly _ Dim ReadOnly _
ring(,) As Integer = Ring(,) As Integer =
{{0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, {{0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29,
7, 28, 12, 35, 3, 26}, 7, 28, 12, 35, 3, 26},
{0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2}} {0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2}}
Dim ReadOnly colors() As ConsoleColor = {ConsoleColor.White, ConsoleColor.Red, ConsoleColor.Black} Dim ReadOnly Colors() As ConsoleColor = {ConsoleColor.White, ConsoleColor.Red, ConsoleColor.Black}
Dim ReadOnly _ Dim ReadOnly _
ringRank0() As Integer = RingRank0() As Integer =
{0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, {0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29,
7, 28, 12, 35, 3, 26} 7, 28, 12, 35, 3, 26}
'ringRank0 нужен, чтобы было удобно подавать массив в поиск индекса 'ringRank0 нужен, чтобы было удобно подавать массив в поиск индекса
Dim ReadOnly logo() As String = { _ Dim ReadOnly Logo() As String = { _
"#### ### # # # ##### ##### ##### #####", "#### ### # # # ##### ##### ##### #####",
"# # # # # # # # # # # ", "# # # # # # # # # # # ",
"# # # # # # # # # # # ", "# # # # # # # # # # # ",
@ -33,11 +33,11 @@ Module Program
Return - 1 Return - 1
End Function End Function
Sub displayHistory(history() As Integer) Sub DisplayHistory(history() As Integer)
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
Console.Write("История выпадений (последние 15): ") Console.Write("История выпадений (последние 15): ")
For i = If(Ubound(history) > 14, Ubound(history) - 14, 0) To UBound(history) For i = If(Ubound(history) > 14, Ubound(history) - 14, 0) To UBound(history)
Console.ForegroundColor = colors(ring(1, getindex(ringRank0, history(i)))) Console.ForegroundColor = Colors(Ring(1, getindex(RingRank0, history(i))))
Console.Write(history(i) & " ") Console.Write(history(i) & " ")
Next Next
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
@ -53,55 +53,55 @@ Module Program
Return outArr Return outArr
End Function End Function
Sub sleep(d As Single) Sub Sleep(d As Single)
Dim t As Single = Timer Dim t As Single = Timer
Do while Timer - t < d Do while Timer - t < d
Loop Loop
End Sub End Sub
Sub intro() Sub Intro()
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
Console.SetCursorPosition(Console.WindowWidth\2 - Len(logo(0))\2, Console.WindowHeight()\2 - UBound(logo) + 3) Console.SetCursorPosition(Console.WindowWidth\2 - Len(Logo(0))\2, Console.WindowHeight()\2 - UBound(Logo) + 3)
For i = 0 To UBound(logo) For i = 0 To UBound(Logo)
Console.WriteLine(logo(i)) Console.WriteLine(Logo(i))
Console.SetCursorPosition(Console.WindowWidth\2 - Len(logo(0))\2, Console.GetCursorPosition().Item2) Console.SetCursorPosition(Console.WindowWidth\2 - Len(Logo(0))\2, Console.GetCursorPosition().Item2)
sleep(0.04444) Sleep(0.04444)
Next Next
'sleep(5) 'sleep(5)
Console.SetCursorPosition(0, 0) Console.SetCursorPosition(0, 0)
For i = 0 To (Console.WindowHeight()\2 - UBound(logo) + 2)\2 For i = 0 To (Console.WindowHeight()\2 - UBound(Logo) + 2)\2
Console.WriteLine(StrDup(Console.WindowWidth - 1, "#")) Console.WriteLine(StrDup(Console.WindowWidth - 1, "#"))
sleep(0.04444) Sleep(0.04444)
Next Next
For i = 0 To Console.WindowHeight - (Console.WindowHeight()\2 - UBound(logo) + 2) - 3 For i = 0 To Console.WindowHeight - (Console.WindowHeight()\2 - UBound(Logo) + 2) - 3
Console.Write(StrDup((Console.WindowWidth\2 - Len(logo(0))\2)\2, "#")) Console.Write(StrDup((Console.WindowWidth\2 - Len(Logo(0))\2)\2, "#"))
Console.SetCursorPosition(Console.WindowWidth - (Console.WindowWidth\2 - Len(logo(0))\2)\2, Console.SetCursorPosition(Console.WindowWidth - (Console.WindowWidth\2 - Len(Logo(0))\2)\2,
(Console.GetCursorPosition().Item2)) (Console.GetCursorPosition().Item2))
Console.WriteLine(StrDup((Console.WindowWidth\2 - Len(logo(0))\2)\2 - 1, "#")) Console.WriteLine(StrDup((Console.WindowWidth\2 - Len(Logo(0))\2)\2 - 1, "#"))
sleep(0.04444) Sleep(0.04444)
Next Next
For i = 0 To (Console.WindowHeight()\2 - UBound(logo) + 2)\2 - 1 For i = 0 To (Console.WindowHeight()\2 - UBound(Logo) + 2)\2 - 1
Console.WriteLine(StrDup(Console.WindowWidth - 1, "#")) Console.WriteLine(StrDup(Console.WindowWidth - 1, "#"))
sleep(0.04444) Sleep(0.04444)
Next Next
Dim entr = " Нажмите любую кнопку, чтобы начать игру! " Const entr As String = " Нажмите любую кнопку, чтобы начать игру! "
Console.SetCursorPosition((Console.WindowWidth\2) - Len(entr)\2, Console.SetCursorPosition((Console.WindowWidth\2) - Len(entr)\2,
Console.WindowHeight - (Console.WindowHeight()\2 - UBound(logo) + 2)\4 - 3) Console.WindowHeight - (Console.WindowHeight()\2 - UBound(Logo) + 2)\4 - 3)
Console.Write(StrDup(Len(entr) + 2, " ")) Console.Write(StrDup(Len(entr) + 2, " "))
Console.SetCursorPosition((Console.WindowWidth\2) - Len(entr)\2, Console.SetCursorPosition((Console.WindowWidth\2) - Len(entr)\2,
Console.WindowHeight - (Console.WindowHeight()\2 - UBound(logo) + 2)\4 - 2) Console.WindowHeight - (Console.WindowHeight()\2 - UBound(Logo) + 2)\4 - 2)
Console.Write(entr & " ") Console.Write(entr & " ")
Console.SetCursorPosition((Console.WindowWidth\2) - Len(entr)\2, Console.SetCursorPosition((Console.WindowWidth\2) - Len(entr)\2,
Console.WindowHeight - (Console.WindowHeight()\2 - UBound(logo) + 2)\4 - 1) Console.WindowHeight - (Console.WindowHeight()\2 - UBound(Logo) + 2)\4 - 1)
Console.Write(StrDup(Len(entr) + 2, " ")) Console.Write(StrDup(Len(entr) + 2, " "))
Console.SetCursorPosition(0, 0) Console.SetCursorPosition(0, 0)
Console.ReadKey Console.ReadKey
Console.Clear Console.Clear
End Sub End Sub
Function spinWheel() As String() Function SpinWheel() As String()
Dim rnd As New Random Dim rnd As New Random
Dim probability(36) As Double Dim probability(36) As Double
Dim whatDropped As New List(Of String) Dim whatDropped As New List(Of String)
@ -124,71 +124,71 @@ Module Program
End If End If
Next Next
whatDropped.Add(ring(0, dropped).ToString()) whatDropped.Add(Ring(0, dropped).ToString())
If dropped = 0 Then return whatDropped.ToArray() If dropped = 0 Then return whatDropped.ToArray()
If ring(0, dropped) mod 2 = 0 And dropped > 0 If Ring(0, dropped) mod 2 = 0 And dropped > 0
whatDropped.Add("EVEN") whatDropped.Add("EVEN")
Else Else
whatDropped.Add("ODD") whatDropped.Add("ODD")
End If End If
If ring(0, dropped) mod 3 = 0 And dropped > 0 If Ring(0, dropped) mod 3 = 0 And dropped > 0
whatDropped.Add("3L") whatDropped.Add("3L")
Else If ring(0, dropped) mod 3 = 1 Else If Ring(0, dropped) mod 3 = 1
whatDropped.Add("2L") whatDropped.Add("2L")
Else Else
whatDropped.Add("1L") whatDropped.Add("1L")
End If End If
If ring(1, dropped) = 1 If Ring(1, dropped) = 1
whatDropped.Add("RED") whatDropped.Add("RED")
Else If ring(1, dropped) = 2 Else If Ring(1, dropped) = 2
whatDropped.Add("BLACK") whatDropped.Add("BLACK")
End If End If
If ring(0, dropped) > 0 And ring(0, dropped) <= 12 If Ring(0, dropped) > 0 And Ring(0, dropped) <= 12
whatDropped.Add("F12") whatDropped.Add("F12")
Else If ring(0, dropped) > 12 And ring(0, dropped) <= 24 Else If Ring(0, dropped) > 12 And Ring(0, dropped) <= 24
whatDropped.Add("S12") whatDropped.Add("S12")
Else If ring(0, dropped) > 24 Else If Ring(0, dropped) > 24
whatDropped.Add("T12") whatDropped.Add("T12")
End If End If
If ring(0, dropped) > 0 And ring(0, dropped) < 19 If Ring(0, dropped) > 0 And Ring(0, dropped) < 19
whatDropped.Add("TO18") whatDropped.Add("TO18")
ElseIf ring(0, dropped) > 18 ElseIf Ring(0, dropped) > 18
whatDropped.Add("FROM18") whatDropped.Add("FROM18")
End If End If
Return whatDropped.ToArray() Return whatDropped.ToArray()
End Function End Function
Sub display(dropped As Integer) Sub Display(dropped As Integer)
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Console.Clear() Console.Clear()
If ring(0, 0) <> dropped If Ring(0, 0) <> dropped
Console.BackgroundColor = ConsoleColor.Black Console.BackgroundColor = ConsoleColor.Black
Console.ForegroundColor = colors(ring(1, 0)) Console.ForegroundColor = Colors(Ring(1, 0))
Console.Write(ring(0, 0) & " ") Console.Write(Ring(0, 0) & " ")
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Else Else
Console.BackgroundColor = ConsoleColor.White Console.BackgroundColor = ConsoleColor.White
Console.ForegroundColor = ConsoleColor.Black Console.ForegroundColor = ConsoleColor.Black
Console.Write(ring(0, 0)) Console.Write(Ring(0, 0))
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Console.Write(" ") Console.Write(" ")
End If End If
For i = 1 To 36 For i = 1 To 36
If ring(0, i) <> dropped If Ring(0, i) <> dropped
Console.ForegroundColor = colors(ring(1, i)) Console.ForegroundColor = Colors(Ring(1, i))
Console.Write(ring(0, i) & " ") Console.Write(Ring(0, i) & " ")
Else Else
Console.BackgroundColor = ConsoleColor.White Console.BackgroundColor = ConsoleColor.White
Console.ForegroundColor = colors(ring(1, i)) Console.ForegroundColor = Colors(Ring(1, i))
Console.Write(ring(0, i)) Console.Write(Ring(0, i))
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Console.Write(" ") Console.Write(" ")
End If End If
@ -199,13 +199,13 @@ Module Program
Console.WriteLine() Console.WriteLine()
For i = 3 To 36 Step 3 For i = 3 To 36 Step 3
temp = GetIndex(ringRank0, i) temp = GetIndex(RingRank0, i)
If i <> dropped If i <> dropped
Console.ForegroundColor = colors(ring(1, temp)) Console.ForegroundColor = Colors(Ring(1, temp))
Console.Write("{0,2:G} ", i) Console.Write("{0,2:G} ", i)
Else Else
Console.BackgroundColor = ConsoleColor.White Console.BackgroundColor = ConsoleColor.White
Console.ForegroundColor = colors(ring(1, temp)) Console.ForegroundColor = Colors(Ring(1, temp))
Console.Write("{0,2:G}", i) Console.Write("{0,2:G}", i)
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Console.Write(" ") Console.Write(" ")
@ -217,13 +217,13 @@ Module Program
Console.WriteLine() Console.WriteLine()
For i = 2 To 36 Step 3 For i = 2 To 36 Step 3
temp = GetIndex(ringRank0, i) temp = GetIndex(RingRank0, i)
If i <> dropped If i <> dropped
Console.ForegroundColor = colors(ring(1, temp)) Console.ForegroundColor = Colors(Ring(1, temp))
Console.Write("{0,2:G} ", i) Console.Write("{0,2:G} ", i)
Else Else
Console.BackgroundColor = ConsoleColor.White Console.BackgroundColor = ConsoleColor.White
Console.ForegroundColor = colors(ring(1, temp)) Console.ForegroundColor = Colors(Ring(1, temp))
Console.Write("{0,2:G}", i) Console.Write("{0,2:G}", i)
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Console.Write(" ") Console.Write(" ")
@ -235,13 +235,13 @@ Module Program
Console.WriteLine() Console.WriteLine()
For i = 1 To 36 Step 3 For i = 1 To 36 Step 3
temp = GetIndex(ringRank0, i) temp = GetIndex(RingRank0, i)
If i <> dropped If i <> dropped
Console.ForegroundColor = colors(ring(1, temp)) Console.ForegroundColor = Colors(Ring(1, temp))
Console.Write("{0,2:G} ", i) Console.Write("{0,2:G} ", i)
Else Else
Console.BackgroundColor = ConsoleColor.White Console.BackgroundColor = ConsoleColor.White
Console.ForegroundColor = colors(ring(1, temp)) Console.ForegroundColor = Colors(Ring(1, temp))
Console.Write("{0,2:G}", i) Console.Write("{0,2:G}", i)
Console.BackgroundColor = ConsoleColor.Green Console.BackgroundColor = ConsoleColor.Green
Console.Write(" ") Console.Write(" ")
@ -255,7 +255,7 @@ Module Program
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
End Sub End Sub
Sub rules() Sub Rules()
Console.Clear Console.Clear
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
Console.WriteLine("Рекомендуемое разрешение консоли: 100x35") Console.WriteLine("Рекомендуемое разрешение консоли: 100x35")
@ -282,7 +282,7 @@ Module Program
Console.ReadKey() Console.ReadKey()
End Sub End Sub
Sub game() Sub Game()
Console.WriteLine("Игра началась!") Console.WriteLine("Игра началась!")
Dim fish As Long = 5000 Dim fish As Long = 5000
Dim history As New List(Of Integer) Dim history As New List(Of Integer)
@ -301,13 +301,13 @@ Module Program
Console.WriteLine("Неверный ввод, продолжаем игру.") Console.WriteLine("Неверный ввод, продолжаем игру.")
End If End If
Dim generated() As String = spinWheel() Dim generated() As String = SpinWheel()
Console.Clear Console.Clear
history.Add(generated(0)) history.Add(generated(0))
Console.WriteLine("Делайте ставки:") Console.WriteLine("Делайте ставки:")
Console.Write(">>> ") Console.Write(">>> ")
Dim stav As New List(Of String) Dim stav
stav = UCase(Console.ReadLine()).Split.ToList() stav = UCase(Console.ReadLine()).Split.ToList()
Console.WriteLine("Укажите суммы ставок:") Console.WriteLine("Укажите суммы ставок:")
Console.Write(">>> ") Console.Write(">>> ")
@ -334,8 +334,8 @@ Module Program
End If End If
Next Next
Console.WriteLine("Крутим колесо...") Console.WriteLine("Крутим колесо...")
sleep(1) Sleep(1)
display(Int(generated(0))) Display(Int(generated(0)))
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
Dim indedx As Integer Dim indedx As Integer
For i = 0 To UBound(generated) For i = 0 To UBound(generated)
@ -371,7 +371,7 @@ Module Program
Console.Write(generated(i) & " ") Console.Write(generated(i) & " ")
Next Next
Console.WriteLine() Console.WriteLine()
displayHistory(history.ToArray()) DisplayHistory(history.ToArray())
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
Console.WriteLine() Console.WriteLine()
Loop Loop
@ -385,7 +385,7 @@ Module Program
Console.ForegroundColor = ConsoleColor.DarkBlue Console.ForegroundColor = ConsoleColor.DarkBlue
Randomize() Randomize()
Console.Clear() Console.Clear()
intro() Intro()
Console.WriteLine("Игра Рулетка") Console.WriteLine("Игра Рулетка")
Console.WriteLine("1) Начать игру") Console.WriteLine("1) Начать игру")
Console.WriteLine("2) Ознакомиться с правилами") Console.WriteLine("2) Ознакомиться с правилами")
@ -398,14 +398,14 @@ Module Program
Case 0 Case 0
Console.WriteLine() Console.WriteLine()
Console.WriteLine("Неправильный ввод!") Console.WriteLine("Неправильный ввод!")
sleep(5) Sleep(5)
Main() Main()
Case 1 Case 1
Console.Clear Console.Clear
game() Game()
Main() Main()
Case 2 Case 2
rules() Rules()
Main() Main()
Case 3 Case 3
Exit Sub Exit Sub