Exemple #1
0
 private void handleRespawnedEvent(RespawnedEvent @event)
 {
     if (@event.timestamp > updateDat || (@event.timestamp == updateDat && [email protected]))
     {
         updateDat = @event.timestamp;
         _handleRespawnedEvent(@event);
         writeRecord();
     }
 }
Exemple #2
0
        private void _handleRespawnedEvent(RespawnedEvent @event)
        {
            void RemoveCriminalRecords(string faction = null)
            {
                // Update the criminal record fines and bounties for each faction, as appropriate.
                foreach (FactionRecord record in criminalrecord.ToList())
                {
                    if ((!string.IsNullOrEmpty(faction) && faction == record.faction) || string.IsNullOrEmpty(faction))
                    {
                        var crimeReports = record.factionReports
                                           .Where(r => r.crimeDef != Crime.None && r.crimeDef != Crime.Claim)
                                           .ToList();
                        // Remove all pending fines and bounties (from a named faction, if a faction name is given)
                        string forFaction = !string.IsNullOrEmpty(faction) ? $"for faction {record.faction} " : "";
                        Logging.Debug($"Paid {@event.price} credits to resolve fines and bounties {forFaction} (expected {crimeReports.Sum(r => r.amount)}).");
                        record.factionReports = record.factionReports.Except(crimeReports).ToList();
                        RemoveRecordIfEmpty(record);
                    }
                }
            }

            void RemoveClaimsRecords()
            {
                // Update the criminal record pending claims for each faction, as appropriate.
                foreach (FactionRecord record in criminalrecord.ToList())
                {
                    // Remove all pending claims from faction
                    var claimReports = record.factionReports
                                       .Where(r => r.crimeDef == Crime.None || r.crimeDef == Crime.Claim)
                                       .ToList();
                    Logging.Debug($"Removed vouchers for {claimReports.Sum(r => r.amount)} unclaimed credits from {record.faction}.");
                    record.factionReports = record.factionReports.Except(claimReports).ToList();
                    RemoveRecordIfEmpty(record);
                }
            }

            switch (@event.trigger)
            {
            case "rebuy":     // Repurchase a destroyed ship. All fines and bounties must be paid. Claims are lost.
            {
                RemoveCriminalRecords();
                RemoveClaimsRecords();
                break;
            }

            case "recover":      // Recover from an on-foot critical injury. All fines and bounties for the local authority faction (only) must be paid. Claims are lost.
            {
                RemoveCriminalRecords(crimeAuthorityFaction);
                RemoveClaimsRecords();
                break;
            }

            case "rejoin":     // Rejoin your ship. Fines and bounties remain unpaid. Claims are lost.
            {
                RemoveClaimsRecords();
                break;
            }

            case "handin":     // Hand-in to authorities. Fines and bounties for the station authority faction (only) must be paid.
                               // Claims are preserved. Fines and bounties pertaining to other factions are preserved.
            {
                RemoveCriminalRecords(EDDI.Instance.CurrentStation?.Faction?.name);
                break;
            }
            }
        }