From b090604bc124b5b0126169d0e9cf9e34a0f5c993 Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Thu, 6 Mar 2025 12:35:25 -0800 Subject: [PATCH] add message for earning xp (wojs) --- src/Services/AchievementService.cs | 8 +++++++- src/Services/MessagingService.cs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Services/AchievementService.cs b/src/Services/AchievementService.cs index 7e89658..771bc7e 100644 --- a/src/Services/AchievementService.cs +++ b/src/Services/AchievementService.cs @@ -9,11 +9,13 @@ namespace sodoff.Services { public class AchievementService { private AchievementStoreSingleton achievementStore; private InventoryService inventoryService; + private MessagingService messagingService; public readonly DBContext ctx; - public AchievementService(AchievementStoreSingleton achievementStore, InventoryService inventoryService, DBContext ctx) { + public AchievementService(AchievementStoreSingleton achievementStore, InventoryService inventoryService, MessagingService messagingService, DBContext ctx) { this.achievementStore = achievementStore; this.inventoryService = inventoryService; + this.messagingService = messagingService; this.ctx = ctx; } @@ -137,6 +139,10 @@ namespace sodoff.Services { grantedRewards.Add( ApplyAchievementReward(viking, reward) ); + + // add message for earning xp (wojs) + if (reward.PointTypeID == AchievementPointTypes.PlayerXP && viking.GameVersion <= ClientVersion.WoJS) + messagingService.AddMessageToViking(null, viking, MessageType.Data, MessageTypeID.Jumpstar, MessageLevel.WhiteList, $"[[Line1]]=[[Congratulations, You've Earned {reward.Amount} JumpStars!]]", $"[[Line1]]=[[Congratulations, You've Earned {reward.Amount} JumpStars!]]", $"[[Line1]]=[[Congratulations, You've Earned {reward.Amount} JumpStars!]]"); } } diff --git a/src/Services/MessagingService.cs b/src/Services/MessagingService.cs index fc13216..958916f 100644 --- a/src/Services/MessagingService.cs +++ b/src/Services/MessagingService.cs @@ -128,7 +128,7 @@ public class MessagingService continue; } - if (message.IsPrivate && (viking.Id != publicViking.Id)) continue; + if (message.IsPrivate && (viking.Id != publicViking.Id) || message.VikingId == -1) continue; Viking? msgAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == message.VikingId) ?? new Viking(); @@ -259,7 +259,7 @@ public class MessagingService { Viking? msgAuthor = ctx.Vikings.FirstOrDefault(e => e.Id == message.VikingId) ?? new Viking(); - if(message.IsDeleted) { ctx.Messages.Remove(message); continue; } + 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(!message.IsNew && !showOldMessages) continue; messageInfos.Add(new MessageInfo