From 7c651ce48d025bceceea114f72987d15954d50ff Mon Sep 17 00:00:00 2001 From: Kullberg Joonatan <joonatan.kullberg@gmail.com> Date: Mon, 24 Mar 2025 19:03:09 +0200 Subject: [PATCH] geeking frfr --- .../Financial_Freedom/Financial_Freedom.cs | 77 +++++++++++++++---- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs index c915a4b..a079ae1 100644 --- a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs +++ b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs @@ -11,6 +11,7 @@ using Jypeli; using Jypeli.Assets; using Jypeli.Controls; using Jypeli.Widgets; +using Microsoft.VisualBasic; using Silk.NET.Input; using Silk.NET.OpenAL; using Silk.NET.SDL; @@ -89,11 +90,11 @@ public class Card // tehdään kortit public class RouletteBet { - public string Pocket { get; } // Panoskohteen nimi ("0", "00", "28", jne.) + public int Pocket { get; } // Panoskohteen nimi ("0", "00", "28", jne.) public string Color { get; } // Väri ("Green", "Red", "Black") public double Angle { get; } // Kulma-arvo asteina, jossa panoskohde sijaitsee pöydällä - public RouletteBet(string pocket, string color, double angle) + public RouletteBet(int pocket, string color, double angle) { Pocket = pocket; Color = color; @@ -124,7 +125,6 @@ public class Financial_Freedom : PhysicsGame private List<Card> jakajanKortit; // Jakajan kortit kentäksi private List<string> clickLog = new List<string>(); //ruletin panostuksen clikkailulogi - private List<string> Betit; //läpikäyty klikkauslogi private GameObject doneButton = null; private double realangle; @@ -161,9 +161,9 @@ public class Financial_Freedom : PhysicsGame { var rulettitaskut = new List<RouletteBet>(); - string[] pockets = new string[] { - "6", "27", "13", "36", "11", "30", "8", "23", "10", "5", "00", "24", "16", "33", "1", "20", "14", "31", "9", "22", - "18", "29", "7", "28", "12", "35", "3", "26", "0", "32", "15", "19", "4", "21", "2", "25", "17", "34" + int[] pockets = new int[] { + 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 00, 24, 16, 33, 1, 20, 14, 31, 9, 22, + 18, 29, 7, 28, 12, 35, 3, 26, 0, 32, 15, 19, 4, 21, 2, 25, 17, 34 }; // Värit: Vihreät 0 ja 00, muut ovat virallisesti määrättyjä. @@ -182,7 +182,7 @@ public class Financial_Freedom : PhysicsGame for (int i = 0; i < pockets.Length; i++) { - string name = pockets[i]; + int name = pockets[i]; string color = colors[i]; double angle = anglet[i]; rulettitaskut.Add(new RouletteBet(name, color, angle)); @@ -1600,7 +1600,7 @@ public class Financial_Freedom : PhysicsGame if (punainenPanos.IsInside(Mouse.PositionOnScreen)) { // Tallennetaan värin nimi välimuistiin - clickLog.Add("Punainen"); + clickLog.Add("Red"); AsetaPanosVärille("Punainen"); if (doneButton == null) { @@ -1626,7 +1626,7 @@ public class Financial_Freedom : PhysicsGame if (mustaPanos.IsInside(Mouse.PositionOnScreen)) { // Tallennetaan värin nimi välimuistiin - clickLog.Add("Punainen"); + clickLog.Add("Black"); AsetaPanosVärille("Musta"); if (doneButton == null) { @@ -1656,7 +1656,9 @@ public class Financial_Freedom : PhysicsGame { if (Done.IsInside(Mouse.PositionOnScreen)) { + peliKesken += 1; panosAsetettu.TrySetResult(true); + pistelaskuri.Value -= panos; RulettiPyöritys(); } }, "Aseta panos värille Musta"); @@ -1681,10 +1683,11 @@ public class Financial_Freedom : PhysicsGame { ClearGameObjects(); ClearControls(); - List<string> Betit = new HashSet<string>(clickLog).ToList(); - MessageDisplay.Add($"Panokset on jaettu kohtiin:{string.Join(", ", Betit)}"); - Console.WriteLine($"Panokset on jaettu kohtiin:{string.Join(", ", Betit)}"); + clickLog = new HashSet<string>(clickLog).ToList(); + MessageDisplay.Add($"Panokset on jaettu kohtiin:{string.Join(", ", clickLog)}"); + Console.WriteLine($"Panokset on jaettu kohtiin:{string.Join(", ", clickLog)}"); Console.WriteLine($"Panos per kohde on {panos} jaettuna {clickLog.Count} on {panos/clickLog.Count}"); + RulettiLauta(this, 850, 25, 40, 0, 0); TakaisinPV(); @@ -1730,6 +1733,7 @@ public class Financial_Freedom : PhysicsGame public async Task pyorautalauta(PhysicsObject transpallo, PhysicsObject pelilauta, double pn, bool pyorii, List<Angle> checkAngles) { + ClearControls(); transpallo.AngularDamping = RandomGen.NextDouble(0.7,2);// molemmat hidastuu eri nopeuksilla pelilauta.AngularDamping = RandomGen.NextDouble(0.3,0.5); transpallo.AngularVelocity = pn + RandomGen.NextDouble(4, 10); @@ -1770,8 +1774,52 @@ public class Financial_Freedom : PhysicsGame MessageDisplay.Add("aloitetaan tarkistus"); Console.WriteLine("aloitetaan tarkistus"); - palloangle(realangle); + int pallosijainti = (int)palloangle(realangle); + + Console.WriteLine($"Se TOIMIIIIIII {palloangle(realangle)}"); + + ClearGameObjects(); + + // Erilliset listat numeroille ja sanoille + List<int> numbers = new List<int>(); + List<string> colors = new List<string>(); + + // Käydään läpi alkuperäinen lista + foreach (var i in clickLog) + { + // Tarkistetaan, onko item numero + if (int.TryParse(i, out int result)) + { + // Jos on numero, lisätään numerolistaan + numbers.Add(result); + } + else + { + // Jos ei ole numero, lisätään värilistaan + colors.Add(i); + } + } + + foreach (var i in numbers) + { + if (i == pallosijainti) + { + pistelaskuri.Value += panos/clickLog.Count*36; + } + } + foreach (var i in colors) + { + var rulettitaskut = CreateRouletteBets(); + foreach (var rouletteBet in rulettitaskut) + { + if (rouletteBet.Pocket == pallosijainti) + { + string vari = rouletteBet.Color; + } + } + } + peliKesken -= 1; } @@ -1788,7 +1836,8 @@ public class Financial_Freedom : PhysicsGame { Console.WriteLine(rouletteBet.Pocket); tarkastettu = true; - return rouletteBet.Angle; + int pocketdb = rouletteBet.Pocket; + return pocketdb; } } } -- GitLab