Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions Fracture.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33829.357
# Visual Studio Version 18
VisualStudioVersion = 18.3.11520.95 d18.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fracture.Server", "Server\Fracture.Server.csproj", "{D06D3FCB-F773-4E5E-A6D3-6C6D052F7996}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{1A6377C4-4C62-4360-B547-EED1C1C6F949}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{D06D3FCB-F773-4E5E-A6D3-6C6D052F7996}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D06D3FCB-F773-4E5E-A6D3-6C6D052F7996}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D06D3FCB-F773-4E5E-A6D3-6C6D052F7996}.Release|Any CPU.Build.0 = Release|Any CPU
{1A6377C4-4C62-4360-B547-EED1C1C6F949}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A6377C4-4C62-4360-B547-EED1C1C6F949}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A6377C4-4C62-4360-B547-EED1C1C6F949}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A6377C4-4C62-4360-B547-EED1C1C6F949}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions Server/Components/Pages/GamePage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class GamePage

protected override async Task OnInitializedAsync()
{
bool userLoaded = await LoadUser();
bool userLoaded = await LoadUserAsync();
if (!userLoaded)
{
NavigationManager.NavigateTo("/");
Expand Down Expand Up @@ -54,7 +54,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
}

private async Task<bool> LoadUser()
private async Task<bool> LoadUserAsync()
{
var username = await ProtectedSessionStore.GetAsync<string>("username");
if (!username.Success)
Expand Down
2 changes: 1 addition & 1 deletion Server/Modules/MapGenerator/UI/MapView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@if (MapDisplayOptions.ShowPlayer && x == CharacterX && y == CharacterY)
{
<td style='background: @GetTileColor(Map.Grid[x, y]); font-size:6px;'>
@SpecialChars.Icons.Player
&#128528;
</td>
}
else if (MapDisplayOptions.TileInformationDisplay == TileInformationDisplay.Position)
Expand Down
2 changes: 1 addition & 1 deletion Server/Modules/MapGenerator/UI/Models/SpecialChars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public static class Arrows

public static class Icons
{
public const string Player = "&#128528";
public const string Player = "&#128528;";
}
}
19 changes: 18 additions & 1 deletion Server/Modules/Shared/NameGenerators/MarkovNameGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Fracture.Server.Modules.Shared.NameGenerators;
public class MarkovNameGenerator : INameGenerator
{
private readonly MarkovChain<char> _chain;
private HashSet<string> _names = new();

/// <summary>
/// Initializes a new instance of a generator
Expand All @@ -26,13 +27,29 @@ public MarkovNameGenerator(IOptions<NameGeneratorConfig> options)

_chain = new MarkovChain<char>(2);

// We need at least 10 names to generate good results
// otherwise the generation will hang
if (options.Value.DefaultNameBase.Count() < 10)
throw new ArgumentException(
"More names are needed!",
nameof(options.Value.DefaultNameBase)
);

foreach (var name in options.Value.DefaultNameBase)
_chain.Add(name);
}

/// <inheritdoc />
public Task<string> GenerateNameAsync()
{
return Task.FromResult(new string([.. _chain.Chain(Random.Shared)]));
string s;
do
{
var chains = _chain.Chain(Random.Shared).ToArray();
s = new string(chains);
} while (_names.Contains(s));
_names.Add(s);

return Task.FromResult(s);
}
}
Loading