private void handleBountyPaidEvent(BountyPaidEvent @event) { if (@event.timestamp > updateDat || (@event.timestamp == updateDat && [email protected])) { updateDat = @event.timestamp; if (_handleBountyPaidEvent(@event)) { writeRecord(); } } }
private void handleBountyPaidEvent(BountyPaidEvent @event) { if (@event.timestamp > updateDat) { updateDat = @event.timestamp; if (_handleBountyPaidEvent(@event)) { writeRecord(); } } }
private bool _handleBountyPaidEvent(BountyPaidEvent @event) { bool update = false; foreach (FactionRecord record in criminalrecord.ToList()) { if (@event.allbounties || record.faction == @event.faction) { // Get all bounties incurred, excluding the discrepancy report List <FactionReport> reports = record.factionReports .Where(r => r.crimeDef != Crime.None && r.crimeDef != Crime.Bounty) .ToList(); long total = reports.Sum(r => r.amount); // Check for discrepancy in logged bounties incurred if (total < @event.amount) { // Adjust the discrepancy report & remove when zeroed out FactionReport report = record.factionReports .FirstOrDefault(r => r.crimeDef == Crime.Bounty); if (report != null) { report.amount -= Math.Min(@event.amount - total, report.amount); if (report.amount == 0) { reports.Add(report); } } } // Remove associated records record.factionReports = record.factionReports.Except(reports).ToList(); // Adjust the total bounties incurred amount record.bounties -= Math.Min(@event.amount, record.bounties); RemoveRecordIfEmpty(record); update = true; if (record.faction == @event.faction) { break; } } } return(update); }
private bool _handleBountyPaidEvent(BountyPaidEvent @event) { bool update = false; foreach (FactionRecord record in criminalrecord.ToList()) { // If paid at 'Legal Facilities', bounties are grouped by superpower bool match = @event.brokerpercentage == null ? record.faction == @event.faction : record.Allegiance.invariantName == @event.faction; if (@event.allbounties || match) { // Get all bounties incurred, excluding the discrepancy report // Note that all bounties are assigned to the ship, not the commander List <FactionReport> reports = record.factionReports .Where(r => r.bounty && r.crimeDef != Crime.None && r.crimeDef != Crime.Bounty && r.shipId == @event.shipid) .ToList(); long total = reports?.Sum(r => r.amount) ?? 0; // Check for discrepancy in logged bounties incurred if (total < @event.amount) { // Adjust the discrepancy report & remove when zeroed out FactionReport report = record.factionReports .FirstOrDefault(r => r.crimeDef == Crime.Bounty); if (report != null) { report.amount -= Math.Min(@event.amount - total, report.amount); if (report.amount == 0) { reports.Add(report); } } } // Remove associated bounties record.factionReports = record.factionReports.Except(reports).ToList(); // Adjust the total bounties incurred amount record.bounties -= Math.Min(@event.amount, record.bounties); RemoveRecord(record); update = true; } } return(update); }