예제 #1
0
파일: Saver.cs 프로젝트: hooperk/Starship
 /// <summary>
 /// Save a Starship in the old .sss format
 /// </summary>
 /// <param name="ship">Starship to save</param>
 /// <param name="path">Path of the file to save to</param>
 public static void SaveSSS(Starship ship, String path)
 {
     using (FileStream fs = File.OpenWrite(path))
     {
         SaveSSS(ship, fs);
     }
 }
예제 #2
0
 public CrewRating(Starship starship)
 {
     if (starship == null)
         throw new ArgumentNullException("Cannot initialise Crew Rating with a null ship");
     Starship = starship;
     RaceCount = 0;
     InitializeComponent();
     foreach (Race race in Enum.GetValues(typeof(Race)))
     {
         Button button = new Button();
         button.Content = race.Name();
         button.Click += ((s, e) => SetRace(race));
         Grid.SetColumn(button, 0);
         Grid.SetRow(button, RaceCount);
         TextBlock textblock = new TextBlock();
         textblock.Text = race.Description();
         textblock.TextWrapping = TextWrapping.WrapWithOverflow;
         textblock.Margin = new Thickness(3, 1, 1, 1);
         Border border = new Border();
         border.BorderBrush = Brushes.Black;
         border.BorderThickness = new Thickness(0, 1, 0, 1);
         border.Child = textblock;
         Grid.SetColumn(border, 1);
         Grid.SetRow(border, RaceCount++);
         Races.Children.Add(button);
         Races.Children.Add(border);
     }
     Servitor.ItemsSource = Enum.GetValues(typeof(ServitorQuality));
     CrewQuality.ItemsSource = Enum.GetValues(typeof(StarshipGenerator.Utils.CrewRating));
     SetRace(Starship.CrewRace);
 }
예제 #3
0
 public HullChooser(Starship starship, IEnumerable<Hull> hulls)
 {
     if(starship == null)
         throw new ArgumentNullException("Cannot initialise Hull Chooser with a null ship");
     HullCount = 1;
     Starship = starship;
     InitializeComponent();
     ClearButton.Click += ((s, e) => SetHull(null));
     foreach (Hull hull in hulls)
     {
         Hulls.Children.Add(MakeName(hull));
         Hulls.Children.Add(MakeColumn(hull.SP, 1));
         Hulls.Children.Add(MakeColumn(hull.Space, 2));
         Hulls.Children.Add(MakeClass(hull));
         Hulls.Children.Add(MakeColumn(hull.Speed, 4));
         Hulls.Children.Add(MakeColumn(hull.Manoeuvrability, 5));
         Hulls.Children.Add(MakeColumn(hull.DetectionRating, 6));
         Hulls.Children.Add(MakeColumn(hull.HullIntegrity, 7));
         Hulls.Children.Add(MakeColumn(hull.Armour, 8));
         Hulls.Children.Add(MakeColumn(hull.TurretRating, 9));
         Hulls.Children.Add(MakeSlots(hull));
         Hulls.Children.Add(MakeSource(hull));
         String description = hull.Description;
         if (!String.IsNullOrWhiteSpace(description))
             Hulls.Children.Add(MakeDecription(description));
     }
     UpdateHull();
 }
예제 #4
0
 public Upgrades(Starship starship)
 {
     if (starship == null)
         throw new ArgumentNullException("Cannot initialise Upgrades with a null ship");
     this.Starship = starship;
     UpgradeCount = 0;
     InitializeComponent();
     generateUpgrades();
     UpdateAll();
 }
예제 #5
0
 public Backgrounds(Starship starship)
 {
     if (starship == null)
         throw new ArgumentNullException("Cannot initialise Backgrounds with a null ship");
     Starship = starship;
     this.Closed += onClose;
     InitializeComponent();
     d5.Value = 1;
     switch (Starship.Background)
     {
         case StarshipGenerator.Utils.Background.ThulianExploratorVessel:
             ThulianExploratorVessel.IsChecked = true;
             break;
         case StarshipGenerator.Utils.Background.ReaverOfTheUnbeholdenReaches:
             ReaverOfTheUnbeholdenReaches.IsChecked = true;
             break;
         case StarshipGenerator.Utils.Background.VeteranOfTheAngevinCrusade:
             VeteranOfTheAngevinCrusade.IsChecked = true;
             break;
         case StarshipGenerator.Utils.Background.ImplacableFoeOfTheFleet:
             ImplacableFoeOfTheFleet.IsChecked = true;
             break;
         case StarshipGenerator.Utils.Background.SteadfastAllyofTheFleet:
             SteadfastAllyofTheFleet.IsChecked = true;
             break;
         default:
             StarshipGenerator.Utils.Background planetbound = Starship.Background & StarshipGenerator.Utils.Background.PlanetBoundForMillenia;
             if (planetbound != 0)
             {
                 PlanetBoundForMillenia.IsChecked = true;
                 d5.Value = (int)planetbound;
             }
             break;
     }
     Speed.Value = Starship.GMSpeed;
     HullIntegrity.Value = Starship.GMHullIntegrity;
     Detection.Value = Starship.GMDetection;
     Manoeuvrability.Value = Starship.GMManoeuvrability;
     Armour.Value = Starship.GMArmour;
     TurretRating.Value = Starship.GMTurretRating;
     Morale.Value = Starship.GMMorale;
     CrewPopulation.Value = Starship.GMCrewPopulation;
     Shields.Value = Starship.GMShields;
     CrewRating.Value = Starship.GMCrewRating;
     Special.Text = Starship.GMSpecial;
 }
예제 #6
0
파일: Loader.cs 프로젝트: hooperk/Starship
 //Modified -> Regular w/ Modified = true
 //Some components were renamed for move to c#
 //name.Replace("†","") for finding supplementals
 /// <summary>
 /// do fetches by name to update information in case of fixes
 /// </summary>
 public static void Update(Starship ship)
 {
 }
예제 #7
0
 private void LoadMenu_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog dialog = new OpenFileDialog();
     dialog.Filter = "Starship Sheets (.sss)|*.sss|Live Ship Sheets (.lss)|*.lss|All Ship Sheets|*.sss;*.lss";
     dialog.FilterIndex = 3;
     dialog.CheckFileExists = true;
     if (dialog.ShowDialog() ?? false)
     {
         try
         {
             Starship = loader.LoadStarship(dialog.FileName);
             UpdateAll();
             HullName.Text = Starship.Name;
         }
         catch (FormatException)
         {
             MessageBox.Show("Invalid .sss file, letters stored in number field", "Error Opening File");
         }
         catch (ArgumentException)
         {
             MessageBox.Show("Invalid .sss file.", "Error Opening File");
         }
         catch (KeyNotFoundException)
         {
             MessageBox.Show("Invalid .sss file, missing required key", "Error Opening File");
         }
     }
 }
예제 #8
0
 private void ClearMenu_Click(object sender, RoutedEventArgs e)
 {
     Starship = new Starship();
     HullName.Text = "";
     UpdateAll();
 }
예제 #9
0
 public StarshipCreator()
 {
     loader = new Loader();//initialise with default components TODO:Loading of saved custom components
     Starship = new Starship();//fresh starship
     InitializeComponent();
 }
예제 #10
0
 public WeaponUpgrades(Starship starship)
 {
     if (starship == null)
         throw new ArgumentException("Cannot make weapon ugprades with a null ship");
     this.Starship = starship;
     this.Weapons = new List<Weapon>();
     this.Ranges = new List<TextBox>();
     this.Ballistics = new List<TextBox>();
     this.Matrices = new List<CheckBox>();
     this.WeaponRowCount = 0;
     InitializeComponent();
     AllCheck.IsChecked = (Starship.TargettingMatrix == Quality.Common);
     Label label;
     TextBox textbox;
     CheckBox checkbox;
     int count = 0;
     foreach (Tuple<WeaponSlot, Weapon> WeaponPackage in Starship.WeaponList)
     {
         if (WeaponPackage.Item2 != null)
         {
             int index = count;//initialise ints for each time around or lambdas will all use final count value of 3 and be out of bounds
             ComboBox combobox;//declare memory inside loop for same reason as above
             Weapons.Add(WeaponPackage.Item2);
             label = new Label();
             label.Content = WeaponPackage.Item1.ToString();
             Grid.SetRow(label, WeaponRowCount);
             Grid.SetColumn(label, 0);
             WeaponGrid.Children.Add(label);
             textbox = new TextBox();
             textbox.Text = WeaponPackage.Item2.QualityName;
             textbox.IsReadOnly = true;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 1);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Ranges.Add(textbox);
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 2);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Ballistics.Add(textbox);
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 3);
             WeaponGrid.Children.Add(textbox);
             combobox = new ComboBox();
             combobox.ItemsSource = Qualities;
             combobox.SelectedItem = WeaponPackage.Item2.TurboWeapon;
             if (WeaponPackage.Item2.Type != WeaponType.Macrobattery)
             {
                 combobox.IsEnabled = false;
                 combobox.ToolTip = "Only Macrobatteries may have turbo-weapon batteries";
                 ToolTipService.SetShowOnDisabled(combobox, true);
             }
             combobox.SelectionChanged += ((s, e) => QualityChanged(combobox, index));
             Grid.SetRow(combobox, WeaponRowCount);
             Grid.SetColumn(combobox, 4);
             WeaponGrid.Children.Add(combobox);
             checkbox = new CheckBox();
             checkbox.IsChecked = (Starship.TargettingMatrix == Quality.Common || WeaponPackage.Item2.TargettingMatrix == Quality.Poor);
             checkbox.Click += ((s, e) => SetMatrixIndex(index));
             checkbox.ToolTip = "Poor Quality";
             checkbox.VerticalAlignment = System.Windows.VerticalAlignment.Center;
             checkbox.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
             checkbox.Margin = new Thickness(17, 0, 0, 0);
             Matrices.Add(checkbox);
             Grid.SetRow(checkbox, WeaponRowCount++);
             Grid.SetColumn(checkbox, 5);
             WeaponGrid.Children.Add(checkbox);
             UpdateWeapon(count++);
         }
     }
 }
예제 #11
0
 public static Complication ShipHistory(Starship starship)
 {
     return new Complication(starship, false);
 }
예제 #12
0
파일: Saver.cs 프로젝트: hooperk/Starship
 /// <summary>
 /// Save a Starship in the new .lss format
 /// </summary>
 /// <param name="ship">Starship to save</param>
 public static void SaveLSS(Starship ship, String path)
 {
 }
