diff --git a/Core/Generators/BotLevelGenerator.cs b/Core/Generators/BotLevelGenerator.cs
index 6f5dc9dd..d074ef8a 100644
--- a/Core/Generators/BotLevelGenerator.cs
+++ b/Core/Generators/BotLevelGenerator.cs
@@ -42,7 +42,7 @@ public class BotLevelGenerator
var botLevelRange = GetRelativeBotLevelRange(botGenerationDetails, levelDetails, expTable.Length);
// Get random level based on the exp table.
- double exp = 0;
+ int exp = 0;
var level = int.Parse(ChooseBotLevel(botLevelRange.Min.Value, botLevelRange.Max.Value, 1, 1.15).ToString()); // TODO - nasty double to string to int conversion
for (var i = 0; i < level; i++)
{
@@ -52,7 +52,7 @@ public class BotLevelGenerator
// Sprinkle in some random exp within the level, unless we are at max level.
if (level < expTable.Length - 1)
{
- exp += _randomUtil.GetDouble(0, expTable[level].Experience.Value - 1);
+ exp += _randomUtil.GetInt(0, expTable[level].Experience.Value - 1);
}
return new RandomisedBotLevelResult{ Level = level, Exp = exp };
diff --git a/Core/Helpers/DialogueHelper.cs b/Core/Helpers/DialogueHelper.cs
index 5d4c2f05..afef1631 100644
--- a/Core/Helpers/DialogueHelper.cs
+++ b/Core/Helpers/DialogueHelper.cs
@@ -1,12 +1,46 @@
using Core.Annotations;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Profile;
+using Core.Servers;
+using Core.Services;
+using Core.Utils;
+using ILogger = Core.Models.Utils.ILogger;
namespace Core.Helpers;
[Injectable]
public class DialogueHelper
{
+ private readonly ILogger _logger;
+ private readonly HashUtil _hashUtil;
+ private readonly SaveServer _saveServer;
+ private readonly DatabaseServer _databaseServer;
+ private readonly NotifierHelper _notifierHelper;
+ private readonly NotificationSendHelper _notificationSendHelper;
+ private readonly LocalisationService _localisationService;
+ private readonly ItemHelper _itemHelper;
+
+ public DialogueHelper
+ (
+ ILogger logger,
+ HashUtil hashUtil,
+ SaveServer saveServer,
+ DatabaseServer databaseServer,
+ NotifierHelper notifierHelper,
+ NotificationSendHelper notificationSendHelper,
+ LocalisationService localisationService,
+ ItemHelper itemHelper
+ )
+ {
+ _logger = logger;
+ _hashUtil = hashUtil;
+ _saveServer = saveServer;
+ _databaseServer = databaseServer;
+ _notifierHelper = notifierHelper;
+ _localisationService = localisationService;
+ _itemHelper = itemHelper;
+ }
+
///
/// Get the preview contents of the last message in a dialogue.
///
@@ -14,7 +48,23 @@ public class DialogueHelper
/// MessagePreview
public MessagePreview GetMessagePreview(Models.Eft.Profile.Dialogue dialogue)
{
- throw new NotImplementedException();
+ // The last message of the dialogue should be shown on the preview.
+ var message = dialogue.Messages[dialogue.Messages.Count - 1];
+ MessagePreview result = new()
+ {
+ DateTime = message?.DateTime,
+ MessageType = message?.MessageType,
+ TemplateId = message?.TemplateId,
+ UserId = dialogue?.Id
+ };
+
+ if (message?.Text is not null)
+ result.Text = message.Text;
+
+ if (message?.SystemData is not null)
+ result.SystemData = message?.SystemData;
+
+ return result;
}
///
@@ -26,7 +76,36 @@ public class DialogueHelper
///
public List- GetMessageItemContents(string messageID, string sessionID, string itemId)
{
- throw new NotImplementedException();
+ var dialogueData = _saveServer.GetProfile(sessionID).DialogueRecords;
+ foreach (var dialogue in dialogueData)
+ {
+ var message = dialogueData[dialogue.Key].Messages.FirstOrDefault(x => x.Id == messageID);
+ if (message is null)
+ continue;
+
+ if (message.Id == messageID)
+ {
+ var attachmentsNew = _saveServer.GetProfile(sessionID).DialogueRecords[dialogue.Key].AttachmentsNew;
+ if (attachmentsNew > 0)
+ _saveServer.GetProfile(sessionID).DialogueRecords[dialogue.Key].AttachmentsNew = attachmentsNew - 1;
+
+ // Check reward count when item being moved isn't in reward list
+ // If count is 0, it means after this move occurs the reward array will be empty and all rewards collected
+ if (message.Items.Data is null)
+ message.Items.Data = new();
+
+ var rewardItems = message.Items.Data?.Where(x => x.Id != itemId);
+ if (rewardItems.Count() == 0)
+ {
+ message.RewardCollected = true;
+ message.HasRewards = false;
+ }
+
+ return message.Items.Data;
+ }
+ }
+
+ return new List
- ();
}
///
@@ -36,6 +115,26 @@ public class DialogueHelper
/// Dialog dictionary
public Dictionary GetDialogsForProfile(string sessionId)
{
- throw new NotImplementedException();
+ var profile = _saveServer.GetProfile(sessionId);
+ if (profile.DialogueRecords is null)
+ profile.DialogueRecords = new();
+
+ return profile.DialogueRecords;
+ }
+
+ public Models.Eft.Profile.Dialogue? GetDialogueFromProfile(string profileId, string dialogueId)
+ {
+ Models.Eft.Profile.Dialogue? returnDialogue = null;
+ var dialogues = GetDialogsForProfile(profileId);
+
+ foreach (var dialogue in dialogues.Values)
+ {
+ if (dialogue.Id == dialogueId)
+ returnDialogue = dialogue;
+
+ break;
+ }
+
+ return returnDialogue;
}
}
diff --git a/Core/Models/Eft/Bot/RandomisedBotLevelResult.cs b/Core/Models/Eft/Bot/RandomisedBotLevelResult.cs
index d9187556..82bce567 100644
--- a/Core/Models/Eft/Bot/RandomisedBotLevelResult.cs
+++ b/Core/Models/Eft/Bot/RandomisedBotLevelResult.cs
@@ -1,12 +1,12 @@
-using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
namespace Core.Models.Eft.Bot;
public class RandomisedBotLevelResult
{
[JsonPropertyName("level")]
- public double? Level { get; set; }
+ public int? Level { get; set; }
[JsonPropertyName("exp")]
- public double? Exp { get; set; }
+ public int? Exp { get; set; }
}
diff --git a/Core/Models/Eft/Common/Globals.cs b/Core/Models/Eft/Common/Globals.cs
index 880d7786..f1c7609c 100644
--- a/Core/Models/Eft/Common/Globals.cs
+++ b/Core/Models/Eft/Common/Globals.cs
@@ -1,4 +1,4 @@
-using Core.Models.Eft.Common.Tables;
+using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Hideout;
namespace Core.Models.Eft.Common;
@@ -1255,7 +1255,7 @@ public class Level
public class ExpTable
{
[JsonPropertyName("exp")]
- public double? Experience { get; set; }
+ public int? Experience { get; set; }
}
public class LootAttempt
diff --git a/Core/Services/MailSendService.cs b/Core/Services/MailSendService.cs
index 242efb62..1ff9588e 100644
--- a/Core/Services/MailSendService.cs
+++ b/Core/Services/MailSendService.cs
@@ -94,6 +94,7 @@ public class MailSendService
DialogType = MessageType.NPC_TRADER,
Trader = trader,
MessageText = message,
+ Items = new ()
};
// Add items to message
@@ -150,6 +151,7 @@ public class MailSendService
DialogType = MessageType.NPC_TRADER,
Trader = trader,
TemplateId = messageLocaleId,
+ Items = new()
};
// add items to message
@@ -188,6 +190,7 @@ public class MailSendService
RecipientId = sessionId,
Sender = MessageType.SYSTEM_MESSAGE,
MessageText = message,
+ Items = new()
};
// add items to message
@@ -217,7 +220,8 @@ public class MailSendService
{
RecipientId = sessionId,
Sender = MessageType.SYSTEM_MESSAGE,
- TemplateId = messageLocaleId
+ TemplateId = messageLocaleId,
+ Items = new()
};
// add items to message
@@ -254,7 +258,8 @@ public class MailSendService
RecipientId = sessionId,
Sender = MessageType.USER_MESSAGE,
SenderDetails = senderDetails,
- MessageText = message
+ MessageText = message,
+ Items = new ()
};
// add items to message