Sunday, October 29, 2017

Traveller Tracker - Trade Classifications

I've added the trade classification table and an initial list.  I went through a few choices before settling on the code below. I was going to actually pull the various codes (size, atmosphere, etc) into another table, so that a trade code was a list of various things, but while this gives an immense flexibility and future proofs it to some extent, I also realized I am not writing an EHR system anymore and that sort of complexity, while making future updates a lot easier, does not apply to this. So I just stuck in the UWP attributes as a list. More choices - straight list, comma, space delimited...Ended up space delimited to make the UI simpler. Backend may be a bit more complicated.

So, how does this work?  I'll add a method that you pass in the world and it returns the various trade codes.  I need to update the cargo table a bit to have how the trade codes affect the price, but I may make that another table that also includes the Traveller version. Maybe - I've not added that anyplace, but may add that to the ship. That's what I did before I think.

I've also added a class to seed the DB. Currently it just as Ag so I could at least test the trade code listing. But I'll probably get around to adding all of them.  And some basic classic ship classes.

Trade classification class:

 public class TradeClassification
    {
        public int TradeClassificationID { get; set; }

        // 2 character code (Ag)
        public string Classification { get; set; }

        // spelled out name (Agrictulteral)
        public string Name { get; set; }

        // longer description (The world has the climate and conditions that promote...)
        public string Description { get; set; }

        public string Sizes { get; set; }           // list of sizes space delimited (0 1 2)
        public string Atmospheres { get; set; }     // list of atmospheres space delimited (0 1 2)
        public string Hydro { get; set; }           // list of Hydrographics space delimited (0 1 2)
        public string Pop { get; set; }             // list of Pop space delimited (0 1 2)
        public string Gov { get; set; }             // list of Gov space delimited (0 1 2)
        public string Law { get; set; }             // list of Law space delimited (0 1 2)

        [NotMapped]
        public string Codes {  get { return string.Format("Size: {0} Atm: {1} Hydro: {2} Pop: {3} Gov: {4} Law: {5}", Sizes, Atmospheres, Hydro, Pop, Gov, Law); } }

        [NotMapped]
        public string ShortDescription {  get { return string.Format("{0} {1} [{2}]", Classification, Name, Codes);  } }





No comments: