Datenbank mit komischen Nomen von Wikipedia

This commit is contained in:
Meiko Remiorz 2022-04-13 22:07:06 +02:00
parent d218b291aa
commit 3e162c84b3
2 changed files with 29 additions and 3 deletions

View File

@ -75,6 +75,7 @@
public MudTextField<string> textField; public MudTextField<string> textField;
public List<string> PreviousGuesses = new List<string>(); public List<string> PreviousGuesses = new List<string>();
public List<string> SecretList = new List<string>();
//Keine Ahnung wie das funktionert... Danke StackOverflow :) //Keine Ahnung wie das funktionert... Danke StackOverflow :)
public IMask mask = new RegexMask(@"^[A-Za-z]{0,5}$"); public IMask mask = new RegexMask(@"^[A-Za-z]{0,5}$");
@ -82,10 +83,31 @@
public string secret = "penis"; public string secret = "penis";
private bool found = false; private bool found = false;
protected override void OnInitialized()
{
try
{
string text = File.ReadAllText("nomen.txt");
string[] splitArray = text.Split(",");
foreach(var w in splitArray)
{
SecretList.Add(w);
}
Random r = new Random();
secret = SecretList.ElementAt<string>(r.Next(SecretList.Count));
Console.WriteLine("[SECRET]: " + secret.ToLower());
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public void Check4Enter(KeyboardEventArgs e) public void Check4Enter(KeyboardEventArgs e)
{ {
Console.Out.WriteLine(e);
Console.Out.WriteLine(e.Code);
if (e.Code == "Enter" || e.Code == "NumpadEnter") if (e.Code == "Enter" || e.Code == "NumpadEnter")
{ {
if(found) if(found)
@ -103,7 +125,6 @@
{ {
if(Input != null && Input.Length == 5 && !found) if(Input != null && Input.Length == 5 && !found)
{ {
Console.Out.WriteLine(Input);
PreviousGuesses.Add(Input); PreviousGuesses.Add(Input);
if(secret.ToLower() == Input.ToLower()) if(secret.ToLower() == Input.ToLower())
{ {
@ -123,5 +144,9 @@
PreviousGuesses.Clear(); PreviousGuesses.Clear();
hideAlert = true; hideAlert = true;
found = false; found = false;
Random r = new Random();
secret = SecretList.ElementAt<string>(r.Next(SecretList.Count));
Console.WriteLine("[SECRET]: " + secret.ToLower());
} }
} }

File diff suppressed because one or more lines are too long