mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-23 02:12:14 +00:00
Intro uses new login system
This commit is contained in:
parent
aec0eff818
commit
5f11bf2d29
1 changed files with 1 additions and 166 deletions
|
@ -141,173 +141,8 @@ namespace ShiftOS.WinForms
|
|||
Console.WriteLine();
|
||||
Console.WriteLine("Next, let's get user information.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Please enter a system hostname.");
|
||||
string allowed_chars = "abcdefghijklmnopqrstuvwxyz1234567890_";
|
||||
bool userExists = false;
|
||||
Applications.Terminal.TextSent += (text) =>
|
||||
{
|
||||
if(position == 0)
|
||||
{
|
||||
if(text.Length < 5)
|
||||
{
|
||||
Console.WriteLine("Your hostname must be at least 5 characters long.");
|
||||
return;
|
||||
}
|
||||
ShiftOS.Engine.OutOfBoxExperience.PromptForLogin();
|
||||
|
||||
if(!isValid(text, allowed_chars))
|
||||
{
|
||||
Console.WriteLine("Your hostname contains illegal characters. You can only use these characters: " + allowed_chars);
|
||||
return;
|
||||
}
|
||||
SaveSystem.CurrentSave.SystemName = text;
|
||||
position = 1;
|
||||
}
|
||||
else if(position == 1)
|
||||
{
|
||||
if (text.Length < 5)
|
||||
{
|
||||
Console.WriteLine("Your username must be at least 5 characters long.");
|
||||
return;
|
||||
}
|
||||
if (!isValid(text, allowed_chars))
|
||||
{
|
||||
Console.WriteLine("Your username contains illegal characters. You can only use these characters: " + allowed_chars);
|
||||
return;
|
||||
}
|
||||
SaveSystem.CurrentSave.Username = text;
|
||||
position = 2;
|
||||
}
|
||||
else if(position == 3)
|
||||
{
|
||||
if (!userExists)
|
||||
{
|
||||
if (text.Length < 5)
|
||||
{
|
||||
Console.WriteLine("Your password must be at least 5 characters long.");
|
||||
return;
|
||||
}
|
||||
SaveSystem.CurrentSave.Password = text;
|
||||
position = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new
|
||||
{
|
||||
username = SaveSystem.CurrentSave.Username,
|
||||
password = text
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TerminalBackend.InStory = false;
|
||||
|
||||
while (position == 0)
|
||||
Thread.Sleep(10);
|
||||
Console.WriteLine("Connecting to the multi-user domain as " + SaveSystem.CurrentSave.SystemName + "...");
|
||||
bool connected = false;
|
||||
Engine.AudioManager.PlayCompleted += () => { connected = true; };
|
||||
Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02);
|
||||
while (connected == false)
|
||||
Thread.Sleep(10);
|
||||
Console.WriteLine("Connection successful, system spinning up...");
|
||||
Thread.Sleep(200);
|
||||
UsernameWait:
|
||||
Console.WriteLine("No users associated with this system. Please enter a username.");
|
||||
Console.WriteLine(" - If the username is registered as a digital being, you will be prompted for your password. Else, you will be prompted to create a new account.");
|
||||
while(position == 1)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
bool goBack = false;
|
||||
int incorrectChances = 2;
|
||||
Console.WriteLine("Checking sentience records...");
|
||||
ServerMessageReceived smr = (msg) =>
|
||||
{
|
||||
if (position == 2)
|
||||
{
|
||||
if (msg.Name == "mud_found")
|
||||
{
|
||||
Console.WriteLine("Your username has been taken by another sentient being within the digital society.");
|
||||
Console.WriteLine("If you are that sentience, you have two chances to type the correct password.");
|
||||
userExists = true;
|
||||
}
|
||||
else if (msg.Name == "mud_notfound")
|
||||
{
|
||||
Console.WriteLine("Please enter a password for this new user.");
|
||||
userExists = false;
|
||||
}
|
||||
position = 3;
|
||||
}
|
||||
else if (position == 3)
|
||||
{
|
||||
if(userExists == true)
|
||||
{
|
||||
if(msg.Name == "mud_savefile")
|
||||
{
|
||||
Console.WriteLine("Your sentience profile has been assigned to your system successfully. We will bring you to your system shortly.");
|
||||
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
position = 4;
|
||||
}
|
||||
else if(msg.Name == "mud_login_denied")
|
||||
{
|
||||
if (incorrectChances > 0)
|
||||
{
|
||||
incorrectChances--;
|
||||
Console.WriteLine("Access denied. Chances: " + incorrectChances);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Access denied.");
|
||||
position = 2;
|
||||
goBack = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
ServerManager.MessageReceived += smr;
|
||||
ServerManager.SendMessage("mud_checkuserexists", JsonConvert.SerializeObject(new { username = SaveSystem.CurrentSave.Username }));
|
||||
while (position == 2)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
while (position == 3)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
if (goBack)
|
||||
{
|
||||
ServerManager.MessageReceived -= smr;
|
||||
goto UsernameWait;
|
||||
}
|
||||
Console.WriteLine("Sentience linkup successful.");
|
||||
Console.WriteLine("We will bring you to your system in 5 seconds.");
|
||||
Thread.Sleep(5000);
|
||||
Desktop.InvokeOnWorkerThread(() =>
|
||||
{
|
||||
SaveSystem.CurrentSave.StoryPosition = 3;
|
||||
SaveSystem.SaveGame();
|
||||
while (!Shiftorium.IsInitiated)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
if (!Shiftorium.UpgradeInstalled("desktop"))
|
||||
{
|
||||
SaveSystem.GameReady += () =>
|
||||
{
|
||||
term.ClearText();
|
||||
TerminalBackend.PrintPrompt();
|
||||
Console.Write("sos.status");
|
||||
TerminalBackend.InvokeCommand("sos.status");
|
||||
TerminalBackend.PrintPrompt();
|
||||
Console.Write("sos.help");
|
||||
TerminalBackend.InvokeCommand("sos.help");
|
||||
Thread.Sleep(1000);
|
||||
TerminalBackend.PrintPrompt();
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
private static bool isValid(string text, string chars)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue