diff --git a/GottfriedsNackenWebseite/GottfriedsNackenUtility/GottfriedsNackenUtility.csproj b/GottfriedsNackenWebseite/GottfriedsNackenUtility/GottfriedsNackenUtility.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/GottfriedsNackenWebseite/GottfriedsNackenUtility/GottfriedsNackenUtility.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/GottfriedsNackenWebseite/GottfriedsNackenUtility/MathHelper.cs b/GottfriedsNackenWebseite/GottfriedsNackenUtility/MathHelper.cs new file mode 100644 index 0000000..ead18bf --- /dev/null +++ b/GottfriedsNackenWebseite/GottfriedsNackenUtility/MathHelper.cs @@ -0,0 +1,32 @@ +using System.Numerics; + +namespace GottfriedsNackenUtility; + +/// +/// Bietet nütliche mathematische Funktionen. +/// +public static class MathHelper +{ + /// + /// Enumeriert die Zahlen der Fibonacci-Folge. + /// + /// + /// Der Datentyp ist , da es ein paar Fibonacci-Zahlen gibt die nicht von dargestellt werden können. + /// + public static IEnumerable Fibonacci() + { + BigInteger i = 0; + BigInteger j = 1; + + while (true) + { + BigInteger fib = i + j; + + i = j; + j = fib; + + yield return fib; + } + } +} + diff --git a/GottfriedsNackenWebseite/GottfriedsNackenUtility/SusHelper.cs b/GottfriedsNackenWebseite/GottfriedsNackenUtility/SusHelper.cs new file mode 100644 index 0000000..7de9991 --- /dev/null +++ b/GottfriedsNackenWebseite/GottfriedsNackenUtility/SusHelper.cs @@ -0,0 +1,42 @@ +using System.Numerics; + +namespace GottfriedsNackenUtility; + +/// +/// Hier sind suspiziöse Funktionen versteckt. +/// +public static class SusHelper +{ + /// + /// Dies ist der ausgeklügelste fake-Fortschrittbalkensalgorithmus den die Welt je erblickt hat. + /// + /// + /// Dieser Task läuft in einer Endlosschleife und MUSS mit Hilfe des Abbruchtokens abgebrochen werden! + /// + /// Das callback das aufgerufen wird, wenn der Fortschritt sich geändert hat. + /// Gibt einen Int zwischen 0 und 100 zurück oder -1, wenn der Fortschrittsbalken auf einen "indefinite" Zustand wechseln soll. + /// Ein Abbruchtoken, das beim Warten auf den Abschluss der Aufgabe überwacht werden soll. + public static async Task UpdateDefinitelyNotFakeProgress(Action progressChangedCallback, CancellationToken cancellationToken) + { + try + { + foreach (BigInteger fibonacci in MathHelper.Fibonacci()) + { + await Task.Delay(250 + (int)(fibonacci % 420), cancellationToken); + + if (cancellationToken.IsCancellationRequested) + break; + + if (fibonacci.IsEven && (int)(fibonacci % 42) == 0) + { + progressChangedCallback(-1); + await Task.Delay(1337, cancellationToken); + continue; + } + + progressChangedCallback((int)(fibonacci % 69)); + } + } + catch (TaskCanceledException) { } + } +} diff --git a/GottfriedsNackenWebseite/GottfriedsNackenWebseite.sln b/GottfriedsNackenWebseite/GottfriedsNackenWebseite.sln index d1895ef..9270526 100644 --- a/GottfriedsNackenWebseite/GottfriedsNackenWebseite.sln +++ b/GottfriedsNackenWebseite/GottfriedsNackenWebseite.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GottfriedsNackenWebseite", "GottfriedsNackenWebseite\GottfriedsNackenWebseite.csproj", "{464DD643-DAD9-4E16-BB24-36F789ED4C15}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GottfriedsNackenUtility", "GottfriedsNackenUtility\GottfriedsNackenUtility.csproj", "{0122762F-9961-4D28-8AA9-0D6AE7630208}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {464DD643-DAD9-4E16-BB24-36F789ED4C15}.Debug|Any CPU.Build.0 = Debug|Any CPU {464DD643-DAD9-4E16-BB24-36F789ED4C15}.Release|Any CPU.ActiveCfg = Release|Any CPU {464DD643-DAD9-4E16-BB24-36F789ED4C15}.Release|Any CPU.Build.0 = Release|Any CPU + {0122762F-9961-4D28-8AA9-0D6AE7630208}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0122762F-9961-4D28-8AA9-0D6AE7630208}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0122762F-9961-4D28-8AA9-0D6AE7630208}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0122762F-9961-4D28-8AA9-0D6AE7630208}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/GottfriedsNackenWebseite/GottfriedsNackenWebseite/Components/WordleComponent.razor b/GottfriedsNackenWebseite/GottfriedsNackenWebseite/Components/WordleComponent.razor index 9db207b..4b49608 100644 --- a/GottfriedsNackenWebseite/GottfriedsNackenWebseite/Components/WordleComponent.razor +++ b/GottfriedsNackenWebseite/GottfriedsNackenWebseite/Components/WordleComponent.razor @@ -1,13 +1,25 @@ - -