Skip to content

Commit

Permalink
Bounty awarded updated to include new pilot property
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkael committed May 12, 2024
1 parent 836102d commit b90fb8c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 55 deletions.
5 changes: 4 additions & 1 deletion EDDI/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ Full details of the variables available for each noted event, and VoiceAttack in

## 4.0.4-b1
* Core
* Updated ship and module definitions.
* Revised jump calculations for new SCO FSDs.
* EDDI will no longer report your environment as "Supercruise" right after a Thargoid hyperdiction. (#2597)
* EDDI will no longer report your enviroment as "Normal Space" when starting docked. (#2598)
* EDDI will delay rather than discard speech when hit by a full Thargoid shutdown. (#2603)
* Fixed a crash when using the Cottle `dump()` function to enumerate a `Haulage` object. Removed the `expiry` property from the `Haulage` object (but it is still available from the `Mission` object). (#2593)
* EDDN Responder
* Add support for `DockingDenied` and `DockingGranted` schemas
* Events
* `Bounty awarded` updated to include new `pilot` property (when applicable).
* `Hyperdicted` added.
* `Signal detected` updated to include new `signaltype` property.
* `Ship shutdown` updated include new `partialshutdown` property (for instances where the power flickers but doesn't go out completely). (#2603)
* `Ship shutdown` updated to include new `partialshutdown` property (for instances where the power flickers but doesn't go out completely). (#2603)
* `Ship targeted` updated to better utilize localized names (where available). (#2604)
* Navigation Monitor
* Improved route guidance updates.
Expand Down
35 changes: 31 additions & 4 deletions Events/BountyAwardedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using EddiDataDefinitions;
using Rollbar.DTOs;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -9,11 +11,14 @@ public class BountyAwardedEvent : Event
{
public const string NAME = "Bounty awarded";
public const string DESCRIPTION = "Triggered when you are awarded a bounty";
public const string SAMPLE = @"{ ""timestamp"":""2016-12-29T10:10:11Z"", ""event"":""Bounty"", ""Rewards"":[ { ""Faction"":""FrogCorp"", ""Reward"":400 }, { ""Faction"":""Federation"", ""Reward"":123187 } ], ""Target"":""federation_dropship_mkii"", ""TotalReward"":123587, ""VictimFaction"":""TZ Arietis Purple Council"" }";
public const string SAMPLE = @"{ ""timestamp"":""2023-10-20T22:46:00Z"", ""event"":""Bounty"", ""Rewards"":[ { ""Faction"":""Amarishvaru Advanced Holdings"", ""Reward"":527518 } ], ""PilotName"":""$npc_name_decorate:#name=Christopher;"", ""PilotName_Localised"":""Christopher"", ""Target"":""anaconda"", ""TotalReward"":527518, ""VictimFaction"":""Orom Blue Council"" }";

[PublicAPI("The name of the asset you destroyed (if applicable)")]
public string target { get; private set; }

[PublicAPI( "The pilot of the asset you destroyed (if applicable)" )]
public string pilot { get; private set; }

[PublicAPI("The name of the faction whose asset you destroyed")]
public string faction { get; private set; }

Expand All @@ -26,10 +31,32 @@ public class BountyAwardedEvent : Event
[PublicAPI("True if the rewards have been shared with wing-mates")]
public bool shared { get; private set; }

public BountyAwardedEvent(DateTime timestamp, string target, string faction, long reward, List<Reward> rewards, bool shared) : base(timestamp, NAME)
public BountyAwardedEvent(DateTime timestamp, string target, string target_localised, string victimName, string victimFaction, long reward, List<Reward> rewards, bool shared) : base(timestamp, NAME)
{
if ( target != null )
{
// Might be a ship
var targetShip = ShipDefinitions.FromEDModel(target, false);

// Might be a SRV or Fighter
var targetVehicle = VehicleDefinition.EDNameExists(target) ? VehicleDefinition.FromEDName(target) : null;

// Might be an on foot commander
var targetCmdrSuit = Suit.EDNameExists(target) ? Suit.FromEDName(target) : null;

// Might be an on foot NPC
var targetNpcSuitLoadout = NpcSuitLoadout.EDNameExists(target) ? NpcSuitLoadout.FromEDName(target) : null;

target = targetShip?.model
?? targetCmdrSuit?.localizedName
?? targetVehicle?.localizedName
?? targetNpcSuitLoadout?.localizedName
?? target_localised;
}

this.target = target;
this.faction = faction;
this.pilot = victimName;
this.faction = victimFaction;
this.reward = reward;
this.rewards = rewards;
this.shared = shared;
Expand Down
29 changes: 3 additions & 26 deletions JournalMonitor/JournalMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,31 +445,8 @@ public static List<Event> ParseJournalEntry(string line, bool fromLogLoad = fals
case "Bounty":
{
var target = JsonParsing.getString(data, "Target");
if ( target != null)
{
// Might be a ship
var targetShip = ShipDefinitions.FromEDModel(target, false);

// Might be a SRV or Fighter
var targetVehicle = VehicleDefinition.EDNameExists(target) ? VehicleDefinition.FromEDName(target) : null;

// Might be an on foot commander
var targetCmdrSuit = Suit.EDNameExists(target) ? Suit.FromEDName(target) : null;

// Might be an on foot NPC
var targetNpcSuitLoadout = NpcSuitLoadout.EDNameExists(target) ? NpcSuitLoadout.FromEDName(target) : null;

target = targetShip?.SpokenModel()
?? targetCmdrSuit?.localizedName
?? targetVehicle?.localizedName
?? targetNpcSuitLoadout?.localizedName
?? JsonParsing.getString(data, "Target_Localised")
;
}

var pilot = JsonParsing.getString(data, "PilotName");
var pilotLocalised = JsonParsing.getString(data, "PilotName_Localised");

var target_localised = JsonParsing.getString( data, "Target_Localised" );
var victimName = JsonParsing.getString(data, "PilotName_Localised");
var victimFaction = GetFactionName(data, "VictimFaction");

data.TryGetValue("SharedWithOthers", out object val);
Expand Down Expand Up @@ -516,7 +493,7 @@ public static List<Event> ParseJournalEntry(string line, bool fromLogLoad = fals
}
}

events.Add(new BountyAwardedEvent(timestamp, target, victimFaction, reward, rewards, shared) { raw = line, fromLoad = fromLogLoad });
events.Add(new BountyAwardedEvent(timestamp, target, target_localised, victimName, victimFaction, reward, rewards, shared) { raw = line, fromLoad = fromLogLoad });
}
handled = true;
break;
Expand Down
63 changes: 39 additions & 24 deletions Tests/JournalMonitorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2011,33 +2011,48 @@ public void TestSurfaceSignalsEvent(string line, string expectedDetectionType, s
Assert.AreEqual(expectedOtherSignals, @event.surfacesignals?.FirstOrDefault(s => s.signalSource.edname == "SAA_SignalType_Other")?.amount ?? 0);
}

[TestMethod]
public void TestBountyAwardedOdyssey()
[ TestMethod ]
public void TestBountyAwardedOdyssey ()
{
string line1 = @"{ ""timestamp"":""2023-01-28T23:36:38Z"", ""event"":""Bounty"", ""Rewards"":[ { ""Faction"":""Duwali Liberty Party"", ""Reward"":2050 } ], ""Target"":""citizensuitai_scientific"", ""Target_Localised"":""Researcher"", ""TotalReward"":2050, ""VictimFaction"":""Duwali Partnership"" }";
string line2 = @"{ ""timestamp"":""2023-01-28T23:36:59Z"", ""event"":""Bounty"", ""Rewards"":[ { ""Faction"":""Defence Party of Duwali"", ""Reward"":14100 } ], ""Target"":""citizensuitai_industrial"", ""Target_Localised"":""Technician"", ""TotalReward"":14100, ""VictimFaction"":""Duwali Partnership"" }";

var events1 = JournalMonitor.ParseJournalEntry(line1);
Assert.AreEqual(1, events1.Count);
var event1 = (BountyAwardedEvent)events1[0];
Assert.IsNotNull(event1);
Assert.AreEqual(1, event1.rewards.Count);
Assert.AreEqual("Duwali Liberty Party", event1.rewards[0].faction);
Assert.AreEqual(2050, event1.rewards[0].amount);
Assert.AreEqual("Researcher", event1.target);
Assert.AreEqual(2050, event1.reward);
Assert.AreEqual("Duwali Partnership", event1.faction);

var events2 = JournalMonitor.ParseJournalEntry(line2);
Assert.AreEqual(1, events2.Count);
var event2 = (BountyAwardedEvent)events2[0];
Assert.IsNotNull(event2);
Assert.AreEqual(1, event2.rewards.Count);
Assert.AreEqual("Defence Party of Duwali", event2.rewards[0].faction);
Assert.AreEqual(14100, event2.rewards[0].amount);
Assert.AreEqual("Technician", event2.target);
Assert.AreEqual(14100, event2.reward);
Assert.AreEqual("Duwali Partnership", event2.faction);
string line3 = @"{ ""timestamp"":""2023-10-20T23:43:59Z"", ""event"":""Bounty"", ""Rewards"":[ { ""Faction"":""New Gungkuni Alliance"", ""Reward"":67748 } ], ""PilotName"":""$npc_name_decorate:#name=Morty;"", ""PilotName_Localised"":""Morty"", ""Target"":""cobramkiii"", ""Target_Localised"":""Cobra Mk III"", ""TotalReward"":67748, ""VictimFaction"":""Copityar Purple Posse"" }";

var events1 = JournalMonitor.ParseJournalEntry( line1 );
Assert.AreEqual( 1, events1.Count );
var event1 = (BountyAwardedEvent)events1[ 0 ];
Assert.IsNotNull( event1 );
Assert.AreEqual( 1, event1.rewards.Count );
Assert.AreEqual( "Duwali Liberty Party", event1.rewards[ 0 ].faction );
Assert.AreEqual( 2050, event1.rewards[ 0 ].amount );
Assert.AreEqual( "Researcher", event1.target );
Assert.AreEqual( 2050, event1.reward );
Assert.AreEqual( null, event1.pilot );
Assert.AreEqual( "Duwali Partnership", event1.faction );

var events2 = JournalMonitor.ParseJournalEntry( line2 );
Assert.AreEqual( 1, events2.Count );
var event2 = (BountyAwardedEvent)events2[ 0 ];
Assert.IsNotNull( event2 );
Assert.AreEqual( 1, event2.rewards.Count );
Assert.AreEqual( "Defence Party of Duwali", event2.rewards[ 0 ].faction );
Assert.AreEqual( 14100, event2.rewards[ 0 ].amount );
Assert.AreEqual( "Technician", event2.target );
Assert.AreEqual( 14100, event2.reward );
Assert.AreEqual( null, event2.pilot );
Assert.AreEqual( "Duwali Partnership", event2.faction );

var events3 = JournalMonitor.ParseJournalEntry( line3 );
Assert.AreEqual( 1, events3.Count );
var event3 = (BountyAwardedEvent)events3[ 0 ];
Assert.IsNotNull( event3 );
Assert.AreEqual( 1, event3.rewards.Count );
Assert.AreEqual( "New Gungkuni Alliance", event3.rewards[ 0 ].faction );
Assert.AreEqual( 67748, event3.rewards[ 0 ].amount );
Assert.AreEqual( "Cobra Mk. III", event3.target );
Assert.AreEqual( 67748, event3.reward );
Assert.AreEqual( "Morty", event3.pilot );
Assert.AreEqual( "Copityar Purple Posse", event3.faction );
}

[TestMethod, DoNotParallelize]
Expand Down

0 comments on commit b90fb8c

Please sign in to comment.