basic character, equipment and weapon management

This commit is contained in:
raphaeIl 2024-05-11 00:30:17 -04:00
parent 2df7a83576
commit 735db02c50
18 changed files with 1795 additions and 33 deletions

View File

@ -12,5 +12,44 @@
return [.. characters]; return [.. characters];
} }
public static List<EquipmentDB> AddEquipment(this AccountDB account, SCHALEContext context, params EquipmentDB[] equipmentDB)
{
foreach (var equipment in equipmentDB)
{
equipment.AccountServerId = account.ServerId;
var existingEquipment = account.Equipment.FirstOrDefault(x => x.UniqueId == equipment.UniqueId);
if (existingEquipment != null && equipment.BoundCharacterServerId == default)
existingEquipment.StackCount += equipment.StackCount;
else
context.Equipment.Add(equipment);
}
return [.. equipmentDB];
}
public static List<WeaponDB> AddWeapons(this AccountDB account, SCHALEContext context, params WeaponDB[] weapons)
{
foreach (var weapon in weapons)
{
weapon.AccountServerId = account.ServerId;
context.Weapons.Add(weapon);
}
return [.. weapons];
}
public static List<ItemDB> AddItems(this AccountDB account, SCHALEContext context, params ItemDB[] items)
{
foreach (var item in items)
{
item.AccountServerId = account.ServerId;
context.Items.Add(item);
}
return [.. items];
}
} }
} }

View File

@ -11,10 +11,15 @@ namespace SCHALE.Common.Database
public DbSet<GuestAccount> GuestAccounts { get; set; } public DbSet<GuestAccount> GuestAccounts { get; set; }
public DbSet<AccountDB> Accounts { get; set; } public DbSet<AccountDB> Accounts { get; set; }
public DbSet<MissionProgressDB> MissionProgresses { get; set; } public DbSet<MissionProgressDB> MissionProgresses { get; set; }
public DbSet<ItemDB> Items { get; set; } public DbSet<ItemDB> Items { get; set; }
public DbSet<CharacterDB> Characters { get; set; } public DbSet<CharacterDB> Characters { get; set; }
public DbSet<EquipmentDB> Equipment { get; set; }
public DbSet<WeaponDB> Weapons { 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>()
@ -47,8 +52,21 @@ 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.Equipment)
.WithOne(x => x.Account)
.HasForeignKey(x => x.AccountServerId)
.IsRequired();
modelBuilder.Entity<AccountDB>()
.HasMany(x => x.Weapons)
.WithOne(x => x.Account)
.HasForeignKey(x => x.AccountServerId)
.IsRequired();
modelBuilder.Entity<ItemDB>().Property(x => x.ServerId).ValueGeneratedOnAdd(); modelBuilder.Entity<ItemDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
modelBuilder.Entity<EquipmentDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
modelBuilder.Entity<WeaponDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
modelBuilder.Entity<EchelonDB>().Property(x => x.ServerId).ValueGeneratedOnAdd(); modelBuilder.Entity<EchelonDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
modelBuilder.Entity<CharacterDB>().Property(x => x.ServerId).ValueGeneratedOnAdd(); modelBuilder.Entity<CharacterDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();

View File

