Repository navigation
feat: 던전 타입별 진행도 및 최고 기록 추적 기능 추가 #32
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
03179a2
feat: PlayerDungeonProgress 엔티티 및 마이그레이션 추가
Sean-mn 137cd92
feat: PlayerDungeonProgressRepository 추가 및 DI 등록
Sean-mn 69e0476
feat: 무기 던전에 독립 진행도 적용
Sean-mn 75881d9
feat: 보스 던전에 독립 진행도 적용
Sean-mn 8d37ae4
feat: 골드 던전 claim에 HighScore 갱신 적용
Sean-mn 464c36d
chore: 던전 타입별 진행도 계획 및 설계 문서 추가
Sean-mn 12761cb
chore: 던전 타입별 진행도 문서 갱신
Sean-mn 0c09be4
fix: PlayerDungeonProgress 조회 시 AsNoTracking 제거로 xmin 동시성 토큰 유실 방지
Sean-mn 70781eb
fix: xmin 동시성 토큰 엔티티 조회 시 AsNoTracking 제거로 UpdateAsync 실패 방지
Sean-mn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Fantasy-server/Fantasy.Server/Domain/Dungeon/Entity/Config/PlayerDungeonProgressConfig.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using Fantasy.Server.Domain.Dungeon.Entity; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
| using PlayerEntity = Fantasy.Server.Domain.Player.Entity.Player; | ||
|
|
||
| namespace Fantasy.Server.Domain.Dungeon.Entity.Config; | ||
|
|
||
| public class PlayerDungeonProgressConfig : IEntityTypeConfiguration<PlayerDungeonProgress> | ||
| { | ||
| public void Configure(EntityTypeBuilder<PlayerDungeonProgress> builder) | ||
| { | ||
| builder.ToTable("player_dungeon_progress", "dungeon"); | ||
|
|
||
| builder.HasKey(p => p.Id); | ||
|
|
||
| builder.Property(p => p.Id) | ||
| .ValueGeneratedOnAdd(); | ||
|
|
||
| builder.Property(p => p.PlayerId) | ||
| .IsRequired(); | ||
|
|
||
| builder.Property(p => p.DungeonType) | ||
| .HasConversion<string>() | ||
| .IsRequired(); | ||
|
|
||
| builder.Property(p => p.HighestClearedStage) | ||
| .IsRequired() | ||
| .HasDefaultValue(1L); | ||
|
|
||
| builder.Property(p => p.HighScore) | ||
| .IsRequired() | ||
| .HasDefaultValue(0L); | ||
|
|
||
| builder.Property(p => p.LastClearedAt) | ||
| .IsRequired(false); | ||
|
|
||
| builder.HasIndex(p => new { p.PlayerId, p.DungeonType }) | ||
| .IsUnique(); | ||
|
|
||
| builder.HasOne<PlayerEntity>() | ||
| .WithMany() | ||
| .HasForeignKey(p => p.PlayerId) | ||
| .OnDelete(DeleteBehavior.Cascade); | ||
|
|
||
| builder.Property<uint>("xmin") | ||
| .HasColumnName("xmin") | ||
| .HasColumnType("xid") | ||
| .ValueGeneratedOnAddOrUpdate() | ||
| .IsConcurrencyToken(); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
Fantasy-server/Fantasy.Server/Domain/Dungeon/Entity/PlayerDungeonProgress.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using Fantasy.Server.Domain.Dungeon.Enum; | ||
|
|
||
| namespace Fantasy.Server.Domain.Dungeon.Entity; | ||
|
|
||
| public class PlayerDungeonProgress | ||
| { | ||
| public long Id { get; private set; } | ||
| public long PlayerId { get; private set; } | ||
| public DungeonType DungeonType { get; private set; } | ||
| public long HighestClearedStage { get; private set; } | ||
| public long HighScore { get; private set; } | ||
| public DateTime? LastClearedAt { get; private set; } | ||
|
|
||
| public static PlayerDungeonProgress Create(long playerId, DungeonType dungeonType) => new() | ||
| { | ||
| PlayerId = playerId, | ||
| DungeonType = dungeonType, | ||
| HighestClearedStage = 1, | ||
| HighScore = 0, | ||
| LastClearedAt = null | ||
| }; | ||
|
|
||
| public void ClearStage(long stage) | ||
| { | ||
| if (stage > HighestClearedStage) HighestClearedStage = stage; | ||
| LastClearedAt = DateTime.UtcNow; | ||
| } | ||
|
|
||
| public void UpdateHighScore(long score) | ||
| { | ||
| if (score > HighScore) HighScore = score; | ||
| LastClearedAt = DateTime.UtcNow; | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
Fantasy-server/Fantasy.Server/Domain/Dungeon/Enum/DungeonType.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| namespace Fantasy.Server.Domain.Dungeon.Enum; | ||
|
|
||
| public enum DungeonType | ||
| { | ||
| Basic, | ||
| Gold, | ||
| Weapon, | ||
| Boss | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...er/Fantasy.Server/Domain/Dungeon/Repository/Interface/IPlayerDungeonProgressRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using Fantasy.Server.Domain.Dungeon.Entity; | ||
| using Fantasy.Server.Domain.Dungeon.Enum; | ||
|
|
||
| namespace Fantasy.Server.Domain.Dungeon.Repository.Interface; | ||
|
|
||
| public interface IPlayerDungeonProgressRepository | ||
| { | ||
| Task<PlayerDungeonProgress?> FindByPlayerIdAndDungeonTypeAsync(long playerId, DungeonType dungeonType); | ||
| Task SaveAsync(PlayerDungeonProgress progress); | ||
| Task UpdateAsync(PlayerDungeonProgress progress); | ||
| } |
30 changes: 30 additions & 0 deletions
30
Fantasy-server/Fantasy.Server/Domain/Dungeon/Repository/PlayerDungeonProgressRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using Fantasy.Server.Domain.Dungeon.Entity; | ||
| using Fantasy.Server.Domain.Dungeon.Enum; | ||
| using Fantasy.Server.Domain.Dungeon.Repository.Interface; | ||
| using Fantasy.Server.Global.Infrastructure; | ||
| using Microsoft.EntityFrameworkCore; | ||
|
|
||
| namespace Fantasy.Server.Domain.Dungeon.Repository; | ||
|
|
||
| public class PlayerDungeonProgressRepository : IPlayerDungeonProgressRepository | ||
| { | ||
| private readonly AppDbContext _db; | ||
|
|
||
| public PlayerDungeonProgressRepository(AppDbContext db) => _db = db; | ||
|
|
||
| public async Task<PlayerDungeonProgress?> FindByPlayerIdAndDungeonTypeAsync(long playerId, DungeonType dungeonType) | ||
| => await _db.PlayerDungeonProgresses | ||
| .FirstOrDefaultAsync(p => p.PlayerId == playerId && p.DungeonType == dungeonType); | ||
|
|
||
| public async Task SaveAsync(PlayerDungeonProgress progress) | ||
| { | ||
| await _db.PlayerDungeonProgresses.AddAsync(progress); | ||
| await _db.SaveChangesAsync(); | ||
| } | ||
|
|
||
| public async Task UpdateAsync(PlayerDungeonProgress progress) | ||
| { | ||
| _db.PlayerDungeonProgresses.Update(progress); | ||
| await _db.SaveChangesAsync(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.