Saturday, November 18, 2017

Worlds within jump range

I have draft 1 of this working. It is a brute force approach and limited to the worlds within the current subsector. It is those literal edge cases I may have to figure a way around.

The code is very simple though:

       public List JumpRange(int jump)
        {
            Utilities util = new Utilities();
            List results = new List();
            foreach (World world in TravellerTracker.App.DB.Worlds.Where(x => x.SectorID == this.SectorID))
            {
                if (this.Hex != world.Hex)
                    if (util.calcDistance(this.Hex, world.Hex) <= jump)
                        results.Add(world);
            }

            return results;
        }

Just go through the list of the worlds in your subsector and if they are in range and not your planet, add them to the return list.  The jump range calculation is based on hex maps for calculating ranges. I've added this method to the world class. It was either there or the ship class.

I am also thinking we could shorten the list down a bit by limiting the set of worlds to search from the entire subsector to just those with +/- jump range for the hex pairs. So that a world at 1020 and a jump range of 3 would give us the range of 0717 to 1323. However - systems are fast enough to use the brute force approach so that works for me.

Still need to make the UI prettier, and add a button to allow the user to jump to that system (add 7 days, subtract the appropriate amount of fuel). I also need to do this on the cargo tab - each world would have the passenger and bulk cargo available going to that world. Add the buttons to accept and subtract from available tonnage or steerage (well, that's not there) and add the credits.


Wednesday, November 15, 2017

Alell World Map

Just so there is something that is not software related. I really need to start another game...


Monday, November 13, 2017

Traveller Tracker - another view

I may not have made this clear when I started this latest version of the ship tracking software: the idea behind this is to support at least 2, maybe 3 versions of Traveller. But, everything will be user-editable and hopefully extendable. For example, right now I've got the classic book 2 d66 cargo table built. I do have the cargo loading method returning something from that table if your ship is running Classic.  However, you can change the entries, and in theory, we could even extend the table, making it a D1010 table if you wanted a wide range of things. To do this, we'd have to allow you to put in a custom version you want to play, but it is based off of one of the 3 I am hoping to support. So for instance, you are basing your game off of Traveller, but really want a much wide range of cargos. So the version table will have to have information allowing you to customize things to your game.

That will probably be further off (although now I think I'll add the dice to roll for cargo in the versions table, so classic will be d66). I need to get the durn thing to work first...

Bottom line - I want this to (a) work and (b) be able to be customized.  Which is why pretty much everything is table-based, and I'll be giving the end user the ability to update these tables. 

And there will be an option to reset to seed to reset everything back to the initial state. Hmm, meaning I may want the ability to export ship classes and ships at least.  Drat - I do need to make a project board or something to track all this! It's become a larger project than expected.

And I really want to play Traveller again - maybe I can figure a way to do that. There's just so little time available outside of all the other things I need to do. Being an adult is not what is is cracked up to be sometimes.

Sunday, November 12, 2017

Tracker - Classic speculative trade

Got it to load a classic speculative trade item, compete with the tons and all that calculated via the cargo table.

What I realized while doing this is that the cargo and passengers are based on the destination world.  So my UI will be changing.  The load cargo routine passes in the ship object, which basically contains a pointer to the current world. What I need to do is also have the list of worlds available based on the ship's jump capacity also be available. I need this for the jump worlds list, and also for the cargo and passenger calculations. What I am going for is a list, with a row per world, something like:

World    Major Minor Incidental  High  Mid   Low
Trane    5 [ ] 2 [ ] 0 [ ]       1 [ ] 3 [ ] 12 [ ]
New Rome 6 [ ] 8 [ ] 1 [ ]       2 [ ] 2 [ ] 12 [ ]

(numbers are made up and do not represent what the tables may actually yield). Click the button and (1) you are credited with the credits due, (2) updates your available cargo, (3) updates cabin space. Err, huh, I've not added cabin space in the ships.  While the base ship class probably can have this, I do believe the ship may be able to adjust this. Or just not track it just yet. Maybe version 1.1...

Still needs work on the UI.  

And now the work week starts again, so probably no updates until next weekend.  Both child & wife were away this weekend so I had some time to work on this.  Honestly, 20 hours of work would probably make this ready to test publish if I had 3 straight days to keep in the groove. As it is, an hour or two here, and part of that is just remembering where I left off...




Traveller Tracker - cargo pt 2

Got the basic cargo editor in place. I also did a test deploy to my tablet - so I can run the software on a different machine, one that is much more touch-based.  Interestingly enough it actually works. I just need to play around a bit on the tablet to see how things play out.

I still need to actually get the speculative trade part done, then also look at the basic non-spec trade (major, minor and incidental cargos).  I am really thinking about somehow rolling those into the cargos as they are cargo, but they aren't as well seeing as you just get paid to move them along with little risk.

I may have to create the list of things to do with this. As I am starting on a project management degree in a couple of months (and so kiss free time goodbye for 2 years as I work on another master's degree) this could be a good test bed for project management.


Traveller Tracker - cargo v1

I've seeded the DB with the book 2 cargos, and have an initial draft not yet in place. Part of this is also having a cargo editor.  I've the cargo list going, but also realize I may have to end up putting in a search function as well - T5 has perhaps hundreds of cargos.

The cargo class itself is a blend of the various versions.  I'm concentrating on Classic at the moment until I get that working.

If there were interest, I'd actually open up a Trello board or something to allow potential users a voice in where this is going. And as previously mentioned the source code is on my GitHub account with an open source license.  If anyone is interested in running this locally (Windows 10 only, sorry!) let me know & I can add an entry on how to do all that (clone the repo, install the tools, run the thing).

I also had to reset the migrations again: I misnamed a column in the cargo table, and renaming columns is not supported for SQLite / Entity Framework. Darn.

Cargo definition at the moment:

   public class Cargo
    {
        public int CargoID { get; set; }
        public int dTons { get; set; }
        public int BasePurchasePrice { get; set; }
        public string CargoCode { get; set; }
        public string Description { get; set; }
        // FK to CargoType
        public int CargoTypeId { get; set; }
        public int TravellerVersionId { get; set; }  // which version of Traveller this belongs to; 0 = all
        // version specific items
        // classic d66 table
        public int D1 { get; set; }
        public int D2 { get; set; }
        public int QtyDie { get; set; }
        public int Multiplier { get; set; }
        public string GetCargoType()
        {
            if (CargoTypeId > 0)
                return TravellerTracker.App.DB.CargoTypes.Where(x => x.CargoTypeId == CargoTypeId).FirstOrDefault().Description;
            else
                return "n/a";
        }
        [NotMapped]
        public string ListDesc => string.Format("[{0} {1}] {2}", D1, D2, Description);
    }







Tuesday, November 07, 2017

Traveller Tracker - Trade Goods

I pulled in a previous version set of trade goods: book 2 goods list (a d66 list) and the T5 random goods table by trade codes. Oddly one is an XML file, the other CSV.  What I will do is update the seed to add those to the DB if not already added.  The seed function only adds things if they don't exist, the theory being that once you do have it installed, you don't want to overwrite anything anyone has added.  The options section will probably have a function to reset all back to the initial data. Probably.

Now I still have to figure out how to generate the goods available based on versions. I've stubbed out the methods based on version, and they all return a list of cargos (although I may have to make some changes to include tons, codes and other odds and ends. The cargo table itself does not include tons, just what the cargo is; another table will hold the mods by version for buy/sell.  I am making this far more complex than necessary...

I may move the Traveller versions to be an enumeration instead, but I am thinking the trade code modifiers may get added in there somehow as well.

public void SeedDB(TravellerContext db)
{
   if (db.TradeClassifications.Count() == 0)
   {
      TradeClassification tc = new TradeClassification();
      tc.Classification = "Ag";
      tc.Name = "Agriculteral";
      tc.Description = "The world has climate and conditions that promote farming and ranching. It is a producer of inexpensive food stuffs. It also is a source of unusual, exotic or strange delicacies";
       tc.Sizes = "";
       tc.Atmospheres = "4 5 6 7 8 9";
       tc.Hydro = "4 5 6 7 8";
       tc.Pop = "5 6 7";
       tc.Gov = "";
       tc.Law = "";
       db.Add(tc);
   }
   if (db.TravellerVersions.Count() == 0)
   {
       db.Add(new TravellerVersion() { Name = "Classic" });
       db.Add(new TravellerVersion() { Name = "Mongoose Traveller" });
       db.Add(new TravellerVersion() { Name = "T5" });
    }
    if (db.CargoTypes.Count() == 0)
    {
        db.Add(new CargoType() { Type = "Consumables", Description = "Consumables are food and drink, and may also include aromatics. Consumable foods are gourmet items, common flavorings or staples necessary on worlds where it cannot be produced." });
        db.Add(new CargoType() { Type = "Data", Description = "Data is information that can be consumed, reproduced or processed on the target workd. It includes books, tapes, wafers, software, creative works and scientific data." });
        db.Add(new CargoType() { Type = "Entertainments", Description = "Creative workss and diversionsa are always in demand." });
        db.Add(new CargoType() { Type = "Imbalances", Description = "When the cost of producing a trade item is very low, then it can be shipped between the stara and sold at a market for less than it can be produced locally. Worlds with low labor costs can often produce goods that can be sold elsewhere at a profit." });
        db.Add(new CargoType() { Type = "Manufactureds", Description = "Worlds with establisged factories export their products to worlds that cannot produce them." });
        db.Add(new CargoType() { Type = "Novelties", Description = "New products never before seen." });
        db.Add(new CargoType() { Type = "Pharma", Description = "Pharmaceuticals and medicine for treatment of all manner of illness or disability." });
        db.Add(new CargoType() { Type = "Rares", Description = "Many trade goods are in demand because of their rarity or relative scarcity." });
        db.Add(new CargoType() { Type = "Raws", Description = "One of the basic trade goos in interstellar trade is raw materials." });
        db.Add(new CargoType() { Type = "Red Tape", Description = "Because there are interstellar governments, the products of their bureacracy must be distributed throughout their area of authority." });
        db.Add(new CargoType() { Type = "Samples", Description = "Newly discovered, created or manufactured items may be distributed to other workds for analysis or evaluation." });
        db.Add(new CargoType() { Type = "Scrap/Waste", Description = "The trash of some worlds can be a valued commodity on other worlds." });
        db.Add(new CargoType() { Type = "Uniques", Description = "Some items cannot be reproduced, adding value to the product." });
        db.Add(new CargoType() { Type = "Valuta", Description = "Sometimes shipments between worlds consist of money itself." });
     }
     db.SaveChangesAsync();
    }

Saturday, November 04, 2017

Traveller Tracker - Jump map, trade class editor

Finished up the trade code editor, complete with a delete option. Although I will probably put all the basic codes into the seed class to have them out of the box.  I still need to add a matrix of how the trade codes affect trade (buy, sell, availability). This is pretty much version dependent so I need to figure a way to allow the eventual users the ability to edit this (huh, maybe I am designing an EHR all over again!)

I also finally got the jump map display to work (thanks TravellerMap!) The code is pretty straight forward - pass in the world object & the jump range and you get a URL back.  I do have to replace all spaces with %20.  Now that I am thinking about it, I could just return a proper Uri instead of a string...next commit!

        public string JumpMapURL(World w, int jump)
        {
            string sector = App.DB.Sectors.Where(x => x.SectorID == w.SectorID).FirstOrDefault().Name.Replace(" ", "%20");
            return  string.Format("Https://travellermap.com/api/jumpmap?sector={0}&hex={1}&jump={2}", sector, w.Hex, jump);
        }


I also return the trade code in alphabetical order based on the 2 character code.  

I can generate the list of worlds within jump range from the downloaded worlds (I cache all sectors & worlds you load in the local DB, and I've code to figure out the worlds based on the hex position).

Still need to plumb in the buttons for searching for cargo, but first I have to figure that part out. And a cargo editor.





Tuesday, October 31, 2017