MemoryLobby, Scenario, basic Account Profile

This commit is contained in:
raphaeIl 2024-05-30 12:46:17 +08:00
parent adf06a75d5
commit 7d1a57c984
11 changed files with 951 additions and 5 deletions

View File

@ -76,5 +76,27 @@
return [.. echelons]; return [.. echelons];
} }
public static List<MemoryLobbyDB> AddMemoryLobbies(this AccountDB account, SCHALEContext context, params MemoryLobbyDB[] memoryLobbies)
{
foreach (var lobby in memoryLobbies)
{
lobby.AccountServerId = account.ServerId;
context.MemoryLobbies.Add(lobby);
}
return [.. memoryLobbies];
}
public static List<ScenarioHistoryDB> AddScenarios(this AccountDB account, SCHALEContext context, params ScenarioHistoryDB[] scenarios)
{
foreach (var scenario in scenarios)
{
scenario.AccountServerId = account.ServerId;
context.Scenarios.Add(scenario);
}
return [.. scenarios];
}
} }
} }

View File

@ -18,10 +18,12 @@ namespace SCHALE.Common.Database
public DbSet<WeaponDB> Weapons { get; set; } public DbSet<WeaponDB> Weapons { get; set; }
public DbSet<GearDB> Gears { get; set; } public DbSet<GearDB> Gears { get; set; }
public DbSet<MemoryLobbyDB> MemoryLobbies { get; set; }
public DbSet<ScenarioHistoryDB> Scenarios { get; set; }
public DbSet<EchelonDB> Echelons { get; set; } public DbSet<EchelonDB> Echelons { get; set; }
public DbSet<AccountTutorial> AccountTutorials { get; set; } public DbSet<AccountTutorial> AccountTutorials { get; set; }
public static SCHALEContext Create(string connectionString) => public static SCHALEContext Create(string connectionString) =>
new(new DbContextOptionsBuilder<SCHALEContext>() new(new DbContextOptionsBuilder<SCHALEContext>()
.UseSqlServer(connectionString) .UseSqlServer(connectionString)
@ -68,6 +70,16 @@ namespace SCHALE.Common.Database
.WithOne(x => x.Account) .WithOne(x => x.Account)
.HasForeignKey(x => x.AccountServerId) .HasForeignKey(x => x.AccountServerId)
.IsRequired(); .IsRequired();
modelBuilder.Entity<AccountDB>()
.HasMany(x => x.MemoryLobbies)
.WithOne(x => x.Account)
.HasForeignKey(x => x.AccountServerId)
.IsRequired();
modelBuilder.Entity<AccountDB>()
.HasMany(x => x.Scenarios)
.WithOne(x => x.Account)
.HasForeignKey(x => x.AccountServerId)
.IsRequired();
modelBuilder.Entity<AccountDB>(x => x.Property(b => b.RaidInfo).HasJsonConversion()); modelBuilder.Entity<AccountDB>(x => x.Property(b => b.RaidInfo).HasJsonConversion());
modelBuilder.Entity<ItemDB>().Property(x => x.ServerId).ValueGeneratedOnAdd(); modelBuilder.Entity<ItemDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();

View File

@ -342,6 +342,12 @@ namespace SCHALE.Common.Database
[JsonIgnore] [JsonIgnore]
public virtual ICollection<GearDB> Gears { get; } public virtual ICollection<GearDB> Gears { get; }
[JsonIgnore]
public virtual ICollection<MemoryLobbyDB> MemoryLobbies { get; }
[JsonIgnore]
public virtual ICollection<ScenarioHistoryDB> Scenarios { get; }
[JsonIgnore] [JsonIgnore]
public virtual RaidInfo RaidInfo { get; set; } public virtual RaidInfo RaidInfo { get; set; }
@ -1733,10 +1739,19 @@ namespace SCHALE.Common.Database
{ {
public override ParcelType Type { get => ParcelType.MemoryLobby; } public override ParcelType Type { get => ParcelType.MemoryLobby; }
[NotMapped]
[JsonIgnore] [JsonIgnore]
public override IEnumerable<ParcelInfo> ParcelInfos { get; } public override IEnumerable<ParcelInfo> ParcelInfos { get; }
[JsonIgnore]
public virtual AccountDB Account { get; set; }
[JsonIgnore]
public long AccountServerId { get; set; } public long AccountServerId { get; set; }
[Key]
public long ServerId { get; set; }
public long MemoryLobbyUniqueId { get; set; } public long MemoryLobbyUniqueId { get; set; }
} }
@ -2197,7 +2212,15 @@ namespace SCHALE.Common.Database
public class ScenarioHistoryDB public class ScenarioHistoryDB
{ {
[JsonIgnore]
public virtual AccountDB Account { get; set; }
[JsonIgnore]
public long AccountServerId { get; set; } public long AccountServerId { get; set; }
[Key]
public long ServerId { get; set; }
public long ScenarioUniqueId { get; set; } public long ScenarioUniqueId { get; set; }
public DateTime ClearDateTime { get; set; } public DateTime ClearDateTime { get; set; }
} }

View File

@ -0,0 +1,597 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240530042248_MemoryLobby_and_Scenario")]
partial class MemoryLobby_and_Scenario
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true)
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<DateTime?>("BirthDay")
.HasColumnType("datetime2");
b.Property<string>("CallName")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CallNameUpdateTime")
.HasColumnType("datetime2");
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreateDate")
.HasColumnType("datetime2");
b.Property<string>("DevId")
.HasColumnType("nvarchar(max)");
b.Property<long>("Exp")
.HasColumnType("bigint");
b.Property<DateTime>("LastConnectTime")
.HasColumnType("datetime2");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<DateTime?>("LinkRewardDate")
.HasColumnType("datetime2");
b.Property<int>("LobbyMode")
.HasColumnType("int");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("bigint");
b.Property<string>("Nickname")
.HasColumnType("nvarchar(max)");
b.Property<long>("PublisherAccountId")
.HasColumnType("bigint");
b.Property<string>("RaidInfo")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("RepresentCharacterServerId")
.HasColumnType("int");
b.Property<int?>("RetentionDays")
.HasColumnType("int");
b.Property<int>("State")
.HasColumnType("int");
b.Property<int?>("UnReadMailCount")
.HasColumnType("int");
b.Property<int?>("VIPLevel")
.HasColumnType("int");
b.HasKey("ServerId");
b.ToTable("Accounts");
});
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<string>("EquipmentServerIds")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("EquipmentSlotAndDBIds")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ExSkillLevel")
.HasColumnType("int");
b.Property<long>("Exp")
.HasColumnType("bigint");
b.Property<int>("ExtraPassiveSkillLevel")
.HasColumnType("int");
b.Property<long>("FavorExp")
.HasColumnType("bigint");
b.Property<int>("FavorRank")
.HasColumnType("int");
b.Property<bool>("IsFavorite")
.HasColumnType("bit");
b.Property<bool>("IsLocked")
.HasColumnType("bit");
b.Property<int>("LeaderSkillLevel")
.HasColumnType("int");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("PassiveSkillLevel")
.HasColumnType("int");
b.Property<string>("PotentialStats")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("PublicSkillLevel")
.HasColumnType("int");
b.Property<int>("StarGrade")
.HasColumnType("int");
b.Property<long>("UniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Characters");
});
modelBuilder.Entity("SCHALE.Common.Database.EchelonDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<string>("CombatStyleIndex")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<long>("EchelonNumber")
.HasColumnType("bigint");
b.Property<int>("EchelonType")
.HasColumnType("int");
b.Property<int>("ExtensionType")
.HasColumnType("int");
b.Property<long>("LeaderServerId")
.HasColumnType("bigint");
b.Property<string>("MainSlotServerIds")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SkillCardMulliganCharacterIds")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SupportSlotServerIds")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<long>("TSSInteractionServerId")
.HasColumnType("bigint");
b.Property<int>("UsingFlag")
.HasColumnType("int");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Echelons");
});
modelBuilder.Entity("SCHALE.Common.Database.EquipmentDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("bigint");
b.Property<long>("Exp")
.HasColumnType("bigint");
b.Property<bool>("IsLocked")
.HasColumnType("bit");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<long>("StackCount")
.HasColumnType("bigint");
b.Property<int>("Tier")
.HasColumnType("int");
b.Property<long>("UniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Equipment");
});
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("bigint");
b.Property<long>("Exp")
.HasColumnType("bigint");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<long>("SlotIndex")
.HasColumnType("bigint");
b.Property<int>("Tier")
.HasColumnType("int");
b.Property<long>("UniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Gears");
});
modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<bool>("IsLocked")
.HasColumnType("bit");
b.Property<long>("StackCount")
.HasColumnType("bigint");
b.Property<long>("UniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Items");
});
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MemoryLobbies");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<bool>("Complete")
.HasColumnType("bit");
b.Property<long>("MissionUniqueId")
.HasColumnType("bigint");
b.Property<string>("ProgressParameters")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("StartTime")
.HasColumnType("datetime2");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MissionProgresses");
});
modelBuilder.Entity("SCHALE.Common.Database.Models.AccountTutorial", b =>
{
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<string>("TutorialIds")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("AccountServerId");
b.ToTable("AccountTutorials");
});
modelBuilder.Entity("SCHALE.Common.Database.Models.GuestAccount", b =>
{
b.Property<long>("Uid")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Uid"));
b.Property<string>("DeviceId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Uid");
b.ToTable("GuestAccounts");
});
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<DateTime>("ClearDateTime")
.HasColumnType("datetime2");
b.Property<long>("ScenarioUniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Scenarios");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("bigint");
b.Property<long>("Exp")
.HasColumnType("bigint");
b.Property<bool>("IsLocked")
.HasColumnType("bit");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("StarGrade")
.HasColumnType("int");
b.Property<long>("UniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Weapons");
});
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Characters")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.EchelonDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Echelons")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.EquipmentDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Equipment")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Gears")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Items")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MemoryLobbies")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MissionProgresses")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Scenarios")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Weapons")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{
b.Navigation("Characters");
b.Navigation("Echelons");
b.Navigation("Equipment");
b.Navigation("Gears");
b.Navigation("Items");
b.Navigation("MemoryLobbies");
b.Navigation("MissionProgresses");
b.Navigation("Scenarios");
b.Navigation("Weapons");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,76 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SCHALE.Common.Migrations
{
/// <inheritdoc />
public partial class MemoryLobby_and_Scenario : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "MemoryLobbies",
columns: table => new
{
ServerId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountServerId = table.Column<long>(type: "bigint", nullable: false),
MemoryLobbyUniqueId = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MemoryLobbies", x => x.ServerId);
table.ForeignKey(
name: "FK_MemoryLobbies_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Scenarios",
columns: table => new
{
ServerId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountServerId = table.Column<long>(type: "bigint", nullable: false),
ScenarioUniqueId = table.Column<long>(type: "bigint", nullable: false),
ClearDateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Scenarios", x => x.ServerId);
table.ForeignKey(
name: "FK_Scenarios_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_MemoryLobbies_AccountServerId",
table: "MemoryLobbies",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Scenarios_AccountServerId",
table: "Scenarios",
column: "AccountServerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MemoryLobbies");
migrationBuilder.DropTable(
name: "Scenarios");
}
}
}

View File

@ -322,6 +322,27 @@ namespace SCHALE.Common.Migrations
b.ToTable("Items"); b.ToTable("Items");
}); });
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MemoryLobbies");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b => modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{ {
b.Property<long>("ServerId") b.Property<long>("ServerId")
@ -388,6 +409,30 @@ namespace SCHALE.Common.Migrations
b.ToTable("GuestAccounts"); b.ToTable("GuestAccounts");
}); });
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
b.Property<long>("AccountServerId")
.HasColumnType("bigint");
b.Property<DateTime>("ClearDateTime")
.HasColumnType("datetime2");
b.Property<long>("ScenarioUniqueId")
.HasColumnType("bigint");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Scenarios");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b => modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{ {
b.Property<long>("ServerId") b.Property<long>("ServerId")
@ -479,6 +524,17 @@ namespace SCHALE.Common.Migrations
b.Navigation("Account"); b.Navigation("Account");
}); });
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MemoryLobbies")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b => modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{ {
b.HasOne("SCHALE.Common.Database.AccountDB", "Account") b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
@ -490,6 +546,17 @@ namespace SCHALE.Common.Migrations
b.Navigation("Account"); b.Navigation("Account");
}); });
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Scenarios")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b => modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{ {
b.HasOne("SCHALE.Common.Database.AccountDB", "Account") b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
@ -513,8 +580,12 @@ namespace SCHALE.Common.Migrations
b.Navigation("Items"); b.Navigation("Items");
b.Navigation("MemoryLobbies");
b.Navigation("MissionProgresses"); b.Navigation("MissionProgresses");
b.Navigation("Scenarios");
b.Navigation("Weapons"); b.Navigation("Weapons");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618

View File

@ -26,6 +26,8 @@ namespace SCHALE.GameServer.Commands
InventoryUtils.AddAllEquipment(connection); InventoryUtils.AddAllEquipment(connection);
InventoryUtils.AddAllItems(connection); InventoryUtils.AddAllItems(connection);
InventoryUtils.AddAllGears(connection); InventoryUtils.AddAllGears(connection);
InventoryUtils.AddAllMemoryLobbies(connection);
InventoryUtils.AddAllScenarios(connection);
connection.SendChatMessage("Added Everything!"); connection.SendChatMessage("Added Everything!");
break; break;
@ -36,6 +38,8 @@ namespace SCHALE.GameServer.Commands
context.Equipment.RemoveRange(context.Equipment.Where(x => x.AccountServerId == connection.AccountServerId)); context.Equipment.RemoveRange(context.Equipment.Where(x => x.AccountServerId == connection.AccountServerId));
context.Items.RemoveRange(context.Items.Where(x => x.AccountServerId == connection.AccountServerId)); context.Items.RemoveRange(context.Items.Where(x => x.AccountServerId == connection.AccountServerId));
context.Gears.RemoveRange(context.Gears.Where(x => x.AccountServerId == connection.AccountServerId)); context.Gears.RemoveRange(context.Gears.Where(x => x.AccountServerId == connection.AccountServerId));
context.MemoryLobbies.RemoveRange(context.MemoryLobbies.Where(x => x.AccountServerId == connection.AccountServerId));
context.Scenarios.RemoveRange(context.Scenarios.Where(x => x.AccountServerId == connection.AccountServerId));
connection.SendChatMessage("Removed Everything!"); connection.SendChatMessage("Removed Everything!");
break; break;

View File

@ -400,6 +400,12 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
EchelonDBs = [.. account.Echelons] EchelonDBs = [.. account.Echelons]
}, },
MemoryLobbyListResponse = new MemoryLobbyListResponse()
{
MemoryLobbyDBs = [.. account.MemoryLobbies]
},
EventContentPermanentListResponse = new EventContentPermanentListResponse() EventContentPermanentListResponse = new EventContentPermanentListResponse()
{ {
PermanentDBs = PermanentDBs =
@ -435,6 +441,11 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
AccountClanMemberDB = new() { AccountId = account.ServerId } AccountClanMemberDB = new() { AccountId = account.ServerId }
}, },
ScenarioListResponse = new ScenarioListResponse()
{
ScenarioHistoryDBs = [.. account.Scenarios]
},
EliminateRaidLoginResponse = new EliminateRaidLoginResponse() EliminateRaidLoginResponse = new EliminateRaidLoginResponse()
{ {
SeasonType = RaidSeasonType.Open, SeasonType = RaidSeasonType.Open,
@ -489,6 +500,24 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
return new AccountSetTutorialResponse(); return new AccountSetTutorialResponse();
} }
[ProtocolHandler(Protocol.Account_SetRepresentCharacterAndComment)]
public ResponsePacket SetRepresentCharacterAndCommentHandler(AccountSetRepresentCharacterAndCommentRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
account.RepresentCharacterServerId = req.RepresentCharacterServerId;
account.Comment = req.Comment;
context.SaveChanges();
return new AccountSetRepresentCharacterAndCommentResponse()
{
AccountDB = account,
RepresentCharacterDB = account.Characters.FirstOrDefault(x => x.ServerId == req.RepresentCharacterServerId)
};
}
// TODO: others handlers, move to different handler group later // TODO: others handlers, move to different handler group later
[ProtocolHandler(Protocol.NetworkTime_Sync)] [ProtocolHandler(Protocol.NetworkTime_Sync)]
public ResponsePacket NetworkTime_SyncHandler(NetworkTimeSyncRequest req) public ResponsePacket NetworkTime_SyncHandler(NetworkTimeSyncRequest req)
@ -571,5 +600,25 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
return new MiniGameMissionListResponse(); return new MiniGameMissionListResponse();
} }
[ProtocolHandler(Protocol.Attachment_EmblemAcquire)]
public ResponsePacket Attachment_EmblemAcquireHandler(AttachmentEmblemAcquireRequest req)
{
return new AttachmentEmblemAcquireResponse();
}
[ProtocolHandler(Protocol.Friend_List)]
public ResponsePacket Attachment_EmblemAcquireHandler(FriendListRequest req)
{
return new FriendListResponse();
}
[ProtocolHandler(Protocol.Friend_GetIdCard)]
public ResponsePacket Friend_GetIdCardHandler(FriendGetIdCardRequest req)
{
return new FriendGetIdCardResponse();
}
} }
} }