@ -1,12 +1,18 @@
using SCHALE.Common.FlatData; using SCHALE.Common.FlatData;
using SCHALE.Common.NetworkProtocol; using SCHALE.Common.NetworkProtocol;
using SCHALE.Common.Parcel; using SCHALE.Common.Parcel;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace SCHALE.Common.Database namespace SCHALE.Common.Database
{ {
public class SingleRaidLobbyInfoDB : RaidLobbyInfoDB
{
}
// Battle? probably need to implement these our selves // Battle? probably need to implement these our selves
public class BattleSummary public class BattleSummary
{ {
@ -197,6 +203,12 @@ namespace SCHALE.Common.Database
[JsonIgnore] [JsonIgnore]
public virtual ICollection<EchelonDB> Echelons { get; } public virtual ICollection<EchelonDB> Echelons { get; }
[JsonIgnore]
public virtual ICollection<EquipmentDB> Equipment { get; }
[JsonIgnore]
public virtual ICollection<WeaponDB> Weapons { get; }
public AccountDB() { } public AccountDB() { }
public AccountDB(long publisherAccountId) public AccountDB(long publisherAccountId)
@ -358,7 +370,7 @@ namespace SCHALE.Common.Database
Cheat = 4 Cheat = 4
} }
public class AssistCharacterDB public class AssistCharacterDB : CharacterDB
{ {
public EchelonType EchelonType { get; set; } public EchelonType EchelonType { get; set; }
public int SlotNumber { get; set; } public int SlotNumber { get; set; }
@ -1108,8 +1120,10 @@ namespace SCHALE.Common.Database
public class EquipmentDB : ConsumableItemBaseDB public class EquipmentDB : ConsumableItemBaseDB
{ {
[NotMapped]
public override ParcelType Type { get => ParcelType.Equipment; } public override ParcelType Type { get => ParcelType.Equipment; }
[NotMapped]
[JsonIgnore] [JsonIgnore]
public override IEnumerable<ParcelInfo> ParcelInfos { get; } public override IEnumerable<ParcelInfo> ParcelInfos { get; }
@ -1738,6 +1752,16 @@ namespace SCHALE.Common.Database
public long PurchaseOrderId { get; set; } public long PurchaseOrderId { get; set; }
} }
public class RaidMemberCollection : KeyedCollection<long, RaidMemberDescription>
{
public long TotalDamage { get; set; }
protected override long GetKeyForItem(RaidMemberDescription item)
{
return -1;
}
//public IEnumerable<RaidDamage> RaidDamages { get; set; }
}
public class RaidBattleDB public class RaidBattleDB
{ {
@ -1749,7 +1773,7 @@ namespace SCHALE.Common.Database
public long CurrentBossAIPhase { get; set; } public long CurrentBossAIPhase { get; set; }
public string BIEchelon { get; set; } public string BIEchelon { get; set; }
public bool IsClear { get; set; } public bool IsClear { get; set; }
//public RaidMemberCollection RaidMembers { get; set; } public RaidMemberCollection RaidMembers { get; set; }
public List<long> SubPartsHPs { get; set; } public List<long> SubPartsHPs { get; set; }
} }
@ -1777,10 +1801,23 @@ namespace SCHALE.Common.Database
public long CostumeId { get; set; } public long CostumeId { get; set; }
} }
public class RaidMemberDescription : IEquatable<RaidMemberDescription>
public class RaidDB
{ {
//public RaidMemberDescription Owner { get; set; } public long AccountId { get; set; }
public string AccountName { get; set; }
public long CharacterId { get; set; }
public bool Equals(RaidMemberDescription? other)
{
return this.AccountId == other.AccountId;
}
}
public class RaidDB
{
public RaidMemberDescription Owner { get; set; }
public ContentType ContentType { get; set; } public ContentType ContentType { get; set; }
public long ServerId { get; set; } public long ServerId { get; set; }
public long UniqueId { get; set; } public long UniqueId { get; set; }
@ -1832,7 +1869,7 @@ namespace SCHALE.Common.Database
} }
public class RaidLobbyInfoDB public abstract class RaidLobbyInfoDB
{ {
public long SeasonId { get; set; } public long SeasonId { get; set; }
public int Tier { get; set; } public int Tier { get; set; }
@ -2113,10 +2150,123 @@ namespace SCHALE.Common.Database
public RaidTeamSettingDB RaidTeamSettingDB { get; set; } public RaidTeamSettingDB RaidTeamSettingDB { get; set; }
} }
public enum SkillSlot
{
None,
NormalAttack01,
NormalAttack02,
NormalAttack03,
NormalAttack04,
NormalAttack05,
NormalAttack06,
NormalAttack07,
NormalAttack08,
NormalAttack09,
NormalAttack10,
ExSkill01,
ExSkill02,
ExSkill03,
ExSkill04,
ExSkill05,
ExSkill06,
ExSkill07,
ExSkill08,
ExSkill09,
ExSkill10,
Passive01,
Passive02,
Passive03,
Passive04,
Passive05,
Passive06,
Passive07,
Passive08,
Passive09,
Passive10,
ExtraPassive01,
ExtraPassive02,
ExtraPassive03,
ExtraPassive04,
ExtraPassive05,
ExtraPassive06,
ExtraPassive07,
ExtraPassive08,
ExtraPassive09,
ExtraPassive10,
Support01,
Support02,
Support03,
Support04,
Support05,
Support06,
Support07,
Support08,
Support09,
Support10,
EnterBattleGround,
LeaderSkill01,
LeaderSkill02,
LeaderSkill03,
LeaderSkill04,
LeaderSkill05,
LeaderSkill06,
LeaderSkill07,
LeaderSkill08,
LeaderSkill09,
LeaderSkill10,
Equipment01,
Equipment02,
Equipment03,
Equipment04,
Equipment05,
Equipment06,
Equipment07,
Equipment08,
Equipment09,
Equipment10,
PublicSkill01,
PublicSkill02,
PublicSkill03,
PublicSkill04,
PublicSkill05,
PublicSkill06,
PublicSkill07,
PublicSkill08,
PublicSkill09,
PublicSkill10,
GroupBuff01,
HexaBuff01,
EventBuff01,
EventBuff02,
EventBuff03,
MoveAttack01,
MetamorphNormalAttack,
GroundPassive01,
GroundPassive02,
GroundPassive03,
GroundPassive04,
GroundPassive05,
GroundPassive06,
GroundPassive07,
GroundPassive08,
GroundPassive09,
GroundPassive10,
HiddenPassive01,
HiddenPassive02,
HiddenPassive03,
HiddenPassive04,
HiddenPassive05,
HiddenPassive06,
HiddenPassive07,
HiddenPassive08,
HiddenPassive09,
HiddenPassive10,
Count
}
public class SkillLevelBatchGrowthRequestDB public class SkillLevelBatchGrowthRequestDB
{ {
//public SkillSlot SkillSlot { get; set; } public SkillSlot SkillSlot { get; set; }
public int Level { get; set; } public int Level { get; set; }
public List<SelectTicketReplaceInfo> ReplaceInfos { get; set; } public List<SelectTicketReplaceInfo> ReplaceInfos { get; set; }
} }
@ -2241,11 +2391,22 @@ namespace SCHALE.Common.Database
public class WeaponDB : ParcelBase public class WeaponDB : ParcelBase
{ {
[NotMapped]
public override ParcelType Type { get => ParcelType.CharacterWeapon; } public override ParcelType Type { get => ParcelType.CharacterWeapon; }
[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; }
[Key]
public long ServerId { get; set; }
public long UniqueId { get; set; } public long UniqueId { get; set; }
public int Level { get; set; } public int Level { get; set; }
public long Exp { get; set; } public long Exp { get; set; }

View File

@ -0,0 +1,420 @@
// <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("20240510003553_Equipment")]
partial class Equipment
{
/// <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<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<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.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.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.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.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.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.AccountDB", b =>
{
b.Navigation("Characters");
b.Navigation("Echelons");
b.Navigation("Equipment");
b.Navigation("Items");
b.Navigation("MissionProgresses");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SCHALE.Common.Migrations
{
/// <inheritdoc />
public partial class Equipment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Equipment",
columns: table => new
{
ServerId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Level = table.Column<int>(type: "int", nullable: false),
Exp = table.Column<long>(type: "bigint", nullable: false),
Tier = table.Column<int>(type: "int", nullable: false),
BoundCharacterServerId = table.Column<long>(type: "bigint", nullable: false),
IsLocked = table.Column<bool>(type: "bit", nullable: false),
AccountServerId = table.Column<long>(type: "bigint", nullable: false),
UniqueId = table.Column<long>(type: "bigint", nullable: false),
StackCount = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Equipment", x => x.ServerId);
table.ForeignKey(
name: "FK_Equipment_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Equipment_AccountServerId",
table: "Equipment",
column: "AccountServerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Equipment");
}
}
}

View File

@ -0,0 +1,469 @@
// <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("20240510093842_Weapons")]
partial class Weapons
{
/// <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<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<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.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.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.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.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.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.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("Items");
b.Navigation("MissionProgresses");
b.Navigation("Weapons");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SCHALE.Common.Migrations
{
/// <inheritdoc />
public partial class Weapons : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Weapons",
columns: table => new
{
ServerId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountServerId = table.Column<long>(type: "bigint", nullable: false),
UniqueId = table.Column<long>(type: "bigint", nullable: false),
Level = table.Column<int>(type: "int", nullable: false),
Exp = table.Column<long>(type: "bigint", nullable: false),
StarGrade = table.Column<int>(type: "int", nullable: false),
BoundCharacterServerId = table.Column<long>(type: "bigint", nullable: false),
IsLocked = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Weapons", x => x.ServerId);
table.ForeignKey(
name: "FK_Weapons_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Weapons_AccountServerId",
table: "Weapons",
column: "AccountServerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Weapons");
}
}
}

View File

@ -212,6 +212,45 @@ namespace SCHALE.Common.Migrations
b.ToTable("Echelons"); 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.ItemDB", b => modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{ {
b.Property<long>("ServerId") b.Property<long>("ServerId")
@ -305,6 +344,42 @@ namespace SCHALE.Common.Migrations
b.ToTable("GuestAccounts"); b.ToTable("GuestAccounts");
}); });
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 => modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{ {
b.HasOne("SCHALE.Common.Database.AccountDB", "Account") b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
@ -327,6 +402,17 @@ namespace SCHALE.Common.Migrations
b.Navigation("Account"); 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.ItemDB", b => modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{ {
b.HasOne("SCHALE.Common.Database.AccountDB", "Account") b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
@ -349,15 +435,30 @@ namespace SCHALE.Common.Migrations
b.Navigation("Account"); 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 => modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{ {
b.Navigation("Characters"); b.Navigation("Characters");
b.Navigation("Echelons"); b.Navigation("Echelons");
b.Navigation("Equipment");
b.Navigation("Items"); b.Navigation("Items");
b.Navigation("MissionProgresses"); b.Navigation("MissionProgresses");
b.Navigation("Weapons");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -2693,7 +2693,7 @@ namespace SCHALE.Common.NetworkProtocol
{ {
get get
{ {
return NetworkProtocol.Protocol.None; return NetworkProtocol.Protocol.Character_SetFavorites;
} }
} }
public List<CharacterDB> CharacterDBs { get; set; } public List<CharacterDB> CharacterDBs { get; set; }
@ -2819,7 +2819,7 @@ namespace SCHALE.Common.NetworkProtocol
{ {
get get
{ {
return NetworkProtocol.Protocol.None; return NetworkProtocol.Protocol.Character_BatchSkillLevelUpdate;
} }
} }
public CharacterDB CharacterDB { get; set; } public CharacterDB CharacterDB { get; set; }
@ -2870,7 +2870,7 @@ namespace SCHALE.Common.NetworkProtocol
{ {
get get
{ {
return NetworkProtocol.Protocol.None; return NetworkProtocol.Protocol.Clan_Search;
} }
} }
public List<ClanDB> ClanDBs { get; set; } public List<ClanDB> ClanDBs { get; set; }
@ -3487,7 +3487,7 @@ namespace SCHALE.Common.NetworkProtocol
{ {
get get
{ {
return NetworkProtocol.Protocol.None; return NetworkProtocol.Protocol.Clan_SetAssist;
} }
} }
public EchelonType EchelonType { get; set; } public EchelonType EchelonType { get; set; }
@ -5460,8 +5460,8 @@ namespace SCHALE.Common.NetworkProtocol
return NetworkProtocol.Protocol.Equipment_Equip; return NetworkProtocol.Protocol.Equipment_Equip;
} }
} }
public CharacterDB CharacterDB; public CharacterDB CharacterDB { get; set; }
public List<EquipmentDB> EquipmentDBs; public List<EquipmentDB> EquipmentDBs { get; set; }
} }
@ -8477,7 +8477,7 @@ namespace SCHALE.Common.NetworkProtocol
public bool IsPractice { get; set; } public bool IsPractice { get; set; }
[JsonIgnore] [JsonIgnore]
public int LastBossIndex { get; set; } public int LastBossIndex { get; set; }
[JsonIgnore] //[JsonIgnore]
//public IEnumerable<RaidDamage> RaidBossDamages { get; set; } //public IEnumerable<RaidDamage> RaidBossDamages { get; set; }
//[JsonIgnore] //[JsonIgnore]
//public RaidBossResultCollection RaidBossResults { get; set; } //public RaidBossResultCollection RaidBossResults { get; set; }
@ -8712,7 +8712,7 @@ namespace SCHALE.Common.NetworkProtocol
} }
public RaidSeasonType SeasonType { get; set; } public RaidSeasonType SeasonType { get; set; }
public RaidGiveUpDB RaidGiveUpDB { get; set; } public RaidGiveUpDB RaidGiveUpDB { get; set; }
//public SingleRaidLobbyInfoDB RaidLobbyInfoDB { get; set; } public SingleRaidLobbyInfoDB RaidLobbyInfoDB { get; set; }
public AccountCurrencyDB AccountCurrencyDB { get; set; } public AccountCurrencyDB AccountCurrencyDB { get; set; }
} }

