예제 #1
0
        /// <summary>
        ///     This function fills in the details of the star.
        /// </summary>
        /// <param name="s">The star to be filled in</param>
        /// <param name="ourDice">The Ddice object used</param>
        /// <param name="maxMass">Max mass of the system</param>
        /// <param name="sysName">The name of the system</param>
        public static void GenerateAStar( Star s, Dice ourDice, double maxMass, string sysName )
        {
            //check mass first - if unset, set it.
            if (Math.Abs(s.CurrMass) < 0)
            {
                s.UpdateMass(s.OrderId == Star.IsPrimary ? RollStellarMass(ourDice, s.OrderId) : RollStellarMass(ourDice, s.OrderId, maxMass));
            }

            //if we are in the white dwarf branch, reroll mass.
            if (s.EvoLine.FindCurrentAgeGroup(s.StarAge) == StarAgeLine.RetCollaspedstar)
            {
                s.UpdateMass(ourDice.RollInRange(0.9, 1.4), true);
            }

            //set the generic name
            s.Name = Star.GenGenericName(sysName, s.OrderId);

            //initalize the luminosity first, then update it given the current age, status and mass.
            s.SetLumin();
            s.CurrLumin = Star.GetCurrLumin(s.EvoLine, s.StarAge, s.CurrMass);

            //determine the temperature
            s.EffTemp = Star.GetInitTemp(s.CurrMass);
            s.EffTemp = Star.GetCurrentTemp(s.EvoLine, s.CurrLumin, s.StarAge, s.CurrMass, ourDice);

            //DERIVED STATS: RADIUS, Spectral Type
            s.Radius = Star.GetRadius(s.CurrMass, s.EffTemp, s.CurrLumin, s.EvoLine.FindCurrentAgeGroup(s.StarAge));
            s.SetSpectralType();
            s.StarColor = Star.SetColor(ourDice, s.EffTemp);

            //set flare status.
            SetFlareStatus(s, ourDice);

            //end this here. We will hand orbital mechanics elsewhere.
        }
예제 #2
0
        /// <summary>
        ///     This function rolls for mass on a star.
        /// </summary>
        /// <param name="velvetBag">The Ddice object</param>
        /// <param name="orderId">The order ID of the star</param>
        /// <param name="maxMass">the maximum mass. Has a default value of 0.0, indicating no max mass (may be left out)</param>
        /// <returns>The rolled mass of a star</returns>
        public static double RollStellarMass( Dice velvetBag, int orderId, double maxMass = 0.0 )
        {
            int rollA; //roll integers

            if (Math.Abs(maxMass) < 0.0)
            {
                if (!(bool) !OptionCont.StellarMassRangeSet)
                {
                    return velvetBag.RollInRange(OptionCont.MinStellarMass, OptionCont.MaxStellarMass);
                }
                if (OptionCont.ForceGardenFavorable != null && ( orderId != Star.IsPrimary || !(bool) OptionCont.ForceGardenFavorable ))
                {
                    return Star.GetMassByRoll(velvetBag.GurpsRoll(), velvetBag.GurpsRoll());
                }
                rollA = velvetBag.Rng(6);
                if (rollA == 1)
                {
                    rollA = 5;
                }
                if (rollA == 2)
                {
                    rollA = 6;
                }
                if (rollA == 3 || rollA == 4)
                {
                    rollA = 7;
                }
                if (rollA == 5 || rollA == 6)
                {
                    rollA = 8;
                }

                return Star.GetMassByRoll(rollA, velvetBag.GurpsRoll());
            }

            var currPos = Star.GetStellarMassPos(maxMass);

            //error bound checking. The entire program is kinda predicated aroudn the idea you won't have this happen.
            //IF IT DOES, then do the simple method.
            if (currPos == -1)
            {
                double tmpRoll; //test value.
                do
                {
                    tmpRoll = Star.GetMassByRoll(velvetBag.GurpsRoll(), velvetBag.GurpsRoll());
                }
                while (tmpRoll > maxMass);

                return tmpRoll;
            }

            //else, roll for the new index.
            rollA = velvetBag.GurpsRoll();
            var rollB = velvetBag.Rng(rollA, 6); //roll integers

            //get the new index
            if (currPos - rollB <= 0)
            {
                currPos = 0;
            }
            else
            {
                currPos = currPos - rollB;
            }

            return Star.GetMassByIndex(currPos);
        }