/// <summary> /// generate a report of all trade codes /// </summary> private void reportAllCodes() { List<string> codes = new List<string>(); foreach (string line in cbWorlds.Items) { try { Traveller.World tw = new Traveller.World(line, ship.Version); Traveller.Trade trade = new Traveller.Trade(ship, tw); List<Traveller.Starship.cargoDesc> cargoes = trade.findCargo(); string cc = String.Format("{0,-25} {1} [{2}] {3}", tw.Name, tw.UWP, tw.Hex, cargoes[0].origCode); codes.Add(cc); } catch (Exception ex) { codes.Add("Error on line: " + line + ": " + ex.Message); } } SaveFileDialog sv = new SaveFileDialog(); if (sv.ShowDialog() == DialogResult.OK) { File.WriteAllLines(sv.FileName, codes.ToArray()); } }
/// <summary> /// generate the list of J6 worlds and their expected base value /// </summary> private void reportJ6Trade() { // 1st, we need a cargo code from the current world Traveller.Trade trade = new Traveller.Trade(ship, world); Traveller.Starship.cargoDesc origCargo = trade.findCargo()[0]; List<string> codes = new List<string>(); codes.Add(String.Format("Selling from {0} [{1}] Cargo Origin Code: {2}", world.Name, world.Hex, origCargo.origCode)); codes.Add(" "); foreach (ListViewItem lvi in lvJ6.Items) { try { Traveller.World tw = new Traveller.World(lvi.Text, ship.Version); trade = new Traveller.Trade(ship, tw); origCargo = trade.sell(origCargo, tw, 0); string cc = String.Format("{0,-20} {1} [{2}] Cr{3}", tw.Name, tw.UWP, tw.Hex, origCargo.basecostsell); codes.Add(cc); } catch (Exception ex) { codes.Add("Error on line: " + lvi.Text + ": " + ex.Message); } } SaveFileDialog sv = new SaveFileDialog(); if (sv.ShowDialog() == DialogResult.OK) { File.WriteAllLines(sv.FileName, codes.ToArray()); } }
// generate the cargo. T5 & CT return a single cargo; Mongoose multiple ones private void btnGenerateCargo_Click(object sender, EventArgs e) { if (ship == null | world == null) { MessageBox.Show("You must have a ship in port to search for cargo!"); return; } Traveller.Trade trade = new Traveller.Trade(ship, world); trade.useExpandedTradeTables = ckMTExpanded.Checked; List<Traveller.Starship.cargoDesc> cargoes = trade.findCargo(); foreach (Traveller.Starship.cargoDesc cargo in cargoes) { ListViewItem li = new ListViewItem(cargo.origCode); li.SubItems.Add(cargo.purchasePrice.ToString()); li.SubItems.Add(cargo.dtons.ToString()); li.SubItems.Add(cargo.desc); li.SubItems.Add(cargo.basecostbuy.ToString()); li.SubItems.Add(cargo.avBuy.ToString()); lvAvailableCargo.Items.Add(li); } }