View File

@ -170,6 +170,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
PotentialStats = { { 1, 0 }, { 2, 0 }, { 3, 0 } } PotentialStats = { { 1, 0 }, { 2, 0 }, { 3, 0 } }
}; };
}).ToList(); }).ToList();
account.AddCharacters(context, [.. newCharacters]); account.AddCharacters(context, [.. newCharacters]);
context.SaveChanges(); context.SaveChanges();
@ -218,6 +219,12 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
var account = sessionKeyService.GetAccount(req.SessionKey); var account = sessionKeyService.GetAccount(req.SessionKey);
// add everything manually
//AddAllCharacters(account);
//AddAllEquipment(account);
//AddAllItems(account);
//AddAllWeapons(account);
return new AccountLoginSyncResponse() return new AccountLoginSyncResponse()
{ {
AccountCurrencySyncResponse = new AccountCurrencySyncResponse() AccountCurrencySyncResponse = new AccountCurrencySyncResponse()
@ -230,8 +237,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
{ CurrencyTypes.Gem, long.MaxValue }, // gacha currency 600 { CurrencyTypes.Gem, long.MaxValue }, // gacha currency 600
{ CurrencyTypes.GemPaid, 0 }, { CurrencyTypes.GemPaid, 0 },
{ CurrencyTypes.GemBonus, 89473598435 }, // default blue gem? { CurrencyTypes.GemBonus, long.MaxValue }, // default blue gem?
{ CurrencyTypes.Gold, long.MaxValue }, // credit 10,000 { CurrencyTypes.Gold, 962_350_000 }, // credit 10,000
{ CurrencyTypes.ActionPoint, long.MaxValue }, // energy 24 { CurrencyTypes.ActionPoint, long.MaxValue }, // energy 24
{ CurrencyTypes.AcademyTicket, 3 }, { CurrencyTypes.AcademyTicket, 3 },
{ CurrencyTypes.ArenaTicket, 5 }, { CurrencyTypes.ArenaTicket, 5 },
@ -277,16 +284,21 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ CurrencyTypes.EliminateTicketB, DateTime.Parse("2024-04-26T19:29:12") }, { CurrencyTypes.EliminateTicketB, DateTime.Parse("2024-04-26T19:29:12") },
{ CurrencyTypes.EliminateTicketC, DateTime.Parse("2024-04-26T19:29:12") }, { CurrencyTypes.EliminateTicketC, DateTime.Parse("2024-04-26T19:29:12") },
{ CurrencyTypes.EliminateTicketD, DateTime.Parse("2024-04-26T19:29:12") } { CurrencyTypes.EliminateTicketD, DateTime.Parse("2024-04-26T19:29:12") }
} }
} }
}, },
CharacterListResponse = new CharacterListResponse() CharacterListResponse = new CharacterListResponse()
{ {
CharacterDBs = [.. account.Characters], CharacterDBs = [.. account.Characters],
TSSCharacterDBs = [], TSSCharacterDBs = [],
WeaponDBs = [], WeaponDBs = [.. account.Weapons],
CostumeDBs = [], CostumeDBs = [],
}, },
ItemListResponse = new ItemListResponse()
{
ItemDBs = [.. account.Items],
},
EchelonListResponse = new EchelonListResponse() EchelonListResponse = new EchelonListResponse()
{ {
EchelonDBs = [.. account.Echelons] EchelonDBs = [.. account.Echelons]
@ -309,7 +321,13 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
new() { EventContentId = 900701 }, new() { EventContentId = 900701 },
], ],
}, },
FriendCode = "SCHALE"
EquipmentItemListResponse = new EquipmentItemListResponse()
{
EquipmentDBs = [.. account.Equipment]
},
FriendCode = "SCHALE",
}; };
} }
@ -389,13 +407,16 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
public ResponsePacket OpenCondition_EventListHandler(OpenConditionEventListRequest req) public ResponsePacket OpenCondition_EventListHandler(OpenConditionEventListRequest req)
{ {
return new OpenConditionEventListResponse(); return new OpenConditionEventListResponse()
{
// all open for now ig
StaticOpenConditions = Enum.GetValues(typeof(OpenConditionContent)).Cast<OpenConditionContent>().ToDictionary(key => key, key => OpenConditionLockReason.None)
};
} }
[ProtocolHandler(Protocol.Notification_EventContentReddotCheck)] [ProtocolHandler(Protocol.Notification_EventContentReddotCheck)]
public ResponsePacket Notification_EventContentReddotCheckHandler(NotificationEventContentReddotRequest req) public ResponsePacket Notification_EventContentReddotCheckHandler(NotificationEventContentReddotRequest req)
{ {
return new NotificationEventContentReddotResponse(); return new NotificationEventContentReddotResponse();
} }
@ -405,6 +426,107 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
return new BillingPurchaseListByYostarResponse(); return new BillingPurchaseListByYostarResponse();
} }
[ProtocolHandler(Protocol.WeekDungeon_List)]
public ResponsePacket WeekDungeon_ListHandler(WeekDungeonListRequest req)
{
return new WeekDungeonListResponse();
}
[ProtocolHandler(Protocol.SchoolDungeon_List)]
public ResponsePacket SchoolDungeon_ListHandler(SchoolDungeonListRequest req)
{
return new SchoolDungeonListResponse();
}
[ProtocolHandler(Protocol.MiniGame_MissionList)]
public ResponsePacket MiniGame_MissionListHandler(MiniGameMissionListRequest req)
{
return new MiniGameMissionListResponse();
}
// these will probably be commands
private void AddAllCharacters(AccountDB account)
{
var characterExcel = excelTableService.GetTable<CharacterExcelTable>().UnPack().DataList;
var allCharacters = characterExcel.Where(x => x.IsPlayable && x.IsPlayableCharacter && x.CollectionVisible && !account.Characters.Any(c => c.UniqueId == x.Id)).Select(x =>
{
return new CharacterDB()
{
UniqueId = x.Id,
StarGrade = x.MaxStarGrade,
Level = 90,
Exp = 0,
PublicSkillLevel = 10,
ExSkillLevel = 5,
PassiveSkillLevel = 10,
ExtraPassiveSkillLevel = 10,
LeaderSkillLevel = 1,
FavorRank = 500,
IsNew = true,
IsLocked = true,
PotentialStats = { { 1, 0 }, { 2, 0 }, { 3, 0 } },
EquipmentServerIds = [0, 0, 0]
};
}).ToList();
account.AddCharacters(context, [.. allCharacters]);
context.SaveChanges();
}
private void AddAllEquipment(AccountDB account)
{
var equipmentExcel = excelTableService.GetTable<EquipmentExcelTable>().UnPack().DataList;
var allEquipment = equipmentExcel.Select(x =>
{
return new EquipmentDB()
{
UniqueId = x.Id,
Level = 1,
StackCount = 100, // ~ 90,000 cap, auto converted if over
};
}).ToList();
account.AddEquipment(context, [.. allEquipment]);
context.SaveChanges();
}
private void AddAllItems(AccountDB account)
{
var itemExcel = excelTableService.GetTable<ItemExcelTable>().UnPack().DataList;
var allItems = itemExcel.Select(x =>
{
return new ItemDB()
{
IsNew = true,
UniqueId = x.Id,
StackCount = 5555,
};
}).ToList();
account.AddItems(context, [.. allItems]);
context.SaveChanges();
}
private void AddAllWeapons(AccountDB account)
{
// only for current characters
var allWeapons = account.Characters.Select(x =>
{
return new WeaponDB()
{
UniqueId = x.UniqueId,
BoundCharacterServerId = x.ServerId,
IsLocked = false,
StarGrade = 5,
Level = 70
};
});
account.AddWeapons(context, [.. allWeapons]);
context.SaveChanges();
}
} }
} }

