bind fleet summaries, fixup fleet post processing
This commit is contained in:
		@@ -94,8 +94,8 @@ public partial class CSVDataLoader : IEnableLogger
 | 
			
		||||
                var fleetLoader = new CSV.FleetLoader();
 | 
			
		||||
                fleetLoader.ImportForRace(Services.Game.Player);
 | 
			
		||||
 | 
			
		||||
                FleetManager.PostProcessImportedData(); 
 | 
			
		||||
                FleetManager fleetManager = Locator.Current.GetService<FleetManager>()!;
 | 
			
		||||
                FleetManager.PostProcessImportedData(); 
 | 
			
		||||
                fleetManager.InitFromDatabase();
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -144,14 +144,16 @@ public class FleetManager : IEnableLogger, IDisposable
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                flt.TrueDestination = "-- ";
 | 
			
		||||
                flt.TrueDestination = flt.Planet;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            Match m = shipPattern.Match(flt.FleetName);
 | 
			
		||||
            if (m.Success)
 | 
			
		||||
                flt.ShipTypeGuess = m.Groups[1].Value;
 | 
			
		||||
 | 
			
		||||
            db.Update(flt);            
 | 
			
		||||
            flt.Colonists *= 100;
 | 
			
		||||
 | 
			
		||||
            db.Update(flt);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        db.SaveChanges();
 | 
			
		||||
 
 | 
			
		||||
@@ -135,18 +135,17 @@ public class Game
 | 
			
		||||
        GameEngine.Game = this;
 | 
			
		||||
        Locator.CurrentMutable.RegisterConstant(new CSVDataLoader(), typeof(CSVDataLoader));
 | 
			
		||||
        Locator.CurrentMutable.Register(() => new StarsDatabase(DatabaseFileName), typeof(StarsDatabase));
 | 
			
		||||
        PlanetManager PlanetManager = new();
 | 
			
		||||
        Locator.CurrentMutable.RegisterConstant(PlanetManager, typeof(Services.PlanetManager));
 | 
			
		||||
        FleetManager FleetManager = new();
 | 
			
		||||
        Locator.CurrentMutable.RegisterConstant(FleetManager, typeof(Services.FleetManager));
 | 
			
		||||
        PlanetManager PlanetManager = new();
 | 
			
		||||
        Locator.CurrentMutable.RegisterConstant(PlanetManager, typeof(Services.PlanetManager));
 | 
			
		||||
 | 
			
		||||
        // TESTING HELPER
 | 
			
		||||
        if (__doCreateTestData)
 | 
			
		||||
            __createTestData();
 | 
			
		||||
 | 
			
		||||
        PlanetManager.InitFromDatabase();
 | 
			
		||||
        FleetManager.InitFromDatabase();
 | 
			
		||||
        FleetManager.test();
 | 
			
		||||
        PlanetManager.InitFromDatabase();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ using StarsAssistant.ViewModels;
 | 
			
		||||
 | 
			
		||||
namespace StarsAssistant.Services;
 | 
			
		||||
 | 
			
		||||
public class PlanetManager
 | 
			
		||||
public class PlanetManager : IDisposable, IEnableLogger
 | 
			
		||||
{
 | 
			
		||||
    protected Services.Game Game = Locator.Current.GetService<Services.Game>()!;
 | 
			
		||||
 | 
			
		||||
@@ -27,7 +27,11 @@ public class PlanetManager
 | 
			
		||||
                .Filter(planet => planet.OwnerId == Game.Player.Name)
 | 
			
		||||
                .Transform(planet => new PlayerPlanetViewModel(planet));
 | 
			
		||||
 | 
			
		||||
    public PlanetManager() {}
 | 
			
		||||
    public PlanetManager() 
 | 
			
		||||
    {
 | 
			
		||||
        FleetManager fleetManager = Locator.Current.GetService<FleetManager>()!;
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Load the planet records from the database and push them into our source cache.
 | 
			
		||||
@@ -47,4 +51,24 @@ public class PlanetManager
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Handle disposal of all subscriptions and dependencies.
 | 
			
		||||
    /// </summary>/
 | 
			
		||||
    protected virtual void Dispose(bool disposing)
 | 
			
		||||
    {
 | 
			
		||||
        if (disposing)
 | 
			
		||||
        {
 | 
			
		||||
            _planets.Dispose();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Boilerplate disposal
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public void Dispose()
 | 
			
		||||
    {
 | 
			
		||||
        Dispose(true);
 | 
			
		||||
        GC.SuppressFinalize(this);
 | 
			
		||||
    }    
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user