2021-03-21 22:30:20 +03:00
Imports System
Imports System . Formats . Asn1
Module Program
Dim 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 , 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 } }
Dim colors ( ) As ConsoleColor = { ConsoleColor . White , ConsoleColor . Red , ConsoleColor . Black }
Dim 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 , 7 , 28 , 12 , 35 , 3 , 26 }
2021-04-08 20:14:30 +03:00
Dim intr ( ) As String = {
" #### ### # # # ##### ##### ##### ##### " ,
" # # # # # # # # # # # " ,
" # # # # # # # # # # # " ,
" # # # # # # # # # # # " ,
" #### # # # # # #### # # #### " ,
" ## # # # # # # # # # " ,
" # # # # # # # # # # # " ,
" # # # # # # # # # # # " ,
" # # ### ### ##### ##### # # ##### " }
2021-03-21 22:30:20 +03:00
Function GetIndex ( mass ( ) As Integer , obj As Integer ) As Integer
For i = 0 To UBound ( mass )
If mass ( i ) = obj Then Return i
Next
End Function
2021-04-02 20:52:31 +03:00
Sub sleep ( d As Single )
Dim t As Single = Timer
Do while Timer - t < d
Loop
End Sub
2021-04-08 20:14:30 +03:00
Sub intro ( )
2021-04-08 21:22:49 +03:00
Console . SetCursorPosition ( Console . WindowWidth \ 2 - Len ( intr ( 0 ) ) \ 2 , Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 3 )
2021-04-08 20:14:30 +03:00
For i = 0 To UBound ( intr )
Console . WriteLine ( intr ( i ) )
Console . SetCursorPosition ( Console . WindowWidth \ 2 - Len ( intr ( 0 ) ) \ 2 , Console . GetCursorPosition ( ) . Item2 )
sleep ( 0 . 0888 )
Next
'sleep(5)
Console . SetCursorPosition ( 0 , 0 )
For i = 0 To ( Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 2 ) \ 2
Console . Write ( StrDup ( Console . WindowWidth , " # " ) )
sleep ( 0 . 0888 )
Next
For i = 0 To Console . WindowHeight - ( Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 2 ) - 3
Console . Write ( StrDup ( ( Console . WindowWidth \ 2 - Len ( intr ( 0 ) ) \ 2 ) \ 2 , " # " ) )
Console . SetCursorPosition ( Console . WindowWidth - ( Console . WindowWidth \ 2 - Len ( intr ( 0 ) ) \ 2 ) \ 2 , ( Console . GetCursorPosition ( ) . Item2 ) )
Console . WriteLine ( StrDup ( ( Console . WindowWidth \ 2 - Len ( intr ( 0 ) ) \ 2 ) \ 2 - 1 , " # " ) )
sleep ( 0 . 0888 )
Next
For i = 0 To ( Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 2 ) \ 2
Console . Write ( StrDup ( Console . WindowWidth , " # " ) )
sleep ( 0 . 0888 )
Next
2021-04-08 21:22:49 +03:00
Dim entr As String = " Нажмите любую кнопку, чтобы начать игру! "
Console . SetCursorPosition ( ( Console . WindowWidth \ 2 ) - Len ( entr ) \ 2 , Console . WindowHeight - ( Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 2 ) \ 4 - 1 )
Console . Write ( StrDup ( Len ( entr ) + 2 , " " ) )
Console . SetCursorPosition ( ( Console . WindowWidth \ 2 ) - Len ( entr ) \ 2 , Console . WindowHeight - ( Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 2 ) \ 4 )
Console . Write ( entr & " " )
Console . SetCursorPosition ( ( Console . WindowWidth \ 2 ) - Len ( entr ) \ 2 , Console . WindowHeight - ( Console . WindowHeight ( ) \ 2 - UBound ( intr ) + 2 ) \ 4 + 1 )
Console . Write ( StrDup ( Len ( entr ) + 2 , " " ) )
2021-04-08 20:14:30 +03:00
Console . ReadKey
2021-04-08 21:22:49 +03:00
Console . Clear
2021-04-08 20:14:30 +03:00
End Sub
2021-03-21 22:30:20 +03:00
Function spinWheel ( ) As String ( )
Dim rnd As New Random
Dim probability ( 36 ) As Double
Dim whatDropped As New List ( Of String )
For k = 0 To rnd . Next ( 1 , 5 )
For i = 0 To rnd . Next ( 1 , rnd . Next ( 5 , 100 ) )
rnd . NextDouble ( )
Next
Next
Dim max As Double = 0
Dim dropped As Integer
For i = 0 To 36
probability ( i ) = rnd . NextDouble ( )
if probability ( i ) > max then
max = probability ( i )
dropped = i
End If
Next
whatDropped . Add ( ring ( 0 , dropped ) . ToString ( ) )
If ring ( 0 , dropped ) mod 2 = 0 And dropped > 0
whatDropped . Add ( " EVEN " )
Else
whatDropped . Add ( " ODD " )
End If
If ring ( 0 , dropped ) mod 3 = 0 And dropped > 0
whatDropped . Add ( " 3L " )
Else If ring ( 0 , dropped ) mod 3 = 1
whatDropped . Add ( " 2L " )
Else
whatDropped . Add ( " 1L " )
End If
If ring ( 1 , dropped ) = 1
whatDropped . Add ( " RED " )
Else If ring ( 1 , dropped ) = 2
whatDropped . Add ( " BLACK " )
End If
If ring ( 0 , dropped ) > 0 And ring ( 0 , dropped ) <= 12
whatDropped . Add ( " F12 " )
Else If ring ( 0 , dropped ) > 12 And ring ( 0 , dropped ) <= 24
whatDropped . Add ( " S12 " )
Else If ring ( 0 , dropped ) > 24
whatDropped . Add ( " T12 " )
End If
If ring ( 0 , dropped ) > 0 And ring ( 0 , dropped ) < 19
whatDropped . Add ( " TO18 " )
ElseIf ring ( 0 , dropped ) > 18
whatDropped . Add ( " FROM18 " )
End If
Return whatDropped . ToArray ( )
End Function
Sub display ( dropped As Integer )
Console . BackgroundColor = ConsoleColor . Green
Console . Clear ( )
For i = 0 To 36
2021-04-17 09:34:22 +03:00
If ring ( 0 , i ) <> dropped
2021-03-21 22:30:20 +03:00
Console . ForegroundColor = colors ( ring ( 1 , i ) )
Console . Write ( ring ( 0 , i ) & " " )
Else
Console . BackgroundColor = ConsoleColor . White
Console . ForegroundColor = colors ( ring ( 1 , i ) )
Console . Write ( ring ( 0 , i ) )
Console . BackgroundColor = ConsoleColor . Green
Console . Write ( " " )
End If
Next
Dim temp As Integer
Console . WriteLine ( )
Console . WriteLine ( )
For i = 3 To 36 Step 3
temp = GetIndex ( ringRank0 , i )
2021-04-17 09:34:22 +03:00
If i <> dropped
2021-03-21 22:30:20 +03:00
Console . ForegroundColor = colors ( ring ( 1 , temp ) )
Console . Write ( i & " " )
Else
Console . BackgroundColor = ConsoleColor . White
Console . ForegroundColor = colors ( ring ( 1 , temp ) )
Console . Write ( i )
Console . BackgroundColor = ConsoleColor . Green
Console . Write ( " " )
End If
Next
Console . WriteLine ( )
For i = 2 To 36 Step 3
temp = GetIndex ( ringRank0 , i )
2021-04-17 09:34:22 +03:00
If i <> dropped
2021-03-21 22:30:20 +03:00
Console . ForegroundColor = colors ( ring ( 1 , temp ) )
Console . Write ( i & " " )
Else
Console . BackgroundColor = ConsoleColor . White
Console . ForegroundColor = colors ( ring ( 1 , temp ) )
Console . Write ( i )
Console . BackgroundColor = ConsoleColor . Green
Console . Write ( " " )
End If
Next
Console . WriteLine ( )
For i = 1 To 36 Step 3
temp = GetIndex ( ringRank0 , i )
2021-04-17 09:34:22 +03:00
If i <> dropped
2021-03-21 22:30:20 +03:00
Console . ForegroundColor = colors ( ring ( 1 , temp ) )
Console . Write ( i & " " )
Else
Console . BackgroundColor = ConsoleColor . White
Console . ForegroundColor = colors ( ring ( 1 , temp ) )
Console . Write ( i )
Console . BackgroundColor = ConsoleColor . Green
Console . Write ( " " )
End If
Next
End Sub
Sub rules ( )
Console . Clear
Console . WriteLine ( " Правила: " )
Console . WriteLine ( " Игра представляет собой Европейскую рулетку. Игрок должен сделать ставку на определённую зону, будь то число, сектор, строка, чётность или цвет. Игрок может делать несколько ставок. Ставки вводятся в предоставленную зону через пробел. " )
Console . WriteLine ( " <число 0 - 36> - ставка на число (1:36). " )
Console . WriteLine ( " 1L/2L/3L - 1/2/3 линия соответственно, снизу вверх (1:3). " )
Console . WriteLine ( " F12/S12/T12 - ставка на сектора от 1 по 12/от 13 по 24/от 25 по 36 соответственно (1:3). " )
Console . WriteLine ( " RED/BLACK - ставка на цвет (1:2). " )
Console . WriteLine ( " TO18/FROM18 - ставка на сектор от 1 по 18/от 19 по 36 (1:2). " )
Console . WriteLine ( " EVEN/ODD - чётные/нечётные (1:2). " )
Console . WriteLine ( " Игрок изначально получает 5000 фишек. " )
2021-03-22 13:55:49 +03:00
Console . WriteLine ( " После того, как игрок укажет, на что ставит, он указывает количество фишек на каждую ставку через пробел. " )
Console . WriteLine ( " Например: " )
2021-03-22 14:08:35 +03:00
Console . WriteLine ( " Н а что ставите: 0 16 2L T12 RED ODD" )
2021-03-22 13:55:49 +03:00
Console . WriteLine ( " Сколько ставите: 100 50 500 500 1000 1000 " )
2021-03-22 14:08:35 +03:00
Console . WriteLine ( " ВНИМАНИЕ! Количество ставок должно совпадать с количеством фишек, которые ставите, в примере 6 = 6. " )
2021-04-02 20:52:31 +03:00
Console . WriteLine ( " Или просто нажмите ENTER, чтобы пропустить ставку. " )
2021-03-21 22:30:20 +03:00
Console . WriteLine ( " Удачи! " )
2021-03-22 14:08:35 +03:00
Console . ReadKey ( )
2021-03-21 22:30:20 +03:00
End Sub
Sub game ( )
2021-04-02 20:52:31 +03:00
Console . WriteLine ( " Игра началась! " )
Dim fish As Long = 5000
Dim isGaming As Boolean = True
2021-04-17 09:34:22 +03:00
Do while fish > 0
2021-04-02 20:52:31 +03:00
Console . WriteLine ( " У В а с {0} фишек." , fish )
Console . WriteLine ( " Продолжить игру? (Y/n) " )
Dim temp As String = Console . ReadLine ( )
If temp = " n " or temp = " N " Then
2021-04-17 09:34:22 +03:00
Exit Sub
2021-04-02 20:52:31 +03:00
Else IF temp = " " or temp = " y " or temp = " Y "
isGaming = True
2021-04-08 21:22:49 +03:00
Else
Console . WriteLine ( " Неверный ввод, продолжаем игру. " )
2021-04-02 20:52:31 +03:00
End If
2021-04-08 21:22:49 +03:00
Dim generated ( ) As String = spinWheel ( )
Console . Clear
Console . Write ( " Делайте ставки: " )
Dim stav As New List ( Of String )
stav = Console . ReadLine ( ) . Split . ToList ( )
Console . Write ( " Укажите суммы ставок: " )
Dim summ ( ) As String
summ = Console . ReadLine ( ) . Split
2021-04-22 19:06:10 +03:00
Dim summs ( UBound ( summ ) ) As Integer
2021-04-08 21:22:49 +03:00
For i = 0 To UBound ( summ )
2021-04-22 19:06:10 +03:00
summs ( i ) = Int ( summ ( i ) )
2021-04-08 21:22:49 +03:00
Next
2021-04-22 19:06:10 +03:00
If stav . Count <> summs . Count Or summs . ToArray . Sum ( ) > fish Then
2021-04-17 09:34:22 +03:00
Console . WriteLine ( " Ставки не корректны. Пропуск. " )
Continue Do
End If
2021-04-08 21:22:49 +03:00
Console . WriteLine ( " Крутим колесо... " )
2021-04-22 19:06:10 +03:00
sleep ( 2 )
2021-04-17 09:34:22 +03:00
display ( Int ( generated ( 0 ) ) )
2021-04-08 21:22:49 +03:00
Dim indedx As Integer
2021-04-17 09:34:22 +03:00
For i = 0 To UBound ( generated )
If stav . Contains ( generated ( i ) ) Then
2021-04-08 21:22:49 +03:00
indedx = stav . IndexOf ( generated ( i ) )
2021-04-17 09:34:22 +03:00
If IsNumeric ( generated ( i ) )
2021-04-22 19:06:10 +03:00
fish += summs ( indedx ) * 35
2021-04-17 09:34:22 +03:00
Else If generated ( i ) = " RED " Or generated ( i ) = " BLACK " Or generated ( i ) = " ODD " Or generated ( i ) = " EVEN " Or generated ( i ) = " FROM18 " Or generated ( i ) = " TO18 " Then
2021-04-22 19:06:10 +03:00
fish += summs ( indedx ) * 1
2021-04-17 09:34:22 +03:00
Else If generated ( i ) = " 3L " Or generated ( i ) = " 2L " Or generated ( i ) = " 1L " Or generated ( i ) = " F12 " Or generated ( i ) = " S12 " Or generated ( i ) = " T12 " Then
2021-04-22 19:06:10 +03:00
fish += summs ( indedx ) * 2
2021-04-17 09:34:22 +03:00
Else
2021-04-22 19:06:10 +03:00
fish -= summs ( indedx ) * 2
2021-04-17 09:34:22 +03:00
End If
2021-04-08 21:22:49 +03:00
End If
Next
2021-04-17 09:34:22 +03:00
Console . WriteLine ( )
Console . WriteLine ( " Выпало: " )
For i = 0 To UBound ( generated )
Console . Write ( generated ( i ) & " " )
Next
Console . WriteLine ( )
2021-04-02 20:52:31 +03:00
Loop
2021-03-21 22:30:20 +03:00
End Sub
Sub Main ( )
Console . BackgroundColor = ConsoleColor . Green
Randomize ( )
Console . Clear ( )
Console . ForegroundColor = ConsoleColor . Black
2021-04-08 20:14:30 +03:00
intro ( )
2021-03-21 22:30:20 +03:00
'Console.SetWindowSize(108,100)
Console . WriteLine ( " Игра Рулетка " )
Console . WriteLine ( " 1) Начать игру " )
Console . WriteLine ( " 2) Ознакомиться с правилами " )
Console . WriteLine ( " 3) Выйти из игры " )
2021-04-08 21:22:49 +03:00
Dim input As Char = Console . ReadKey . KeyChar
Dim n As Integer = If ( Int ( input . ToString ( ) ) = 1 Or Int ( input . ToString ( ) ) = 2 Or Int ( input . ToString ( ) ) = 3 , Int ( input . ToString ( ) ) , 0 )
2021-03-22 14:08:35 +03:00
Dim history As New List ( Of Integer )
Dim historyC As New List ( Of Integer )
2021-03-21 22:30:20 +03:00
Select Case n
2021-04-08 21:22:49 +03:00
Case 0
Console . WriteLine ( )
Console . WriteLine ( " Неправильный ввод! " )
sleep ( 5 )
Main
2021-03-21 22:30:20 +03:00
Case 1
2021-04-11 15:53:37 +03:00
Console . Clear
2021-03-21 22:30:20 +03:00
game ( )
Main ( )
Case 2
2021-04-11 15:53:37 +03:00
Console . Clear
2021-03-21 22:30:20 +03:00
rules ( )
Main ( )
Case 3
Exit Sub
End Select
End Sub
End Module