View File

@ -0,0 +1,68 @@
using SCHALE.Common.Database;
using SCHALE.Common.Database.ModelExtensions;
using SCHALE.Common.NetworkProtocol;
using SCHALE.GameServer.Services;
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{
public class Character : ProtocolHandlerBase
{
private readonly ISessionKeyService sessionKeyService;
private readonly SCHALEContext context;
private readonly ExcelTableService excelTableService;
public Character(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
{
sessionKeyService = _sessionKeyService;
context = _context;
excelTableService = _excelTableService;
}
[ProtocolHandler(Protocol.Character_SetFavorites)]
public ResponsePacket SetFavoritesHandler(CharacterSetFavoritesRequest req)
{
return new CharacterSetFavoritesResponse();
}
[ProtocolHandler(Protocol.Character_UnlockWeapon)]
public ResponsePacket UnlockWeaponHandler(CharacterUnlockWeaponRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var newWeapon = new WeaponDB()
{
UniqueId = account.Characters.FirstOrDefault(x => x.ServerId == req.TargetCharacterServerId).UniqueId,
BoundCharacterServerId = req.TargetCharacterServerId,
IsLocked = false,
StarGrade = 1,
Level = 1
};
account.AddWeapons(context, [newWeapon]);
context.SaveChanges();
return new CharacterUnlockWeaponResponse()
{
WeaponDB = newWeapon,
};
}
[ProtocolHandler(Protocol.Character_PotentialGrowth)]
public ResponsePacket PotentialGrowthHandler(CharacterPotentialGrowthRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var targetCharacter = account.Characters.FirstOrDefault(x => x.ServerId == req.TargetCharacterDBId);
foreach (var growthReq in req.PotentialGrowthRequestDBs)
{
targetCharacter.PotentialStats[(int)growthReq.Type] = growthReq.Level;
}
context.SaveChanges();
return new CharacterPotentialGrowthResponse()
{
CharacterDB = targetCharacter
};
}
}
}

View File

@ -9,11 +9,30 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
[ProtocolHandler(Protocol.Clan_Check)] [ProtocolHandler(Protocol.Clan_Check)]
public ResponsePacket CheckHandler(ClanCheckRequest req) public ResponsePacket CheckHandler(ClanCheckRequest req)
{ {
return new ClanCheckResponse();
}
return new ClanCheckResponse() [ProtocolHandler(Protocol.Clan_AllAssistList)]
public ResponsePacket AllAssistListHandler(ClanAllAssistListRequest req)
{
return new ClanAllAssistListResponse()
{ {
AssistCharacterDBs = [
new() {
AccountId = 1,
AssistCharacterServerId = 1,
EchelonType = Common.FlatData.EchelonType.Raid,
AssistRelation = Common.Database.AssistRelation.Friend,
EquipmentDBs = [],
WeaponDB = new(),
NickName = "Arona",
UniqueId = 20024,
}
],
AssistCharacterRentHistoryDBs = []
}; };
} }
} }
} }

