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

chore: formatting #82

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"husky": {
"version": "0.6.2",
"version": "0.7.1",
"commands": [
"husky"
],
Expand All @@ -17,7 +17,7 @@
"rollForward": false
},
"gitversion.tool": {
"version": "5.12.0",
"version": "6.0.5",
"commands": [
"dotnet-gitversion"
],
Expand Down
61 changes: 29 additions & 32 deletions Server/Migrations/Initial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table =>
new
{
Id = table
.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Username = table.Column<string>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
columns: table => new
{
Id = table
.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Username = table.Column<string>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
Expand All @@ -30,20 +29,19 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "Items",
columns: table =>
new
{
Id = table
.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
History = table.Column<string>(type: "TEXT", nullable: true),
Rarity = table.Column<int>(type: "INTEGER", nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
IsEquipped = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedById = table.Column<int>(type: "INTEGER", nullable: false)
},
columns: table => new
{
Id = table
.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
History = table.Column<string>(type: "TEXT", nullable: true),
Rarity = table.Column<int>(type: "INTEGER", nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
IsEquipped = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedById = table.Column<int>(type: "INTEGER", nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.Id);
Expand All @@ -59,15 +57,14 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "ItemStatistics",
columns: table =>
new
{
ItemId = table.Column<int>(type: "INTEGER", nullable: false),
Luck = table.Column<int>(type: "INTEGER", nullable: false),
Health = table.Column<int>(type: "INTEGER", nullable: false),
Armor = table.Column<int>(type: "INTEGER", nullable: false),
Power = table.Column<int>(type: "INTEGER", nullable: false)
},
columns: table => new
{
ItemId = table.Column<int>(type: "INTEGER", nullable: false),
Luck = table.Column<int>(type: "INTEGER", nullable: false),
Health = table.Column<int>(type: "INTEGER", nullable: false),
Armor = table.Column<int>(type: "INTEGER", nullable: false),
Power = table.Column<int>(type: "INTEGER", nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_ItemStatistics", x => x.ItemId);
Expand Down
8 changes: 4 additions & 4 deletions Server/Modules/Database/ItemsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ public async Task<Item> AddItemAsync(Item item)

public async Task<Item?> GetItemAsync(int id)
{
var item = await _dbContext.Items
.Where(i => i.Id == id)
var item = await _dbContext
.Items.Where(i => i.Id == id)
.Include(i => i.Statistics)
.FirstOrDefaultAsync();
return item;
}

public async Task<ICollection<Item>> GetItemsOfUserAsync(int userId)
{
var items = await _dbContext.Items
.Where(i => i.CreatedById == userId)
var items = await _dbContext
.Items.Where(i => i.CreatedById == userId)
.Include(i => i.Statistics)
.ToListAsync();
return items;
Expand Down
8 changes: 4 additions & 4 deletions Server/Modules/Database/UsersRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public async Task<User> AddUserAsync(User user)

public async Task<User?> GetUserAsync(int id)
{
var user = await _dbContext.Users
.Where(u => u.Id == id)
var user = await _dbContext
.Users.Where(u => u.Id == id)
.Include(u => u.Items)
.ThenInclude(i => i.Statistics)
.FirstOrDefaultAsync();
Expand All @@ -31,8 +31,8 @@ public async Task<User> AddUserAsync(User user)

public async Task<User?> GetUserAsync(string username)
{
var user = await _dbContext.Users
.Where(u => u.Username == username)
var user = await _dbContext
.Users.Where(u => u.Username == username)
.Include(u => u.Items)
.ThenInclude(i => i.Statistics)
.FirstOrDefaultAsync();
Expand Down
13 changes: 6 additions & 7 deletions Server/Modules/Items/Models/ItemRarity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum ItemRarity
Rare,
Insane,
Epic,
Legendary
Legendary,
}
}

Expand All @@ -29,12 +29,11 @@ public static string ToCssClassName(this ItemRarity rarity)
ItemRarity.Insane => "--rarity-insane",
ItemRarity.Epic => "--rarity-epic",
ItemRarity.Legendary => "--rarity-legendary",
_
=> throw new ArgumentOutOfRangeException(
nameof(rarity),
rarity,
$"Rarity '{rarity}' does not have a corresponding CSS class."
)
_ => throw new ArgumentOutOfRangeException(
nameof(rarity),
rarity,
$"Rarity '{rarity}' does not have a corresponding CSS class."
),
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion Server/Modules/Items/Models/ItemStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public enum ItemStat
Luck,
Health,
Armor,
Power
Power,
}
2 changes: 1 addition & 1 deletion Server/Modules/Items/Models/ItemStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

[InverseProperty(nameof(Item.Statistics))]
[JsonIgnore]
public virtual Item Item { get; set; }

Check warning on line 23 in Server/Modules/Items/Models/ItemStatistics.cs

View workflow job for this annotation

GitHub Actions / Checks

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

public int GetStatFromItemStat(ItemStat stat)
{
Expand All @@ -30,7 +30,7 @@
ItemStat.Health => Health,
ItemStat.Armor => Armor,
ItemStat.Power => Power,
_ => throw new ArgumentOutOfRangeException(nameof(stat), stat, null)
_ => throw new ArgumentOutOfRangeException(nameof(stat), stat, null),
};
}

Expand Down
2 changes: 1 addition & 1 deletion Server/Modules/Items/Models/ItemType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public enum ItemType
Gauntlets,
Leggings,
Boots,
Ring
Ring,
}
}
14 changes: 7 additions & 7 deletions Server/Modules/Items/Models/PrefixesGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Fracture.Server.Modules.Shared;
using System;
using System;
using Fracture.Server.Modules.Shared;

namespace Fracture.Server.Modules.Items.Models
{
Expand All @@ -16,7 +16,7 @@ public class PrefixesGenerator
{ "Poisoned", -40 },
{ "Toxic", -60 },
{ "Cursed", -80 },
{ "Demonic", -100 }
{ "Demonic", -100 },
};

private static readonly Dictionary<ItemStat, Dictionary<string, int>> StatNames =
Expand All @@ -35,7 +35,7 @@ public class PrefixesGenerator
{ "Unfortunate", -40 },
{ "Clumsy", -60 },
{ "Fateful", -80 },
{ "Misfortune-laden", -100 }
{ "Misfortune-laden", -100 },
}
},
{
Expand All @@ -51,7 +51,7 @@ public class PrefixesGenerator
{ "Feeble", -40 },
{ "Flimsy", -60 },
{ "Fragile", -80 },
{ "Ethereal", -100 }
{ "Ethereal", -100 },
}
},
{
Expand All @@ -67,7 +67,7 @@ public class PrefixesGenerator
{ "Plain", -40 },
{ "Rusty", -60 },
{ "Unreliable", -80 },
{ "Primitive", -100 }
{ "Primitive", -100 },
}
},
{
Expand All @@ -83,7 +83,7 @@ public class PrefixesGenerator
{ "Dull", -40 },
{ "Brittle", -60 },
{ "Weak", -80 },
{ "Wasteful", -100 }
{ "Wasteful", -100 },
}
},
};
Expand Down
8 changes: 4 additions & 4 deletions Server/Modules/Items/Services/ItemGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Fracture.Server.Modules.AI.Services;
using System.Text.Json;
using Fracture.Server.Modules.AI.Services;
using Fracture.Server.Modules.Items.Models;
using Fracture.Server.Modules.Shared;
using Fracture.Server.Modules.Shared.Configuration;
using Microsoft.FeatureManagement;
using System.Text.Json;

