diff --git a/src/Controllers/Common/ContentController.cs b/src/Controllers/Common/ContentController.cs index 8054a7e..7bf0823 100644 --- a/src/Controllers/Common/ContentController.cs +++ b/src/Controllers/Common/ContentController.cs @@ -25,6 +25,7 @@ public class ContentController : Controller { private NeighborhoodService neighborhoodService; private WorldIdService worldIdService; private BuddyService buddyService; + private MessagingService messagingService; private Random random = new Random(); private readonly IOptions config; @@ -42,6 +43,7 @@ public class ContentController : Controller { NeighborhoodService neighborhoodService, WorldIdService worldIdService, BuddyService buddyService, + MessagingService messagingService, IOptions config ) { this.ctx = ctx; @@ -57,6 +59,7 @@ public class ContentController : Controller { this.neighborhoodService = neighborhoodService; this.worldIdService = worldIdService; this.buddyService = buddyService; + this.messagingService = messagingService; this.config = config; } @@ -1264,6 +1267,28 @@ public class ContentController : Controller { else return Ok(false); } + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/InviteBuddy")] + [VikingSession] + public IActionResult InviteBuddy(Viking viking, [FromForm] Guid buddyUserId) + { + Viking? viking1 = ctx.Vikings.FirstOrDefault(e => e.Uid == buddyUserId); + + if (viking1 != null) messagingService.SendInvite(viking, viking1); + return Ok(true); + } + + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/GetBuddyLocation")] + public IActionResult GetBuddyLocation([FromForm] Guid buddyUserID) + { + Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == buddyUserID); + if (viking != null) return Ok(buddyService.GetLocationOfBuddy(viking)); + else return Ok(new BuddyLocation()); + } + [HttpPost] [Produces("application/xml")] [Route("ContentWebService.asmx/GetBuddyList")] diff --git a/src/Controllers/Common/PrecenseController.cs b/src/Controllers/Common/PrecenseController.cs index d522dea..1741e17 100644 --- a/src/Controllers/Common/PrecenseController.cs +++ b/src/Controllers/Common/PrecenseController.cs @@ -26,5 +26,31 @@ namespace sodoff.Controllers.Common return Ok(viking.Online); } else return Ok(false); } + + [HttpPost] + [Produces("application/json")] + [Route("Precense/SetVikingRoom")] + public IActionResult SetVikingRoom([FromForm] Guid token, [FromForm] int roomId, [FromForm] string zoneName) + { + // get viking from session + Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == token)?.Viking; + + if (viking != null) + { + if (roomId <= 0 && string.IsNullOrEmpty(zoneName)) + { + viking.CurrentRoomId = null; + viking.CurrentZone = null; + ctx.SaveChanges(); + return Ok(true); + } + + viking.CurrentRoomId = roomId; + viking.CurrentZone = zoneName; + ctx.SaveChanges(); + return Ok(true); + } + else return Ok(false); + } } } diff --git a/src/Migrations/20250318195040_Viking_CurrentRoomId.Designer.cs b/src/Migrations/20250318195040_Viking_CurrentRoomId.Designer.cs new file mode 100644 index 0000000..879ac40 --- /dev/null +++ b/src/Migrations/20250318195040_Viking_CurrentRoomId.Designer.cs @@ -0,0 +1,1326 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using sodoff.Model; + +#nullable disable + +namespace sodoff.Migrations +{ + [DbContext(typeof(DBContext))] + [Migration("20250318195040_Viking_CurrentRoomId")] + partial class Viking_CurrentRoomId + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true); + + modelBuilder.Entity("GroupViking", b => + { + b.Property("GroupsId") + .HasColumnType("INTEGER"); + + b.Property("VikingsId") + .HasColumnType("INTEGER"); + + b.HasKey("GroupsId", "VikingsId"); + + b.HasIndex("VikingsId"); + + b.ToTable("GroupViking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "Type"); + + b.ToTable("AchievementPoints"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Points") + .HasColumnType("INTEGER"); + + b.HasKey("TaskId", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("AchievementTaskState"); + }); + + modelBuilder.Entity("sodoff.Model.Buddy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BuddyStatus1") + .HasColumnType("INTEGER"); + + b.Property("BuddyStatus2") + .HasColumnType("INTEGER"); + + b.Property("BuddyVikingId") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("IsBestFriend1") + .HasColumnType("INTEGER"); + + b.Property("IsBestFriend2") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("BuddyVikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Buddies"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EntityId") + .HasColumnType("TEXT"); + + b.Property("PetXP") + .HasColumnType("INTEGER"); + + b.Property("RaisedPetData") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Dragons"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DatePlayed") + .HasColumnType("TEXT"); + + b.Property("Difficulty") + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("GameLevel") + .HasColumnType("INTEGER"); + + b.Property("IsMultiplayer") + .HasColumnType("INTEGER"); + + b.Property("Loss") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Win") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDataId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GameDataId"); + + b.ToTable("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApiKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Color") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GroupID") + .HasColumnType("TEXT"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.Property("ImageType") + .HasColumnType("TEXT"); + + b.Property("ImageSlot") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("ImageData") + .HasColumnType("TEXT"); + + b.Property("TemplateName") + .HasColumnType("TEXT"); + + b.HasKey("ImageType", "ImageSlot", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AttributesSerialized") + .HasColumnType("TEXT"); + + b.Property("ItemId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.Property("StatsSerialized") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("InventoryItems"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MMORoles"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConversationID") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("IsDeleted") + .HasColumnType("INTEGER"); + + b.Property("IsNew") + .HasColumnType("INTEGER"); + + b.Property("IsPrivate") + .HasColumnType("INTEGER"); + + b.Property("LastUpdatedAt") + .HasColumnType("TEXT"); + + b.Property("MemberMessage") + .HasColumnType("TEXT"); + + b.Property("MessageLevel") + .HasColumnType("INTEGER"); + + b.Property("MessageType") + .HasColumnType("INTEGER"); + + b.Property("MessageTypeID") + .HasColumnType("INTEGER"); + + b.Property("NonMemberMessage") + .HasColumnType("TEXT"); + + b.Property("ParentMessageId") + .HasColumnType("INTEGER"); + + b.Property("QueueID") + .HasColumnType("INTEGER"); + + b.Property("ToVikingId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ParentMessageId"); + + b.HasIndex("ToVikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("MissionStatus") + .HasColumnType("INTEGER"); + + b.Property("UserAccepted") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MissionStates"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Slot0") + .HasColumnType("TEXT"); + + b.Property("Slot1") + .HasColumnType("TEXT"); + + b.Property("Slot2") + .HasColumnType("TEXT"); + + b.Property("Slot3") + .HasColumnType("TEXT"); + + b.Property("Slot4") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId") + .IsUnique(); + + b.ToTable("Neighborhoods"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MasterId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MasterId"); + + b.ToTable("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DragonId") + .HasColumnType("INTEGER"); + + b.Property("PairId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DragonId"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssetBundle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("Location") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LocationIconAsset") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PrivateParty") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Parties"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AnswerID") + .HasColumnType("INTEGER"); + + b.Property("QuestionID") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("ProfileAnswers"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("RankId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RankId"); + + b.HasIndex("VikingId"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryID") + .HasColumnType("INTEGER"); + + b.Property("Rank") + .HasColumnType("INTEGER"); + + b.Property("RatedEntityID") + .HasColumnType("INTEGER"); + + b.Property("RatedUserID") + .HasColumnType("TEXT"); + + b.Property("RatingAverage") + .HasColumnType("REAL"); + + b.Property("UpdateDate") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("RatingRanks"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("RoomId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Rooms"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RoomId") + .HasColumnType("INTEGER"); + + b.Property("RoomItemData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoomId"); + + b.ToTable("RoomItems"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("SaveId") + .HasColumnType("INTEGER"); + + b.Property("SerializedData") + .HasColumnType("TEXT"); + + b.HasKey("VikingId", "SaveId"); + + b.ToTable("SavedData"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("SceneName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("XmlData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("SceneData"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.Property("ApiToken") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("ApiToken"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("Completed") + .HasColumnType("INTEGER"); + + b.Property("Payload") + .HasColumnType("TEXT"); + + b.HasKey("Id", "VikingId", "MissionId"); + + b.HasIndex("VikingId"); + + b.ToTable("TaskStatuses"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BadgeId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("UserBadgesCompleted"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("UserBanType") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("WorldId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("IsCompleted") + .HasColumnType("INTEGER"); + + b.Property("StepId") + .HasColumnType("INTEGER"); + + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "WorldId", "MissionId"); + + b.ToTable("UserMissionData"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvatarSerialized") + .HasColumnType("TEXT"); + + b.Property("BirthDate") + .HasColumnType("TEXT"); + + b.Property("BuddyCode") + .HasColumnType("TEXT"); + + b.Property("CreationDate") + .HasColumnType("TEXT"); + + b.Property("CurrentRoomId") + .HasColumnType("INTEGER"); + + b.Property("GameVersion") + .HasColumnType("INTEGER"); + + b.Property("Gender") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Online") + .HasColumnType("INTEGER"); + + b.Property("SelectedDragonId") + .HasColumnType("INTEGER"); + + b.Property("Uid") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SelectedDragonId") + .IsUnique(); + + b.HasIndex("Uid"); + + b.HasIndex("UserId"); + + b.ToTable("Vikings"); + }); + + modelBuilder.Entity("GroupViking", b => + { + b.HasOne("sodoff.Model.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", null) + .WithMany() + .HasForeignKey("VikingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementPoints") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementTaskStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Buddy", b => + { + b.HasOne("sodoff.Model.Viking", "BuddyViking") + .WithMany("BuddyList") + .HasForeignKey("BuddyVikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("BuddiesMade") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BuddyViking"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Dragons") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("GameData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.HasOne("sodoff.Model.GameData", "GameData") + .WithMany("GameDataPairs") + .HasForeignKey("GameDataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Images") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("InventoryItems") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MMORoles") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.HasOne("sodoff.Model.Message", "ParentMessage") + .WithMany("Replies") + .HasForeignKey("ParentMessageId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "ToViking") + .WithMany("MessageBoard") + .HasForeignKey("ToVikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MessagesMade") + .HasForeignKey("VikingId"); + + b.Navigation("ParentMessage"); + + b.Navigation("ToViking"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MissionStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithOne("Neighborhood") + .HasForeignKey("sodoff.Model.Neighborhood", "VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.HasOne("sodoff.Model.PairData", "PairData") + .WithMany("Pairs") + .HasForeignKey("MasterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.HasOne("sodoff.Model.Dragon", "Dragon") + .WithMany("PairData") + .HasForeignKey("DragonId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("PairData") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("PairData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Dragon"); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Parties") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("ProfileAnswers") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.HasOne("sodoff.Model.RatingRank", "Rank") + .WithMany("Ratings") + .HasForeignKey("RankId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Ratings") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Rank"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Rooms") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.HasOne("sodoff.Model.Room", "Room") + .WithMany("Items") + .HasForeignKey("RoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Room"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SavedData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SceneData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.HasOne("sodoff.Model.User", "User") + .WithMany("Sessions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Sessions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("TaskStatuses") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBadgesCompleted") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBans") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserMissions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.HasOne("sodoff.Model.Dragon", "SelectedDragon") + .WithOne() + .HasForeignKey("sodoff.Model.Viking", "SelectedDragonId"); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("Vikings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SelectedDragon"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Navigation("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Navigation("Replies"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Navigation("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Navigation("PairData"); + + b.Navigation("Sessions"); + + b.Navigation("Vikings"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Navigation("AchievementPoints"); + + b.Navigation("AchievementTaskStates"); + + b.Navigation("BuddiesMade"); + + b.Navigation("BuddyList"); + + b.Navigation("Dragons"); + + b.Navigation("GameData"); + + b.Navigation("Images"); + + b.Navigation("InventoryItems"); + + b.Navigation("MMORoles"); + + b.Navigation("MessageBoard"); + + b.Navigation("MessagesMade"); + + b.Navigation("MissionStates"); + + b.Navigation("Neighborhood"); + + b.Navigation("PairData"); + + b.Navigation("Parties"); + + b.Navigation("ProfileAnswers"); + + b.Navigation("Ratings"); + + b.Navigation("Rooms"); + + b.Navigation("SavedData"); + + b.Navigation("SceneData"); + + b.Navigation("Sessions"); + + b.Navigation("TaskStatuses"); + + b.Navigation("UserBadgesCompleted"); + + b.Navigation("UserBans"); + + b.Navigation("UserMissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20250318195040_Viking_CurrentRoomId.cs b/src/Migrations/20250318195040_Viking_CurrentRoomId.cs new file mode 100644 index 0000000..1443c8e --- /dev/null +++ b/src/Migrations/20250318195040_Viking_CurrentRoomId.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace sodoff.Migrations +{ + /// + public partial class Viking_CurrentRoomId : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CurrentRoomId", + table: "Vikings", + type: "INTEGER", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CurrentRoomId", + table: "Vikings"); + } + } +} diff --git a/src/Migrations/20250318223639_Viking_CurrentZone.Designer.cs b/src/Migrations/20250318223639_Viking_CurrentZone.Designer.cs new file mode 100644 index 0000000..5b211e5 --- /dev/null +++ b/src/Migrations/20250318223639_Viking_CurrentZone.Designer.cs @@ -0,0 +1,1329 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using sodoff.Model; + +#nullable disable + +namespace sodoff.Migrations +{ + [DbContext(typeof(DBContext))] + [Migration("20250318223639_Viking_CurrentZone")] + partial class Viking_CurrentZone + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true); + + modelBuilder.Entity("GroupViking", b => + { + b.Property("GroupsId") + .HasColumnType("INTEGER"); + + b.Property("VikingsId") + .HasColumnType("INTEGER"); + + b.HasKey("GroupsId", "VikingsId"); + + b.HasIndex("VikingsId"); + + b.ToTable("GroupViking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "Type"); + + b.ToTable("AchievementPoints"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Points") + .HasColumnType("INTEGER"); + + b.HasKey("TaskId", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("AchievementTaskState"); + }); + + modelBuilder.Entity("sodoff.Model.Buddy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BuddyStatus1") + .HasColumnType("INTEGER"); + + b.Property("BuddyStatus2") + .HasColumnType("INTEGER"); + + b.Property("BuddyVikingId") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("IsBestFriend1") + .HasColumnType("INTEGER"); + + b.Property("IsBestFriend2") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("BuddyVikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Buddies"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EntityId") + .HasColumnType("TEXT"); + + b.Property("PetXP") + .HasColumnType("INTEGER"); + + b.Property("RaisedPetData") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Dragons"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DatePlayed") + .HasColumnType("TEXT"); + + b.Property("Difficulty") + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("GameLevel") + .HasColumnType("INTEGER"); + + b.Property("IsMultiplayer") + .HasColumnType("INTEGER"); + + b.Property("Loss") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("Win") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDataId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GameDataId"); + + b.ToTable("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApiKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Color") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GroupID") + .HasColumnType("TEXT"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.Property("ImageType") + .HasColumnType("TEXT"); + + b.Property("ImageSlot") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("ImageData") + .HasColumnType("TEXT"); + + b.Property("TemplateName") + .HasColumnType("TEXT"); + + b.HasKey("ImageType", "ImageSlot", "VikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AttributesSerialized") + .HasColumnType("TEXT"); + + b.Property("ItemId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("INTEGER"); + + b.Property("StatsSerialized") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("InventoryItems"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MMORoles"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConversationID") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("IsDeleted") + .HasColumnType("INTEGER"); + + b.Property("IsNew") + .HasColumnType("INTEGER"); + + b.Property("IsPrivate") + .HasColumnType("INTEGER"); + + b.Property("LastUpdatedAt") + .HasColumnType("TEXT"); + + b.Property("MemberMessage") + .HasColumnType("TEXT"); + + b.Property("MessageLevel") + .HasColumnType("INTEGER"); + + b.Property("MessageType") + .HasColumnType("INTEGER"); + + b.Property("MessageTypeID") + .HasColumnType("INTEGER"); + + b.Property("NonMemberMessage") + .HasColumnType("TEXT"); + + b.Property("ParentMessageId") + .HasColumnType("INTEGER"); + + b.Property("QueueID") + .HasColumnType("INTEGER"); + + b.Property("ToVikingId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ParentMessageId"); + + b.HasIndex("ToVikingId"); + + b.HasIndex("VikingId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("MissionStatus") + .HasColumnType("INTEGER"); + + b.Property("UserAccepted") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("MissionStates"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Slot0") + .HasColumnType("TEXT"); + + b.Property("Slot1") + .HasColumnType("TEXT"); + + b.Property("Slot2") + .HasColumnType("TEXT"); + + b.Property("Slot3") + .HasColumnType("TEXT"); + + b.Property("Slot4") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId") + .IsUnique(); + + b.ToTable("Neighborhoods"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MasterId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MasterId"); + + b.ToTable("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DragonId") + .HasColumnType("INTEGER"); + + b.Property("PairId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DragonId"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AssetBundle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("Location") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LocationIconAsset") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PrivateParty") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Parties"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AnswerID") + .HasColumnType("INTEGER"); + + b.Property("QuestionID") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("ProfileAnswers"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("RankId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RankId"); + + b.HasIndex("VikingId"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryID") + .HasColumnType("INTEGER"); + + b.Property("Rank") + .HasColumnType("INTEGER"); + + b.Property("RatedEntityID") + .HasColumnType("INTEGER"); + + b.Property("RatedUserID") + .HasColumnType("TEXT"); + + b.Property("RatingAverage") + .HasColumnType("REAL"); + + b.Property("UpdateDate") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("RatingRanks"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("RoomId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Rooms"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RoomId") + .HasColumnType("INTEGER"); + + b.Property("RoomItemData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoomId"); + + b.ToTable("RoomItems"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("SaveId") + .HasColumnType("INTEGER"); + + b.Property("SerializedData") + .HasColumnType("TEXT"); + + b.HasKey("VikingId", "SaveId"); + + b.ToTable("SavedData"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("SceneName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("XmlData") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("SceneData"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.Property("ApiToken") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("ApiToken"); + + b.HasIndex("UserId"); + + b.HasIndex("VikingId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("Completed") + .HasColumnType("INTEGER"); + + b.Property("Payload") + .HasColumnType("TEXT"); + + b.HasKey("Id", "VikingId", "MissionId"); + + b.HasIndex("VikingId"); + + b.ToTable("TaskStatuses"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BadgeId") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("UserBadgesCompleted"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("ExpiresOn") + .HasColumnType("TEXT"); + + b.Property("UserBanType") + .HasColumnType("INTEGER"); + + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VikingId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.Property("VikingId") + .HasColumnType("INTEGER"); + + b.Property("WorldId") + .HasColumnType("INTEGER"); + + b.Property("MissionId") + .HasColumnType("INTEGER"); + + b.Property("IsCompleted") + .HasColumnType("INTEGER"); + + b.Property("StepId") + .HasColumnType("INTEGER"); + + b.Property("TaskId") + .HasColumnType("INTEGER"); + + b.HasKey("VikingId", "WorldId", "MissionId"); + + b.ToTable("UserMissionData"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvatarSerialized") + .HasColumnType("TEXT"); + + b.Property("BirthDate") + .HasColumnType("TEXT"); + + b.Property("BuddyCode") + .HasColumnType("TEXT"); + + b.Property("CreationDate") + .HasColumnType("TEXT"); + + b.Property("CurrentRoomId") + .HasColumnType("INTEGER"); + + b.Property("CurrentZone") + .HasColumnType("TEXT"); + + b.Property("GameVersion") + .HasColumnType("INTEGER"); + + b.Property("Gender") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Online") + .HasColumnType("INTEGER"); + + b.Property("SelectedDragonId") + .HasColumnType("INTEGER"); + + b.Property("Uid") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SelectedDragonId") + .IsUnique(); + + b.HasIndex("Uid"); + + b.HasIndex("UserId"); + + b.ToTable("Vikings"); + }); + + modelBuilder.Entity("GroupViking", b => + { + b.HasOne("sodoff.Model.Group", null) + .WithMany() + .HasForeignKey("GroupsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", null) + .WithMany() + .HasForeignKey("VikingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("sodoff.Model.AchievementPoints", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementPoints") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.AchievementTaskState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("AchievementTaskStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Buddy", b => + { + b.HasOne("sodoff.Model.Viking", "BuddyViking") + .WithMany("BuddyList") + .HasForeignKey("BuddyVikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("BuddiesMade") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BuddyViking"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Dragons") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("GameData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.GameDataPair", b => + { + b.HasOne("sodoff.Model.GameData", "GameData") + .WithMany("GameDataPairs") + .HasForeignKey("GameDataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GameData"); + }); + + modelBuilder.Entity("sodoff.Model.Image", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Images") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.InventoryItem", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("InventoryItems") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MMORole", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MMORoles") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.HasOne("sodoff.Model.Message", "ParentMessage") + .WithMany("Replies") + .HasForeignKey("ParentMessageId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "ToViking") + .WithMany("MessageBoard") + .HasForeignKey("ToVikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MessagesMade") + .HasForeignKey("VikingId"); + + b.Navigation("ParentMessage"); + + b.Navigation("ToViking"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.MissionState", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("MissionStates") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Neighborhood", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithOne("Neighborhood") + .HasForeignKey("sodoff.Model.Neighborhood", "VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Pair", b => + { + b.HasOne("sodoff.Model.PairData", "PairData") + .WithMany("Pairs") + .HasForeignKey("MasterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.HasOne("sodoff.Model.Dragon", "Dragon") + .WithMany("PairData") + .HasForeignKey("DragonId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("PairData") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("PairData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Dragon"); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Party", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Parties") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.ProfileAnswer", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("ProfileAnswers") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Rating", b => + { + b.HasOne("sodoff.Model.RatingRank", "Rank") + .WithMany("Ratings") + .HasForeignKey("RankId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Ratings") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Rank"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Rooms") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.RoomItem", b => + { + b.HasOne("sodoff.Model.Room", "Room") + .WithMany("Items") + .HasForeignKey("RoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Room"); + }); + + modelBuilder.Entity("sodoff.Model.SavedData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SavedData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.SceneData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("SceneData") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Session", b => + { + b.HasOne("sodoff.Model.User", "User") + .WithMany("Sessions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("Sessions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.TaskStatus", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("TaskStatuses") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBadgeCompleteData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBadgesCompleted") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserBan", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserBans") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.UserMissionData", b => + { + b.HasOne("sodoff.Model.Viking", "Viking") + .WithMany("UserMissions") + .HasForeignKey("VikingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viking"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.HasOne("sodoff.Model.Dragon", "SelectedDragon") + .WithOne() + .HasForeignKey("sodoff.Model.Viking", "SelectedDragonId"); + + b.HasOne("sodoff.Model.User", "User") + .WithMany("Vikings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SelectedDragon"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("sodoff.Model.Dragon", b => + { + b.Navigation("PairData"); + }); + + modelBuilder.Entity("sodoff.Model.GameData", b => + { + b.Navigation("GameDataPairs"); + }); + + modelBuilder.Entity("sodoff.Model.Message", b => + { + b.Navigation("Replies"); + }); + + modelBuilder.Entity("sodoff.Model.PairData", b => + { + b.Navigation("Pairs"); + }); + + modelBuilder.Entity("sodoff.Model.RatingRank", b => + { + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("sodoff.Model.Room", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("sodoff.Model.User", b => + { + b.Navigation("PairData"); + + b.Navigation("Sessions"); + + b.Navigation("Vikings"); + }); + + modelBuilder.Entity("sodoff.Model.Viking", b => + { + b.Navigation("AchievementPoints"); + + b.Navigation("AchievementTaskStates"); + + b.Navigation("BuddiesMade"); + + b.Navigation("BuddyList"); + + b.Navigation("Dragons"); + + b.Navigation("GameData"); + + b.Navigation("Images"); + + b.Navigation("InventoryItems"); + + b.Navigation("MMORoles"); + + b.Navigation("MessageBoard"); + + b.Navigation("MessagesMade"); + + b.Navigation("MissionStates"); + + b.Navigation("Neighborhood"); + + b.Navigation("PairData"); + + b.Navigation("Parties"); + + b.Navigation("ProfileAnswers"); + + b.Navigation("Ratings"); + + b.Navigation("Rooms"); + + b.Navigation("SavedData"); + + b.Navigation("SceneData"); + + b.Navigation("Sessions"); + + b.Navigation("TaskStatuses"); + + b.Navigation("UserBadgesCompleted"); + + b.Navigation("UserBans"); + + b.Navigation("UserMissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20250318223639_Viking_CurrentZone.cs b/src/Migrations/20250318223639_Viking_CurrentZone.cs new file mode 100644 index 0000000..63130fb --- /dev/null +++ b/src/Migrations/20250318223639_Viking_CurrentZone.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace sodoff.Migrations +{ + /// + public partial class Viking_CurrentZone : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CurrentZone", + table: "Vikings", + type: "TEXT", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CurrentZone", + table: "Vikings"); + } + } +} diff --git a/src/Migrations/DBContextModelSnapshot.cs b/src/Migrations/DBContextModelSnapshot.cs index ce20490..0f64e78 100644 --- a/src/Migrations/DBContextModelSnapshot.cs +++ b/src/Migrations/DBContextModelSnapshot.cs @@ -823,6 +823,12 @@ namespace sodoff.Migrations b.Property("CreationDate") .HasColumnType("TEXT"); + b.Property("CurrentRoomId") + .HasColumnType("INTEGER"); + + b.Property("CurrentZone") + .HasColumnType("TEXT"); + b.Property("GameVersion") .HasColumnType("INTEGER"); diff --git a/src/Model/Viking.cs b/src/Model/Viking.cs index 50418d1..11da4d6 100644 --- a/src/Model/Viking.cs +++ b/src/Model/Viking.cs @@ -24,6 +24,8 @@ public class Viking { public int? SelectedDragonId { get; set; } public bool? Online { get; set; } + public int? CurrentRoomId { get; set; } + public string? CurrentZone { get; set; } public virtual ICollection Sessions { get; set; } = null!; public virtual User User { get; set; } = null!; diff --git a/src/Schema/BuddyLocation.cs b/src/Schema/BuddyLocation.cs new file mode 100644 index 0000000..87baf96 --- /dev/null +++ b/src/Schema/BuddyLocation.cs @@ -0,0 +1,33 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema +{ + [XmlRoot(ElementName = "BuddyLocation", Namespace = "")] + [Serializable] + public class BuddyLocation + { + [XmlElement(ElementName = "UserID")] + public string UserID; + + [XmlElement(ElementName = "Server")] + public string Server; + + [XmlElement(ElementName = "Zone")] + public string Zone; + + [XmlElement(ElementName = "Room")] + public string Room; + + [XmlElement(ElementName = "MultiplayerID")] + public int MultiplayerID; + + [XmlElement(ElementName = "ServerVersion")] + public string ServerVersion; + + [XmlElement(ElementName = "AppName")] + public string AppName; + + [XmlElement(ElementName = "ServerPort")] + public int ServerPort; + } +} diff --git a/src/Services/BuddyService.cs b/src/Services/BuddyService.cs index c3abd93..7771989 100644 --- a/src/Services/BuddyService.cs +++ b/src/Services/BuddyService.cs @@ -1,6 +1,8 @@ using System; using System.Data; using System.Security; +using Microsoft.Extensions.Options; +using sodoff.Configuration; using sodoff.Model; using sodoff.Schema; using sodoff.Util; @@ -15,12 +17,14 @@ public class BuddyService private readonly DBContext ctx; private readonly MessagingService messagingService; private readonly MMOClientService mMOClientService; + private readonly IOptions config; - public BuddyService(DBContext ctx, MessagingService messagingService, MMOClientService mMOClientService) + public BuddyService(DBContext ctx, MessagingService messagingService, MMOClientService mMOClientService, IOptions config) { this.ctx = ctx; this.messagingService = messagingService; this.mMOClientService = mMOClientService; + this.config = config; } public BuddyActionResult CreateBuddyRelation(Viking viking1, Viking viking2, BuddyStatus buddyStatus1 = BuddyStatus.PendingApprovalFromOther, BuddyStatus buddyStatus2 = BuddyStatus.PendingApprovalFromSelf) @@ -176,6 +180,31 @@ public class BuddyService else return false; } + public BuddyLocation GetLocationOfBuddy(Viking viking) + { + if (viking.CurrentRoomId != null && viking.CurrentZone != null) + { + // construct + BuddyLocation buddyLocation = new() + { + UserID = viking.Uid.ToString(), + Room = viking.CurrentRoomId.Value.ToString(), + Server = config.Value.MMOAdress, + ServerPort = config.Value.MMOPort, + ServerVersion = "S2X", + Zone = viking.CurrentZone, + MultiplayerID = viking.CurrentRoomId.Value + }; + + if (viking.GameVersion <= ClientVersion.WoJS) buddyLocation.AppName = "JSMain"; + else if (viking.GameVersion <= ClientVersion.MB) buddyLocation.AppName = "MBMain"; + + // return + return buddyLocation; + } + else return new BuddyLocation(); + } + public BuddyList ConstructBuddyList(Viking viking) { // get all relationships viking has made diff --git a/src/Services/MMOClientService.cs b/src/Services/MMOClientService.cs index a51a9ac..6691db5 100644 --- a/src/Services/MMOClientService.cs +++ b/src/Services/MMOClientService.cs @@ -45,12 +45,14 @@ public class MMOClientService : IHostedService SFSClient.Connect(SFSConfig); SFSClient.AddEventListener(SFSEvent.CONNECTION, OnConnectionEstablished); + SFSClient.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); SFSClient.AddEventListener(SFSEvent.LOGIN, OnLogin); // return completed task (SmartFox seems to be completely synchronous) return Task.CompletedTask; } + public Task SetRoomVarForRoom(int roomId, RoomVariable var) { if (IsLoggedIn) @@ -100,6 +102,12 @@ public class MMOClientService : IHostedService } } + private void OnConnectionLost(BaseEvent evt) + { + Console.WriteLine($"Connection To The MMO Server Was Lost. Reason - {(string)evt.Params["reason"]}"); + Console.WriteLine("MMO Service Currently Not Ready.\nThis Required A Full API Restart For Realtime Communication To Be Reestablished."); + } + private void OnLogin(BaseEvent evt) { CurrentUser = (User)evt.Params["user"]; diff --git a/src/Services/MessagingService.cs b/src/Services/MessagingService.cs index 1967dbd..f50332b 100644 --- a/src/Services/MessagingService.cs +++ b/src/Services/MessagingService.cs @@ -68,7 +68,7 @@ public class MessagingService message.ConversationID = messageToReplyTo.ConversationID; // add a message to the replier's board saying a thread update has occured (if reply isn't to self) - if (message.VikingId != message.ToVikingId) AddMessageToViking(message.Viking, message.ToViking, MessageType.Data, MessageTypeID.ThreadUpdate, MessageLevel.WhiteList, "[[Line1]]=[[{{BuddyUserName}} Replied To Your Message In {{BuddyUserName}}'s Message Board!]]", "[[Line1]]=[[{{BuddyUserName}} Replied To Your Message In {{BuddyUserName}}'s Message Board!]]", "[[Line1]]=[[{{BuddyUserName}} Replied To Your Message In {{BuddyUserName}}'s Message Board!]]", isPrivate: true); + if (message.VikingId != message.ToVikingId) AddMessageToViking(message.Viking, message.ToViking, MessageType.Data, MessageTypeID.ThreadUpdate, MessageLevel.WhiteList, "[[Line1]]=[[{{BuddyUserName}} Replied To Your Message In {{OwnerUserName}}'s Message Board!]]", "[[Line1]]=[[{{BuddyUserName}} Replied To Your Message In {{OwnerUserName}}'s Message Board!]]", "[[Line1]]=[[{{BuddyUserName}} Replied To Your Message In {{OwnerUserName}}'s Message Board!]]", isPrivate: true); } else throw new InvalidOperationException("Tried To Reply To A Message That Doesn't Exist"); } @@ -87,6 +87,14 @@ public class MessagingService return message; } + public void SendInvite(Viking viking, Viking buddyViking) + { + if(buddyViking.Online ?? false) // TODO - also account for LIMBO + { + mMOClientService.SendCommandToUser(buddyViking.Uid.ToString(), "SPI", new string[] { "SPI", "-1", viking.Uid.ToString(), "1", "5" }); + } + } + public void RemoveMessage(int id) { // find message @@ -269,7 +277,7 @@ public class MessagingService Viking? msgAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == message.VikingId) ?? new Viking(); if(message.IsDeleted && !showDeletedMessages) { ctx.Messages.Remove(message); continue; } - if(DateTime.Compare(now, message.CreatedAt.AddMinutes(30)) > 0 && !showOldMessages) { message.IsNew = false; continue; } // sometimes clients won't set IsNew flag when updating messages, so do not add messages more than 30 minutes old to response + if(DateTime.Compare(now, message.CreatedAt.AddMinutes(5)) > 0 && !showOldMessages) { message.IsNew = false; continue; } // sometimes clients won't set IsNew flag when updating messages, so do not add messages more than 30 minutes old to response if(!message.IsNew && !showOldMessages) continue; MessageInfo messageInfo = new MessageInfo