View File

@ -1,4 +1,6 @@
using SCHALE.Common.Database; using SCHALE.Common.Database;
using SCHALE.Common.Database.ModelExtensions;
using SCHALE.Common.FlatData;
using SCHALE.Common.NetworkProtocol; using SCHALE.Common.NetworkProtocol;
using SCHALE.GameServer.Services; using SCHALE.GameServer.Services;
@ -8,11 +10,13 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
private readonly ISessionKeyService sessionKeyService; private readonly ISessionKeyService sessionKeyService;
private readonly SCHALEContext context; private readonly SCHALEContext context;
private readonly ExcelTableService excelTableService;
public Echelon(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context) : base(protocolHandlerFactory) public Echelon(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
{ {
sessionKeyService = _sessionKeyService; sessionKeyService = _sessionKeyService;
context = _context; context = _context;
excelTableService = _excelTableService;
} }
[ProtocolHandler(Protocol.Echelon_List)] [ProtocolHandler(Protocol.Echelon_List)]
@ -25,5 +29,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
EchelonDBs = account.Echelons.ToList() EchelonDBs = account.Echelons.ToList()
}; };
} }
[ProtocolHandler(Protocol.Echelon_Save)]
public ResponsePacket SaveHandler(EchelonSaveRequest req)
{
return new EchelonSaveResponse()
{
EchelonDB = req.EchelonDB,
};
}
} }
} }

