add message for earning xp (wojs)

This commit is contained in:
Alan Moon 2025-03-06 12:35:25 -08:00
parent 7e29d5cd4a
commit b090604bc1
2 changed files with 9 additions and 3 deletions

View File

@ -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!]]");
}
}

View File

@ -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