diff --git a/.idea/.idea.ZahlenRaten/.idea/avalonia.xml b/.idea/.idea.ZahlenRaten/.idea/avalonia.xml index 5c27876..0f8ef7d 100644 --- a/.idea/.idea.ZahlenRaten/.idea/avalonia.xml +++ b/.idea/.idea.ZahlenRaten/.idea/avalonia.xml @@ -3,6 +3,7 @@ diff --git a/ZahlenRaten/App.axaml b/ZahlenRaten/App.axaml index 424c73e..fe715a0 100644 --- a/ZahlenRaten/App.axaml +++ b/ZahlenRaten/App.axaml @@ -1,7 +1,7 @@ + RequestedThemeVariant="Dark"> diff --git a/ZahlenRaten/MainWindow.axaml b/ZahlenRaten/MainWindow.axaml index 7b67dab..21cc0fe 100644 --- a/ZahlenRaten/MainWindow.axaml +++ b/ZahlenRaten/MainWindow.axaml @@ -4,13 +4,56 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="ZahlenRaten.MainWindow" - Title="ZahlenRaten"> + Title="ZahlenRaten" + Background="#1e1e1e" + Width="400" Height="500" + WindowStartupLocation="CenterScreen"> - - Gib deine Zahl ein: - - - - + + + Zahlen raten + + Gib deine Zahl ein (0-9): + + + + + + + + + diff --git a/ZahlenRaten/MainWindow.axaml.cs b/ZahlenRaten/MainWindow.axaml.cs index d5548c5..23efb08 100644 --- a/ZahlenRaten/MainWindow.axaml.cs +++ b/ZahlenRaten/MainWindow.axaml.cs @@ -1,6 +1,7 @@ using System; using Avalonia.Controls; using Avalonia.Interactivity; +using Avalonia.Media; namespace ZahlenRaten; @@ -25,42 +26,51 @@ public partial class MainWindow : Window private void btnRaten_OnClick(object sender, RoutedEventArgs e) { - if (_leben > 0) + if (string.IsNullOrWhiteSpace(txtInput.Text)) return; + + if (int.TryParse(txtInput.Text, out int input)) { - int input = Convert.ToInt32(txtInput.Text); if (input == _zielZahl) { - txtOutput.Text = $"Du hast die Zahl erraten! Es war die Zahl: {_zielZahl}"; + txtOutput.Text = $"🎉 Richtig! Es war die Zahl: {_zielZahl}"; + txtOutput.Foreground = Brushes.LightGreen; btnRaten.IsVisible = false; btnNeueZahl.IsVisible = true; } - else if (input > _zielZahl) - { - txtOutput.Text = $"Deine Zahl ist kleiner als die Gesuchte Zahl. \nDu hast noch {_leben} Leben. \nDeine zuletzt geratene Zahl war die {input}"; - } else { - txtOutput.Text = $"Deine Zahl ist höher als die gesuchte Zahl. \nDu hast noch {_leben} Leben. \nDeine zuletzt geratene Zahl war die {input}"; + _leben--; + if (_leben > 0) + { + string richtung = input > _zielZahl ? "kleiner" : "größer"; + txtOutput.Text = $"Die gesuchte Zahl ist {richtung}.\nLeben: {_leben}\nLetzter Tipp: {input}"; + txtOutput.Foreground = Brushes.Orange; + } + else + { + txtOutput.Text = $"❌ Verloren! Die Zahl war: {_zielZahl}"; + txtOutput.Foreground = Brushes.Salmon; + btnRaten.IsVisible = false; + btnNeueZahl.IsVisible = true; + } } - - txtInput.Text = ""; - txtInput.Focus(); - _leben--; } else { - txtOutput.Text = $"Du hast Verloren! Die Zahl war die {_zielZahl}"; - btnRaten.IsVisible = false; - btnNeueZahl.IsVisible = true; + txtOutput.Text = "Ungültige Eingabe!"; + txtOutput.Foreground = Brushes.Yellow; } - + + txtInput.Text = ""; + txtInput.Focus(); } private void btnNeueZahl_OnClick(object sender, RoutedEventArgs e) { _leben = StandartLeben; txtInput.Text = ""; - txtOutput.Text = String.Empty; + txtOutput.Text = string.Empty; + txtOutput.Foreground = new SolidColorBrush(Color.Parse("#3498db")); _zielZahl = ZahlErstellen(); btnRaten.IsVisible = true; btnNeueZahl.IsVisible = false; diff --git a/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.dll b/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.dll index 4864ab2..7849958 100644 Binary files a/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.dll and b/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.dll differ diff --git a/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.exe b/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.exe index 5fb9dea..837b32d 100644 Binary files a/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.exe and b/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.exe differ diff --git a/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.pdb b/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.pdb index f71ffd7..82d2457 100644 Binary files a/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.pdb and b/ZahlenRaten/bin/Debug/net10.0/ZahlenRaten.pdb differ diff --git a/ZahlenRaten/obj/Debug/net10.0/Avalonia/resources b/ZahlenRaten/obj/Debug/net10.0/Avalonia/resources index acd084a..6f0d650 100644 Binary files a/ZahlenRaten/obj/Debug/net10.0/Avalonia/resources and b/ZahlenRaten/obj/Debug/net10.0/Avalonia/resources differ diff --git a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfo.cs b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfo.cs index 09a4577..e9f4570 100644 --- a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfo.cs +++ b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("ZahlenRaten")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0b20a47ad1499453d8f57815037750761f0e31a2")] [assembly: System.Reflection.AssemblyProductAttribute("ZahlenRaten")] [assembly: System.Reflection.AssemblyTitleAttribute("ZahlenRaten")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfoInputs.cache b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfoInputs.cache index c4965f2..810c796 100644 --- a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfoInputs.cache +++ b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.AssemblyInfoInputs.cache @@ -1 +1 @@ -f93a9366a989cb1b34fe487bdcb104c8c4f6e0edc88af14844591a28c252bd90 +e2ab9cd92d5fe7380e4803bd6803a1f41bd7cb5d6818965969dc31e782b439cb diff --git a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.dll b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.dll index 4864ab2..7849958 100644 Binary files a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.dll and b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.dll differ diff --git a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.pdb b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.pdb index f71ffd7..82d2457 100644 Binary files a/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.pdb and b/ZahlenRaten/obj/Debug/net10.0/ZahlenRaten.pdb differ diff --git a/ZahlenRaten/obj/Debug/net10.0/apphost.exe b/ZahlenRaten/obj/Debug/net10.0/apphost.exe index 5fb9dea..837b32d 100644 Binary files a/ZahlenRaten/obj/Debug/net10.0/apphost.exe and b/ZahlenRaten/obj/Debug/net10.0/apphost.exe differ diff --git a/ZahlenRaten/obj/Debug/net10.0/ref/ZahlenRaten.dll b/ZahlenRaten/obj/Debug/net10.0/ref/ZahlenRaten.dll index 0b979a4..33b8b52 100644 Binary files a/ZahlenRaten/obj/Debug/net10.0/ref/ZahlenRaten.dll and b/ZahlenRaten/obj/Debug/net10.0/ref/ZahlenRaten.dll differ diff --git a/ZahlenRaten/obj/Debug/net10.0/refint/ZahlenRaten.dll b/ZahlenRaten/obj/Debug/net10.0/refint/ZahlenRaten.dll index 0b979a4..33b8b52 100644 Binary files a/ZahlenRaten/obj/Debug/net10.0/refint/ZahlenRaten.dll and b/ZahlenRaten/obj/Debug/net10.0/refint/ZahlenRaten.dll differ