View File

@ -0,0 +1,103 @@
using SCHALE.Common.Database;
using SCHALE.Common.Database.ModelExtensions;
using SCHALE.Common.NetworkProtocol;
using SCHALE.GameServer.Services;
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{
public class Equipment : ProtocolHandlerBase
{
private readonly ISessionKeyService sessionKeyService;
private readonly SCHALEContext context;
private readonly ExcelTableService excelTableService;
public Equipment(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
{
sessionKeyService = _sessionKeyService;
context = _context;
excelTableService = _excelTableService;
}
[ProtocolHandler(Protocol.Equipment_Equip)]
public ResponsePacket EquipHandler(EquipmentItemEquipRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var originalStack = account.Equipment.FirstOrDefault(x => x.ServerId == req.EquipmentServerId);
var newEquipment = new EquipmentDB()
{
UniqueId = originalStack.UniqueId,
Level = originalStack.Level,
StackCount = 1,
BoundCharacterServerId = req.CharacterServerId,
};
var equippedCharacter = account.Characters.FirstOrDefault(x => x.ServerId == req.CharacterServerId);
// remove 1 from original equipment stack
originalStack.StackCount--;
// add new equipment w BoundCharacterServerId (with different EquipmentServerId)
account.AddEquipment(context, [newEquipment]);
context.SaveChanges(); // (need newEquipment.ServerId in the next line, so save here first, otherwise its 0)
// set the character's EquipmentServerIds
equippedCharacter.EquipmentServerIds[req.SlotIndex] = newEquipment.ServerId;
context.SaveChanges();
return new EquipmentItemEquipResponse()
{
CharacterDB = equippedCharacter,
EquipmentDBs = [newEquipment, originalStack]
};
}
// dont use this, too lazy to implement, just use batch growth ty
[ProtocolHandler(Protocol.Equipment_LevelUp)]
public ResponsePacket LevelUpHandler(EquipmentItemLevelUpRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var targetEquipment = account.Equipment.FirstOrDefault(x => x.ServerId == req.TargetServerId);
targetEquipment.Level = 65;
targetEquipment.Tier = 9;
context.SaveChanges();
return new EquipmentItemLevelUpResponse()
{
EquipmentDB = targetEquipment,
};
}
[ProtocolHandler(Protocol.Equipment_BatchGrowth)]
public ResponsePacket Equipment_BatchGrowthHandler(EquipmentBatchGrowthRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var upgradedEquipment = new List<EquipmentDB>();
foreach (var batchGrowthDB in req.EquipmentBatchGrowthRequestDBs)
{
var targetEquipment = account.Equipment.FirstOrDefault(x => x.ServerId == batchGrowthDB.TargetServerId);
targetEquipment.Tier = (int)batchGrowthDB.AfterTier;
targetEquipment.Level = (int)batchGrowthDB.AfterLevel;
targetEquipment.UniqueId = targetEquipment.UniqueId + batchGrowthDB.AfterTier - 1; // should prob use excel, im lazyzz...
targetEquipment.IsNew = true;
targetEquipment.StackCount = 1;
context.SaveChanges();
upgradedEquipment.Add(targetEquipment);
}
context.SaveChanges();
return new EquipmentBatchGrowthResponse()
{
EquipmentDBs = upgradedEquipment,
};
}
}
}

View File

@ -26,5 +26,13 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
ExpiryItemDBs = [] ExpiryItemDBs = []
}; };
} }
[ProtocolHandler(Protocol.Item_AutoSynth)]
public ResponsePacket AutoSynthHandler(ItemAutoSynthRequest req)
{
return new ItemAutoSynthResponse()
{
};
}
} }
} }

