Beispiel #1
0
 /// <summary>
 /// Create a new weapon
 /// </summary>
 /// <param name="name">name of the weapon</param>
 /// <param name="type">class of weapon</param>
 /// <param name="hulls">class fo ship that can mount this weapon</param>
 /// <param name="slots">locatiosn where this weapon can be mounted</param>
 /// <param name="power">power used by this weapon</param>
 /// <param name="space">space used by this method</param>
 /// <param name="sp">cost of this weapon</param>
 /// <param name="str">strength of the weapon</param>
 /// <param name="damage">damage of the weapon</param>
 /// <param name="crit">crit rating of the weapon</param>
 /// <param name="range">range of the weapon</param>
 /// <param name="origin">rulebook containing this weapon</param>
 /// <param name="page">page this weapon can be found on</param>
 /// <param name="quality">quality of this weapon</param>
 /// <param name="wq">enum declaring which qualities to be adjusted</param>
 /// <param name="special">special rules of this weapon</param>
 /// <param name="turbo">Quality of turboweapon battery upgrade if applicable</param>
 public Weapon(string name, WeaponType type, HullType hulls, WeaponSlot slots, int power, int space, int sp, int str,
     DiceRoll damage, int crit, int range, RuleBook origin, byte page, Quality quality = Quality.Common,
     WeaponQuality wq = WeaponQuality.None, string special = null, Quality turbo = Quality.None, ComponentOrigin comp = ComponentOrigin.Standard, Condition cond = Condition.Intact)
     : base(name, sp, power, space, special, origin, page, hulls, quality, comp, cond)
 {
     this.Type = type;
     this.Slots = slots;
     this.Strength = str;
     this.Damage = damage;
     this.Crit = crit;
     this.Range = range;
     this.WeaponQuality = wq;
     this.TurboWeapon = turbo;
 }
Beispiel #2
0
 public DiceRoll Mul(DiceRoll other)
 {
     if (this.d10 == 0 && this.d5 == 0)
     {
         if (other.d10 != 0 || other.d5 != 0)//by putting this if inside the other instead if as an and, the else if won't be evaluated and the final return statement will perform just modifier * modifier
         {
             return(other.Mul(this.Modifier));
         }
     }
     else if (other.d10 != 0 || other.d5 != 0)
     {
         throw new FormatException("Cannot multiply by dice values, only modifiers and ints");
     }
     return(this.Mul(other.Modifier));
 }
Beispiel #3
0
        public void TestMethod1()
        {
            DiceRoll d1 = new DiceRoll(2, 1, 4);
            DiceRoll d2 = new DiceRoll("2d10+1d5+4");
            DiceRoll d3 = new DiceRoll("1d10");
            DiceRoll d4 = new DiceRoll("5");
            DiceRoll d5 = new DiceRoll(2, 0, 0);

            Assert.AreEqual(d1.ToString(), d2.ToString());

            Assert.AreEqual("1d10+5", (d3 + d4).ToString());

            Assert.AreEqual("2d10+1d5-1", (d2 - d4).ToString());

            Assert.AreEqual("3d10", (d5 + d3).ToString());
        }
