mifriis / edge-of-kuiper

Textbased space rpg somewhat based on real science
Other
7 stars 3 forks source link

Refactor everything to work with JSON and Dependency Injection #39

Closed mifriis closed 2 years ago

mifriis commented 2 years ago

DOTNET SIIIIX!

Based on VisualBeans command setup i have refactored much of the current code to completely use dependency injection (with only few exceptions)

SolarSystem has been rewritten a bit, it's now designed to work with JSON serialization now.

Events are introduced! When you set a course in your ship an event is added to the GameEvents list marking your date of arrival. On load all events are evaluated and executed if they "happened" while you were away.

SaveFile introduced as a domain object. The noble goal of making a root aggregate hasn't worked. This way we can control exactly what is saved, how and where to put it back on load.

mifriis commented 2 years ago

@Nicoolai if you are up for it, i think this is a good place to get a review.

I would love to get your feedback! I think with these basics in place it will be possible to create other systems like commodities/trade, mining, ship upgrades, crew or even story/tutorial missions.

github-actions[bot] commented 2 years ago

Test- and Coverage-report - PR #39

Run Summary

Overall Result: ✔️ Pass
Pass Rate: 100%
Run Duration: 1s 473ms
Date: 2021-11-22 15:38:45 - 2021-11-22 15:38:47
Framework: .NETCoreApp,Version=v6.0
Total Tests: 75

✔️ Passed ❌ Failed ⚠️ Skipped
75 0 0
100% 0% 0%

Result Sets

kuiper-tests.dll - 100%

Full Results
Result Test Duration
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.CalculateAccelerationGsCorrectly 4ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.DeductFuelBasedOnSpentDVCorrectly < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.CalculateDeltaVelocityCorrectly < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.EmptyTheTankOnFullDeltaVSpent < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.ReturnSpentFuel < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.CalculateAccelerationCorrectly < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.RefuelWithoutOverFilling < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.NotPossibleToForceSpendingMoreFuelThanAvailiable < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipShould.RefuelWithoutFillingTheTank < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.SetCourseEventShould.ExecuteTheRightServices 122ms
✔️ Passed Kuiper.Tests.Unit.Services.EventServiceShould.ExecuteAllEventsThatHappenedBeforeNow 117ms
✔️ Passed Kuiper.Tests.Unit.Services.EventServiceShould.AddEventToEventList 4ms
✔️ Passed Kuiper.Tests.Unit.Services.EventServiceShould.RemoveEventFromEventList < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.SolarSystemServiceShould.ReturnBodyBasedOnName 3ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.DoNothingWhenTheDestinationIsFubar 10ms
✔️ Passed Kuiper.Tests.Unit.Services.SolarSystemServiceShould.ReturnCorrectKmDistanceBetweenBodies 2ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.UpdateShipStatusWhenDestinationValid 6ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.UpdateShipStatusWhenDestinationReached < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.SolarSystemServiceShould.ReturnSattelitesAroundABody 2ms
✔️ Passed Kuiper.Tests.Unit.Services.SolarSystemServiceShould.ReturnCorrectAuDistanceBetweenBodies < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.SolarSystemServiceShould.ReturnCorrectKmDistanceBetweenAMoonAndADifferentBody < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.CalculatedVToTarget 1ms
✔️ Passed Kuiper.Tests.Unit.Services.SolarSystemServiceShould.ReturnAllBodiesUnderAStar < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.DoNothingWhenTheDestinationIsNotReachable 2ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.CalculateTimeToTarget 3ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipServiceShould.ReturnMergedListOfPlanetAndMoons 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipEngineShould.CalculateThrustToWeightRationCorrectly < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.SetCorrectName 10ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.SetCorrectOrbitRadius < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.ShipEngineShould.CalculateExhaustVelocityCorretly < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountShould.WithdrawSucessfully 2ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountShould.TransactionsHaveHumanOutput < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.CreateStarBodyTypeFromJson 13ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.SetCorrectOrbitVelocity < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.CreatePlanetBodyTypeFromJson < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.SetCorrectOriginDegrees < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.CreateMoonBodyTypeFromJson < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.NotFailIfJsonFileExist < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.CreateDwarfPlanetBodyTypeFromJson < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.CreateGasGiantBodyTypeFromJson < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.FailIfJsonFileDoesNotExist < 1ms
✔️ Passed Kuiper.Tests.Unit.Repositories.JsonFileSolarSystemRepositoryShould.CreateCorrectAmountOfBodiesFromJson < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountShould.KeepTransactionOfAcitvities 7ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountShould.DepositSucessfully < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.SetCorrectOrbitRadius < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.ReturnItsPositionInSpaceAtAGivenTime 2ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.AddBodyAsSatelliteIfItHasAParent 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateAMoon < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateBodyWithOriginDegrees < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.ReturnItsInitialPositionInSpace < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateBodyWithVelocity < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateAGasGiant < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.SetCorrectOrbitVelocity < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateAStar < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateADwarfPlanet < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.SetCorrectName < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.CreateAPlanet < 1ms
✔️ Passed Kuiper.Tests.Unit.Domain.CelestialBodyShould.SetCorrectOriginDegrees < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountServiceShould.ReturnTransactionalAcitivitesFromAnAccount 7ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountServiceShould.WithdrawFromAnAccount < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.AccountServiceShould.DepositInAnAccount < 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.GameTimeServiceShould.ThrowExceptionIfRealStartTimeNeverSet 6ms
✔️ Passed Kuiper.Tests.Unit.Systems.GameTimeServiceShould.ReturnGameStartDate < 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.GameTimeServiceShould.ReturnGamDateInNextWeekWhenStartingRealYesterday < 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.ConsoleCommandParseShould.ParseAndExecute_WithNullGroupedCommand_ParsesWithNameAsGroup 13ms
✔️ Passed Kuiper.Tests.Unit.Systems.ConsoleCommandParseShould.ParseAndExecute_WithArgs_ExecutesWithArgs < 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.ConsoleCommandParseShould.ParseAndExecute_WithoutArgs_ExecutesWithNullArgs < 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.ConsoleCommandParseShould.Parse_WithoutArgs_ParsesWithNullArgs < 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.ConsoleCommandParseShould.Parse_WithNullGroupedCommand_ParsesWithNameAsGroup 1ms
✔️ Passed Kuiper.Tests.Unit.Systems.ConsoleCommandParseShould.Parse_WithArgs_ParsesWithArgs < 1ms
✔️ Passed Kuiper.Tests.Unit.Services.CaptainServiceShould.SaveSuccessfully 15ms
✔️ Passed Kuiper.Tests.Unit.Services.CaptainServiceShould.LoadCaptainWhenSavesFound 11ms
✔️ Passed Kuiper.Tests.Unit.Services.CaptainServiceShould.SetupANewCaptainIfNoSavesFound 1ms
✔️ Passed Kuiper.Tests.Unit.Services.CaptainServiceShould.ReturnCaptainIfAlreadySetup 1ms
✔️ Passed Kuiper.Tests.Unit.Services.CaptainServiceShould.ThrowIfCaptainIsNotSet < 1ms

Run Messages

Informational

[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 6.0.0-rtm.21522.10)
[xUnit.net 00:00:00.49]   Discovering: kuiper-tests
[xUnit.net 00:00:00.53]   Discovered:  kuiper-tests
[xUnit.net 00:00:00.54]   Starting:    kuiper-tests
[xUnit.net 00:00:00.82]   Finished:    kuiper-tests
Warning

Error


Created using Liquid Test Reports

Code Coverage

# Summary
Generated on: 11/22/2021 - 15:38:47
Parser: CoberturaParser
Assemblies: 1
Classes: 20
Files: 20
Covered lines: 436
Uncovered lines: 44
Coverable lines: 480
Total lines: 923
Line coverage: 90.8% (436 of 480)
Covered branches: 49
Total branches: 58
Branch coverage: 84.4% (49 of 58)
Covered methods: 101
Total methods: 110
Method coverage: 91.8% (101 of 110)
Name Covered Uncovered Coverable Total Line coverage Covered Total Branch coverage Covered Total Method coverage
kuiper-game 436 44 480 923 90.8% 49 58 84.4% 101 110 91.8%
Kuiper.Domain.Account 21 0 21 44 100% 0 0 5 5 100%
Kuiper.Domain.Captain 16 0 16 29 100% 0 0 7 7 100%
Kuiper.Domain.CelestialBodies.CelestialBody 46 0 46 82 100% 4 4 100% 12 12 100%
Kuiper.Domain.Physics 1 0 1 8 100% 0 0 1 1 100%
Kuiper.Domain.SaveFile 4 0 4 14 100% 0 0 4 4 100%
Kuiper.Domain.Ship 47 0 47 84 100% 6 6 100% 14 14 100%
Kuiper.Domain.ShipEngine 18 1 19 35 94.7% 0 0 6 7 85.7%
Kuiper.Domain.ShipStatusExtensions 0 6 6 24 0% 0 4 0% 0 1 0%
Kuiper.Domain.Transaction 12 0 12 22 100% 0 0 5 5 100%
Kuiper.Repositories.JsonFileSolarSystemRepository 25 14 39 72 64.1% 6 8 75% 3 6 50%
Kuiper.Services.AccountService 14 0 14 34 100% 0 0 5 5 100%
Kuiper.Services.CaptainService 58 0 58 93 100% 6 6 100% 5 5 100%
Kuiper.Services.EventService 36 0 36 58 100% 12 12 100% 5 5 100%
Kuiper.Services.GameTimeService 16 0 16 44 100% 2 2 100% 5 5 100%
Kuiper.Services.ShipService 49 0 49 78 100% 4 4 100% 7 7 100%
Kuiper.Services.SolarSystemService 27 0 27 61 100% 0 0 8 8 100%
Kuiper.Systems.CaptainsConsole 0 11 11 29 0% 0 0 0 2 0%
Kuiper.Systems.CommandInfrastructure.ConsoleCommandParser 28 12 40 69 70% 9 12 75% 3 5 60%
Kuiper.Systems.ConsoleWriter 8 0 8 19 100% 0 0 2 2 100%
Kuiper.Systems.Events.SetCourseEvent 10 0 10 24 100% 0 0 4 4 100%