Implement Basic Cafe, Furniture & Cafe Command
This commit is contained in:
parent
5397797315
commit
e69b192c2c
|
@ -108,5 +108,29 @@
|
|||
|
||||
return [.. scenarios];
|
||||
}
|
||||
|
||||
public static List<CafeDB> AddCafes(this AccountDB account, SCHALEContext context, params CafeDB[] cafes)
|
||||
{
|
||||
foreach (var cafe in cafes)
|
||||
{
|
||||
cafe.AccountServerId = account.ServerId;
|
||||
context.Cafes.Add(cafe);
|
||||
}
|
||||
|
||||
return [.. cafes];
|
||||
}
|
||||
|
||||
public static List<FurnitureDB> AddFurnitures(this AccountDB account, SCHALEContext context, params FurnitureDB[] furnitures)
|
||||
{
|
||||
foreach (var furniture in furnitures)
|
||||
{
|
||||
furniture.AccountServerId = account.ServerId;
|
||||
context.Furnitures.Add(furniture);
|
||||
}
|
||||
|
||||
return [.. furnitures];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ namespace SCHALE.Common.Database
|
|||
public DbSet<EchelonDB> Echelons { get; set; }
|
||||
public DbSet<AccountTutorial> AccountTutorials { get; set; }
|
||||
|
||||
public DbSet<CafeDB> Cafes { get; set; }
|
||||
public DbSet<FurnitureDB> Furnitures { get; set; }
|
||||
|
||||
public static SCHALEContext Create(string connectionString) =>
|
||||
new(new DbContextOptionsBuilder<SCHALEContext>()
|
||||
.UseSqlServer(connectionString)
|
||||
|
@ -84,6 +87,16 @@ namespace SCHALE.Common.Database
|
|||
.WithOne(x => x.Account)
|
||||
.HasForeignKey(x => x.AccountServerId)
|
||||
.IsRequired();
|
||||
modelBuilder.Entity<AccountDB>()
|
||||
.HasMany(x => x.Cafes)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey(x => x.AccountServerId)
|
||||
.IsRequired();
|
||||
modelBuilder.Entity<AccountDB>()
|
||||
.HasMany(x => x.Furnitures)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey(x => x.AccountServerId)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<AccountDB>(x => x.Property(b => b.RaidInfo).HasJsonConversion());
|
||||
modelBuilder.Entity<ItemDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
|
||||
|
@ -93,6 +106,14 @@ namespace SCHALE.Common.Database
|
|||
|
||||
modelBuilder.Entity<EchelonDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
|
||||
|
||||
modelBuilder.Entity<CafeDB>().Property(x => x.CafeDBId).ValueGeneratedOnAdd();
|
||||
|
||||
modelBuilder.Entity<CafeDB>().Property(x => x.CafeVisitCharacterDBs).HasJsonConversion();
|
||||
modelBuilder.Entity<CafeDB>().Property(x => x.CurrencyDict_Obsolete).HasJsonConversion();
|
||||
modelBuilder.Entity<CafeDB>().Property(x => x.UpdateTimeDict_Obsolete).HasJsonConversion();
|
||||
|
||||
modelBuilder.Entity<FurnitureDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
|
||||
|
||||
modelBuilder.Entity<CharacterDB>().Property(x => x.ServerId).ValueGeneratedOnAdd();
|
||||
modelBuilder.Entity<CharacterDB>().Property(x => x.EquipmentSlotAndDBIds).HasJsonConversion();
|
||||
modelBuilder.Entity<CharacterDB>().Property(x => x.PotentialStats).HasJsonConversion();
|
||||
|
|
|
@ -349,6 +349,13 @@ namespace SCHALE.Common.Database
|
|||
[JsonIgnore]
|
||||
public virtual ICollection<ScenarioHistoryDB> Scenarios { get; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<CafeDB> Cafes { get; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<FurnitureDB> Furnitures { get; }
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual RaidInfo RaidInfo { get; set; }
|
||||
|
||||
|
@ -362,6 +369,8 @@ namespace SCHALE.Common.Database
|
|||
Gears = new List<GearDB>();
|
||||
MemoryLobbies = new List<MemoryLobbyDB>();
|
||||
Scenarios = new List<ScenarioHistoryDB>();
|
||||
Cafes = new List<CafeDB>();
|
||||
Furnitures = new List<FurnitureDB>();
|
||||
}
|
||||
|
||||
public AccountDB(long publisherAccountId) : this()
|
||||
|
@ -605,8 +614,17 @@ namespace SCHALE.Common.Database
|
|||
|
||||
public class CafeDB
|
||||
{
|
||||
[JsonIgnore]
|
||||
public virtual AccountDB Account { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public long AccountServerId { get; set; }
|
||||
|
||||
[Key]
|
||||
public long CafeDBId { get; set; }
|
||||
|
||||
public long CafeId { get; set; }
|
||||
|
||||
public long AccountId { get; set; }
|
||||
public int CafeRank { get; set; }
|
||||
public DateTime LastUpdate { get; set; }
|
||||
|
@ -615,11 +633,30 @@ namespace SCHALE.Common.Database
|
|||
[NotMapped]
|
||||
public bool IsNew { get; set; }
|
||||
public Dictionary<long, CafeCharacterDB> CafeVisitCharacterDBs { get; set; }
|
||||
public List<FurnitureDB> FurnitureDBs { get; set; }
|
||||
|
||||
public DateTime ProductionAppliedTime { get; set; }
|
||||
public CafeProductionDB ProductionDB { get; set; }
|
||||
public Dictionary<CurrencyTypes, long> CurrencyDict_Obsolete { get; set; }
|
||||
public Dictionary<CurrencyTypes, DateTime> UpdateTimeDict_Obsolete { get; set; }
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public List<FurnitureDB> FurnitureDBs { get => Account.Furnitures.Where(x => x.CafeDBId == CafeDBId).ToList(); }
|
||||
|
||||
// TODO: fix this, probably needs another db for this, and link in OnModelCreate
|
||||
[NotMapped]
|
||||
public CafeProductionDB ProductionDB
|
||||
{
|
||||
get => new()
|
||||
{
|
||||
CafeDBId = 1,
|
||||
AppliedDate = DateTime.UtcNow,
|
||||
ProductionParcelInfos = [
|
||||
new() { Key = { Type = ParcelType.Currency, Id = 1 } }, // id 1
|
||||
new() { Key = { Type = ParcelType.Currency, Id = 5 } }
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
public Dictionary<CurrencyTypes, long> CurrencyDict_Obsolete { get; set; } = new Dictionary<CurrencyTypes, long>();
|
||||
public Dictionary<CurrencyTypes, DateTime> UpdateTimeDict_Obsolete { get; set; } = new Dictionary<CurrencyTypes, DateTime>();
|
||||
}
|
||||
|
||||
public class CafeProductionParcelInfo
|
||||
|
@ -1579,6 +1616,7 @@ namespace SCHALE.Common.Database
|
|||
{
|
||||
public override ParcelType Type { get => ParcelType.Furniture; }
|
||||
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
||||
|
||||
|
|
713
SCHALE.Common/Migrations/SqlServerMigrations/20241108220342_CafeAndFurnitures.Designer.cs
generated
Normal file
713
SCHALE.Common/Migrations/SqlServerMigrations/20241108220342_CafeAndFurnitures.Designer.cs
generated
Normal file
|
@ -0,0 +1,713 @@
|
|||
// <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.SqlServerMigrations
|
||||
{
|
||||
[DbContext(typeof(SCHALEContext))]
|
||||
[Migration("20241108220342_CafeAndFurnitures")]
|
||||
partial class CafeAndFurnitures
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.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.CafeDB", b =>
|
||||
{
|
||||
b.Property<long>("CafeDBId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("CafeDBId"));
|
||||
|
||||
b.Property<long>("AccountId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("AccountServerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("CafeId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("CafeRank")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CafeVisitCharacterDBs")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("CurrencyDict_Obsolete")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime?>("LastSummonDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("ProductionAppliedTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("UpdateTimeDict_Obsolete")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("CafeDBId");
|
||||
|
||||
b.HasIndex("AccountServerId");
|
||||
|
||||
b.ToTable("Cafes");
|
||||
});
|
||||
|
||||
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.FurnitureDB", b =>
|
||||
{
|
||||
b.Property<long>("ServerId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
|
||||
|
||||
b.Property<long>("AccountServerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("CafeDBId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("ItemDeploySequence")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("Location")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("PositionX")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<float>("PositionY")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<float>("Rotation")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<long>("StackCount")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("UniqueId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("ServerId");
|
||||
|
||||
b.HasIndex("AccountServerId");
|
||||
|
||||
b.ToTable("Furnitures");
|
||||
});
|
||||
|
||||
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.CafeDB", b =>
|
||||
{
|
||||
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
|
||||
.WithMany("Cafes")
|
||||
.HasForeignKey("AccountServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
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.FurnitureDB", b =>
|
||||
{
|
||||
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
|
||||
.WithMany("Furnitures")
|
||||
.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("Cafes");
|
||||
|
||||
b.Navigation("Characters");
|
||||
|
||||
b.Navigation("Echelons");
|
||||
|
||||
b.Navigation("Equipment");
|
||||
|
||||
b.Navigation("Furnitures");
|
||||
|
||||
b.Navigation("Gears");
|
||||
|
||||
b.Navigation("Items");
|
||||
|
||||
b.Navigation("MemoryLobbies");
|
||||
|
||||
b.Navigation("MissionProgresses");
|
||||
|
||||
b.Navigation("Scenarios");
|
||||
|
||||
b.Navigation("Weapons");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SCHALE.Common.Migrations.SqlServerMigrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class CafeAndFurnitures : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cafes",
|
||||
columns: table => new
|
||||
{
|
||||
CafeDBId = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AccountServerId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CafeId = table.Column<long>(type: "bigint", nullable: false),
|
||||
AccountId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CafeRank = table.Column<int>(type: "int", nullable: false),
|
||||
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LastSummonDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
CafeVisitCharacterDBs = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ProductionAppliedTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
CurrencyDict_Obsolete = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UpdateTimeDict_Obsolete = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cafes", x => x.CafeDBId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cafes_Accounts_AccountServerId",
|
||||
column: x => x.AccountServerId,
|
||||
principalTable: "Accounts",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Furnitures",
|
||||
columns: table => new
|
||||
{
|
||||
ServerId = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Location = table.Column<int>(type: "int", nullable: false),
|
||||
CafeDBId = table.Column<long>(type: "bigint", nullable: false),
|
||||
PositionX = table.Column<float>(type: "real", nullable: false),
|
||||
PositionY = table.Column<float>(type: "real", nullable: false),
|
||||
Rotation = table.Column<float>(type: "real", nullable: false),
|
||||
ItemDeploySequence = table.Column<long>(type: "bigint", 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_Furnitures", x => x.ServerId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Furnitures_Accounts_AccountServerId",
|
||||
column: x => x.AccountServerId,
|
||||
principalTable: "Accounts",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cafes_AccountServerId",
|
||||
table: "Cafes",
|
||||
column: "AccountServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Furnitures_AccountServerId",
|
||||
table: "Furnitures",
|
||||
column: "AccountServerId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cafes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Furnitures");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ namespace SCHALE.Common.Migrations.SqlServerMigrations
|
|||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.2")
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
|
@ -99,6 +99,54 @@ namespace SCHALE.Common.Migrations.SqlServerMigrations
|
|||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.CafeDB", b =>
|
||||
{
|
||||
b.Property<long>("CafeDBId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("CafeDBId"));
|
||||
|
||||
b.Property<long>("AccountId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("AccountServerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("CafeId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("CafeRank")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CafeVisitCharacterDBs")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("CurrencyDict_Obsolete")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime?>("LastSummonDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("LastUpdate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("ProductionAppliedTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("UpdateTimeDict_Obsolete")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("CafeDBId");
|
||||
|
||||
b.HasIndex("AccountServerId");
|
||||
|
||||
b.ToTable("Cafes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
|
||||
{
|
||||
b.Property<long>("ServerId")
|
||||
|
@ -259,6 +307,48 @@ namespace SCHALE.Common.Migrations.SqlServerMigrations
|
|||
b.ToTable("Equipment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.FurnitureDB", b =>
|
||||
{
|
||||
b.Property<long>("ServerId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("ServerId"));
|
||||
|
||||
b.Property<long>("AccountServerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("CafeDBId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("ItemDeploySequence")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("Location")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("PositionX")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<float>("PositionY")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<float>("Rotation")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<long>("StackCount")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("UniqueId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("ServerId");
|
||||
|
||||
b.HasIndex("AccountServerId");
|
||||
|
||||
b.ToTable("Furnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
|
||||
{
|
||||
b.Property<long>("ServerId")
|
||||
|
@ -469,6 +559,17 @@ namespace SCHALE.Common.Migrations.SqlServerMigrations
|
|||
b.ToTable("Weapons");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.CafeDB", b =>
|
||||
{
|
||||
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
|
||||
.WithMany("Cafes")
|
||||
.HasForeignKey("AccountServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
|
||||
{
|
||||
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
|
||||
|
@ -502,6 +603,17 @@ namespace SCHALE.Common.Migrations.SqlServerMigrations
|
|||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.FurnitureDB", b =>
|
||||
{
|
||||
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
|
||||
.WithMany("Furnitures")
|
||||
.HasForeignKey("AccountServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
|
||||
{
|
||||
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
|
||||
|
@ -570,12 +682,16 @@ namespace SCHALE.Common.Migrations.SqlServerMigrations
|
|||
|
||||
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
|
||||
{
|
||||
b.Navigation("Cafes");
|
||||
|
||||
b.Navigation("Characters");
|
||||
|
||||
b.Navigation("Echelons");
|
||||
|
||||
b.Navigation("Equipment");
|
||||
|
||||
b.Navigation("Furnitures");
|
||||
|
||||
b.Navigation("Gears");
|
||||
|
||||
b.Navigation("Items");
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
using SCHALE.Common.Database;
|
||||
using SCHALE.Common.Database.ModelExtensions;
|
||||
using SCHALE.Common.FlatData;
|
||||
using SCHALE.Common.Utils;
|
||||
using SCHALE.GameServer.Controllers.Api.ProtocolHandlers;
|
||||
using SCHALE.GameServer.Services;
|
||||
using SCHALE.GameServer.Services.Irc;
|
||||
|
||||
namespace SCHALE.GameServer.Commands
|
||||
{
|
||||
[CommandHandler("cafe", "Command to manage the cafe", "/cafe <character|furniture> <add|addall|removeall> [id/amount]")]
|
||||
internal class CafeCommand : Command
|
||||
{
|
||||
|
||||
// /cafe character add 123
|
||||
// /cafe character addall
|
||||
// /cafe character removeall
|
||||
|
||||
public CafeCommand(IrcConnection connection, string[] args, bool validate = true) : base(connection, args, validate) { }
|
||||
|
||||
[Argument(0, @"^character$|^furniture$", "The target type", ArgumentFlags.IgnoreCase)]
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
[Argument(1, @"^add$|^addall$|^removeall$", "The operation selected (add, addall, removeall)", ArgumentFlags.IgnoreCase)]
|
||||
public string Op { get; set; } = string.Empty;
|
||||
|
||||
[Argument(2, @"^[0-9]+$", "The target character id / the add amount for addall", ArgumentFlags.Optional)]
|
||||
public string Target { get; set; } = string.Empty;
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
var context = connection.Context;
|
||||
var targetCafe = connection.Account.Cafes.FirstOrDefault();
|
||||
|
||||
switch (Type.ToLower())
|
||||
{
|
||||
case "character":
|
||||
{
|
||||
switch (Op.ToLower())
|
||||
{
|
||||
case "add":
|
||||
{
|
||||
if (uint.TryParse(Target, out uint characterId))
|
||||
{
|
||||
if (!targetCafe.CafeVisitCharacterDBs.ContainsKey(characterId))
|
||||
{
|
||||
targetCafe.CafeVisitCharacterDBs.Add(characterId, new CafeCharacterDB() { UniqueId = characterId });
|
||||
|
||||
connection.SendChatMessage($"Character {characterId} added to your cafe!");
|
||||
}
|
||||
else
|
||||
{
|
||||
connection.SendChatMessage("That character is already in the cafe, skipped.");
|
||||
}
|
||||
} else
|
||||
{
|
||||
connection.SendChatMessage($"Invalid character id");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case "addall":
|
||||
{
|
||||
int amount = 50;
|
||||
|
||||
if (int.TryParse(Target, out int targetAmount))
|
||||
{
|
||||
amount = targetAmount;
|
||||
}
|
||||
|
||||
var characterExcel = connection.ExcelTableService.GetTable<CharacterExcelTable>().UnPack().DataList;
|
||||
|
||||
var allCharacters = characterExcel.Where(x =>
|
||||
x is
|
||||
{
|
||||
IsPlayable: true,
|
||||
IsPlayableCharacter: true,
|
||||
IsNpc: false,
|
||||
ProductionStep: ProductionStep.Release,
|
||||
}
|
||||
).Select(x => x.Id).ToList();
|
||||
|
||||
var cafeVisitCharacterDBs = allCharacters.Take(amount).ToDictionary(id => id, id => new CafeCharacterDB { UniqueId = id });
|
||||
|
||||
targetCafe.CafeVisitCharacterDBs = cafeVisitCharacterDBs;
|
||||
connection.SendChatMessage($"Added {amount} characters to your cafe!");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case "removeall":
|
||||
{
|
||||
targetCafe.CafeVisitCharacterDBs = new Dictionary<long, CafeCharacterDB>();
|
||||
|
||||
connection.SendChatMessage("Removed all characters from your cafe!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ using SCHALE.Common.Database.ModelExtensions;
|
|||
using SCHALE.Common.FlatData;
|
||||
using SCHALE.Common.NetworkProtocol;
|
||||
using SCHALE.GameServer.Services;
|
||||
using Serilog;
|
||||
using System.Globalization;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||
|
@ -255,6 +257,27 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
}
|
||||
context.SaveChanges();
|
||||
|
||||
// Default cafe
|
||||
CafeDB defaultCafe = new CafeDB()
|
||||
{
|
||||
CafeId = 1,
|
||||
CafeRank = 1,
|
||||
AccountId = account.ServerId,
|
||||
LastUpdate = DateTime.UtcNow,
|
||||
LastSummonDate = DateTime.UtcNow,
|
||||
IsNew = true,
|
||||
CafeVisitCharacterDBs = GetRandomCharactersId(5).ToDictionary(id => id, id => new CafeCharacterDB { UniqueId = id, ServerId = id }),
|
||||
ProductionAppliedTime = DateTime.UtcNow,
|
||||
//ProductionDB =
|
||||
};
|
||||
|
||||
var defaultFurnitures = GetDefaultFurnitures(1);
|
||||
|
||||
account.AddCafes(context, [defaultCafe]);
|
||||
account.AddFurnitures(context, [.. defaultFurnitures]);
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
return new AccountCreateResponse()
|
||||
{
|
||||
SessionKey = sessionKeyService.Create(account.PublisherAccountId)
|
||||
|
@ -282,63 +305,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
{
|
||||
CafeGetInfoResponse = new CafeGetInfoResponse()
|
||||
{
|
||||
CafeDBs = [
|
||||
new CafeDB() {
|
||||
CafeDBId = 3091193,
|
||||
CafeId = 1,
|
||||
AccountId = 1,
|
||||
CafeRank = 1,
|
||||
LastUpdate = DateTime.Parse("2024-04-21T07: 29: 57"),
|
||||
LastSummonDate = DateTime.Parse("0001-01-01T00: 00: 00"),
|
||||
IsNew = true,
|
||||
CafeVisitCharacterDBs = new Dictionary<long, CafeCharacterDB>()
|
||||
{
|
||||
{ 26008, new CafeCharacterDB() { UniqueId = 26008 } },
|
||||
{ 10005, new CafeCharacterDB() { UniqueId = 10005 } },
|
||||
{ 13004, new CafeCharacterDB() { UniqueId = 13004 } },
|
||||
{ 10058, new CafeCharacterDB() { UniqueId = 10058 } },
|
||||
},
|
||||
|
||||
FurnitureDBs = [
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, ItemDeploySequence = 368862451, ServerId = 368862451, UniqueId = 1, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallRight, CafeDBId = 3091193, ItemDeploySequence = 368862452, ServerId = 368862452, UniqueId = 2, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallLeft, CafeDBId = 3091193, ItemDeploySequence = 368862453, ServerId = 368862453, UniqueId = 3, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallRight, CafeDBId = 3091193, PositionX = 8.5f, PositionY = 3.0f, ItemDeploySequence = 368862454, ServerId = 368862454, UniqueId = 4, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 3.0f, PositionY = 1.5f, Rotation = 270.0f, ItemDeploySequence = 368862455, ServerId = 368862455, UniqueId = 5, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862456, ServerId = 368862456, UniqueId = 6, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 6.5f, ItemDeploySequence = 368862457, ServerId = 368862457, UniqueId = 7, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 9.5f, PositionY = 8.5f, ItemDeploySequence = 368862458, ServerId = 368862458, UniqueId = 8, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 4.5f, PositionY = 0.5f, ItemDeploySequence = 368862459, ServerId = 368862459, UniqueId = 9, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862460, ServerId = 368862460, UniqueId = 10, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallLeft, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 3.0f, ItemDeploySequence = 368862461, ServerId = 368862461, UniqueId = 11, StackCount = 1}
|
||||
],
|
||||
|
||||
ProductionAppliedTime = DateTime.Parse("2024-04-21T07: 29: 50"),
|
||||
|
||||
ProductionDB = new () {
|
||||
CafeDBId = 3091193,
|
||||
AppliedDate = DateTime.Parse("2024-04-21T07: 29: 50"),
|
||||
ProductionParcelInfos = [
|
||||
new() { Key = { Type = ParcelType.Currency, Id = 1 } },
|
||||
new() { Key = { Type = ParcelType.Currency, Id = 5 } }
|
||||
],
|
||||
}
|
||||
},
|
||||
],
|
||||
|
||||
FurnitureDBs = [
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, ItemDeploySequence = 368862451, ServerId = 368862451, UniqueId = 1, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallRight, CafeDBId = 3091193, ItemDeploySequence = 368862452, ServerId = 368862452, UniqueId = 2, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallLeft, CafeDBId = 3091193, ItemDeploySequence = 368862453, ServerId = 368862453, UniqueId = 3, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallRight, CafeDBId = 3091193, PositionX = 8.5f, PositionY = 3.0f, ItemDeploySequence = 368862454, ServerId = 368862454, UniqueId = 4, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 3.0f, PositionY = 1.5f, Rotation = 270.0f, ItemDeploySequence = 368862455, ServerId = 368862455, UniqueId = 5, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862456, ServerId = 368862456, UniqueId = 6, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 6.5f, ItemDeploySequence = 368862457, ServerId = 368862457, UniqueId = 7, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 9.5f, PositionY = 8.5f, ItemDeploySequence = 368862458, ServerId = 368862458, UniqueId = 8, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 4.5f, PositionY = 0.5f, ItemDeploySequence = 368862459, ServerId = 368862459, UniqueId = 9, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862460, ServerId = 368862460, UniqueId = 10, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallLeft, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 3.0f, ItemDeploySequence = 368862461, ServerId = 368862461, UniqueId = 11, StackCount = 1}],
|
||||
|
||||
CafeDBs = [.. account.Cafes],
|
||||
FurnitureDBs = [.. account.Furnitures]
|
||||
},
|
||||
AccountCurrencySyncResponse = new AccountCurrencySyncResponse()
|
||||
{
|
||||
|
@ -579,6 +547,66 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
};
|
||||
}
|
||||
|
||||
// Utils stuff
|
||||
private List<FurnitureDB> GetDefaultFurnitures(int cafeDbId)
|
||||
{
|
||||
var defaultFurnitureExcels = excelTableService.GetTable<DefaultFurnitureExcelTable>().UnPack().DataList;
|
||||
|
||||
var defaultCharacters = defaultFurnitureExcels.Select((df, i) => new FurnitureDB()
|
||||
{
|
||||
CafeDBId = cafeDbId,
|
||||
Location = df.Location,
|
||||
ItemDeploySequence = i,
|
||||
UniqueId = df.Id,
|
||||
PositionX = RemoveScientificNotation(df.PositionX),
|
||||
PositionY = RemoveScientificNotation(df.PositionY),
|
||||
Rotation = RemoveScientificNotation(df.Rotation),
|
||||
StackCount = 1,
|
||||
}).ToList();
|
||||
|
||||
return defaultCharacters;
|
||||
}
|
||||
|
||||
private List<long> GetRandomCharactersId(int amount)
|
||||
{
|
||||
var randomCharacters = new List<long>();
|
||||
|
||||
var characterExcel = excelTableService.GetTable<CharacterExcelTable>().UnPack().DataList;
|
||||
|
||||
var allCharacters = characterExcel.Where(x => x is
|
||||
{
|
||||
IsPlayable: true,
|
||||
IsPlayableCharacter: true,
|
||||
IsNpc: false,
|
||||
ProductionStep: ProductionStep.Release,
|
||||
}).Select(x => x.Id).ToList();
|
||||
|
||||
while (randomCharacters.Count < amount)
|
||||
{
|
||||
int randIndex = new Random().Next() % allCharacters.Count;
|
||||
randomCharacters.Add(allCharacters[randIndex]);
|
||||
}
|
||||
|
||||
return randomCharacters;
|
||||
}
|
||||
|
||||
public static float RemoveScientificNotation(float value)
|
||||
{
|
||||
float result = value;
|
||||
|
||||
while (result < 1f)
|
||||
{
|
||||
result *= 10.0f;
|
||||
}
|
||||
|
||||
while (result > 19.0f)
|
||||
{
|
||||
result /= 10.0f;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO: others handlers, move to different handler group later
|
||||
[ProtocolHandler(Protocol.NetworkTime_Sync)]
|
||||
public ResponsePacket NetworkTime_SyncHandler(NetworkTimeSyncRequest req)
|
||||
|
@ -679,112 +707,5 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
{
|
||||
return new FriendGetIdCardResponse();
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Get)]
|
||||
public ResponsePacket Cafe_Get(CafeGetInfoRequest req)
|
||||
{
|
||||
|
||||
List<CafeDB> cafeDBs = [
|
||||
new CafeDB() {
|
||||
CafeDBId = 3091193,
|
||||
CafeId = 1,
|
||||
AccountId = 1,
|
||||
CafeRank = 1,
|
||||
LastUpdate = DateTime.Parse("2024-04-21T07: 29: 57"),
|
||||
LastSummonDate = DateTime.Parse("0001-01-01T00: 00: 00"),
|
||||
IsNew = true,
|
||||
CafeVisitCharacterDBs = new Dictionary<long, CafeCharacterDB>()
|
||||
{
|
||||
{ 26008, new CafeCharacterDB() { UniqueId = 26008 } },
|
||||
{ 10005, new CafeCharacterDB() { UniqueId = 10005 } },
|
||||
{ 13004, new CafeCharacterDB() { UniqueId = 13004 } },
|
||||
{ 10058, new CafeCharacterDB() { UniqueId = 10058 } },
|
||||
},
|
||||
|
||||
FurnitureDBs = [
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, ItemDeploySequence = 368862451, ServerId = 368862451, UniqueId = 1, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallRight, CafeDBId = 3091193, ItemDeploySequence = 368862452, ServerId = 368862452, UniqueId = 2, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallLeft, CafeDBId = 3091193, ItemDeploySequence = 368862453, ServerId = 368862453, UniqueId = 3, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallRight, CafeDBId = 3091193, PositionX = 8.5f, PositionY = 3.0f, ItemDeploySequence = 368862454, ServerId = 368862454, UniqueId = 4, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 3.0f, PositionY = 1.5f, Rotation = 270.0f, ItemDeploySequence = 368862455, ServerId = 368862455, UniqueId = 5, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862456, ServerId = 368862456, UniqueId = 6, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 6.5f, ItemDeploySequence = 368862457, ServerId = 368862457, UniqueId = 7, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 9.5f, PositionY = 8.5f, ItemDeploySequence = 368862458, ServerId = 368862458, UniqueId = 8, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 4.5f, PositionY = 0.5f, ItemDeploySequence = 368862459, ServerId = 368862459, UniqueId = 9, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862460, ServerId = 368862460, UniqueId = 10, StackCount = 1},
|
||||
new() { Location = Common.FlatData.FurnitureLocation.WallLeft, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 3.0f, ItemDeploySequence = 368862461, ServerId = 368862461, UniqueId = 11, StackCount = 1}
|
||||
],
|
||||
|
||||
ProductionAppliedTime = DateTime.Parse("2024-04-21T07: 29: 50"),
|
||||
|
||||
ProductionDB = new () {
|
||||
CafeDBId = 3091193,
|
||||
AppliedDate = DateTime.Parse("2024-04-21T07: 29: 50"),
|
||||
ProductionParcelInfos = [
|
||||
new() { Key = { Type = ParcelType.Currency, Id = 1 } },
|
||||
new() { Key = { Type = ParcelType.Currency, Id = 5 } }
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
var characterExcel = excelTableService.GetTable<CharacterExcelTable>().UnPack().DataList;
|
||||
|
||||
var allCharacters = characterExcel.Where(x =>
|
||||
x is
|
||||
{
|
||||
IsPlayable: true,
|
||||
IsPlayableCharacter: true,
|
||||
IsNpc: false,
|
||||
ProductionStep: ProductionStep.Release,
|
||||
}
|
||||
).Select(x => x.Id).ToList();
|
||||
|
||||
|
||||
|
||||
var cafeVisitCharacterDBs = allCharacters.Take(10).ToDictionary(id => id, id => new CafeCharacterDB { UniqueId = id });
|
||||
|
||||
//cafeVisitCharacterDBs.Add(1, new CafeCharacterDB());
|
||||
|
||||
cafeDBs[0].CafeVisitCharacterDBs = cafeVisitCharacterDBs;
|
||||
|
||||
return new CafeGetInfoResponse()
|
||||
{
|
||||
CafeDBs = cafeDBs,
|
||||
|
||||
FurnitureDBs = [
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, ItemDeploySequence = 368862451, ServerId = 368862451, UniqueId = 1, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallRight, CafeDBId = 3091193, ItemDeploySequence = 368862452, ServerId = 368862452, UniqueId = 2, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallLeft, CafeDBId = 3091193, ItemDeploySequence = 368862453, ServerId = 368862453, UniqueId = 3, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallRight, CafeDBId = 3091193, PositionX = 8.5f, PositionY = 3.0f, ItemDeploySequence = 368862454, ServerId = 368862454, UniqueId = 4, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 3.0f, PositionY = 1.5f, Rotation = 270.0f, ItemDeploySequence = 368862455, ServerId = 368862455, UniqueId = 5, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862456, ServerId = 368862456, UniqueId = 6, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 6.5f, ItemDeploySequence = 368862457, ServerId = 368862457, UniqueId = 7, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 9.5f, PositionY = 8.5f, ItemDeploySequence = 368862458, ServerId = 368862458, UniqueId = 8, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 4.5f, PositionY = 0.5f, ItemDeploySequence = 368862459, ServerId = 368862459, UniqueId = 9, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.Floor, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 8.5f, ItemDeploySequence = 368862460, ServerId = 368862460, UniqueId = 10, StackCount = 1},
|
||||
new() { Location = FurnitureLocation.WallLeft, CafeDBId = 3091193, PositionX = 7.5f, PositionY = 3.0f, ItemDeploySequence = 368862461, ServerId = 368862461, UniqueId = 11, StackCount = 1}],
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Ack)]
|
||||
public ResponsePacket Cafe_Ack(CafeAckRequest req)
|
||||
{
|
||||
return new CafeAckResponse();
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Open)]
|
||||
public ResponsePacket Cafe_Open(CafeOpenRequest req)
|
||||
{
|
||||
return new CafeOpenResponse();
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Interact)]
|
||||
public ResponsePacket Cafe_Interact(CafeInteractWithCharacterRequest req)
|
||||
{
|
||||
return new CafeInteractWithCharacterResponse();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
using Microsoft.IdentityModel.Tokens;
|
||||
using SCHALE.Common.Database;
|
||||
using SCHALE.Common.Database.ModelExtensions;
|
||||
using SCHALE.Common.FlatData;
|
||||
using SCHALE.Common.NetworkProtocol;
|
||||
using SCHALE.GameServer.Services;
|
||||
using Serilog;
|
||||
using System.Transactions;
|
||||
|
||||
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||
{
|
||||
public class Cafe : ProtocolHandlerBase
|
||||
{
|
||||
private readonly ISessionKeyService sessionKeyService;
|
||||
private readonly SCHALEContext context;
|
||||
private readonly ExcelTableService excelTableService;
|
||||
|
||||
public Cafe(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
|
||||
{
|
||||
sessionKeyService = _sessionKeyService;
|
||||
context = _context;
|
||||
excelTableService = _excelTableService;
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Get)]
|
||||
public ResponsePacket Cafe_Get(CafeGetInfoRequest req)
|
||||
{
|
||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||
|
||||
return new CafeGetInfoResponse()
|
||||
{
|
||||
CafeDBs = [.. account.Cafes],
|
||||
FurnitureDBs = [.. account.Furnitures]
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Ack)]
|
||||
public ResponsePacket AckHandler(CafeAckRequest req)
|
||||
{
|
||||
return new CafeAckResponse();
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Open)]
|
||||
public ResponsePacket OpenHandler(CafeOpenRequest req)
|
||||
{
|
||||
return new CafeOpenResponse();
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Interact)]
|
||||
public ResponsePacket InteractHandler(CafeInteractWithCharacterRequest req)
|
||||
{
|
||||
return new CafeInteractWithCharacterResponse();
|
||||
}
|
||||
|
||||
|
||||
[ProtocolHandler(Protocol.Cafe_Relocate)]
|
||||
public ResponsePacket RelocateHandler(CafeRelocateFurnitureRequest req)
|
||||
{
|
||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||
|
||||
var targetCafe = account.Cafes.Where(x => x.CafeDBId == req.CafeDBId).SingleOrDefault();
|
||||
var targetFurniture = targetCafe.FurnitureDBs.Where(x => x.CafeDBId == req.CafeDBId && x.ServerId == req.FurnitureDB.ServerId).SingleOrDefault();
|
||||
|
||||
if (targetFurniture == null)
|
||||
{
|
||||
Log.Error("Target Furniture with Id: " + req.FurnitureDB.ServerId + " was not found.");
|
||||
return new ErrorPacket();
|
||||
}
|
||||
|
||||
targetFurniture.PositionX = req.FurnitureDB.PositionX;
|
||||
targetFurniture.PositionY = req.FurnitureDB.PositionY;
|
||||
targetFurniture.Rotation = req.FurnitureDB.Rotation;
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
return new CafeRelocateFurnitureResponse()
|
||||
{
|
||||
CafeDB = targetCafe,
|
||||
RelocatedFurnitureDB = targetFurniture,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue