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

Feature: Add Challenge & Competition #32

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from
Draft
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: 2 additions & 0 deletions GameDatabase/Context/TaikoDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
});

OnModelCreatingPartial(modelBuilder);
OnModelCreatingChallengeCompete(modelBuilder);
}

partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
partial void OnModelCreatingChallengeCompete(ModelBuilder modelBuilder);
}
}
78 changes: 78 additions & 0 deletions GameDatabase/Context/TaikoDbContextChallengeCompete.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using GameDatabase.Entities;
using Microsoft.EntityFrameworkCore;

namespace GameDatabase.Context;

public partial class TaikoDbContext
{
public virtual DbSet<ChallengeCompeteDatum> ChallengeCompeteData { get; set; } = null;
public virtual DbSet<ChallengeCompeteParticipantDatum> ChallengeCompeteParticipantData { get; set; } = null;
public virtual DbSet<ChallengeCompeteSongDatum> ChallengeCompeteSongData { get; set; } = null;
public virtual DbSet<ChallengeCompeteBestDatum> ChallengeCompeteBestData { get; set; } = null;

partial void OnModelCreatingChallengeCompete(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ChallengeCompeteDatum>(entity =>
{
entity.HasKey(e => new { e.CompId });

entity.Property(e => e.CompeteMode).HasConversion<uint>();
entity.Property(e => e.Share).HasConversion<uint>();
entity.Property(e => e.CompeteTarget).HasConversion<uint>();

entity.Property(e => e.CreateTime).HasColumnType("datetime");
entity.Property(e => e.ExpireTime).HasColumnType("datetime");
});

modelBuilder.Entity<ChallengeCompeteParticipantDatum>(entity =>
{
entity.HasKey(e => new { e.CompId, e.Baid });

entity.HasOne(e => e.UserData)
.WithMany()
.HasPrincipalKey(p => p.Baid)
.HasForeignKey(d => d.Baid)
.OnDelete(DeleteBehavior.Cascade);

entity.HasOne(e => e.ChallengeCompeteData)
.WithMany(p => p.Participants)
.HasPrincipalKey(p => p.CompId)
.HasForeignKey(d => d.CompId)
.OnDelete(DeleteBehavior.Cascade);
});

modelBuilder.Entity<ChallengeCompeteSongDatum>(entity =>
{
entity.HasKey(e => new { e.CompId, e.SongId });

entity.HasOne(e => e.ChallengeCompeteData)
.WithMany(p => p.Songs)
.HasPrincipalKey(p => p.CompId)
.HasForeignKey(d => d.CompId)
.OnDelete(DeleteBehavior.Cascade);

entity.Property(e => e.Difficulty).HasConversion<uint>();
});

modelBuilder.Entity<ChallengeCompeteBestDatum>(entity =>
{
entity.HasKey(e => new { e.CompId, e.Baid, e.SongId });

entity.HasOne(e => e.UserData)
.WithMany()
.HasPrincipalKey(p => p.Baid)
.HasForeignKey(d => d.Baid)
.OnDelete(DeleteBehavior.Cascade);

entity.HasOne(e => e.ChallengeCompeteSongData)
.WithMany(p => p.BestScores)
.HasPrincipalKey(p => new { p.CompId, p.SongId })
.HasForeignKey(d => new { d.CompId, d.SongId })
.OnDelete(DeleteBehavior.Cascade);

entity.Property(e => e.Difficulty).HasConversion<uint>();
entity.Property(e => e.Crown).HasConversion<uint>();
entity.Property(e => e.ScoreRank).HasConversion<uint>();
});
}
}
24 changes: 24 additions & 0 deletions GameDatabase/Entities/ChallengeCompeteBestDatum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using SharedProject.Enums;

namespace GameDatabase.Entities;

public partial class ChallengeCompeteBestDatum
{
public uint CompId { get; set; }
public uint Baid { get; set; }
public uint SongId { get; set; }
public Difficulty Difficulty { get; set; }
public CrownType Crown { get; set; }
public uint Score { get; set; }
public uint ScoreRate { get; set; }
public ScoreRank ScoreRank { get; set; }
public uint GoodCount { get; set; }
public uint OkCount { get; set; }
public uint MissCount { get; set; }
public uint ComboCount { get; set; }
public uint HitCount { get; set; }
public uint DrumrollCount { get; set; }
public bool Skipped { get; set; }
public virtual ChallengeCompeteSongDatum? ChallengeCompeteSongData { get; set; }
public virtual UserDatum? UserData { get; set; }
}
23 changes: 23 additions & 0 deletions GameDatabase/Entities/ChallengeCompeteDatum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using SharedProject.Enums;

namespace GameDatabase.Entities;

public partial class ChallengeCompeteDatum
{
public uint CompId { get; set; }
public CompeteModeType CompeteMode { get; set; } = CompeteModeType.None;
public CompeteState State { get; set; } = CompeteState.Normal;
public uint Baid { get; set; }
public string CompeteName { get; set; } = String.Empty;
public string CompeteDescribe { get; set; } = String.Empty;
public uint MaxParticipant { get; set; } = 2;
public DateTime CreateTime { get; set; }
public DateTime ExpireTime { get; set; }
public uint RequireTitle { get; set; } = 0;
public bool OnlyPlayOnce { get; set; } = false;
public ShareType Share { get; set; } = ShareType.EveryOne;
public CompeteTargetType CompeteTarget { get; set; } = CompeteTargetType.EveryOne;
public List<ChallengeCompeteSongDatum> Songs { get; set; } = new();
public List<ChallengeCompeteParticipantDatum> Participants { get; set; } = new();
}

10 changes: 10 additions & 0 deletions GameDatabase/Entities/ChallengeCompeteParticipantDatum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace GameDatabase.Entities;

public partial class ChallengeCompeteParticipantDatum
{
public uint CompId { get; set; }
public uint Baid { get; set; }
public bool IsActive { get; set; }
public virtual ChallengeCompeteDatum? ChallengeCompeteData { get; set; }
public virtual UserDatum? UserData { get; set; }
}
16 changes: 16 additions & 0 deletions GameDatabase/Entities/ChallengeCompeteSongDatum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using SharedProject.Enums;

namespace GameDatabase.Entities;

public partial class ChallengeCompeteSongDatum
{
public uint CompId { get; set; }
public uint SongId { get; set; }
public Difficulty Difficulty { get; set; }
public uint? Speed { get; set; } = null;
public bool? IsVanishOn { get; set; } = null;
public bool? IsInverseOn { get; set; } = null;
public RandomType? RandomType { get; set; } = null;
public List<ChallengeCompeteBestDatum> BestScores { get; set; } = new();
public virtual ChallengeCompeteDatum? ChallengeCompeteData { get; set; }
}
Loading