78 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
namespace EDPlayerJournal.Entries;
 | 
						|
 | 
						|
public class ReceiveTextEntry : Entry {
 | 
						|
    /// <summary>
 | 
						|
    /// From whom this message is
 | 
						|
    /// </summary>
 | 
						|
    public string? From { get; set; }
 | 
						|
    /// <summary>
 | 
						|
    /// The message, if it is just an NPC text, it will be a message ID
 | 
						|
    /// </summary>
 | 
						|
    public string? Message { get; set; }
 | 
						|
    /// <summary>
 | 
						|
    /// Message localised
 | 
						|
    /// </summary>
 | 
						|
    public string? MessageLocalised { get; set; }
 | 
						|
    /// <summary>
 | 
						|
    /// On what channel this was received.
 | 
						|
    /// </summary>
 | 
						|
    public string? Channel { get; set; }
 | 
						|
 | 
						|
    public bool HasNPCCategory {
 | 
						|
        get {
 | 
						|
            if (From == null) {
 | 
						|
                return false;
 | 
						|
            }
 | 
						|
 | 
						|
            if (From.Contains(';') && From.StartsWith("$")) {
 | 
						|
                return true;
 | 
						|
            }
 | 
						|
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Returns the NPC's category, if it has one.
 | 
						|
    /// </summary>
 | 
						|
    public string? NPCCategory {
 | 
						|
        get {
 | 
						|
            if (!HasNPCCategory || From == null) {
 | 
						|
                return null;
 | 
						|
            }
 | 
						|
 | 
						|
            string[] parts = From.Split(";", StringSplitOptions.TrimEntries);
 | 
						|
            if (parts.Length < 2) {
 | 
						|
                return null;
 | 
						|
            }
 | 
						|
 | 
						|
            return string.Format("{0};", parts[0]);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Returns the NPC's category, if it has one.
 | 
						|
    /// </summary>
 | 
						|
    public string? NPCName {
 | 
						|
        get {
 | 
						|
            if (!HasNPCCategory || From == null) {
 | 
						|
                return null;
 | 
						|
            }
 | 
						|
 | 
						|
            string[] parts = From.Split(";", StringSplitOptions.TrimEntries);
 | 
						|
            if (parts.Length < 2) {
 | 
						|
                return null;
 | 
						|
            }
 | 
						|
 | 
						|
            return parts[1];
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    protected override void Initialise() {
 | 
						|
        From = JSON.Value<string>("From");
 | 
						|
        Message = JSON.Value<string>("Message");
 | 
						|
        MessageLocalised = JSON.Value<string>("Message_localised");
 | 
						|
        Channel = JSON.Value<string>("Channel");
 | 
						|
    }
 | 
						|
}
 |