Beispiel #4
0
 /// <summary>
 /// Create a new supplemental Component
 /// </summary>
 /// <param name="name">name of the component</param>
 /// <param name="types">Classes of ship that can use this component</param>
 /// <param name="power">power used or granted by this component</param>
 /// <param name="space">space used by this component</param>
 /// <param name="sp">cost of this component</param>
 /// <param name="origin">rulebook this component is found in</param>
 /// <param name="page">page number to find this component</param>
 /// <param name="special">special rules of the component</param>
 /// <param name="quality">quality of the component</param>
 /// <param name="speed">speed modifier of the component</param>
 /// <param name="man">manoeuvrability modifier of the component</param>
 /// <param name="hullint">hull integrity modifier of the component</param>
 /// <param name="armour">armour modifier of the component</param>
 /// <param name="turrets">turret modifier of the component</param>
 /// <param name="morale">morale modifier of the component</param>
 /// <param name="crew">crew population modifier of the component</param>
 /// <param name="prowArmour">armour modifier to only the prow from this component</param>
 /// <param name="ramming">Additional damage dealt by ramming with this component</param>
 /// <param name="crewRating">Bonus or penalty to crew rating</param>
 /// <param name="mining">modifier to mining objectives</param>
 /// <param name="creed">modifier to creed objectives</param>
 /// <param name="military">modifier to military objectives</param>
 /// <param name="trade">modifier to trade objectives</param>
 /// <param name="criminal">modifier to criminal objectives</param>
 /// <param name="exploration">modifier to exploration objectives</param>
 /// <param name="generated">If the power listed is generated instead of used</param>
 /// <param name="detection">modifier to detection rating fromt he component</param>
 /// <param name="aux">Auxiliary weapons like hold landing bay granted by this component</param>
 /// <param name="macrodamage">damage modifier to macrobatteries such as from the munitorium</param>
 /// <param name="bs">ballistic skill modifier from this component</param>
 /// <param name="navigate">modifer to navigate the warp</param>
 /// <param name="crewLoss">modifier to crew losses</param>
 /// <param name="moraleLoss">modifier to morale losses</param>
 public Supplemental(string name, HullType types, int power, int space, int sp, RuleBook origin, byte page,
     DiceRoll ramming, String special = null, Quality quality = Quality.Common, int speed = 0, int man = 0,
     int hullint = 0, int armour = 0, int turrets = 0, int morale = 0, int crew = 0,
     int prowArmour = 0, int crewRating = 0,
     int mining = 0, int creed = 0, int military = 0, int trade = 0, int criminal = 0,
     int exploration = 0, bool generated = false, int detection = 0, Weapon aux = null, 
     int macrodamage = 0, int bs = 0, int navigate = 0, int crewLoss = 0, int moraleLoss = 0,
     ComponentOrigin comp = ComponentOrigin.Standard, string replace = null, int max = 0, Condition cond = Condition.Intact)
     : base(name, sp, power, space, special, origin, page, types, quality, comp, cond)
 {
     this.Speed = speed;
     this.Manoeuvrability = man;
     this.HullIntegrity = hullint;
     this.Armour = armour;
     this.TurretRating = turrets;
     this.Morale = morale;
     this.CrewPopulation = crew;
     this.ProwArmour = prowArmour;
     this.RamDamage = ramming;
     this.CrewRating = crewRating;
     this.MiningObjective = mining;
     this.CreedObjective = creed;
     this.MilitaryObjective = military;
     this.TradeObjective = trade;
     this.CriminalObjective = criminal;
     this.ExplorationObjective = exploration;
     this.PowerGenerated = generated;
     this.DetectionRating = detection;
     this.AuxiliaryWeapon = aux;
     this.MacrobatteryModifier = macrodamage;
     this.BSModifier = bs;
     this.NavigateWarp = navigate;
     this.CrewLoss = crewLoss;
     this.MoraleLoss = moraleLoss;
     this.Replace = replace;
     this.Max = max;
 }
Beispiel #5
0
 public bool Equals(DiceRoll other)
 {
     return((this.d10 == other.d10) && (this.d5 == other.d5) && (this.Modifier == other.Modifier));
 }
Beispiel #6
0
 public DiceRoll Sub(DiceRoll other)
 {
     return(new DiceRoll(this.d10 - other.d10, this.d5 - other.d5, this.Modifier - other.Modifier));
 }
Beispiel #7
0
 public DiceRoll Add(DiceRoll other)
 {
     return(new DiceRoll(this.d10 + other.d10, this.d5 + other.d5, this.Modifier + other.Modifier));
 }
Beispiel #8
0
        /// <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;
        }
Beispiel #9
0
        /// <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
                }
            }
        }
Beispiel #10
0
 public DiceRoll Sub(DiceRoll other)
 {
     return new DiceRoll(this.d10 - other.d10, this.d5 - other.d5, this.Modifier - other.Modifier);
 }
Beispiel #11
0
 public DiceRoll Mul(DiceRoll other)
 {
     if (this.d10 == 0 && this.d5 == 0)
     {
         if (other.d10 != 0 || other.d5 != 0)//by putting this if inside the other instead if as an and, the else if won't be evaluated and the final return statement will perform just modifier * modifier
             return other.Mul(this.Modifier);
     }
     else if (other.d10 != 0 || other.d5 != 0)
         throw new FormatException("Cannot multiply by dice values, only modifiers and ints");
     return this.Mul(other.Modifier);
 }
Beispiel #12
0
 public bool Equals(DiceRoll other)
 {
     return (this.d10 == other.d10) && (this.d5 == other.d5) && (this.Modifier == other.Modifier);
 }
Beispiel #13
0
 public DiceRoll Add(DiceRoll other)
 {
     return new DiceRoll(this.d10 + other.d10, this.d5 + other.d5, this.Modifier + other.Modifier);
 }
Beispiel #14
0
 /// <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
         }
     }
 }