add preliminary support for merits gained
This commit is contained in:
		
							parent
							
								
									cdbca10f2d
								
							
						
					
					
						commit
						aeaa6b5220
					
				
							
								
								
									
										25
									
								
								EDPlayerJournal/BGS/MeritsGained.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								EDPlayerJournal/BGS/MeritsGained.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| using EDPlayerJournal.Entries; | ||||
| 
 | ||||
| namespace EDPlayerJournal.BGS; | ||||
| 
 | ||||
| public class MeritsGained : Transaction { | ||||
|     public MeritsGained() { } | ||||
| 
 | ||||
|     public MeritsGained(Entry entry) { | ||||
|         Entries.Add(entry); | ||||
|     } | ||||
| 
 | ||||
|     /// <summary> | ||||
|     /// Number of merits gained | ||||
|     /// </summary> | ||||
|     public long Merits { get; set; } = 0; | ||||
| 
 | ||||
|     /// <summary> | ||||
|     /// For what power those merits were gained | ||||
|     /// </summary> | ||||
|     public string Power { get; set; } = string.Empty; | ||||
| 
 | ||||
|     public override string ToString() { | ||||
|         return string.Format("{0} Merits gained for {1}", Merits, Power); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								EDPlayerJournal/BGS/Parsers/PowerplayParser.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								EDPlayerJournal/BGS/Parsers/PowerplayParser.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| using EDPlayerJournal.Entries; | ||||
| 
 | ||||
| namespace EDPlayerJournal.BGS.Parsers; | ||||
| 
 | ||||
| internal class PowerplayParser : ITransactionParserPart { | ||||
|     public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) { | ||||
|         PowerplayEntry? p = entry as PowerplayEntry; | ||||
|         if (p == null) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         if (context.LastMerits == null) { | ||||
|             context.LastMerits = p.Merits; | ||||
|         } | ||||
| 
 | ||||
|         context.CurrentMerits = p.Merits; | ||||
|   | ||||
|         if (context.LastMerits != context.CurrentMerits) { | ||||
|             transactions.Add(new MeritsGained(entry) { | ||||
|                 Merits = ((long)(context.CurrentMerits - context.LastMerits)), | ||||
|                 Power = p.Power, | ||||
|                 System = context.CurrentSystem, | ||||
|                 Faction = p.Power, | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         context.LastMerits = context.CurrentMerits; | ||||
|     } | ||||
| } | ||||
| @ -638,6 +638,7 @@ public class TransactionParser { | ||||
|         { Events.Missions, new MissionsParser() }, | ||||
|         { Events.MultiSellExplorationData, new MultiSellExplorationDataParser() }, | ||||
|         { Events.Music, new MusicParser() }, | ||||
|         { Events.Powerplay, new PowerplayParser() }, | ||||
|         { Events.ReceiveText, new ReceiveTextParser() }, | ||||
|         { Events.RedeemVoucher, new RedeemVoucherParser() }, | ||||
|         { Events.SearchAndRescue, new SearchAndRescueParser() }, | ||||
|  | ||||
| @ -69,6 +69,16 @@ internal class TransactionParserContext { | ||||
|     /// </summary> | ||||
|     public string? Settlement { get; set; } = null; | ||||
| 
 | ||||
|     /// <summary> | ||||
|     /// Current Merits | ||||
|     /// </summary> | ||||
|     public long? CurrentMerits { get; set; } = null; | ||||
| 
 | ||||
|     /// <summary> | ||||
|     /// Merits from last login | ||||
|     /// </summary> | ||||
|     public long? LastMerits { get; set; } = null; | ||||
| 
 | ||||
|     /// <summary> | ||||
|     /// Returns true if the current session is legacy | ||||
|     /// </summary> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user