View File

@ -0,0 +1,65 @@
using SCHALE.Common.Database;
using SCHALE.Common.NetworkProtocol;
using SCHALE.GameServer.Services;
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{
public class Raid : ProtocolHandlerBase
{
private readonly ISessionKeyService sessionKeyService;
private readonly SCHALEContext context;
private readonly ExcelTableService excelTableService;
public Raid(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
{
sessionKeyService = _sessionKeyService;
context = _context;
excelTableService = _excelTableService;
}
[ProtocolHandler(Protocol.Raid_Lobby)]
public ResponsePacket LobbyHandler(RaidLobbyRequest req)
{
return new RaidLobbyResponse()
{
};
}
[ProtocolHandler(Protocol.Raid_OpponentList)]
public ResponsePacket OpponentListHandler(RaidOpponentListRequest req)
{
return new RaidOpponentListResponse()
{
OpponentUserDBs = []
};
}
[ProtocolHandler(Protocol.Raid_CreateBattle)]
public ResponsePacket CreateBattleHandller(RaidCreateBattleRequest req)
{
return new RaidCreateBattleResponse()
{
};
}
[ProtocolHandler(Protocol.Raid_EnterBattle)] // clicked restart
public ResponsePacket EnterBattleHandler(RaidEnterBattleRequest req)
{
return new RaidEnterBattleResponse()
{
};
}
[ProtocolHandler(Protocol.Raid_EndBattle)]
public ResponsePacket EndBattleHandler(RaidEndBattleRequest req)
{
return new RaidEndBattleResponse()
{
};
}
}
}

View File

@ -10,10 +10,6 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
[ProtocolHandler(Protocol.Scenario_Skip)] [ProtocolHandler(Protocol.Scenario_Skip)]
public ResponsePacket SkipHandler(ScenarioSkipRequest req) public ResponsePacket SkipHandler(ScenarioSkipRequest req)
{ {
Log.Debug($"ScenarioSkipRequest ScriptGroupId:" + req.ScriptGroupId);
Log.Debug($"ScenarioSkipRequest SkipPointScriptCount: " + req.SkipPointScriptCount);
// skip story doesn't work yet, probably need to implement missiondb
return new ScenarioSkipResponse(); return new ScenarioSkipResponse();
} }
@ -22,5 +18,11 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
return new ScenarioSelectResponse(); return new ScenarioSelectResponse();
} }
[ProtocolHandler(Protocol.Scenario_GroupHistoryUpdate)]
public ResponsePacket GroupHistoryUpdateHandler(ScenarioGroupHistoryUpdateRequest req)
{
return new ScenarioGroupHistoryUpdateResponse();
}
} }
} }