View File

@ -1,11 +1,23 @@
using SCHALE.Common.NetworkProtocol; using SCHALE.Common.Database;
using SCHALE.Common.Database.ModelExtensions;
using SCHALE.Common.NetworkProtocol;
using SCHALE.GameServer.Services;
using Serilog; using Serilog;
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
public class Scenario : ProtocolHandlerBase public class Scenario : ProtocolHandlerBase
{ {
public Scenario(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory) { } private readonly ISessionKeyService sessionKeyService;
private readonly SCHALEContext context;
private readonly ExcelTableService excelTableService;
public Scenario(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
{
sessionKeyService = _sessionKeyService;
context = _context;
excelTableService = _excelTableService;
}
[ProtocolHandler(Protocol.Scenario_Skip)] [ProtocolHandler(Protocol.Scenario_Skip)]
public ResponsePacket SkipHandler(ScenarioSkipRequest req) public ResponsePacket SkipHandler(ScenarioSkipRequest req)
@ -24,5 +36,42 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
return new ScenarioGroupHistoryUpdateResponse(); return new ScenarioGroupHistoryUpdateResponse();
} }
[ProtocolHandler(Protocol.Scenario_LobbyStudentChange)]
public ResponsePacket LobbyStudentChangeHandler(ScenarioLobbyStudentChangeRequest req)
{
return new ScenarioLobbyStudentChangeResponse();
}
[ProtocolHandler(Protocol.Scenario_AccountStudentChange)]
public ResponsePacket AccountStudentChangeHandler(ScenarioAccountStudentChangeRequest req)
{
return new ScenarioAccountStudentChangeResponse();
}
[ProtocolHandler(Protocol.Scenario_Clear)]
public ResponsePacket ClearHandler(ScenarioClearRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var scenario = account.Scenarios.FirstOrDefault(x => x.ScenarioUniqueId == req.ScenarioId);
if (scenario == null)
{
scenario = new ScenarioHistoryDB()
{
ScenarioUniqueId = req.ScenarioId,
ClearDateTime = DateTime.UtcNow,
};
account.AddScenarios(context, [scenario]);
context.SaveChanges();
}
return new ScenarioClearResponse()
{
ScenarioHistoryDB = scenario
};
}
} }
} }

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\SCHALE.Common\SCHALE.Common.csproj" /> <ProjectReference Include="..\SCHALE.Common\SCHALE.Common.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Controllers\Data\" />
</ItemGroup>
</Project> </Project>

