Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class CreatePlayerCharacterDataUseCaseTests
private readonly Mock<ICharacterStore> _storeMock = new();
private readonly Mock<ITransactionScope> _txMock = new();

private CreatePlayerCharacterDataUseCase CreateUseCase()
=> new CreatePlayerCharacterDataUseCase(_repoMock.Object, _storeMock.Object, _txMock.Object);
private CreatePlayerCharacterDataUseCase CreateUseCase() => new(_repoMock.Object, _storeMock.Object, _txMock.Object);

[Fact]
public async Task ExecuteAsync_Should_Throw_When_Character_Not_Found()
Expand Down Expand Up @@ -48,10 +47,7 @@ public async Task ExecuteAsync_Should_Create_CharacterData_And_PieceData()
Role: CharacterRole.Main,
Rarity: CharacterRarity.Common,
BaseHP: 100,
BaseATK: 20,
NormalSkillId: 1,
UltimateSkillId: 2,
SupportSkillId: 3
BaseATK: 20
);

_storeMock.Setup(x => x.Get(10)).Returns(character);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public class GetAllPlayerCharacterDataUseCaseTests
{
private readonly Mock<ICharacterRepository> _repoMock = new();

private GetAllPlayerCharacterDataUseCase CreateUseCase()
=> new GetAllPlayerCharacterDataUseCase(_repoMock.Object);
private GetAllPlayerCharacterDataUseCase CreateUseCase() => new(_repoMock.Object);

[Fact]
public async Task ExecuteAsync_Should_Throw_When_UserId_Invalid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public class GetPlayerCharacterUseCaseTests
{
private readonly Mock<ICharacterRepository> _repoMock = new();

private GetPlayerCharacterUseCase CreateUseCase()
=> new GetPlayerCharacterUseCase(_repoMock.Object);
private GetPlayerCharacterUseCase CreateUseCase() => new(_repoMock.Object);

[Fact]
public async Task ExecuteAsync_Should_Throw_When_PlayerCharacter_Not_Found()
Expand Down
4 changes: 0 additions & 4 deletions PaperMania/Server/Api/Extensions/ServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ public static IServiceCollection AddStaticDataStores(
services.AddHostedService(sp =>
(LevelDefinitionStore)sp.GetRequiredService<ILevelDefinitionStore>());

services.AddSingleton<ISkillDataStore, SkillDataStore>();
services.AddHostedService(sp =>
(SkillDataStore)sp.GetRequiredService<ISkillDataStore>());

services.AddSingleton<ICharacterStore, CharacterStore>();
services.AddHostedService(sp =>
(CharacterStore)sp.GetRequiredService<ICharacterStore>());
Expand Down

This file was deleted.

28 changes: 0 additions & 28 deletions PaperMania/Server/Infrastructure/Service/CharacterDataCache.cs

This file was deleted.

73 changes: 0 additions & 73 deletions PaperMania/Server/Infrastructure/Service/CharacterService.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ public record CharacterData(
CharacterRole Role,
CharacterRarity Rarity,
float BaseHP,
float BaseATK,
int NormalSkillId,
int UltimateSkillId,
int SupportSkillId
float BaseATK
);

public enum CharacterRole
Expand Down
31 changes: 0 additions & 31 deletions PaperMania/Server/Infrastructure/StaticData/Model/SkillData.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ public class CharacterStore : ICharacterStore, IHostedService
private readonly HttpClient _httpClient;
private readonly ILogger<CharacterStore> _logger;
private readonly IConfiguration _configuration;
private readonly ISkillDataStore _skillStore;

private Dictionary<int, CharacterData> _characters = new();

public CharacterStore(
IHttpClientFactory httpClientFactory,
ILogger<CharacterStore> logger,
IConfiguration configuration,
ISkillDataStore skillStore)
IConfiguration configuration)
{
_httpClient = httpClientFactory.CreateClient();
_logger = logger;
_configuration = configuration;
_skillStore = skillStore;
}

public CharacterData? Get(int characterId)
Expand Down Expand Up @@ -82,9 +79,6 @@ private static CharacterData Map(string[] cols)
// 3: Rarity
// 4: BaseHP
// 5: BaseATK
// 6: NormalSkillId
// 7: UltimateSkillId
// 8: SupportSkillId

return new CharacterData(
int.Parse(cols[0]),
Expand All @@ -93,11 +87,7 @@ private static CharacterData Map(string[] cols)
CsvHelper.ParseEnum<CharacterRole>(cols[2], "Role"),
CsvHelper.ParseEnum<CharacterRarity>(cols[3], "Rarity"),
float.Parse(cols[4]),
float.Parse(cols[5]),

ParseOptionalInt(cols[6]),
ParseOptionalInt(cols[7]),
ParseOptionalInt(cols[8])
float.Parse(cols[5])
);
}

Expand All @@ -111,35 +101,6 @@ private void ValidateCharacters()
if (c.BaseHP <= 0 || c.BaseATK <= 0)
throw new InvalidOperationException(
$"Invalid base stat for CharacterId={c.CharacterId}");

if (c.Role == CharacterRole.Main)
{
ValidateSkill(c.NormalSkillId, SkillType.Normal, c.CharacterId);
ValidateSkill(c.UltimateSkillId, SkillType.Ultimate, c.CharacterId);
}

if (c.Role == CharacterRole.Support)
{
ValidateSkill(c.SupportSkillId, SkillType.Support, c.CharacterId);
}
}
}

private void ValidateSkill(int skillId, SkillType expectedType, int characterId)
{
if (skillId == 0)
return;

var skill = _skillStore.Get(skillId);
if (skill == null)
throw new InvalidOperationException(
$"Invalid SkillId={skillId} for CharacterId={characterId}");

if (skill.SkillType != expectedType)
throw new InvalidOperationException(
$"SkillType mismatch. CharacterId={characterId}, SkillId={skillId}");
}

private static int ParseOptionalInt(string value)
=> string.IsNullOrWhiteSpace(value) ? 0 : int.Parse(value);
}
Loading
Loading