View File

@ -27,15 +27,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
[ProtocolHandler(Protocol.Shop_BeforehandGachaRun)] [ProtocolHandler(Protocol.Shop_BeforehandGachaRun)]
public ResponsePacket BeforehandGachaRunHandler(ShopBeforehandGachaRunRequest req) public ResponsePacket BeforehandGachaRunHandler(ShopBeforehandGachaRunRequest req)
{ {
// character ids here, just some limited 3 stars for now for fun SavedGachaResults = [16003, 16003, 16003, 16003, 16003, 16003, 16003, 16003, 16003, 16003];
SavedGachaResults = [10059, 20007, 10033, 10074, 10045, 10053, 10054, 10021, 20022, 10057];
return new ShopBeforehandGachaRunResponse() return new ShopBeforehandGachaRunResponse()
{ {
SelectGachaSnapshot = new BeforehandGachaSnapshotDB() SelectGachaSnapshot = new BeforehandGachaSnapshotDB()
{ {
ShopUniqueId = 3, ShopUniqueId = 3,
GoodsId = 1, GoodsId = 1,
LastResults = SavedGachaResults LastResults = SavedGachaResults
} }
}; };
@ -46,7 +45,12 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{ {
return new ShopBeforehandGachaSaveResponse() return new ShopBeforehandGachaSaveResponse()
{ {
SelectGachaSnapshot = new BeforehandGachaSnapshotDB()
{
ShopUniqueId = 3,
GoodsId = 1,
LastResults = SavedGachaResults
}
}; };
} }
@ -85,6 +89,53 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
}; };
} }
[ProtocolHandler(Protocol.Shop_BuyGacha3)]
public ResponsePacket ShopBuyGacha3ResponseHandler(ShopBuyGacha3Request req)
{
var gachaResults = new List<GachaResult>();
for (int i = 0; i < 10; i++)
{
long id = 10000 + new Random().Next(0, 94);
gachaResults.Add(new(id)
{
Character = new() // hardcoded util proper db
{
ServerId = req.AccountId,
UniqueId = 20007,
StarGrade = 3,
Level = 1,
FavorRank = 1,
PublicSkillLevel = 1,
ExSkillLevel = 1,
PassiveSkillLevel = 1,
ExtraPassiveSkillLevel = 1,
LeaderSkillLevel = 1,
IsNew = true,
IsLocked = true
}
});
}
return new ShopBuyGacha3Response()
{
UpdateTime = DateTime.UtcNow,
GemBonusRemain = long.MaxValue,
ConsumedItems = [],
AcquiredItems = [],
MissionProgressDBs = [],
};
}
[ProtocolHandler(Protocol.Shop_List)]
public ResponsePacket ListHandler(ShopListRequest req)
{
return new ShopListResponse()
{
ShopInfos = []
};
}
} }
} }