Ejemplo n.º 1
0
 private void handleFinePaidEvent(FinePaidEvent @event)
 {
     if (@event.timestamp > updateDat)
     {
         updateDat = @event.timestamp;
         if (_handleFinePaidEvent(@event))
         {
             writeRecord();
         }
     }
 }
Ejemplo n.º 2
0
 private void handleFinePaidEvent(FinePaidEvent @event)
 {
     if (@event.timestamp > updateDat || (@event.timestamp == updateDat && [email protected]))
     {
         updateDat = @event.timestamp;
         if (_handleFinePaidEvent(@event))
         {
             writeRecord();
         }
     }
 }
Ejemplo n.º 3
0
        private bool _handleFinePaidEvent(FinePaidEvent @event)
        {
            // This event may trigger for both bounties paid and fines paid (FDev bug)
            bool update = false;

            foreach (FactionRecord record in criminalrecord.ToList())
            {
                if (@event.allfines || record.faction == @event.faction)
                {
                    // Get all fines incurred, excluding the discrepancy report
                    List <FactionReport> reports = record.factionReports
                                                   .Where(r => r.crimeDef != Crime.None && r.crimeDef != Crime.Fine)
                                                   .ToList();
                    long total = reports.Sum(r => r.amount);

                    // Check for discrepancy in logged fines incurred
                    if (total < @event.amount)
                    {
                        // Adjust the discrepancy report & remove when zeroed out
                        FactionReport report = record.factionReports
                                               .FirstOrDefault(r => r.crimeDef == Crime.Fine);
                        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 fines incurred amount
                    record.fines -= Math.Min(@event.amount, record.fines);

                    RemoveRecordIfEmpty(record);
                    update = true;
                    if (record.faction == @event.faction)
                    {
                        break;
                    }
                }
            }
            return(update);
        }
Ejemplo n.º 4
0
        private bool _handleFinePaidEvent(FinePaidEvent @event)
        {
            bool update = false;

            foreach (FactionRecord record in criminalrecord.ToList())
            {
                // If paid at 'Legal Facilities', fines are grouped by superpower
                bool match = @event.brokerpercentage == null ? record.faction == @event.faction : record.Allegiance.invariantName == @event.faction;
                if (@event.allfines || match)
                {
                    // Get all fines incurred, excluding the discrepancy report
                    // Note that all fines are assigned to the ship, not the commander
                    List <FactionReport> reports = record.factionReports
                                                   .Where(r => !r.bounty && r.crimeDef != Crime.None && r.crimeDef != Crime.Fine && r.shipId == @event.shipid)
                                                   .ToList();
                    long total = reports?.Sum(r => r.amount) ?? 0;

                    // Check for discrepancy in logged fines incurred
                    if (total < @event.amount)
                    {
                        // Adjust the discrepancy report & remove when zeroed out
                        FactionReport report = record.factionReports
                                               .FirstOrDefault(r => r.crimeDef == Crime.Fine);
                        if (report != null)
                        {
                            report.amount -= Math.Min(@event.amount - total, report.amount);
                            if (report.amount == 0)
                            {
                                reports.Add(report);
                            }
                        }
                    }
                    // Remove associated fines
                    record.factionReports = record.factionReports.Except(reports).ToList();

                    // Adjust the total fines incurred amount
                    record.fines -= Math.Min(@event.amount, record.fines);

                    RemoveRecord(record);
                    update = true;
                }
            }
            return(update);
        }