diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..add57be --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/.idea/.idea.Ruletka/.idea/.gitignore b/.idea/.idea.Ruletka/.idea/.gitignore new file mode 100644 index 0000000..57c8c14 --- /dev/null +++ b/.idea/.idea.Ruletka/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/contentModel.xml +/projectSettingsUpdater.xml +/modules.xml +/.idea.Ruletka.iml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.Ruletka/.idea/encodings.xml b/.idea/.idea.Ruletka/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Ruletka/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Ruletka/.idea/indexLayout.xml b/.idea/.idea.Ruletka/.idea/indexLayout.xml new file mode 100644 index 0000000..27ba142 --- /dev/null +++ b/.idea/.idea.Ruletka/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Ruletka/.idea/vcs.xml b/.idea/.idea.Ruletka/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.Ruletka/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Ruletka.sln b/Ruletka.sln new file mode 100644 index 0000000..e169eae --- /dev/null +++ b/Ruletka.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Ruletka", "Ruletka\Ruletka.vbproj", "{584852C1-EB9C-46A2-976A-0C311192ACFE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {584852C1-EB9C-46A2-976A-0C311192ACFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {584852C1-EB9C-46A2-976A-0C311192ACFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {584852C1-EB9C-46A2-976A-0C311192ACFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {584852C1-EB9C-46A2-976A-0C311192ACFE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Ruletka/Program.vb b/Ruletka/Program.vb new file mode 100644 index 0000000..1c2422e --- /dev/null +++ b/Ruletka/Program.vb @@ -0,0 +1,179 @@ +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} + 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 + + 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 + If i <> dropped + 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) + If i <> ring(0, dropped) + 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) + If i <> ring(0, dropped) + 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) + If i <> ring(0, dropped) + 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 фишек.") + Console.WriteLine("После того, как игрок укажет, на что ставит, он указывает ОДНО количество фишек на каждую ставку.") + Console.WriteLine("Удачи!") + End Sub + + Sub game() + + End Sub + + Sub Main() + Console.BackgroundColor = ConsoleColor.Green + Randomize() + Console.Clear() + Console.ForegroundColor = ConsoleColor.Black + 'Console.SetWindowSize(108,100) + Console.WriteLine("Игра Рулетка") + Console.WriteLine("1) Начать игру") + Console.WriteLine("2) Ознакомиться с правилами") + Console.WriteLine("3) Выйти из игры") + Dim n As Integer = Console.ReadLine + Select Case n + Case 1 + game() + Main() + Case 2 + rules() + Main() + Case 3 + Exit Sub + End Select + Console.ReadKey() + End Sub +End Module diff --git a/Ruletka/Ruletka.vbproj b/Ruletka/Ruletka.vbproj new file mode 100644 index 0000000..c6a388e --- /dev/null +++ b/Ruletka/Ruletka.vbproj @@ -0,0 +1,9 @@ + + + + Exe + Ruletka + net5.0 + + +