Wednesday, May 10, 2023

Traveller World Explainer - Trade Codes

Trade codes are based on the physical stats out of the UWP. You can pretty much use the chart as-is from Traveller, and a simple text file can give you the resulting trade codes. There are a LOT of ways you can handle this, but as the list is small, and in theory if this text file were available to the end-user (or editable in the software) users could customize their trade code results.

# CT trade classifications

# 2 character code<space>description,size,Atm,Hyd,Pop,Gov,Law,TL,cost effect (purchase)

# to figure it out, just read through the list and that match ('-' means not applicable), the criteria are valid as long as all the criteria matches


# if an additional field is given, it is tech

Ag agricultural,-,456789,45678,567,-,-,-,0

As Asteroid,0,-,-,-,-,-,-,0

De Desert,-,123456789A,0,-,-,-,-,0

Ic Ice capped,-,01,123456789A,-,-,-,-,0

In Industrial,-,012479,-,9ABC,-,-,-,0

Na non-agricultural,-,0123,0123,6789ABC,-,-,-,0

Ni non-industrial,-,-,-,123456,-,-,-,0

Po poor,-,2345,0123,-,-,-,-,0

Ri rich,-,68,-,678,456789,-,-,0

Va vacuum,-,0,-,-,-,-,-,0

Wa Water world,-,-,A,-,-,-,-,0

I generally prefer simple to begin with. And I think this is sort of a variation on how HL7 records work (an old data schema for transferring clinical and administrative data between healthcare providers. I had to convert that to import those records into a system I was a part of years ago. Funny how things stick with you!)

This table is from an older version of the Traveller Tracker, and does look like it may be missing the cost DM. As I am not working on trade (yet!) I can punt that part down the road.

The nice thing is that I could include the tables for various versions of Traveller, so that you can choose which rule set you are using. Again - a future idea assuming that this one moves along and gets to something like a completed or at least ready to share state. And I will note again that this is all in my public Github account here. So you can follow along with my often-bumbling approach. It turns out that MAUI programs have a RAW directory in the resources directory, and stuff placed here gets bundled with the application and can be read. Now, longer term, I'd probably move this sort of thing into the database (SQLite for this application). This would allow us to update the table, and hopefully, not overwrite any user-defined things with future releases. While not a consideration for this project, these are the things I think about. Guess I have been writing software a long time!

An even simpler table is the government table: as the CT ranges from 0..15, I just have a list of governments, and you just grab the one based on the value. Like a lot of languages, the array (or list in this case) starts at 0. I basically snagged all those tables and will use them for some initial lookups. 

And there are text boxes in MAUI, but I can use a label for a display-only set of results. I've added the button action, and while I do have some checks in place to validate a valid world (to some definition of valid) I am currently bypassing those to see how the label looks. And you can see that the port as G is invalid and red. Sadly this is only in the display part of the software: I think I may have to convert to MVVM to have this in the model so that the display gets the model validations. At least I think that is what I have to do.

There are some really nice text tools built-in for editing text. A future phase of this may be to save off your worlds and have your own text for them.

I was trying to get model-level data verification in place, but I think that would be more an MVVM architecture, which currently this project is not. Application architectures are interesting, and like frameworks, can be both very useful and very constraining. But that is a discussion for another post! I did add page-level validation (where a page is like a view for those who are more web-oriented - basically where we are showing something). I'll have to see if I can work that into the actual explanation button action. 

And I need to see about adding unit tests - that was the reason for adding validation so that I can automate all this stuff better. I'm just having a bit of a hard time getting it in place still. 

Some slow and erratic progress. I started this back today as I've had a few screening interviews, and one that I thought I totally messed up I have a call-back for a 2nd interview. And I had an actual face-to-face interview with an interesting and local company. Oddly, they use 3 things (.Net, Filemaker & Rails) that I have that is also not a common shared set of skills. I have had a somewhat circuitous career path it seems! And some of those interviews seem to have gone well, so I may actually have choices to make. Previously I've just grabbed the 1st job that came along: I fear I am often far too much defined by my job. Well, that and I like insurance....

No comments: