diff --git a/Core/Services/MapMarkerService.cs b/Core/Services/MapMarkerService.cs
index 00d40e1f..338781eb 100644
--- a/Core/Services/MapMarkerService.cs
+++ b/Core/Services/MapMarkerService.cs
@@ -1,16 +1,29 @@
-using Core.Annotations;
+using System.Text.RegularExpressions;
+using Core.Annotations;
using Core.Models.Eft.Common;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Inventory;
using Core.Models.Eft.Profile;
using Core.Models.Enums;
using Core.Models.Spt.Dialog;
+using ILogger = Core.Models.Utils.ILogger;
+using MapMarker = Core.Models.Eft.Common.Tables.MapMarker;
namespace Core.Services;
-[Injectable(InjectionType.Singleton)]
+[Injectable]
public class MapMarkerService
{
+ private readonly ILogger _logger;
+
+ public MapMarkerService
+ (
+ ILogger logger
+ )
+ {
+ _logger = logger;
+ }
+
///
/// Add note to a map item in player inventory
///
@@ -19,7 +32,17 @@ public class MapMarkerService
/// Item
public Item CreateMarkerOnMap(PmcData pmcData, InventoryCreateMarkerRequestData request)
{
- throw new NotImplementedException();
+ // Get map from inventory
+ var mapItem = pmcData?.Inventory?.Items?.FirstOrDefault((i) => i?.Id == request?.Item);
+
+ // add marker to map item
+ mapItem.Upd.Map = mapItem?.Upd?.Map ?? new() { Markers = new() };
+
+ // Update request note with text, then add to maps upd
+ request.MapMarker.Note = SanitiseMapMarkerText(request.MapMarker.Note);
+ mapItem?.Upd?.Map?.Markers?.Add(request.MapMarker);
+
+ return mapItem;
}
///
@@ -30,7 +53,16 @@ public class MapMarkerService
/// Item
public Item DeleteMarkerFromMap(PmcData pmcData, InventoryDeleteMarkerRequestData request)
{
- throw new NotImplementedException();
+ // Get map from inventory
+ var mapItem = pmcData.Inventory.Items.FirstOrDefault((item) => item.Id == request.Item);
+
+ // remove marker
+ var markers = mapItem.Upd.Map.Markers.Where((marker) => {
+ return marker.X != request.X && marker.Y != request.Y;
+ }).ToList();
+ mapItem.Upd.Map.Markers = markers;
+
+ return mapItem;
}
///
@@ -41,7 +73,16 @@ public class MapMarkerService
/// Item
public Item EditMarkerOnMap(PmcData pmcData, InventoryEditMarkerRequestData request)
{
- throw new NotImplementedException();
+ // Get map from inventory
+ var mapItem = pmcData.Inventory.Items.FirstOrDefault((item) => item.Id == request.Item);
+
+ // edit marker
+ var indexOfExistingNote = mapItem.Upd.Map.Markers.IndexOf(request.MapMarker);
+ request.MapMarker.Note = SanitiseMapMarkerText(request.MapMarker.Note);
+ mapItem.Upd.Map.Markers.RemoveAt(indexOfExistingNote);
+ mapItem.Upd.Map.Markers.Add(request.MapMarker);
+
+ return mapItem;
}
///
@@ -51,192 +92,6 @@ public class MapMarkerService
/// Sanitised map marker text
protected string SanitiseMapMarkerText(string mapNoteText)
{
- throw new NotImplementedException();
- }
-
- ///
- /// Send a message from an NPC (e.g. prapor) to the player with or without items using direct message text, do not look up any locale
- ///
- /// The session ID to send the message to
- /// The trader sending the message
- /// What type the message will assume (e.g. QUEST_SUCCESS)
- /// Text to send to the player
- /// Optional items to send to player
- /// Optional time to collect items before they expire
- public void SendDirectNpcMessageToPlayer(
- string sessionId,
- object trader,
- MessageType messageType,
- string message,
- List- items = null,
- int? maxStorageTimeSeconds = null,
- SystemData systemData = null,
- MessageContentRagfair ragfair = null)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Send a message from an NPC (e.g. prapor) to the player with or without items
- ///
- /// The session ID to send the message to
- /// The trader sending the message
- /// What type the message will assume (e.g. QUEST_SUCCESS)
- /// The localised text to send to player
- /// Optional items to send to player
- /// Optional time to collect items before they expire
- public void SendLocalisedNpcMessageToPlayer(
- string sessionId,
- object trader,
- MessageType messageType,
- string messageLocaleId,
- List
- items = null,
- int? maxStorageTimeSeconds = null,
- SystemData systemData = null,
- MessageContentRagfair ragfair = null)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Send a message from SYSTEM to the player with or without items
- ///
- /// The session ID to send the message to
- /// The text to send to player
- /// Optional items to send to player
- /// Optional time to collect items before they expire
- public void SendSystemMessageToPlayer(
- string sessionId,
- string message,
- List
- items = null,
- int? maxStorageTimeSeconds = null,
- List profileChangeEvents = null)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Send a message from SYSTEM to the player with or without items with localised text
- ///
- /// The session ID to send the message to
- /// Id of key from locale file to send to player
- /// Optional items to send to player
- /// Optional time to collect items before they expire
- public void SendLocalisedSystemMessageToPlayer(
- string sessionId,
- string messageLocaleId,
- List
- items = null,
- List profileChangeEvents = null,
- int? maxStorageTimeSeconds = null)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Send a USER message to a player with or without items
- ///
- /// The session ID to send the message to
- /// Who is sending the message
- /// The text to send to player
- /// Optional items to send to player
- /// Optional time to collect items before they expire
- public void SendUserMessageToPlayer(
- string sessionId,
- UserDialogInfo senderDetails,
- string message,
- List
- items = null,
- int? maxStorageTimeSeconds = null)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Large function to send messages to players from a variety of sources (SYSTEM/NPC/USER)
- /// Helper functions in this class are available to simplify common actions
- ///
- /// Details needed to send a message to the player
- public void SendMessageToPlayer(SendMessageDetails messageDetails)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Send a message from the player to an NPC
- ///
- /// Player id
- /// NPC message is sent to
- /// Text to send to NPC
- public void SendPlayerMessageToNpc(string sessionId, string targetNpcId, string message)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Create a message for storage inside a dialog in the player profile
- ///
- /// Id of dialog that will hold the message
- /// Various details on what the message must contain/do
- /// Message
- protected Message CreateDialogMessage(string dialogId, SendMessageDetails messageDetails)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Add items to message and adjust various properties to reflect the items being added
- ///
- /// Message to add items to
- /// Items to add to message
- /// total time items are stored in mail before being deleted
- protected void AddRewardItemsToMessage(
- Message message,
- List itemsToSendToPlayer,
- int? maxStorageTimeSeconds)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// perform various sanitising actions on the items before they're considered ready for insertion into message
- ///
- /// The type of the dialog that will hold the reward items being processed
- ///
- /// Sanitised items
- protected List ProcessItemsBeforeAddingToMail(
- MessageType dialogType,
- SendMessageDetails messageDetails)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Try to find the most correct item to be the 'primary' item in a reward mail
- ///
- /// Possible items to choose from
- /// Chosen 'primary' item
- protected Item GetBaseItemFromRewards(List
- items)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Get a dialog with a specified entity (user/trader)
- /// Create and store empty dialog if none exists in profile
- ///
- /// Data on what message should do
- /// Relevant Dialogue
- protected Dialogue GetDialog(SendMessageDetails messageDetails)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Get the appropriate sender id by the sender enum type
- ///
- ///
- /// gets an id of the individual sending it
- protected string GetMessageSenderIdByType(SendMessageDetails messageDetails)
- {
- throw new NotImplementedException();
+ return Regex.Replace(mapNoteText, @"[^\p{L}\d\s]", "", RegexOptions.CultureInvariant);
}
}