Skip to content
Closed
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
2 changes: 0 additions & 2 deletions Server/Components/Pages/GamePage.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.ObjectModel;
using Fracture.Server.Components.UI;
using Fracture.Server.Modules.Items.Models;
using Fracture.Server.Modules.MapGenerator.Models.Map;
using Fracture.Server.Modules.MapGenerator.UI.Models;
using Fracture.Server.Modules.Pathfinding.Models;
Expand All @@ -12,7 +10,7 @@
public partial class GamePage
{
private Dictionary<string, object> _mapPopupParameters = null!;
public static Map Map { get; set; }

Check warning on line 13 in Server/Components/Pages/GamePage.razor.cs

View workflow job for this annotation

GitHub Actions / Checks

Non-nullable property 'Map' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

private PopupContainer _popup = null!;

Expand Down
6 changes: 2 additions & 4 deletions Server/Modules/AI/Services/SingleResponseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

namespace Fracture.Server.Modules.AI.Services;

public class SingleResponseProvider(IChatClient client)
public class SingleResponseProvider(IChatClient _client)
{
private readonly IChatClient _client = client;

/// <summary>
/// Returns a response generated for a given prompt.
/// </summary>
/// <param name="prompt">A simple prompt</param>
/// <returns>A LLM response as a string</returns>
public async Task<string?> GenerateResponse(string prompt)
public async Task<string?> GenerateResponseAsync(string prompt)
{
return await GenerateResponse(new AIGenerationContext { Prompt = prompt });
}
Expand Down
10 changes: 5 additions & 5 deletions Server/Modules/FloodFill/FloodFillService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

public class FloodFillService<T> : IFloodFillService<T>
{
private readonly int[,] directions;
private readonly int[,] _directions;

public FloodFillService(bool useDiagonals = false)
{
directions = useDiagonals
_directions = useDiagonals
? new[,]
{
{ 0, 1 },
Expand Down Expand Up @@ -86,10 +86,10 @@ Func<T, bool> isValidElement
visited[x, y] = true;
result.Add((x, y));

for (var i = 0; i < directions.GetLength(0); i++)
for (var i = 0; i < _directions.GetLength(0); i++)
{
var nx = x + directions[i, 0];
var ny = y + directions[i, 1];
var nx = x + _directions[i, 0];
var ny = y + _directions[i, 1];
queue.Enqueue((nx, ny));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Server/Modules/Items/Models/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Item

public string Name { get; set; } = null!;

public string? History { get; set; } = null!;
public string? History { get; set; }

public ItemRarity Rarity { get; set; } = ItemRarity.Common;

Expand Down
4 changes: 2 additions & 2 deletions Server/Modules/Items/Services/ItemGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Fracture.Server.Modules.Items.Services;
public class ItemGenerator : IItemGenerator
{
private readonly SingleResponseProvider? _ai;
private readonly IFeatureManager _featureManager;
private readonly List<RarityModifier> _modifiers;
private readonly INameGenerator _nameGenerator;
private readonly PrefixesGenerator _prefixes;
Expand Down Expand Up @@ -100,6 +99,7 @@ private async Task<string> GenerateDescription(Item item)

prompt += $"Item is a reward for defeating {enemy}.";

return await _ai.GenerateResponse(prompt);
// this function will not run at all if AI is disabled, so we can be sure that _ai is not null here
return await _ai!.GenerateResponseAsync(prompt)! ?? string.Empty;
}
}
4 changes: 3 additions & 1 deletion Server/Modules/MapGenerator/MathUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public static class MathUtils
namespace Fracture.Server.Modules.MapGenerator;

public static class MathUtils
{
public static float InverseLerp(float a, float b, float v)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class MapGeneratorService : IMapGeneratorService
{
private readonly ILogger<MapGeneratorService> _logger;
private readonly Random _rnd = new();
private int _seed;

public MapGeneratorService(ILogger<MapGeneratorService> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public MapParametersReader(ILogger<MapParametersReader> logger)
}
catch (Exception ex)
{
_logger.LogCritical(ex, "Error while reading map parameters from json file");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Fracture.Server.Modules.MapGenerator;

namespace Fracture.Server.Modules.NoiseGenerator.Services;

Expand Down
8 changes: 4 additions & 4 deletions Server/Modules/Shared/NameGenerators/MarkovNameGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Fracture.Server.Modules.Shared.NameGenerators;
/// </summary>
public class MarkovNameGenerator : INameGenerator
{
private readonly MarkovChain<char> chain;
private readonly MarkovChain<char> _chain;

/// <summary>
/// Initializes a new instance of a generator
Expand All @@ -24,15 +24,15 @@ public MarkovNameGenerator(IOptions<NameGeneratorConfig> options)
"A base set of names is required"
);

chain = new MarkovChain<char>(2);
_chain = new MarkovChain<char>(2);

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

/// <inheritdoc />
public Task<string> GenerateNameAsync()
{
return Task.FromResult(new string(chain.Chain(Random.Shared).ToArray()));
return Task.FromResult(new string([.. _chain.Chain(Random.Shared)]));
}
}
2 changes: 1 addition & 1 deletion Server/Modules/Users/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class User
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }

public string Username { get; set; }
public required string Username { get; set; }

public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

Expand Down
5 changes: 0 additions & 5 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,13 @@
options.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning));
});

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddLogging();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseWebAssemblyDebugging();
}
else
Expand All @@ -114,7 +109,7 @@
}

app.UseHangfireDashboard();
app.UseHangfireServer();

Check warning on line 112 in Server/Program.cs

View workflow job for this annotation

GitHub Actions / Checks

'HangfireApplicationBuilderExtensions.UseHangfireServer(IApplicationBuilder, BackgroundJobServerOptions, IEnumerable<IBackgroundProcess>, JobStorage)' is obsolete: 'Please use IServiceCollection.AddHangfireServer extension method instead in the ConfigureServices method. Will be removed in 2.0.0.'

app.UseStaticFiles();
app.UseAuthorization();
Expand Down
Loading