예제 #13
0
 public WeaponChooser(Starship starship, WeaponSlot slot, int index, Loader loader)
 {
     if (starship == null || starship.Hull == null)
         throw new ArgumentException("Cannot create weapon chooser without starship or hull");
     this.Starship = starship;
     this.Index = index;
     WeaponRowCount = 0;
     InitializeComponent();
     Label label;
     Button button;
     TextBox textbox;
     TextBlock textblock;
     button = new Button();
     button.Content = "Clear Weapon";
     button.Click += ((s, e) => SetCurrent(null));
     Grid.SetRow(button, WeaponRowCount);
     Grid.SetColumn(button, 0);
     WeaponGrid.Children.Add(button);
     foreach (var group in loader.Weapons.Where(x => (x.HullTypes & starship.Hull.HullTypes) != 0 && (x.Slots & slot) != 0).GroupBy(x => x.ComponentOrigin).OrderBy(x => x.Key))
     {
         if (group.Key != ComponentOrigin.Standard)
         {
             label = new Label();
             label.Content = group.Key.ToString();
             Grid.SetRow(label, WeaponRowCount++);
             Grid.SetColumn(label, 0);
             WeaponGrid.Children.Add(label);
         }
         foreach (Weapon weapon in group)
         {
             button = new Button();
             button.Content = weapon.Name;
             button.Click += ((s,e) => SetCurrent(weapon, weapon.Quality, weapon.WeaponQuality));
             Grid.SetRow(button, WeaponRowCount);
             Grid.SetColumn(button, 0);
             WeaponGrid.Children.Add(button);
             textbox = new TextBox();
             textbox.Text = weapon.Type.ToString();
             textbox.IsReadOnly = true;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 1);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.Power.ToString();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 2);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.Space.ToString();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 3);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.SP.ToString();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 4);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.Strength.ToString();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 5);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.Damage.ToString();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 6);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.DisplayRange;
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 7);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.Crit.ToString();
             textbox.IsReadOnly = true;
             textbox.TextAlignment = TextAlignment.Center;
             Grid.SetRow(textbox, WeaponRowCount);
             Grid.SetColumn(textbox, 8);
             WeaponGrid.Children.Add(textbox);
             textbox = new TextBox();
             textbox.Text = weapon.Origin.Name();
             textbox.IsReadOnly = true;
             textbox.ToolTip = weapon.Origin.LongName() + ", Page: " + weapon.PageNumber;
             Grid.SetRow(textbox, WeaponRowCount++);
             Grid.SetColumn(textbox, 10);
             WeaponGrid.Children.Add(textbox);
             if (!String.IsNullOrWhiteSpace(weapon.Description))
             {
                 textblock = new TextBlock();
                 textblock.Text = weapon.Description;
                 textblock.Margin = new Thickness(2, 2, 2, 2);
                 textblock.TextWrapping = TextWrapping.WrapWithOverflow;
                 Grid.SetRow(textblock, WeaponRowCount++);
                 Grid.SetColumnSpan(textblock, 11);
                 WeaponGrid.Children.Add(textblock);
             }
         }
     }
     Current = Starship.Weapons[Index];
     UpdateCurrent();
 }
예제 #14
0
 public SupplementalWindow(Starship starship, Loader loader)
 {
     if (starship == null || starship.Hull == null)
         throw new ArgumentNullException("Cannot choose supplementals without a hull");
     if (loader == null)
         throw new ArgumentNullException("Cannot load supplementals without a loader");
     this.Starship = starship;
     ComponentCount = 0;
     InitializeComponent();
     Label label;
     Button button;
     TextBox textbox;
     TextBlock textblock;
     foreach (var generated in loader.Supplementals.Where(x => (x.HullTypes & Starship.Hull.HullTypes) != 0).GroupBy(x => x.PowerGenerated))
     {
         foreach (var group in generated.GroupBy(x => x.ComponentOrigin))
         {
             if (group.Count() > 0)
             {
                 if (group.Key != ComponentOrigin.Standard)
                 {
                     label = new Label();
                     label.Content = group.Key.ToString();
                     Grid.SetRow(label, ComponentCount);
                     Grid.SetColumn(label, 0);
                     ComponentGrid.Children.Add(label);
                 }
                 label = new Label();
                 label.Content = generated.Key ? "Generated" : "Used";
                 label.HorizontalContentAlignment = HorizontalAlignment.Center;
                 Grid.SetRow(label, ComponentCount++);
                 Grid.SetColumn(label, 2);
                 ComponentGrid.Children.Add(label);
             }
             foreach (Supplemental baseComponent in group)
             {
                 List<Supplemental> qualitycomponents = new List<Supplemental>();
                 if (baseComponent.RawSP > 1)//if component can have a lower cost, include poor quality
                     qualitycomponents.Add(new Supplemental(baseComponent.Name, baseComponent.HullTypes, baseComponent.RawPower, baseComponent.RawSpace, baseComponent.RawSP, baseComponent.Origin, baseComponent.PageNumber,
                         baseComponent.RamDamage, baseComponent.RawSpecial, Quality.Poor, baseComponent.Speed, baseComponent.Manoeuvrability, baseComponent.HullIntegrity, baseComponent.Armour, baseComponent.TurretRating,
                         baseComponent.Morale, baseComponent.CrewPopulation, baseComponent.ProwArmour, baseComponent.CrewRating, baseComponent.MiningObjective, baseComponent.CreedObjective, baseComponent.MilitaryObjective,
                         baseComponent.TradeObjective, baseComponent.CriminalObjective, baseComponent.ExplorationObjective, baseComponent.PowerGenerated, baseComponent.DetectionRating, baseComponent.AuxiliaryWeapon,
                         baseComponent.MacrobatteryModifier, baseComponent.BSModifier, baseComponent.NavigateWarp, baseComponent.CrewLoss, baseComponent.MoraleLoss, baseComponent.ComponentOrigin, baseComponent.Replace, baseComponent.Max,
                         StarshipGenerator.Utils.Condition.Intact));
                 //always add common quality
                 qualitycomponents.Add(new Supplemental(baseComponent.Name, baseComponent.HullTypes, baseComponent.RawPower, baseComponent.RawSpace, baseComponent.RawSP, baseComponent.Origin, baseComponent.PageNumber,
                         baseComponent.RamDamage, baseComponent.RawSpecial, Quality.Common, baseComponent.Speed, baseComponent.Manoeuvrability, baseComponent.HullIntegrity, baseComponent.Armour, baseComponent.TurretRating,
                         baseComponent.Morale, baseComponent.CrewPopulation, baseComponent.ProwArmour, baseComponent.CrewRating, baseComponent.MiningObjective, baseComponent.CreedObjective, baseComponent.MilitaryObjective,
                         baseComponent.TradeObjective, baseComponent.CriminalObjective, baseComponent.ExplorationObjective, baseComponent.PowerGenerated, baseComponent.DetectionRating, baseComponent.AuxiliaryWeapon,
                         baseComponent.MacrobatteryModifier, baseComponent.BSModifier, baseComponent.NavigateWarp, baseComponent.CrewLoss, baseComponent.MoraleLoss, baseComponent.ComponentOrigin, baseComponent.Replace, baseComponent.Max,
                         StarshipGenerator.Utils.Condition.Intact));
                 if ((baseComponent.RawPower > 1) ^ (baseComponent.RawSpace > 1))//if only one possible upgrade for good quality, do default good
                 {
                     qualitycomponents.Add(new Supplemental(baseComponent.Name, baseComponent.HullTypes, baseComponent.RawPower, baseComponent.RawSpace, baseComponent.RawSP, baseComponent.Origin, baseComponent.PageNumber,
                         baseComponent.RamDamage, baseComponent.RawSpecial, Quality.Good, baseComponent.Speed, baseComponent.Manoeuvrability, baseComponent.HullIntegrity, baseComponent.Armour, baseComponent.TurretRating,
                         baseComponent.Morale, baseComponent.CrewPopulation, baseComponent.ProwArmour, baseComponent.CrewRating, baseComponent.MiningObjective, baseComponent.CreedObjective, baseComponent.MilitaryObjective,
                         baseComponent.TradeObjective, baseComponent.CriminalObjective, baseComponent.ExplorationObjective, baseComponent.PowerGenerated, baseComponent.DetectionRating, baseComponent.AuxiliaryWeapon,
                         baseComponent.MacrobatteryModifier, baseComponent.BSModifier, baseComponent.NavigateWarp, baseComponent.CrewLoss, baseComponent.MoraleLoss, baseComponent.ComponentOrigin, baseComponent.Replace, baseComponent.Max,
                         StarshipGenerator.Utils.Condition.Intact));
                 }
                 else if (baseComponent.RawPower > 1 && baseComponent.RawSpace > 1)//If both can be added then can have efficient, slim or best(both) quality
                 {
                     qualitycomponents.Add(new Supplemental(baseComponent.Name, baseComponent.HullTypes, baseComponent.RawPower, baseComponent.RawSpace, baseComponent.RawSP, baseComponent.Origin, baseComponent.PageNumber,
                         baseComponent.RamDamage, baseComponent.RawSpecial, Quality.Slim, baseComponent.Speed, baseComponent.Manoeuvrability, baseComponent.HullIntegrity, baseComponent.Armour, baseComponent.TurretRating,
                         baseComponent.Morale, baseComponent.CrewPopulation, baseComponent.ProwArmour, baseComponent.CrewRating, baseComponent.MiningObjective, baseComponent.CreedObjective, baseComponent.MilitaryObjective,
                         baseComponent.TradeObjective, baseComponent.CriminalObjective, baseComponent.ExplorationObjective, baseComponent.PowerGenerated, baseComponent.DetectionRating, baseComponent.AuxiliaryWeapon,
                         baseComponent.MacrobatteryModifier, baseComponent.BSModifier, baseComponent.NavigateWarp, baseComponent.CrewLoss, baseComponent.MoraleLoss, baseComponent.ComponentOrigin, baseComponent.Replace, baseComponent.Max,
                         StarshipGenerator.Utils.Condition.Intact));
                     qualitycomponents.Add(new Supplemental(baseComponent.Name, baseComponent.HullTypes, baseComponent.RawPower, baseComponent.RawSpace, baseComponent.RawSP, baseComponent.Origin, baseComponent.PageNumber,
                         baseComponent.RamDamage, baseComponent.RawSpecial, Quality.Efficient, baseComponent.Speed, baseComponent.Manoeuvrability, baseComponent.HullIntegrity, baseComponent.Armour, baseComponent.TurretRating,
                         baseComponent.Morale, baseComponent.CrewPopulation, baseComponent.ProwArmour, baseComponent.CrewRating, baseComponent.MiningObjective, baseComponent.CreedObjective, baseComponent.MilitaryObjective,
                         baseComponent.TradeObjective, baseComponent.CriminalObjective, baseComponent.ExplorationObjective, baseComponent.PowerGenerated, baseComponent.DetectionRating, baseComponent.AuxiliaryWeapon,
                         baseComponent.MacrobatteryModifier, baseComponent.BSModifier, baseComponent.NavigateWarp, baseComponent.CrewLoss, baseComponent.MoraleLoss, baseComponent.ComponentOrigin, baseComponent.Replace, baseComponent.Max,
                         StarshipGenerator.Utils.Condition.Intact));
                     qualitycomponents.Add(new Supplemental(baseComponent.Name, baseComponent.HullTypes, baseComponent.RawPower, baseComponent.RawSpace, baseComponent.RawSP, baseComponent.Origin, baseComponent.PageNumber,
                         baseComponent.RamDamage, baseComponent.RawSpecial, Quality.Best, baseComponent.Speed, baseComponent.Manoeuvrability, baseComponent.HullIntegrity, baseComponent.Armour, baseComponent.TurretRating,
                         baseComponent.Morale, baseComponent.CrewPopulation, baseComponent.ProwArmour, baseComponent.CrewRating, baseComponent.MiningObjective, baseComponent.CreedObjective, baseComponent.MilitaryObjective,
                         baseComponent.TradeObjective, baseComponent.CriminalObjective, baseComponent.ExplorationObjective, baseComponent.PowerGenerated, baseComponent.DetectionRating, baseComponent.AuxiliaryWeapon,
                         baseComponent.MacrobatteryModifier, baseComponent.BSModifier, baseComponent.NavigateWarp, baseComponent.CrewLoss, baseComponent.MoraleLoss, baseComponent.ComponentOrigin, baseComponent.Replace, baseComponent.Max,
                         StarshipGenerator.Utils.Condition.Intact));
                 }
                 foreach (Supplemental component in qualitycomponents.Where(x => Starship.SupplementalComponents.Count(y => x.QualityName == y.QualityName && x.Origin == y.Origin) == 0 && (x.Max == 0 || Starship.SupplementalComponents.Count(y => x.Name == y.Name) < x.Max)))
                 {
                     label = new Label();
                     String name = component.QualityName;
                     if (component.Max == 1)
                     {
                         name += "†";
                         label.ToolTip = "Maximum of one " + component.Name;
                     }
                     label.Content = name;
                     Grid.SetRow(label, ComponentCount);
                     Grid.SetColumn(label, 0);
                     ComponentGrid.Children.Add(label);
                     Label countLabel = new Label();
                     countLabel.Content = 0;
                     countLabel.HorizontalContentAlignment = HorizontalAlignment.Center;
                     Grid.SetRow(countLabel, ComponentCount);
                     Grid.SetColumn(countLabel, 1);
                     ComponentGrid.Children.Add(countLabel);
                     label = new Label();
                     label.Content = component.Power;
                     label.HorizontalContentAlignment = HorizontalAlignment.Center;
                     Grid.SetRow(label, ComponentCount);
                     Grid.SetColumn(label, 2);
                     ComponentGrid.Children.Add(label);
                     label = new Label();
                     label.Content = component.Space;
                     label.HorizontalContentAlignment = HorizontalAlignment.Center;
                     Grid.SetRow(label, ComponentCount);
                     Grid.SetColumn(label, 3);
                     ComponentGrid.Children.Add(label);
                     label = new Label();
                     label.Content = component.SP;
                     label.HorizontalContentAlignment = HorizontalAlignment.Center;
                     Grid.SetRow(label, ComponentCount);
                     Grid.SetColumn(label, 4);
                     ComponentGrid.Children.Add(label);
                     button = new Button();
                     button.Content = "+";
                     button.Click += ((s, e) => AddComponent(countLabel, component));
                     Grid.SetRow(button, ComponentCount);
                     Grid.SetColumn(button, 5);
                     ComponentGrid.Children.Add(button);
                     button = new Button();
                     button.Content = "-";
                     button.Click += ((s, e) => RemoveComponent(countLabel, component));
                     Grid.SetRow(button, ComponentCount);
                     Grid.SetColumn(button, 6);
                     ComponentGrid.Children.Add(button);
                     label = new Label();
                     textbox = new TextBox();
                     textbox.Text = component.Origin.Name();
                     textbox.IsReadOnly = true;
                     textbox.ToolTip = component.Origin.LongName() + ", Page: " + component.PageNumber;
                     Grid.SetRow(textbox, ComponentCount++);
                     Grid.SetColumn(textbox, 7);
                     ComponentGrid.Children.Add(textbox);
                     textblock = new TextBlock();
                     textblock.Text = component.Description;
                     textblock.TextWrapping = TextWrapping.WrapWithOverflow;
                     Grid.SetRow(textblock, ComponentCount++);
                     Grid.SetColumnSpan(textblock, 8);
                     ComponentGrid.Children.Add(textblock);
                 }
             }
         }
     }
 }
