Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove 'PlayerInfo' type parameter in ShowSignupDialog #171

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/Application/Players/Accounts/Systems/AccountSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void OnPlayerConnect(ConnectedPlayer connectedPlayer)
PlayerInfo playerInfo = playerRepository.GetOrDefault(connectedPlayer.Name);
if(playerInfo is null)
{
ShowSignupDialog(connectedPlayer, new PlayerInfo());
ShowSignupDialog(connectedPlayer);
return;
}
ShowLoginDialog(connectedPlayer, playerInfo);
Expand All @@ -43,32 +43,30 @@ private static void AddDefaultAccount(ConnectedPlayer connectedPlayer)
connectedPlayer.AddComponent<AccountComponent>(playerInfo, isAuthenticated);
}

private async void ShowSignupDialog(ConnectedPlayer connectedPlayer, PlayerInfo playerInfo)
private async void ShowSignupDialog(ConnectedPlayer connectedPlayer)
{
InputDialogResponse response = await dialogService.ShowAsync(connectedPlayer, _signupDialog);
if (response.Response == DialogResponse.Disconnected)
return;

if (response.Response == DialogResponse.RightButtonOrCancel)
{
ShowSignupDialog(connectedPlayer, playerInfo);
ShowSignupDialog(connectedPlayer);
return;
}

var enteredPassword = response.InputText ?? string.Empty;
CreatePlayerAccount(connectedPlayer, playerInfo, enteredPassword);
CreatePlayerAccount(connectedPlayer, enteredPassword);
}

private void CreatePlayerAccount(
ConnectedPlayer connectedPlayer,
PlayerInfo playerInfo,
string enteredPassword)
private void CreatePlayerAccount(ConnectedPlayer connectedPlayer, string enteredPassword)
{
PlayerInfo playerInfo = connectedPlayer.GetInfo();
Result passwordResult = playerInfo.SetPassword(enteredPassword);
if (passwordResult.IsFailed)
{
connectedPlayer.SendClientMessage(Color.Red, passwordResult.Message);
ShowSignupDialog(connectedPlayer, playerInfo);
ShowSignupDialog(connectedPlayer);
return;
}

Expand Down
Loading