Saturday, August 23, 2025

Traveller System Update 19 - System Features

I started out adding the "Continuation Star System" by following the book, then realized I needed to add yet another table - the system features table. I did all that, got basic CRUD working, but also think I may have to really think about adding versions to some of these tables. For instance, you may want to be able to use the software to generate systems in different versions of Traveller. Currently it is primarily Classic, though the table could be used for any system I only have 1 version in the process. 

So, I am thinking of adding yet another (!) table - versions. And those tables that need that sort of delimiter, such as the system features table, could have that ID added. Then you could generate the system based on your version. Anyway - sort of simple to add later as most tables will not need that differentiation. System features, maybe starports, law levels, hmm, a few more possibly than I initially though. 

Anyway, I've added the system features table and basic CRUD but needs a bit of polishing. But I also added the first few steps of the generation service, which is when I discovered I needed more stuff to make that work. And this is why almost all software projects take a lot longer than expected: there are things we just do not anticipate. Of course, I should have anticipated this but alas, I blame the project manager (hey, I am throwing myself under the bus!)

Some of the rules listed under the table in Book 6 I may just hardcode in there. Not sure yet. While I'd like to make a lot of this completely under user control, not sure just yet how to add this type of rule. But if anyone wants me to think about it and implement that sort of thing, I know I can.

index view

edit

badly scanned book 6

Code for system generation - WIP. 

I got stuck when having to add the CRUD for this table, but the next step is to get the stellar type. Bad news is that we then need to cross-reference that stellar type to get orbit info so we can stash the primary planet into the habitable zone. If it is planet and not a belt. It is amazing the number of things to go through. And I do plan on adding flavor from some of the world builders stuff. It may take a while at the rate I am moving but it will hopefully happen!
 
So far, I just have get the planet, add that planet to our new system, and just the start of getting the stellar type. That was where I discovered I needed that table!

using TravSystem.Data.Repositories;
using TravSystem.Models;

namespace TravSystem.Services;

public class TSystemGenService : ITSystemGenService
{
    private ITPlanetRepository _planetRepository;
    private ITSystemRepository _systemRepository;
    private ITSubSectorRepository _subSectorRepository;
    private readonly ITStellarTypeRepository _stellarTypeRepository;

    public TSystemGenService(ITPlanetRepository planetRepository, 
        ITSystemRepository systemRepository, 
        ITSubSectorRepository subSectorRepository,
        ITStellarTypeRepository stellarTypeRepository)
    {
        _planetRepository = planetRepository;
        _systemRepository = systemRepository;
        _subSectorRepository = subSectorRepository;
        _stellarTypeRepository = stellarTypeRepository;
    }
    /// <summary>
    /// generate a new system based on a main planet
    /// </summary>
    /// <param name="id"></param>
    /// <returns>the new system</returns>
    public async Task<TSystem> GenerateSystemFromMainPlanet(int id)
    {
        TPlanet? mainPlanet = await _planetRepository.GetByID(id);
        TSystem newSystem = new TSystem();
        newSystem.Planets.Add(mainPlanet);

        // determine stellar type from main planet
        TStellarTypes stellarType = await DetermineStellarType(mainPlanet);
        

        _systemRepository.Add(newSystem);
        return newSystem;
    }

    //TODO: implement the complete system generation
    public Task<TSystem> GenerateSystemFromSystem(int id)
    {
        throw new NotImplementedException();
    }

    /// <summary>
    /// get the steller type; we will adjust the planet's orbit to be in the habitable zone
    /// </summary>
    /// <param name="planet">main system planet</param>
    /// <returns></returns>
    private async Task<TStellarTypes> DetermineStellarType(TPlanet planet)
    {
        // logic to determine stellar type based on main planet characteristics
        // this is a placeholder implementation
        var stellarTypes = await _stellarTypeRepository.GetAll();
        return stellarTypes.FirstOrDefault() ?? new TStellarTypes();
    }
}

Related Posts for Traveller System Generator

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-1-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-2-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-3-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-4-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-5-and.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-6.html

Part 7 towards the bottom here

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-8.html

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-9.html

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-10.html

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-11-and.html

https://traveller-ct.blogspot.com/2025/05/game-switching-traveller-system.html

https://traveller-ct.blogspot.com/2025/05/traveller-generator-part-13-settings.html

https://traveller-ct.blogspot.com/2025/06/traveller-system-generator-part-14.html

https://traveller-ct.blogspot.com/2025/06/traveller-system-generator-part-15-and.html

https://traveller-ct.blogspot.com/2025/06/traveller-system-generator-part-16.html

https://traveller-ct.blogspot.com/2025/07/traveller-system-generator-17-minor.html

https://traveller-ct.blogspot.com/2025/08/traveller-system-generator-update-18.html

No comments: