baseline: OpenMU upstream b5a0961 (fresh source)
This commit is contained in:
32
src/GameLogic/PlayerActions/Vault/RemoveVaultPinAction.cs
Normal file
32
src/GameLogic/PlayerActions/Vault/RemoveVaultPinAction.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
// <copyright file="RemoveVaultPinAction.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.GameLogic.PlayerActions.Vault;
|
||||
|
||||
using MUnique.OpenMU.GameLogic.Views.Vault;
|
||||
|
||||
/// <summary>
|
||||
/// Action which removes the pin for the vault of a player, if the correct account password is provided.
|
||||
/// </summary>
|
||||
public class RemoveVaultPinAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes the pin for the vault of a player, if the correct account password is provided.
|
||||
/// </summary>
|
||||
/// <param name="player">The player.</param>
|
||||
/// <param name="accountPassword">The account password.</param>
|
||||
public async ValueTask RemovePinAsync(Player player, string accountPassword)
|
||||
{
|
||||
if (player.Account is not null && BCrypt.Net.BCrypt.Verify(accountPassword, player.Account.PasswordHash))
|
||||
{
|
||||
player.Account.VaultPassword = string.Empty;
|
||||
player.IsVaultLocked = false;
|
||||
await player.InvokeViewPlugInAsync<IUpdateVaultStatePlugIn>(p => p.UpdateStateAsync()).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await player.InvokeViewPlugInAsync<IShowVaultLockChangeResponse>(p => p.ShowResponseAsync(VaultLockChangeResult.RemovePinFailedByWrongPassword)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/GameLogic/PlayerActions/Vault/SetVaultPinAction.cs
Normal file
38
src/GameLogic/PlayerActions/Vault/SetVaultPinAction.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
// <copyright file="SetVaultPinAction.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.GameLogic.PlayerActions.Vault;
|
||||
|
||||
using MUnique.OpenMU.GameLogic.Views.Vault;
|
||||
|
||||
/// <summary>
|
||||
/// Action which sets a new pin for the vault of a player, if the correct account password is provided.
|
||||
/// </summary>
|
||||
public class SetVaultPinAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets a new pin for the vault of a player, if the correct account password is provided.
|
||||
/// </summary>
|
||||
/// <param name="player">The player.</param>
|
||||
/// <param name="newPin">The new pin.</param>
|
||||
/// <param name="accountPassword">The account password.</param>
|
||||
public async ValueTask SetPinAsync(Player player, string newPin, string accountPassword)
|
||||
{
|
||||
if (player.Account is null || player.IsVaultLocked)
|
||||
{
|
||||
await player.InvokeViewPlugInAsync<IShowVaultLockChangeResponse>(p => p.ShowResponseAsync(VaultLockChangeResult.SetPinFailedBecauseLock)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (BCrypt.Net.BCrypt.Verify(accountPassword, player.Account.PasswordHash))
|
||||
{
|
||||
player.Account.VaultPassword = newPin;
|
||||
await player.InvokeViewPlugInAsync<IShowVaultLockChangeResponse>(p => p.ShowResponseAsync(VaultLockChangeResult.Unlocked)).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await player.InvokeViewPlugInAsync<IShowVaultLockChangeResponse>(p => p.ShowResponseAsync(VaultLockChangeResult.SetPinFailedBecauseLock)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
src/GameLogic/PlayerActions/Vault/UnlockVaultAction.cs
Normal file
34
src/GameLogic/PlayerActions/Vault/UnlockVaultAction.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
// <copyright file="UnlockVaultAction.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.GameLogic.PlayerActions.Vault;
|
||||
|
||||
using MUnique.OpenMU.GameLogic.Views.Vault;
|
||||
|
||||
/// <summary>
|
||||
/// Action which unlocks the vault of a player, if the correct pin is provided.
|
||||
/// </summary>
|
||||
public class UnlockVaultAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Unlocks the vault of a player, if the correct pin is provided.
|
||||
/// </summary>
|
||||
/// <param name="player">The player.</param>
|
||||
/// <param name="pin">The pin.</param>
|
||||
public async ValueTask UnlockVaultAsync(Player player, string pin)
|
||||
{
|
||||
VaultLockChangeResult result;
|
||||
if (player.Account?.VaultPassword == pin)
|
||||
{
|
||||
player.IsVaultLocked = false;
|
||||
result = VaultLockChangeResult.Unlocked;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = VaultLockChangeResult.UnlockFailedByWrongPin;
|
||||
}
|
||||
|
||||
await player.InvokeViewPlugInAsync<IShowVaultLockChangeResponse>(p => p.ShowResponseAsync(result)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user