View File

@ -56,7 +56,7 @@ namespace SCHALE.Common.Utils
{ {
IsNew = true, IsNew = true,
UniqueId = x.Id, UniqueId = x.Id,
StackCount = 5555, StackCount = 1000,
}; };
}).ToList(); }).ToList();
@ -113,6 +113,45 @@ namespace SCHALE.Common.Utils
connection.SendChatMessage("Added all gears!"); connection.SendChatMessage("Added all gears!");
} }
public static void AddAllMemoryLobbies(IrcConnection connection)
{
var account = connection.Account;
var context = connection.Context;
var memoryLobbyExcel = connection.ExcelTableService.GetTable<MemoryLobbyExcelTable>().UnPack().DataList;
var allMemoryLobbies = memoryLobbyExcel.Select(x =>
{
return new MemoryLobbyDB()
{
MemoryLobbyUniqueId = x.Id,
};
}).ToList();
account.AddMemoryLobbies(context, [.. allMemoryLobbies]);
context.SaveChanges();
connection.SendChatMessage("Added all Memory Lobbies!");
}
public static void AddAllScenarios(IrcConnection connection)
{
var account = connection.Account;
var context = connection.Context;
var scenarioModeExcel = connection.ExcelTableService.GetTable<ScenarioModeExcelTable>().UnPack().DataList;
var allScenarios = scenarioModeExcel.Select(x =>
{
return new ScenarioHistoryDB()
{
ScenarioUniqueId = x.ModeId,
};
}).ToList();
account.AddScenarios(context, [.. allScenarios]);
context.SaveChanges();
connection.SendChatMessage("Added all Scenarios!");
}
public static void RemoveAllCharacters(IrcConnection connection) // removing default characters breaks game public static void RemoveAllCharacters(IrcConnection connection) // removing default characters breaks game
{ {