namespace Fracture.Server.Modules.Items.Services
{
Expand All @@ -16,7 +16,7 @@
private readonly IAIInstructionProvider? _ai;
private readonly IFeatureManager _featureManager;

public ItemGenerator(

Check warning on line 19 in Server/Modules/Items/Services/ItemGenerator.cs

View workflow job for this annotation

GitHub Actions / Checks

Non-nullable field '_featureManager' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
INameGenerator nameGenerator,
PrefixesGenerator prefixes,
IAIInstructionProvider? ai = null
Expand Down Expand Up @@ -54,7 +54,7 @@
"Tundra",
"Swamp",
"Savanna",
"Desert"
"Desert",
};
List<string> enemies = new List<string>()
{
Expand All @@ -63,7 +63,7 @@
"Skeleton",
"Harpy",
"Vampire",
"Knight"
"Knight",
};

string biome = biomes[_rnd.Next(biomes.Count)];
Expand All @@ -79,7 +79,7 @@

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

return await _ai.GenerateInstructionResponse(prompt);

Check warning on line 82 in Server/Modules/Items/Services/ItemGenerator.cs

View workflow job for this annotation

GitHub Actions / Checks

Dereference of a possibly null reference.
}

public async Task<Item> Generate()
Expand Down
4 changes: 2 additions & 2 deletions Server/Modules/MapGenerator/Services/MapGeneratorService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Fracture.Server.Modules.MapGenerator.Models;
using System.Numerics;
using Fracture.Server.Modules.MapGenerator.Models;
using Fracture.Server.Modules.NoiseGenerator.Models;
using Fracture.Server.Modules.NoiseGenerator.Services;
using System.Numerics;

namespace Fracture.Server.Modules.MapGenerator.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public enum TileInformationDisplay
None,
Position,
Noise,
Path
Path,
}
2 changes: 1 addition & 1 deletion Server/Modules/NoiseGenerator/Services/Perlin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public class Perlin
215,
61,
156,
180
180,
};

private static readonly int[] p; // Doubled permutation to avoid overflow
Expand Down
2 changes: 1 addition & 1 deletion Server/Modules/NoiseGenerator/Services/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Func<float, float, float, float, float>[] GetCustomFunctions()
CustomFunction2,
CustomFunction3,
CustomFunction4,
CustomFunction5
CustomFunction5,
};
}

Expand Down
4 changes: 2 additions & 2 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
OpenAICompatibleInstructionProvider
>(FeatureFlags.USE_AI);

builder.Services
.AddRazorComponents()
builder
.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();

Expand Down
Loading