예제 #15
0
파일: Loader.cs 프로젝트: hooperk/Starship
        /// <summary>
        /// Load a starship form the old .sss format
        /// </summary>
        /// <param name="fs">Filestream open to active .sss file</param>
        /// <returns>Starship imported from old format</returns>
        /// <exception cref="FormatException">If string values stored in numeric fields</exception>
        /// <exception cref="ArgumentException">If non-standard classes listed</exception>
        public Starship LoadSSS(FileStream fs)
        {
            Dictionary<String, String> file = new Dictionary<string, string>();
            using (StreamReader sr = new StreamReader(fs))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    int pos = line.IndexOf(":");
                    if (pos > 0)
                    {
                        file.Add(line.Substring(0, pos), line.Substring(pos + 1, line.Length - pos - 1));
                    }
                }
            }
            Starship ship = new Starship();
            if (!(String.IsNullOrWhiteSpace(file["customhullname"]) || String.IsNullOrWhiteSpace(file["customhullspeed"]) || String.IsNullOrWhiteSpace(file["customhullman"])
                || String.IsNullOrWhiteSpace(file["customhulldet"]) || String.IsNullOrWhiteSpace(file["customhullint"]) || String.IsNullOrWhiteSpace(file["customhullarmour"])
                || String.IsNullOrWhiteSpace(file["customhullturret"]) || String.IsNullOrWhiteSpace(file["customhullspace"]) || String.IsNullOrWhiteSpace(file["customhullclass"])))
            {
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customhullsp"]))
                    sp = int.Parse(file["customhullsp"]);
                HullType type = HullType.None;
                switch (file["customhullclass"])
                {
                    case "Battle":
                        type = HullType.BattleCruiser;
                        break;
                    case "Grand":
                        type = HullType.GrandCruiser;
                        break;
                    default:
                        type = (HullType)Enum.Parse(typeof(HullType), file["customhullclass"]);
                        break;
                }
                int prow = 0;
                int port = 0;
                int starboard = 0;
                int aft = 0;
                int dorsal = 0;
                int keel = 0;
                for (int i = 1; i <= 6; i++)
                {
                    switch (file["customslot" + i])
                    {
                        case "Prow":
                            prow++;
                            break;
                        case "Port":
                            port++;
                            break;
                        case "Starboard":
                            starboard++;
                            break;
                        case "Dorsal":
                            dorsal++;
                            break;
                        case "Keel":
                            keel++;
                            break;
                        case "Aft":
                            aft++;
                            break;
                    }
                }
                Hulls.Add(new Hull(file["customhullname"], int.Parse(file["customhullspeed"]), int.Parse(file["customhullman"]), int.Parse(file["customhulldet"]), int.Parse(file["customhullint"]),
                    int.Parse(file["customhullarmour"]), int.Parse(file["customhullspace"]), sp, type, file["customhullspecial"], RuleBook.Custom, 0, int.Parse(file["customhullturret"]), prow, dorsal,
                    (port + starboard) / 2, keel, aft));

            }
            ship.Hull = Hulls.Where(x => x.Name.Equals(file["hull"], StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
            HullType shipClass = HullType.None;
            if (ship.Hull != null)
                shipClass = ship.Hull.HullTypes;
            //now that ship class and hopefully hull is set, can add custom weapons, then other components custom components can have their hulltypes == shipClass
            for (int i = 1; i <= 6; i++)
            {
                //add each custom weapon - check for duplication
                if (!(String.IsNullOrWhiteSpace(file["customweapon" + i]) || String.IsNullOrWhiteSpace(file["customweapon" + i + "type"]) || String.IsNullOrWhiteSpace(file["customweapon" + i + "range"])))
                {
                    String name = file["customweapon" + i];
                    WeaponType type = WeaponType.Macrobattery;
                    switch (file["customweapon" + i + "type"])
                    {
                        case "Lance":
                            type = WeaponType.Lance;
                            break;
                        case "Landing Bays":
                            type = WeaponType.LandingBay;
                            break;
                        case "Torpedo Tubes":
                            type = WeaponType.TorpedoTube;
                            break;
                        case "Nova Cannon":
                            type = WeaponType.NovaCannon;
                            break;
                    }
                    WeaponSlot slots = WeaponSlot.Auxiliary;//just to be very certain not to have uninitialised
                    if (!String.IsNullOrWhiteSpace(file["customslot" + i]))
                    {
                        slots = (WeaponSlot)Enum.Parse(typeof(WeaponSlot), file["customslot" + i]);
                    }
                    else
                    {
                        switch (type)
                        {
                            case WeaponType.Macrobattery:
                                if (name.IndexOf("Broadside", StringComparison.OrdinalIgnoreCase) >= 0)//ignorecase search for broadside to apply broadside rules
                                    slots = WeaponSlot.Side;
                                else
                                    slots = WeaponSlot.All;
                                break;
                            case WeaponType.Lance:
                                slots = WeaponSlot.Lance;
                                break;
                            case WeaponType.LandingBay:
                                slots = WeaponSlot.Side;
                                break;
                            //case WeaponType.NovaCannon:
                            //    slots = WeaponSlot.Prow;
                            //    break;
                            //case WeaponType.TorpedoTube:
                            //    slots = WeaponSlot.Prow | WeaponSlot.Keel;
                            //    break;
                        }
                    }
                    int str = 0;
                    if (!String.IsNullOrWhiteSpace(file["customweapon" + i + "str"]))
                        str = int.Parse(file["customweapon" + i + "str"]);
                    DiceRoll damage = new DiceRoll(file["customweapon" + i + "dice"]);
                    if (!String.IsNullOrWhiteSpace(file["customweapon" + i + "damage"]))
                        damage += int.Parse(file["customweapon" + i + "damage"]);
                    int range = int.Parse(file["customweapon" + i + "range"]);
                    int crit = 0;
                    if (!String.IsNullOrWhiteSpace(file["customweapon" + i + "crit"]))
                        crit = int.Parse(file["customweapon" + i + "crit"]);
                    int space = 0;
                    if (!String.IsNullOrWhiteSpace(file["customweapon" + i + "space"]))
                        space = int.Parse(file["customweapon" + i + "space"]);
                    int sp = 0;
                    if (!String.IsNullOrWhiteSpace(file["customweapon" + i + "sp"]))
                        sp = int.Parse(file["customweapon" + i + "sp"]);
                    int power = 0;
                    if (!String.IsNullOrWhiteSpace(file["customweapon" + i + "power"]))
                        power = int.Parse(file["customweapon" + i + "power"]);
                    string special = file["customweapon" + i + "special"];
                    HullType weaponClass = HullType.All;
                    if (ship.Hull != null)
                        weaponClass = ship.Hull.HullTypes;
                    switch (type)
                    {
                        case WeaponType.TorpedoTube:
                            Weapons.Add(new TorpedoTubes(name, weaponClass, power, space, sp, str, 0, RuleBook.Custom, 0, special: special));
                            break;
                        case WeaponType.NovaCannon:
                            Weapons.Add(new NovaCannon(name, weaponClass, power, space, sp, damage, range, RuleBook.Custom, 0, special));
                            break;
                        case WeaponType.LandingBay:
                            Weapons.Add(new LandingBay(name, weaponClass, slots, power, space, sp, str, RuleBook.Custom, 0, special: special));
                            break;
                        default:
                            Weapons.Add(new Weapon(name, type, weaponClass, slots, power, space, sp, str, damage, crit, range, RuleBook.Custom, 0, special: special));
                            break;
                    }
                }
            }
            int length = ship.Weapons.Length;
            for (int i = 0; i < length; i++)
            {
                //add each weapon
                string name = file["weapon" + (length - i)];
                switch (name)
                {
                    case Old.BombardmentCannons:
                        name = Names.BombardmentCannons;
                        break;
                    case Old.JovianMissiles:
                        name = Names.JovianMissiles;
                        break;
                    case Old.LatheGravCulverin:
                        name = Names.LatheGravCulverin;
                        break;
                    case Old.MarsBroadsides:
                        name = Names.MarsBroadsides;
                        break;
                    case Old.MarsMacrocannons:
                        name = Names.MarsMacrocannons;
                        break;
                    case Old.MezoaLanceBattery:
                        name = Names.MezoaLanceBattery;
                        break;
                    case Old.MezoaLance:
                        name = Names.MezoaLance;
                        break;
                    case Old.RyzaPlasma:
                        name = Names.RyzaPlasma;
                        break;
                }
                Weapon weapon = Weapons.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (weapon != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrWhiteSpace(file["weapon" + (length - i) + "quality"]))
                        quality = (Quality)Enum.Parse(typeof(Quality), file["weapon" + (length - i) + "quality"]);
                    WeaponQuality wq = WeaponQuality.None;
                    //wxq1 & wxq2 for WeaponQuality, weapxmod for turbo
                    for (int j = 1; j <= 2; j++)
                    {
                        switch (file["w" + (length - i) + "q" + j])
                        {
                            case "Space":
                                wq |= WeaponQuality.Space;
                                break;
                            case "Range":
                                wq |= WeaponQuality.Range;
                                break;
                            case "Crit Rating":
                                wq |= WeaponQuality.Crit;
                                break;
                            case "Strength":
                                wq |= WeaponQuality.Strength;
                                break;
                            case "Damage":
                                wq |= WeaponQuality.Damage;
                                break;
                        }
                    }
                    Quality turbo = Quality.None;
                    if (!String.IsNullOrWhiteSpace(file["weap" + (length - i) + "mod"]))
                        turbo = (Quality)Enum.Parse(typeof(Quality), file["weap" + (length - i) + "mod"]);
                    if (quality != Quality.Common || turbo != Quality.None)
                        ship.Weapons[i] = new Weapon(weapon.Name, weapon.Type, weapon.HullTypes, weapon.Slots, weapon.RawPower, weapon.RawSpace, weapon.RawSP, weapon.RawStrength, weapon.RawDamage, weapon.RawCrit, weapon.RawRange,
                            weapon.Origin, weapon.PageNumber, quality, wq, weapon.RawSpecial, turbo, weapon.ComponentOrigin);
                    else
                        ship.Weapons[i] = weapon;
                }
            }
            if (!(String.IsNullOrWhiteSpace(file["customplasmaname"]) || String.IsNullOrWhiteSpace(file["customplasmapower"]) || String.IsNullOrWhiteSpace(file["customplasmaspace"])))
            {
                string name = file["customplasmaname"];
                int power = int.Parse(file["customplasmapower"]);
                int space = int.Parse(file["customplasmaspace"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customplasmasp"]))
                {
                    sp = int.Parse(file["customplasmasp"]);
                }
                string special = file["customplasmaspecial"];
                PlasmaDrives.Add(new PlasmaDrive(name, shipClass, power, space, special, RuleBook.Custom, 0, sp));
            }
            if (!(String.IsNullOrWhiteSpace(file["customwarpname"]) || String.IsNullOrWhiteSpace(file["customwarppower"]) || String.IsNullOrWhiteSpace(file["customwarpspace"])))
            {
                string name = file["customwarpname"];
                int power = int.Parse(file["customwarppower"]);
                int space = int.Parse(file["customwarpspace"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customwarpsp"]))
                {
                    sp = int.Parse(file["customwarpsp"]);
                }
                string special = file["customwarpspecial"];
                WarpDrives.Add(new WarpDrive(name, shipClass, power, space, RuleBook.Custom, 0, sp, special));
            }
            if (!(String.IsNullOrWhiteSpace(file["customgellarname"]) || String.IsNullOrWhiteSpace(file["customgellarpower"])))
            {
                string name = file["customgellarname"];
                int power = int.Parse(file["customgellarpower"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customgellarsp"]))
                {
                    sp = int.Parse(file["customgellarsp"]);
                }
                string special = file["customgellarspecial"];
                GellarFields.Add(new GellarField(name, shipClass, power, special, RuleBook.Custom, 0, sp));
            }
            bool shieldsDone = false;//if a custom shield was used, don't count the custom shields twice
            if (!(String.IsNullOrWhiteSpace(file["customvoidname"]) || String.IsNullOrWhiteSpace(file["customvoidpower"])
                || String.IsNullOrWhiteSpace(file["customvoidspace"])))
            {
                string name = file["customvoidname"];
                int power = int.Parse(file["customvoidpower"]);
                int space = int.Parse(file["customvoidspace"]);
                int sp = 0;
                int str = 0;
                if(!String.IsNullOrWhiteSpace(file["customshield"]))
                    int.Parse(file["customshield"]);
                if (!String.IsNullOrWhiteSpace(file["customvoidsp"]))
                {
                    sp = int.Parse(file["customvoidsp"]);
                }
                string special = file["customvoidspecial"];
                VoidShields.Add(new VoidShield(name, shipClass, power, space, str, RuleBook.Custom, 0, special, sp: sp));
                shieldsDone = true;
            }
            if (!(String.IsNullOrWhiteSpace(file["custombridgename"]) || String.IsNullOrWhiteSpace(file["custombridgepower"]) || String.IsNullOrWhiteSpace(file["custombridgespace"])))
            {
                string name = file["custombridgename"];
                int power = int.Parse(file["custombridgepower"]);
                int space = int.Parse(file["custombridgespace"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["custombridgesp"]))
                {
                    sp = int.Parse(file["custombridgesp"]);
                }
                string special = file["custombridgespecial"];
                Bridges.Add(new Bridge(name, shipClass, power, space, RuleBook.Custom, 0, special, sp));
            }
            if (!(String.IsNullOrWhiteSpace(file["customlifename"]) || String.IsNullOrWhiteSpace(file["customlifepower"]) || String.IsNullOrWhiteSpace(file["customlifespace"])))
            {
                string name = file["customlifename"];
                int power = int.Parse(file["customlifepower"]);
                int space = int.Parse(file["customlifespace"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customlifesp"]))
                {
                    sp = int.Parse(file["customlifesp"]);
                }
                string special = file["customlifespecial"];
                LifeSustainers.Add(new LifeSustainer(name, shipClass, power, space, 0, RuleBook.Custom, 0, special, sp: sp));
            }
            if (!(String.IsNullOrWhiteSpace(file["customcrewname"]) || String.IsNullOrWhiteSpace(file["customcrewpower"]) || String.IsNullOrWhiteSpace(file["customcrewspace"])))
            {
                string name = file["customcrewname"];
                int power = int.Parse(file["customcrewpower"]);
                int space = int.Parse(file["customcrewspace"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customcrewsp"]))
                {
                    sp = int.Parse(file["customcrewsp"]);
                }
                string special = file["customcrewspecial"];
                CrewQuarters.Add(new CrewQuarters(name, shipClass, power, space, 0, RuleBook.Custom, 0, special, sp: sp));
            }
            if (!(String.IsNullOrWhiteSpace(file["customaugurname"]) || String.IsNullOrWhiteSpace(file["customaugurpower"])))
            {
                string name = file["customaugurname"];
                int power = int.Parse(file["customaugurpower"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customaugursp"]))
                {
                    sp = int.Parse(file["customaugursp"]);
                }
                string special = file["customaugurspecial"];
                AugurArrays.Add(new Augur(name, power, RuleBook.Custom, 0, special: special, sp: sp));
            }
            if (!String.IsNullOrWhiteSpace(file["custommachine"]))
                ship.GMMachineSpirit = file["custommachine"];
            if (!String.IsNullOrWhiteSpace(file["customhistory"]))
                ship.GMShipHistory = file["customhistory"];
            if (!String.IsNullOrWhiteSpace(file["customspeed"]))
                ship.GMSpeed = int.Parse(file["customspeed"]);
            if (!String.IsNullOrWhiteSpace(file["customint"]))
                ship.GMHullIntegrity = int.Parse(file["customint"]);
            if (!String.IsNullOrWhiteSpace(file["customdet"]))
                ship.GMDetection = int.Parse(file["customdet"]);
            if (!String.IsNullOrWhiteSpace(file["customman"]))
                ship.GMManoeuvrability = int.Parse(file["customman"]);
            if (!String.IsNullOrWhiteSpace(file["customarmour"]))
                ship.GMArmour = int.Parse(file["customarmour"]);
            if (!String.IsNullOrWhiteSpace(file["customturret"]))
                ship.GMTurretRating = int.Parse(file["customturret"]);
            if (!String.IsNullOrWhiteSpace(file["custommorale"]))
                ship.GMMorale = int.Parse(file["custommorale"]);
            if (!String.IsNullOrWhiteSpace(file["customcrew"]))
                ship.GMCrewPopulation = int.Parse(file["customcrew"]);
            if (!(shieldsDone || String.IsNullOrWhiteSpace(file["customshield"])))
                ship.GMShields = int.Parse(file["customshield"]);
            ship.GMSpecial = file["customspecial"];
            //custom components as one blob
            if (!(String.IsNullOrWhiteSpace(file["customcomppower"]) && String.IsNullOrWhiteSpace(file["customcompgenerate"])))
            {
                bool doBoth = !(String.IsNullOrWhiteSpace(file["customcomppower"]) || String.IsNullOrWhiteSpace(file["customcompgenerate"]));//if both present, separate comps for generate
                if (doBoth)
                    ship.SupplementalComponents.Add(new Supplemental("Custom Generators", ship.Hull.HullTypes, int.Parse(file["customcompgenerate"]), 0, 0, RuleBook.Custom, 0, generated: true));
                bool usingPower = doBoth || !String.IsNullOrWhiteSpace(file["customcompgenerate"]);
                int space = 0;
                if (!String.IsNullOrWhiteSpace(file["customcompspace"]))
                    space = int.Parse(file["customcompspace"]);
                int sp = 0;
                if (!String.IsNullOrWhiteSpace(file["customcompsp"]))
                    sp = int.Parse(file["customcompsp"]);
                ship.SupplementalComponents.Add(new Supplemental("Custom Components", ship.Hull.HullTypes, (usingPower ? int.Parse(file["customcomppower"]) : int.Parse(file["customcompgenerate"])), space, sp, RuleBook.Custom, 0, special: file["customcomponents"], generated: !usingPower));//account for power being used or generated, all added as one blob to be shown in special field
            }
            //essential components
            {//Plasmadrive
                string name = file["plasma"];
                PlasmaDrive plasma = null;
                HullType size = HullType.None;
                bool modified = false;
                name = name.Replace(" Pattern", "-Pattern");
                if (name.Equals(Old.SprintTrader))
                    name = Names.SprintTrader;
                if (name.Equals(Old.EscortDrive))
                    name = Names.EscortDrive;
                if (name.StartsWith("Modified "))
                {
                    modified = true;
                    name = name.Substring(9);
                }
                if (name.Equals(Old.Viperdrive))
                    name = Names.Viperdrive;
                if (name.StartsWith(Names.WarcruiserDrive))
                {
                    if (name.EndsWith("Large"))
                        size = HullType.CruiserPlus;
                    else
                        size = HullType.LightCruiser;
                    plasma = PlasmaDrives.Where(x => x.Name.Equals(Names.WarcruiserDrive) && x.HullTypes == size).FirstOrDefault();
                }
                else if (name.StartsWith(Names.MimicDrive))
                {
                    switch (name.Substring(Names.MimicDrive.Length))
                    {
                        case "Huge":
                            size = HullType.CruiserPlus;
                            break;
                        case "Large":
                            size = HullType.LightCruiser;
                            break;
                        case "Medium":
                            size = HullType.Raider | HullType.Frigate;
                            break;
                        case "Small":
                            size = HullType.Transport;
                            break;
                    }
                    plasma = PlasmaDrives.Where(x => x.Name.Equals(Names.MimicDrive) && x.HullTypes == size).FirstOrDefault();
                }
                else
                {
                    plasma = PlasmaDrives.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                }
                if (plasma != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["plasmaquality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["plasmaquality"]);
                        if (quality == Quality.Good)
                        {
                            switch (file["plasmachoice"])
                            {
                                case "Power":
                                    quality = Quality.Efficient;
                                    break;
                                case "Space":
                                    quality = Quality.Slim;
                                    break;
                            }
                        }
                    }
                    ship.PlasmaDrive = new PlasmaDrive(plasma.RawName, plasma.HullTypes, plasma.RawPower, plasma.RawSpace, plasma.RawSpecial, plasma.Origin, plasma.PageNumber, plasma.RawSP, quality, plasma.Speed, plasma.Manoeuvrability, plasma.ComponentOrigin, modified);
                }//Warp Drive
                WarpDrive warp = WarpDrives.Where(x => x.Name.Equals(file["warp"], StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (warp != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["warpquality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["warpquality"]);
                        if (quality == Quality.Good)
                        {
                            switch (file["warpchoice"])
                            {
                                case "Power":
                                    quality = Quality.Efficient;
                                    break;
                                case "Space":
                                    quality = Quality.Slim;
                                    break;
                            }
                        }
                    }
                    ship.WarpDrive = new WarpDrive(warp.Name, warp.HullTypes, warp.RawPower, warp.RawSpace, warp.Origin, warp.PageNumber, warp.RawSP, warp.RawSpecial, quality, warp.ComponentOrigin);
                }//Gellar Field
                GellarField gellar = GellarFields.Where(x => x.Name.Equals(file["gellar"], StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (gellar != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["gellarquality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["gellarquality"]);
                    }
                    ship.GellarField = new GellarField(gellar.Name, gellar.HullTypes, gellar.RawPower, gellar.RawSpecial, gellar.Origin, gellar.PageNumber, gellar.RawSP, gellar.NavigateWarp, quality, gellar.ComponentOrigin);
                }//Void shield
                name = file["void"];
                if (name.Equals(Old.RepulsorShield))
                    name = Names.RepulsorShield;
                VoidShield shield = VoidShields.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (shield != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["voidquality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["voidquality"]);
                        if (quality == Quality.Good)
                        {
                            switch (file["voidchoice"])
                            {
                                case "Power":
                                    quality = Quality.Efficient;
                                    break;
                                case "Space":
                                    quality = Quality.Slim;
                                    break;
                            }
                        }
                    }
                    ship.VoidShield = new VoidShield(shield.Name, shield.HullTypes, shield.RawPower, shield.RawSpace, shield.Strength, shield.Origin, shield.PageNumber, shield.RawSpecial, quality, shield.RawSP, shield.ComponentOrigin);
                }//Ship's Bridge
                name = file["bridge"];
                size = HullType.All;
                if (name.EndsWith(", Large"))
                {
                    size = HullType.AllCruiser;
                }
                else if (name.EndsWith(", Small"))
                {
                    size = ~HullType.AllCruiser;
                }
                Bridge bridge = Bridges.Where(x => name.StartsWith(x.Name, StringComparison.OrdinalIgnoreCase) && (x.HullTypes & size) != 0).FirstOrDefault();
                if (bridge != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["bridgequality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["bridgequality"]);
                        if (quality == Quality.Good)
                        {
                            switch (file["bridgechoice"])
                            {
                                case "Power":
                                    quality = Quality.Efficient;
                                    break;
                                case "Space":
                                    quality = Quality.Slim;
                                    break;
                            }
                        }
                    }
                    ship.ShipBridge = new Bridge(bridge.Name, bridge.HullTypes, bridge.RawPower, bridge.RawSpace, bridge.Origin, bridge.PageNumber, bridge.RawSpecial, bridge.RawSP, quality, bridge.Manoeuvrability, bridge.BSModifier, bridge.Command, bridge.Repair, bridge.Pilot, bridge.NavigateWarp, bridge.ComponentOrigin, bridge.MiningObjective, bridge.CreedObjective, bridge.MilitaryObjective, bridge.TradeObjective, bridge.CriminalObjective, bridge.ExplorationObjective);
                }//Life Sustainer
                name = file["life"];
                size = HullType.All;
                name = name.Replace("Vitae ", "Vitae-");
                if (name.EndsWith(", Large"))
                {
                    size = HullType.AllCruiser;
                }
                else if (name.EndsWith(", Small"))
                {
                    size = ~HullType.AllCruiser;
                }
                LifeSustainer sustainer = LifeSustainers.Where(x => name.StartsWith(x.Name, StringComparison.OrdinalIgnoreCase) && (x.HullTypes & size) != 0).FirstOrDefault();
                if (sustainer != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["lifequality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["lifequality"]);
                        if (quality == Quality.Good)
                        {
                            switch (file["lifechoice"])
                            {
                                case "Power":
                                    quality = Quality.Efficient;
                                    break;
                                case "Space":
                                    quality = Quality.Slim;
                                    break;
                            }
                        }
                    }
                    ship.LifeSustainer = new LifeSustainer(sustainer.Name, sustainer.HullTypes, sustainer.RawPower, sustainer.RawSpace, sustainer.Morale, sustainer.Origin, sustainer.PageNumber, sustainer.RawSpecial, quality, sustainer.RawSP, sustainer.MoraleLoss, sustainer.CrewLoss, sustainer.ComponentOrigin);
                }//crew quarters
                name = file["quarters"];
                size = HullType.All;
                if (name.EndsWith(", Large"))
                {
                    size = HullType.AllCruiser;
                }
                else if (name.EndsWith(", Small"))
                {
                    size = ~HullType.AllCruiser;
                }
                CrewQuarters quarters = CrewQuarters.Where(x => name.StartsWith(x.Name, StringComparison.OrdinalIgnoreCase) && (x.HullTypes & size) != 0).FirstOrDefault();
                if (quarters != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["quartersquality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["quartersquality"]);
                        if (quality == Quality.Good)
                        {
                            switch (file["quarterschoice"])
                            {
                                case "Power":
                                    quality = Quality.Efficient;
                                    break;
                                case "Space":
                                    quality = Quality.Slim;
                                    break;
                            }
                        }
                    }
                    ship.CrewQuarters = new CrewQuarters(quarters.Name, quarters.HullTypes, quarters.RawPower, quarters.RawSpace, quarters.Morale, quarters.Origin, quarters.PageNumber, quarters.RawSpecial, quality, quarters.RawSP, quarters.MoraleLoss, quarters.ComponentOrigin);
                }//Augur Arrays
                Augur arrays = AugurArrays.Where(x => x.Name.Equals(file["augur"], StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (arrays != null)
                {
                    Quality quality = Quality.Common;
                    if (!String.IsNullOrEmpty(file["augurquality"]))
                    {
                        quality = (Quality)Enum.Parse(typeof(Quality), file["augurquality"]);
                    }
                    ship.AugurArrays = new Augur(arrays.Name, arrays.RawPower, arrays.Origin, arrays.PageNumber, arrays.DetectionRating, arrays.RawSpecial, quality, arrays.RawSP, arrays.Manoeuvrability, arrays.BSModifier, arrays.MiningObjective, arrays.CreedObjective, arrays.MilitaryObjective, arrays.TradeObjective, arrays.CriminalObjective, arrays.ExplorationObjective, arrays.ComponentOrigin);
                }
            }//end of essential components
            switch (file["machine"])
            {
                case "A Nose For Trouble":
                    ship.MachineSpirit = MachineSpirit.ANoseForTrouble;
                    break;
                case "Blasphemous Tendencies":
                    ship.MachineSpirit = MachineSpirit.BlasphemousTendencies;
                    break;
                case "Martial Hubris":
                    ship.MachineSpirit = MachineSpirit.MartialHubris;
                    break;
                case "Rebellious":
                    ship.MachineSpirit = MachineSpirit.Rebellious;
                    break;
                case "Stoic":
                    ship.MachineSpirit = MachineSpirit.Stoic;
                    break;
                case "Skittish":
                    ship.MachineSpirit = MachineSpirit.Skittish;
                    break;
                case "Wrothful":
                    ship.MachineSpirit = MachineSpirit.Wrothful;
                    break;
                case "Resolute":
                    ship.MachineSpirit = MachineSpirit.Resolute;
                    break;
                case "Adventurous":
                    ship.MachineSpirit = MachineSpirit.Adventurous;
                    break;
                case "Ancient and Wise":
                    ship.MachineSpirit = MachineSpirit.AncientAndWise;
                    break;
            }
            switch (file["history"])
            {
                case "Reliquary of Mars":
                    ship.ShipHistory = ShipHistory.ReliquaryOfMars;
                    break;
                case "Haunted":
                    ship.ShipHistory = ShipHistory.Haunted;
                    break;
                case "Emissary of the Imperator":
                    ship.ShipHistory = ShipHistory.EmissaryOfTheImperator;
                    break;
                case "Wolf in Sheeps Clothing":
                    ship.ShipHistory = ShipHistory.WolfInSheepsClothing;
                    break;
                case "Turbulent Past":
                    ship.ShipHistory = ShipHistory.TurbulentPast;
                    break;
                case "Death Cult":
                    ship.ShipHistory = ShipHistory.DeathCult;
                    break;
                case "Wrested from a Space Hulk":
                    ship.ShipHistory = ShipHistory.WrestedFromASpaceHulk;
                    break;
                case "Temperamental Warp Engine":
                    ship.ShipHistory = ShipHistory.TemperamentalWarpEngine;
                    break;
                case "Finances in Arrears":
                    ship.ShipHistory = ShipHistory.FinancesInArrears;
                    break;
                case "Xenophilous":
                    ship.ShipHistory = ShipHistory.Xenophilous;
                    break;
            }
            if (!String.IsNullOrWhiteSpace(file["crew"]))
                ship.CrewRace = (Race)Enum.Parse(typeof(Race), file["crew"]);
            if (!String.IsNullOrWhiteSpace(file["crewrating"]))
            {
                CrewRating rating = 0;
                if (Enum.TryParse<CrewRating>(file["crewrating"], out rating))
                    ship.CrewRating = (int)rating;
                else
                    ship.CrewRating = (int)Enum.Parse(typeof(ServitorQuality), file["crewrating"]);
            }
            if (!String.IsNullOrWhiteSpace(file["crewmod"]))
                ship.GMCrewRating = int.Parse(file["crewmod"]);
            if (!String.IsNullOrWhiteSpace(file["arrestor"]))
                ship.ArresterEngines = (Quality)Enum.Parse(typeof(Quality), file["arrestor"]);
            if (!String.IsNullOrWhiteSpace(file["cherubim"]))
                ship.CherubimAerie = (Quality)Enum.Parse(typeof(Quality), file["cherubim"]);
            if (!String.IsNullOrWhiteSpace(file["improvements"]))
                ship.CrewImprovements = (Quality)Enum.Parse(typeof(Quality), file["imperovements"]);
            if (!String.IsNullOrWhiteSpace(file["disciplinarium"]))
                ship.Disciplinarium = (Quality)Enum.Parse(typeof(Quality), file["disciplinarium"]);
            if (!String.IsNullOrWhiteSpace(file["distribute"]))
                ship.DistributedCargoHold = (Quality)Enum.Parse(typeof(Quality), file["distributed"]);
            if (!String.IsNullOrWhiteSpace(file["mimic"]))
                ship.MimicDrive = (Quality)Enum.Parse(typeof(Quality), file["mimic"]);
            if (!String.IsNullOrWhiteSpace(file["ostentatious"]))
                ship.OstentatiousDisplayOfWealth = (Quality)Enum.Parse(typeof(Quality), file["ostentatious"]);
            if (!String.IsNullOrWhiteSpace(file["overload"]))
                ship.OverloadShieldCapacitors = (Quality)Enum.Parse(typeof(Quality), file["overload"]);
            if (!String.IsNullOrWhiteSpace(file["resolution"]))
                ship.ResolutionArena = (Quality)Enum.Parse(typeof(Quality), file["resolution"]);
            if (!String.IsNullOrWhiteSpace(file["secondary"]))
                ship.SecondaryReactor = (Quality)Enum.Parse(typeof(Quality), file["secondary"]);
            if (!String.IsNullOrWhiteSpace(file["starchart"]))
                ship.StarchartCollection = (Quality)Enum.Parse(typeof(Quality), file["starchart"]);
            if (!String.IsNullOrWhiteSpace(file["trooper"]))
                ship.StormTrooperDetachment = (Quality)Enum.Parse(typeof(Quality), file["trooper"]);
            if (!String.IsNullOrWhiteSpace(file["superior"]))
                ship.SuperiorDamageControl = (Quality)Enum.Parse(typeof(Quality), file["superior"]);
            if (!String.IsNullOrWhiteSpace(file["targeting"]))
                ship.TargettingMatrix = (Quality)Enum.Parse(typeof(Quality), file["targeting"]);
            if (!String.IsNullOrWhiteSpace(file["vaulted"]))
                ship.VaultedCeilings = (Quality)Enum.Parse(typeof(Quality), file["vaulted"]);
            switch (file["background"])
            {
                case "Thulian Explorator Vessel":
                    ship.Background = Background.ThulianExploratorVessel;
                    break;
                case "Reaver of the Unbeholden Reaches":
                    ship.Background = Background.ReaverOfTheUnbeholdenReaches;
                    break;
                case "Veteran of the Angevin Crusade":
                    ship.Background = Background.VeteranOfTheAngevinCrusade;
                    break;
                case "Implacable Foe of The Fleet":
                    ship.Background = Background.ImplacableFoeOfTheFleet;
                    break;
                case "Steadfast Ally of the Fleet":
                    ship.Background = Background.SteadfastAllyofTheFleet;
                    break;
                case "Planet-Bound for Millenia":
                    if (!String.IsNullOrWhiteSpace(file["hullloss"]))
                    {
                        byte loss = byte.Parse(file["hullloss"]);
                        ship.Background = (Background)loss;//and it to get number of hull lost
                    }
                    else
                        ship.Background = Background.PlanetBoundForMillenia;
                    break;
            }
            //supplemental components
            if (shipClass == HullType.None)
                shipClass = HullType.All;//if not set by a hull, now set assumed class to max
            foreach (KeyValuePair<String, String> pair in file.Skip(243))//supplemental components start after the first 243 entries
            {
                if (!String.IsNullOrWhiteSpace(pair.Value))
                {
                    String name = pair.Key.Replace("†","");
                    Quality quality = Quality.Common;
                    if (name.StartsWith("Poor Quality "))
                    {
                        name = name.Substring(13);
                        quality = Quality.Poor;
                    }
                    else if (name.StartsWith("Slim "))
                    {
                        name = name.Substring(5);
                        quality = Quality.Slim;
                    }
                    else if (name.StartsWith("Efficient "))
                    {
                        name = name.Substring(10);
                        quality = Quality.Efficient;
                    }
                    else if (name.StartsWith("Good Quality "))
                    {
                        name = name.Substring(13);
                        quality = Quality.Good;
                    }
                    else if (name.StartsWith("Best Quality"))
                    {
                        name = name.Substring(13);
                        quality = Quality.Best;
                    }
                    switch (name)
                    {
                        case Old.CogitatorInterlink:
                            name = Names.CogitatorInterlink;
                            break;
                        case Old.JammingSystem:
                            name = Names.JammingSystem;
                            break;
                    }
                    //check for all with same name, then get the largest one(ships capable of say cruiser and transport use cruiser size if that is what is available)
                    Supplemental component = Supplementals.Where(x => name.StartsWith(x.Name, StringComparison.OrdinalIgnoreCase)).OrderByDescending(x => x.HullTypes).FirstOrDefault();
                    int count = int.Parse(pair.Value);
                    if (component != null)
                    {
                        for (int i = 0; i < count; i++)
                            ship.SupplementalComponents.Add(new Supplemental(component.Name, component.HullTypes, component.RawPower, component.RawSpace, component.RawSP, component.Origin, component.PageNumber, component.RamDamage, component.RawSpecial, quality, component.Speed, component.Manoeuvrability, component.HullIntegrity, component.Armour, component.TurretRating, component.Morale, component.CrewPopulation, component.ProwArmour, component.CrewRating, component.MiningObjective, component.CreedObjective, component.MilitaryObjective, component.TradeObjective, component.CriminalObjective, component.ExplorationObjective, component.PowerGenerated, component.DetectionRating, component.AuxiliaryWeapon, component.MacrobatteryModifier, component.BSModifier, component.NavigateWarp, component.CrewLoss, component.MoraleLoss, component.ComponentOrigin, component.Replace, component.Max));
                    }
                }
            }
            return ship;
        }
예제 #16
0
 public static Complication MachineSpirit(Starship starship)
 {
     return new Complication(starship, true);
 }
예제 #17
0
파일: Saver.cs 프로젝트: hooperk/Starship
 public static void SaveStarship(Starship ship, String path)
 {
     if (Path.GetExtension(path).Equals(".sss"))
         SaveSSS(ship, path);
     else if (Path.GetExtension(path).Equals(".lss"))
         SaveLSS(ship, path);
 }
예제 #18
0
 private Complication(Starship starship, bool MorH)
 {
     if (starship == null)
         throw new ArgumentNullException("Cannot create a complication for a null starship");
     this.Starship = starship;
     this.MachineOrHistory = MorH;
     InitializeComponent();
     if (MachineOrHistory)
     {
         TitleName.Content = "Machine Spirit Complication";
         Name1.Text = ((Machine)1).Name();
         Effect1.Text = ((Machine)1).Description();
         Name2.Text = ((Machine)2).Name();
         Effect2.Text = ((Machine)2).Description();
         Name3.Text = ((Machine)3).Name();
         Effect3.Text = ((Machine)3).Description();
         Name4.Text = ((Machine)4).Name();
         Effect4.Text = ((Machine)4).Description();
         Name5.Text = ((Machine)5).Name();
         Effect5.Text = ((Machine)5).Description();
         Name6.Text = ((Machine)6).Name();
         Effect6.Text = ((Machine)6).Description();
         Name7.Text = ((Machine)7).Name();
         Effect7.Text = ((Machine)7).Description();
         Name8.Text = ((Machine)8).Name();
         Effect8.Text = ((Machine)8).Description();
         Name9.Text = ((Machine)9).Name();
         Effect9.Text = ((Machine)9).Description();
         Name10.Text = ((Machine)10).Name();
         Effect10.Text = ((Machine)10).Description();
         Custom.Content = "Custom Machine Spirit";
         if (!String.IsNullOrWhiteSpace(Starship.GMMachineSpirit))
         {
             String[] parts = Starship.GMMachineSpirit.Split(new char[]{':'},2);
             CustomName.Text = parts[0].Trim();
             CustomEffect.Text = parts[1].Trim();
         }
     }
     else
     {
         TitleName.Content = "Ship History Complication";
         Name1.Text = ((History)1).Name();
         Effect1.Text = ((History)1).Description();
         Name2.Text = ((History)2).Name();
         Effect2.Text = ((History)2).Description();
         Name3.Text = ((History)3).Name();
         Effect3.Text = ((History)3).Description();
         Name4.Text = ((History)4).Name();
         Effect4.Text = ((History)4).Description();
         Name5.Text = ((History)5).Name();
         Effect5.Text = ((History)5).Description();
         Name6.Text = ((History)6).Name();
         Effect6.Text = ((History)6).Description();
         Name7.Text = ((History)7).Name();
         Effect7.Text = ((History)7).Description();
         Name8.Text = ((History)8).Name();
         Effect8.Text = ((History)8).Description();
         Name9.Text = ((History)9).Name();
         Effect9.Text = ((History)9).Description();
         Name10.Text = ((History)10).Name();
         Effect10.Text = ((History)10).Description();
         Custom.Content = "Custom Ship History";
         if (!String.IsNullOrWhiteSpace(Starship.GMShipHistory))
         {
             String[] parts = Starship.GMShipHistory.Split(new char[] { ':' }, 2);
             CustomName.Text = parts[0].Trim();
             CustomEffect.Text = parts[1].Trim();
         }
     }
 }
예제 #19
0
파일: Saver.cs 프로젝트: hooperk/Starship
 /// <summary>
 /// Save a Starship in the old .sss format
 /// </summary>
 /// <param name="ship">Starship to save</param>
 /// <param name="fs">Open filestream ot a file to write to</param>
 public static void SaveSSS(Starship ship, FileStream fs)
 {
     using (StreamWriter writer = new StreamWriter(fs, ASCIIEncoding.Unicode))
     {
         string name;
         writer.WriteLine("version:" + Assembly.GetExecutingAssembly().GetName().Version);
         writer.WriteLine("name:" + ship.Name);
         writer.WriteLine("hull:" + ship.Hull.GetName());
         name = ship.PlasmaDrive.GetName();
         switch (name)
         {
             case Names.SprintTrader:
                 name = Old.SprintTrader;
                 break;
             case Names.EscortDrive:
                 name = Old.EscortDrive;
                 break;
             case Names.WarcruiserDrive:
                 if (ship.Hull == null || (ship.Hull.HullTypes & HullType.CruiserPlus) > 0)
                     name += ", Large";
                 else
                     name += ", Small";
                 break;
             case Names.MimicDrive:
                 if (ship.Hull == null || (ship.Hull.HullTypes & HullType.CruiserPlus) > 0)
                     name += ", Huge";
                 else if ((ship.Hull.HullTypes & HullType.LightCruiser) > 0)
                     name += ", Large";
                 else if ((ship.Hull.HullTypes & (HullType.Raider | HullType.Frigate)) > 0)
                     name += ", Medium";
                 else
                     name += ", Small";
                 break;
             case Names.Viperdrive:
                 name = Old.Viperdrive;
                 break;
         }
         writer.WriteLine("plasma:" + name);
         writer.WriteLine("warp:" + ship.WarpDrive.GetName());
         writer.WriteLine("gellar:" + ship.GellarField.GetName());
         name = ship.VoidShield.GetName();
         if(name.Equals(Names.RepulsorShield))
             name = Old.RepulsorShield;
         writer.WriteLine("void:" + name);
         name = ship.ShipBridge.GetName();
         switch (name)
         {
             case Names.ArmouredBridge:
             case Names.BridgeOfAntiquity:
             case Names.CombatBridge:
             case Names.CommandBridge:
             case Names.ExplorationBridge:
                 if (ship.Hull == null || (ship.Hull.HullTypes & HullType.AllCruiser) > 0)
                     name += ", Large";
                 else
                     name += ", Small";
                 break;
         }
         writer.WriteLine("bridge:" + name);
         writer.WriteLine("life:" + ship.LifeSustainer.GetName().Replace("Vitae-","Vitae ") + (ship.Hull == null || (ship.Hull.HullTypes & HullType.AllCruiser) != 0 ? ", Large" : ", Small"));
         writer.WriteLine("quarters:" + ship.CrewQuarters.GetName() + (ship.Hull == null || (ship.Hull.HullTypes & HullType.AllCruiser) != 0 ? ", Large" : ", Small"));
         writer.WriteLine("augur:" + ship.AugurArrays.GetName());
         String[] qualities = new String[14];
         if (ship.PlasmaDrive != null)
         {
             switch (ship.PlasmaDrive.Quality)
             {
                 case Quality.Poor:
                     qualities[0] = "Poor";
                     break;
                 case Quality.Good:
                     qualities[0] = "Good";
                     break;
                 case Quality.Slim:
                     qualities[0] = "Good";
                     qualities[8] = "Space";
                     break;
                 case Quality.Efficient:
                     qualities[0] = "Good";
                     qualities[8] = "Power";
                     break;
                 case Quality.Best:
                     qualities[0] = "Best";
                     break;
             }
         }
         if (ship.WarpDrive != null)
         {
             switch (ship.WarpDrive.Quality)
             {
                 case Quality.Poor:
                     qualities[1] = "Poor";
                     break;
                 case Quality.Good:
                     qualities[1] = "Good";
                     break;
                 case Quality.Slim:
                     qualities[1] = "Good";
                     qualities[9] = "Space";
                     break;
                 case Quality.Efficient:
                     qualities[1] = "Good";
                     qualities[9] = "Power";
                     break;
                 case Quality.Best:
                     qualities[1] = "Best";
                     break;
             }
         }
         if (ship.GellarField != null)
         {
             switch (ship.GellarField.Quality)
             {
                 case Quality.Poor:
                     qualities[2] = "Poor";
                     break;
                 case Quality.Good:
                 case Quality.Slim:
                 case Quality.Efficient:
                     qualities[2] = "Good";
                     break;
                 case Quality.Best:
                     qualities[2] = "Best";
                     break;
             }
         }
         if (ship.VoidShield != null)
         {
             switch (ship.VoidShield.Quality)
             {
                 case Quality.Poor:
                     qualities[3] = "Poor";
                     break;
                 case Quality.Good:
                     qualities[3] = "Good";
                     break;
                 case Quality.Slim:
                     qualities[3] = "Good";
                     qualities[10] = "Space";
                     break;
                 case Quality.Efficient:
                     qualities[3] = "Good";
                     qualities[10] = "Power";
                     break;
                 case Quality.Best:
                     qualities[3] = "Best";
                     break;
             }
         }
         if (ship.ShipBridge != null)
         {
             switch (ship.ShipBridge.Quality)
             {
                 case Quality.Poor:
                     qualities[4] = "Poor";
                     break;
                 case Quality.Good:
                     qualities[4] = "Good";
                     break;
                 case Quality.Slim:
                     qualities[4] = "Good";
                     qualities[11] = "Space";
                     break;
                 case Quality.Efficient:
                     qualities[4] = "Good";
                     qualities[11] = "Power";
                     break;
                 case Quality.Best:
                     qualities[4] = "Best";
                     break;
             }
         }
         if (ship.LifeSustainer != null)
         {
             switch (ship.LifeSustainer.Quality)
             {
                 case Quality.Poor:
                     qualities[5] = "Poor";
                     break;
                 case Quality.Good:
                     qualities[5] = "Good";
                     break;
                 case Quality.Slim:
                     qualities[5] = "Good";
                     qualities[12] = "Space";
                     break;
                 case Quality.Efficient:
                     qualities[5] = "Good";
                     qualities[12] = "Power";
                     break;
                 case Quality.Best:
                     qualities[5] = "Best";
                     break;
             }
         }
         if (ship.CrewQuarters != null)
         {
             switch (ship.CrewQuarters.Quality)
             {
                 case Quality.Poor:
                     qualities[6] = "Poor";
                     break;
                 case Quality.Good:
                     qualities[6] = "Good";
                     break;
                 case Quality.Slim:
                     qualities[6] = "Good";
                     qualities[13] = "Space";
                     break;
                 case Quality.Efficient:
                     qualities[6] = "Good";
                     qualities[13] = "Power";
                     break;
                 case Quality.Best:
                     qualities[6] = "Best";
                     break;
             }
         }
         if (ship.AugurArrays != null)
         {
             switch (ship.AugurArrays.Quality)
             {
                 case Quality.Poor:
                     qualities[7] = "Poor";
                     break;
                 case Quality.Good:
                 case Quality.Slim:
                 case Quality.Efficient:
                     qualities[7] = "Good";
                     break;
                 case Quality.Best:
                     qualities[7] = "Best";
                     break;
             }
         }
         writer.WriteLine("plasmaquality:" + qualities[0].Escape());
         writer.WriteLine("warpquality:" + qualities[1].Escape());
         writer.WriteLine("gellarquality:" + qualities[2].Escape());
         writer.WriteLine("voidquality:" + qualities[3].Escape());
         writer.WriteLine("bridgequality:" + qualities[4].Escape());
         writer.WriteLine("lifequality:" + qualities[5].Escape());
         writer.WriteLine("quartersquality:" + qualities[6].Escape());
         writer.WriteLine("augurquality:" + qualities[7].Escape());
         writer.WriteLine("plasmachoice:" + qualities[8].Escape());
         writer.WriteLine("warpchoice:" + qualities[9].Escape());
         writer.WriteLine("gellarchoice:");
         writer.WriteLine("voidchoice:" + qualities[10].Escape());
         writer.WriteLine("bridgechoice:" + qualities[11].Escape());
         writer.WriteLine("lifechoice:" + qualities[12].Escape());
         writer.WriteLine("quarterschoice:" + qualities[13].Escape());
         writer.WriteLine("augurchoice:");
         writer.WriteLine("crew:" + ship.CrewRace.Name());
         writer.WriteLine("crewrating:" + (ship.CrewRating == 0 ? "" : (ship.CrewRace == Race.Servitor ? ((ServitorQuality)ship.CrewRating).ToString() : ((CrewRating)ship.CrewRating).ToString())));
         writer.WriteLine("crewmod:" + ship.GMCrewRating);
         //weapons, need to redo ordering when converting
         Weapon[] weapons = ship.Weapons.Reverse().ToArray();//old ship sheet ordered weaposn in opposite way to new ship generator
         int i = 0;
         for (; i < weapons.Length; i++)
         {
             name = "";
             String quality = "";
             String weapq1 = "";
             String weapq2 = "";
             String turbo = "";
             if (weapons[i] != null)
             {
                 name = weapons[i].Name;
                 switch (weapons[i].Quality)
                 {
                     case Quality.Poor:
                         quality = "Poor";
                         break;
                     case Quality.Good:
                     case Quality.Slim:
                     case Quality.Efficient:
                         quality = "Good";
                         break;
                     case Quality.Best:
                         quality = "Best";
                         break;
                 }
                 //weaponqualities parsing
                 String[] weaponqualities = weapons[i].WeaponQuality.ToString().Replace(" ","").Split(new char[]{','});
                 if (weaponqualities.Length > 0)
                     weapq1 = weaponqualities[0];
                 if (weaponqualities.Length > 1)
                     weapq2 = weaponqualities[1];
                 if (weapons[i].TurboWeapon != Quality.None)
                     turbo = weapons[i].TurboWeapon.ToString();
             }
             writer.WriteLine("weapon{0}:{1}", i+1, name);
             writer.WriteLine("weapon{0}quality:{1}", i+1, quality);
             writer.WriteLine("w{0}q1:{1}", i+1, (weapq1.Equals("Crit") ? "Crit Rating" : weapq1));
             writer.WriteLine("w{0}q2:{1}", i+1, (weapq2.Equals("Crit") ? "Crit Rating" : weapq2));
             writer.WriteLine("weap{0}mod:{1}", i+1, turbo);
         }
         for (; i < 6; i++)
         {
             writer.WriteLine("weapon{0}:", i+1);
             writer.WriteLine("weapon{0}quality:", i+1);
             writer.WriteLine("w{0}q1:", i+1);
             writer.WriteLine("w{0}q2:", i+1);
             writer.WriteLine("weap{0}mod:", i+1);
         }
         writer.WriteLine("machine:" + ship.MachineSpirit.Name());
         writer.WriteLine("history:" + ship.ShipHistory.Name());
         writer.WriteLine("arrestor:" + (ship.ArresterEngines != Quality.None ? ship.ArresterEngines.ToString() : ""));
         writer.WriteLine("cherubim:" + (ship.CherubimAerie != Quality.None ? ship.CherubimAerie.ToString() : ""));
         writer.WriteLine("improvements:" + (ship.CrewImprovements != Quality.None ? ship.CrewImprovements.ToString() : ""));
         writer.WriteLine("disciplinarium:" + (ship.Disciplinarium != Quality.None ? ship.Disciplinarium.ToString() : ""));
         writer.WriteLine("distribute:" + (ship.DistributedCargoHold != Quality.None ? ship.DistributedCargoHold.ToString() : ""));
         writer.WriteLine("mimic:" + (ship.MimicDrive != Quality.None ? ship.MimicDrive.ToString() : ""));
         writer.WriteLine("ostentatious:" + (ship.OstentatiousDisplayOfWealth != Quality.None ? ship.OstentatiousDisplayOfWealth.ToString() : ""));
         writer.WriteLine("overload:" + (ship.OverloadShieldCapacitors != Quality.None ? ship.OverloadShieldCapacitors.ToString() : ""));
         writer.WriteLine("resolution:" + (ship.ResolutionArena != Quality.None ? ship.ResolutionArena.ToString() : ""));
         writer.WriteLine("secondary:" + (ship.SecondaryReactor != Quality.None ? ship.SecondaryReactor.ToString() : ""));
         writer.WriteLine("starchart:" + (ship.StarchartCollection != Quality.None ? ship.StarchartCollection.ToString() : ""));
         writer.WriteLine("trooper:" + (ship.StormTrooperDetachment != Quality.None ? ship.StormTrooperDetachment.ToString() : ""));
         writer.WriteLine("superior:" + (ship.SuperiorDamageControl != Quality.None ? ship.SuperiorDamageControl.ToString() : ""));
         writer.WriteLine("targeting:" + (ship.TargettingMatrix != Quality.None ? ship.TargettingMatrix.ToString() : ""));
         writer.WriteLine("vaulted:" + (ship.VaultedCeilings != Quality.None ? ship.VaultedCeilings.ToString() : ""));
         //If I add atomics recordable, display here
         writer.WriteLine
             (
     @"atomics:
     atomicquality:
     tno1:
     torpedo1:
     guidance1:
     tno2:
     torpedo2:
     guidance2:
     tno3:
     torpedo3:
     guidance3:
     tno4:
     torpedo4:
     guidance4:
     tno5:
     torpedo5:
     guidance5:
     tno6:
     torpedo6:
     guidance6:
     cno1:0
     craft1:Fury Interceptor
     cno2:0
     craft2:Starhawk Bomber
     cno3:0
     craft3:Shark Assault Boat"
             );
         writer.WriteLine("background:" + ship.Background.Name());
         writer.WriteLine("hullloss:" + (int)(ship.Background & Background.PlanetBoundForMillenia));
         //line 106
         String[] customhull = new String[17];
         if (ship.Hull != null && ship.Hull.Origin == RuleBook.Custom)
         {
             customhull[0] = ship.Hull.Name;
             customhull[1] = ship.Hull.Speed.ToString();
             customhull[2] = ship.Hull.Manoeuvrability.ToString();
             customhull[3] = ship.Hull.DetectionRating.ToString();
             customhull[4] = ship.Hull.HullIntegrity.ToString();
             customhull[5] = ship.Hull.Armour.ToString();
             customhull[6] = ship.Hull.TurretRating.ToString();
             customhull[7] = ship.Hull.RawSpace.ToString();
             customhull[8] = ship.Hull.RawSP.ToString();
             if ((ship.Hull.HullTypes & HullType.BattleShip) > 0)
                 customhull[9] = "Battleship";
             else if ((ship.Hull.HullTypes & HullType.GrandCruiser) > 0)
                 customhull[9] = "Grand";
             else if ((ship.Hull.HullTypes & HullType.BattleCruiser) > 0)
                 customhull[9] = "Battle";
             else if ((ship.Hull.HullTypes & HullType.Cruiser) > 0)
                 customhull[9] = "Cruiser";
             else if ((ship.Hull.HullTypes & HullType.LightCruiser) > 0)
                 customhull[9] = "Light";
             else if ((ship.Hull.HullTypes & HullType.Frigate) > 0)
                 customhull[9] = "Frigate";
             else if ((ship.Hull.HullTypes & HullType.Raider) > 0)
                 customhull[9] = "Raider";
             else if ((ship.Hull.HullTypes & HullType.Transport) > 0)
                 customhull[9] = "Transport";
             customhull[10] = ship.Hull.RawSpecial;
             i = 0;
             for (; i < ship.Hull.AftSlots; i++)
                 customhull[11 + i] = "Aft";
             for (; i < ship.Hull.AftSlots + ship.Hull.KeelSlots; i++)
                 customhull[11 + i] = "Keel";
             for (; i < ship.Hull.AftSlots + ship.Hull.KeelSlots + ship.Hull.SideSlots; i++)
                 customhull[11 + i] = "Starboard";
             for (; i < ship.Hull.AftSlots + ship.Hull.KeelSlots + (2 * ship.Hull.SideSlots); i++)
                 customhull[11 + i] = "Port";
             for (; i < ship.Hull.AftSlots + ship.Hull.KeelSlots + (2 * ship.Hull.SideSlots) + ship.Hull.DorsalSlots; i++)
                 customhull[11 + i] = "Dorsal";
             for (; i < ship.Hull.AftSlots + ship.Hull.KeelSlots + (2 * ship.Hull.SideSlots) + ship.Hull.DorsalSlots + ship.Hull.ProwSlots; i++)
                 customhull[11 + i] = "Prow";
         }
         writer.WriteLine("customhullname:" + customhull[0]);
         writer.WriteLine("customhullspeed:" + customhull[1]);
         writer.WriteLine("customhullman:" + customhull[2]);
         writer.WriteLine("customhulldet:" + customhull[3]);
         writer.WriteLine("customhullint:" + customhull[4]);
         writer.WriteLine("customhullarmour:" + customhull[5]);
         writer.WriteLine("customhullturret:" + customhull[6]);
         writer.WriteLine("customhullspace:" + customhull[7]);
         writer.WriteLine("customhullsp:" + customhull[8]);
         writer.WriteLine("customhullclass:" + customhull[9]);
         writer.WriteLine("customhullspecial:" + customhull[10]);
         int weaponcount = ship.Weapons.Length;
         for(i = 0; i < 6; i++)
         {
             writer.WriteLine("customslot{0}:{1}", i+1, customhull[11+i]);//include the weapon slots form the hull
             String[] customweapon = new String[11];
             if (i < weaponcount)
             {
                 Weapon current = ship.Weapons[weaponcount - 1 - i];
                 if (current != null)
                 {
                     customweapon[0] = current.Name;
                     customweapon[1] = current.Type.Name();
                     customweapon[2] = current.RawStrength.ToString();
                     customweapon[3] = new DiceRoll(current.RawDamage.d10, current.RawDamage.d5, 0).ToString();//get just dice portion of roll
                     customweapon[4] = current.RawDamage.Modifier.PrintInt();
                     customweapon[5] = current.RawRange.PrintInt();
                     customweapon[6] = current.RawCrit.PrintInt();
                     customweapon[7] = current.RawSpace.PrintInt();
                     customweapon[8] = current.RawSP.PrintInt();
                     customweapon[9] = current.RawPower.PrintInt();
                     customweapon[10] = current.RawSpecial;
                 }
             }
             writer.WriteLine("customweapon{0}:{1}", i + 1, customweapon[0]);
             writer.WriteLine("customweapon{0}type:{1}", i + 1, customweapon[1]);
             writer.WriteLine("customweapon{0}str:{1}", i + 1, customweapon[2]);
             writer.WriteLine("customweapon{0}dice:{1}", i + 1, customweapon[3]);
             writer.WriteLine("customweapon{0}damage:{1}", i + 1, customweapon[4]);
             writer.WriteLine("customweapon{0}range:{1}", i + 1, customweapon[5]);
             writer.WriteLine("customweapon{0}crit:{1}", i + 1, customweapon[6]);
             writer.WriteLine("customweapon{0}space:{1}", i + 1, customweapon[7]);
             writer.WriteLine("customweapon{0}sp:{1}", i + 1, customweapon[8]);
             writer.WriteLine("customweapon{0}power:{1}", i + 1, customweapon[9]);
             writer.WriteLine("customweapon{0}special:{1}", i + 1, customweapon[10]);
         }
         String[] customplasma = new String[5];
         if (ship.PlasmaDrive != null && ship.PlasmaDrive.Origin == RuleBook.Custom)
         {
             customplasma[0] = ship.PlasmaDrive.Name;
             customplasma[1] = ship.PlasmaDrive.RawPower.PrintInt();
             customplasma[2] = ship.PlasmaDrive.RawSpace.PrintInt();
             customplasma[3] = ship.PlasmaDrive.RawSP.PrintInt();
             customplasma[4] = ship.PlasmaDrive.RawSpecial;
         }
         writer.WriteLine("customplasmaname:" + customplasma[0]);
         writer.WriteLine("customplasmapower:" + customplasma[1]);
         writer.WriteLine("customplasmaspace:" + customplasma[2]);
         writer.WriteLine("customplasmasp:" + customplasma[3]);
         writer.WriteLine("customplasmaspecial:" + customplasma[4]);
         String[] customwarp = new String[5];
         if (ship.WarpDrive != null && ship.WarpDrive.Origin == RuleBook.Custom)
         {
             customwarp[0] = ship.WarpDrive.Name;
             customwarp[1] = ship.WarpDrive.RawPower.PrintInt();
             customwarp[2] = ship.WarpDrive.RawSpace.PrintInt();
             customwarp[3] = ship.WarpDrive.RawSP.PrintInt();
             customwarp[4] = ship.WarpDrive.RawSpecial;
         }
         writer.WriteLine("customwarpname:" + customwarp[0]);
         writer.WriteLine("customwarppower:" + customwarp[1]);
         writer.WriteLine("customwarpspace:" + customwarp[2]);
         writer.WriteLine("customwarpsp:" + customwarp[3]);
         writer.WriteLine("customwarpspecial:" + customwarp[4]);
         String[] customgellar = new String[4];
         if (ship.GellarField != null && ship.GellarField.Origin == RuleBook.Custom)
         {
             customgellar[0] = ship.GellarField.Name;
             customgellar[1] = ship.GellarField.RawPower.PrintInt();
             customgellar[2] = ship.GellarField.RawSP.PrintInt();
             customgellar[3] = ship.GellarField.RawSpecial;
         }
         writer.WriteLine("customgellarname:" + customgellar[0]);
         writer.WriteLine("customgellarpower:" + customgellar[1]);
         writer.WriteLine("customgellarsp:" + customgellar[2]);
         writer.WriteLine("customgellarspecial:" + customgellar[3]);
         String[] customvoid = new String[5];
         int customshields = 0;
         if (ship.VoidShield != null && ship.VoidShield.Origin == RuleBook.Custom)
         {
             customvoid[0] = ship.VoidShield.Name;
             customvoid[1] = ship.VoidShield.RawPower.PrintInt();
             customvoid[2] = ship.VoidShield.RawSpace.PrintInt();
             customvoid[3] = ship.VoidShield.RawSP.PrintInt();
             customvoid[4] = ship.VoidShield.RawSpecial;
             customshields += ship.VoidShield.Strength;
         }
         writer.WriteLine("customvoidname:" + customvoid[0]);
         writer.WriteLine("customvoidpower:" + customvoid[1]);
         writer.WriteLine("customvoidspace:" + customvoid[2]);
         writer.WriteLine("customvoidsp:" + customvoid[3]);
         writer.WriteLine("customvoidspecial:" + customvoid[4]);
         String[] custombridge = new String[5];
         if (ship.ShipBridge != null && ship.ShipBridge.Origin == RuleBook.Custom)
         {
             custombridge[0] = ship.ShipBridge.Name;
             custombridge[1] = ship.ShipBridge.RawPower.PrintInt();
             custombridge[2] = ship.ShipBridge.RawSpace.PrintInt();
             custombridge[3] = ship.ShipBridge.RawSP.PrintInt();
             custombridge[4] = ship.ShipBridge.RawSpecial;
         }
         writer.WriteLine("custombridgename:" + custombridge[0]);
         writer.WriteLine("custombridgepower:" + custombridge[1]);
         writer.WriteLine("custombridgespace:" + custombridge[2]);
         writer.WriteLine("custombridgesp:" + custombridge[3]);
         writer.WriteLine("custombridgespecial:" + custombridge[4]);
         String[] customlife = new String[5];
         if (ship.LifeSustainer != null && ship.LifeSustainer.Origin == RuleBook.Custom)
         {
             customlife[0] = ship.LifeSustainer.Name;
             customlife[1] = ship.LifeSustainer.RawPower.PrintInt();
             customlife[2] = ship.LifeSustainer.RawSpace.PrintInt();
             customlife[3] = ship.LifeSustainer.RawSP.PrintInt();
             customlife[4] = ship.LifeSustainer.RawSpecial;
         }
         writer.WriteLine("customlifename:" + customlife[0]);
         writer.WriteLine("customlifepower:" + customlife[1]);
         writer.WriteLine("customlifespace:" + customlife[2]);
         writer.WriteLine("customlifesp:" + customlife[3]);
         writer.WriteLine("customlifespecial:" + customlife[4]);
         String[] customcrew = new String[5];
         if (ship.CrewQuarters != null && ship.CrewQuarters.Origin == RuleBook.Custom)
         {
             customcrew[0] = ship.CrewQuarters.Name;
             customcrew[1] = ship.CrewQuarters.RawPower.PrintInt();
             customcrew[2] = ship.CrewQuarters.RawSpace.PrintInt();
             customcrew[3] = ship.CrewQuarters.RawSP.PrintInt();
             customcrew[4] = ship.CrewQuarters.RawSpecial;
         }
         writer.WriteLine("customcrewname:" + customcrew[0]);
         writer.WriteLine("customcrewpower:" + customcrew[1]);
         writer.WriteLine("customcrewspace:" + customcrew[2]);
         writer.WriteLine("customcrewsp:" + customcrew[3]);
         writer.WriteLine("customcrewspecial:" + customcrew[4]);
         String[] customaugur = new String[4];
         if (ship.AugurArrays != null && ship.AugurArrays.Origin == RuleBook.Custom)
         {
             customaugur[0] = ship.AugurArrays.Name;
             customaugur[1] = ship.AugurArrays.RawPower.PrintInt();
             customaugur[2] = ship.AugurArrays.RawSP.PrintInt();
             customaugur[3] = ship.AugurArrays.RawSpecial;
         }
         writer.WriteLine("customaugurname:" + customaugur[0]);
         writer.WriteLine("customaugurpower:" + customaugur[1]);
         writer.WriteLine("customaugursp:" + customaugur[2]);
         writer.WriteLine("customaugurspecial:" + customaugur[3]);
         writer.WriteLine("custommachine:" + ship.GMMachineSpirit);
         writer.WriteLine("customhistory:" + ship.GMShipHistory);
         writer.WriteLine("customspeed:" + ship.GMSpeed.PrintInt());
         writer.WriteLine("customint:" + ship.GMHullIntegrity.PrintInt());
         writer.WriteLine("customdet:" + ship.GMDetection.PrintInt());
         writer.WriteLine("customman:" + ship.GMManoeuvrability.PrintInt());
         writer.WriteLine("customarmour:" + ship.GMArmour.PrintInt());
         writer.WriteLine("customturret:" + ship.GMTurretRating.PrintInt());
         writer.WriteLine("custommorale:" + ship.GMMorale.PrintInt());
         writer.WriteLine("customcrew:" + ship.GMCrewPopulation.PrintInt());
         customshields += ship.GMShields;
         writer.WriteLine("customshield:" + customshields.PrintInt());
         writer.WriteLine("customspecial:" + ship.GMSpecial);
         int powerused = 0;
         int powergen = 0;
         int space = 0;
         int sp = 0;
         StringBuilder componentspecial = new StringBuilder();
         foreach (Supplemental component in ship.SupplementalComponents)
         {
             if (component.Origin == RuleBook.Custom)
             {
                 if (component.PowerGenerated)
                     powergen += component.RawPower;
                 else
                     powerused += component.RawPower;
                 space += component.RawSpace;
                 sp += component.RawSP;
                 if (!(component.Name.Equals("Custom Components") || component.Name.Equals("Custom Generators")))
                 {
                     componentspecial.Append(component.Name + ":" + component.RawSpecial + ";");//if added by this program
                 }
                 else//if from ship sheet originally
                     componentspecial.Append(component.RawSpecial);
             }
         }
         writer.WriteLine("customcomppower:" + powerused.PrintInt());
         writer.WriteLine("customcompgenerate:" + powergen.PrintInt());
         writer.WriteLine("customcompspace:" + space.PrintInt());
         writer.WriteLine("customcompsp:" + sp.PrintInt());
         writer.WriteLine("customcomponents:" + sp.PrintInt());
         foreach (String compName in ship.SupplementalComponents.Where(x => x.Origin != RuleBook.Custom).Select(x => x.QualityName).Distinct())
         {
             writer.WriteLine("{0}:{1}", compName, ship.SupplementalComponents.Count(x => x.Origin != RuleBook.Custom && x.QualityName.Equals(compName)) - (ship.Hull == null && ship.Hull.DefaultComponents == null ? 0 : ship.Hull.DefaultComponents.Count(x => x.QualityName == compName)));//double check origin in case duplicate name
         }
     }
 }