示例#1
0
        /// <summary>
        /// 指定された数値に対して、端数処理を行います。
        /// </summary>
        /// <param name="value">処理対象数値を指定して下さい。</param>
        /// <param name="decimals">小数点以下の有効桁数を指定して下さい。</param>
        /// <param name="roundType">丸め区分を指定して下さい。</param>
        /// <exception cref="System.ArgumentOutOfRangeException">decimalsに0未満、28より大きい値が設定された場合、発生します。</exception>
        /// <exception cref="System.ArgumentException">roundTypeに想定しない値が設定された場合、発生します。</exception>
        /// <returns>端数処理された数値</returns>
        public static decimal Round(decimal value, int decimals = 0, RoundType roundType = RoundType.RoundOff)
        {
            // 丸め区分によって調整値を算出
            decimal adjuster;
            switch (roundType)
            {
                // 四捨五入:調整値なし
                case RoundType.RoundOff:
                    adjuster = 0;
                    break;

                // 切り上げ:丸め幅の半分 - 1を加算
                case RoundType.RoundUp:
                    adjuster = Convert.ToDecimal(0 + Math.Pow(0.1D, decimals)) * 0.4M;
                    adjuster *= Math.Sign(value);
                    break;

                // 切り下げ:丸め幅の半分を減算
                case RoundType.RoundDown:
                    adjuster = Convert.ToDecimal(0 - Math.Pow(0.1D, decimals)) * 0.5M;
                    adjuster *= Math.Sign(value);
                    break;

                default:
                    throw new InvalidEnumArgumentException("丸め区分の値が不正です。");
            }

            // 丸め処理
            value = Math.Round(value + adjuster, decimals, MidpointRounding.AwayFromZero);
            return value;
        }
 public NumberTextBox()
     : base()
 {
     base.Text = "";
     this.ImeMode = ImeMode.Disable;
     this.TextAlign = HorizontalAlignment.Right;
     this.FormatText = "#,##0.##";
     this.MaxValue = 999999999999;
     this.MinValue = -999999999999;
     this.Digit = 2;
     this._roundmode = NumberTextBox.RoundType.Adjust;
 }
示例#3
0
        private void okButton_Click(object sender, EventArgs e)
        {
            if (valueToQueryTextBox.Text.Length == 0)
            {
                MessageBox.Show("Missing value to query", "Value missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MainForm form = (MainForm)Application.OpenForms[0];

            MemoryDataType memoryType = ((MemoryDataType[])Enum.GetValues(typeof(MemoryDataType)))[dataPickerBox.SelectedIndex];
            RoundType      roundType  = ((RoundType[])Enum.GetValues(typeof(RoundType)))[roundComboBox.SelectedIndex];

            try
            {
                form.SetMemoryDataType(memoryType, roundType, BitConverter.GetBytes(int.Parse(valueToQueryTextBox.Text)));
                Close();
            }
            catch
            {
                MessageBox.Show("Invalid value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        public static string AsString(this RoundType type)
        {
            switch (type)
            {
            case RoundType.ECO:
                return(AppSettings.ECO);

            case RoundType.SEMI_ECO:
                return(AppSettings.SEMI_ECO);

            case RoundType.FORCE_BUY:
                return(AppSettings.FORCE_BUY);

            case RoundType.NORMAL:
                return(AppSettings.NORMAL);

            case RoundType.PISTOL_ROUND:
                return(AppSettings.PISTOL_ROUND);

            default:
                return(AppSettings.UNKNOWN);
            }
        }
示例#5
0
        private string GenerateRoundName(int numCompetitors, RoundType roundType, int losersRoundNum = -1)
        {
            var roundName = "";

            switch (roundType)
            {
            case RoundType.Winners:
                switch (numCompetitors)
                {
                case 2:
                    roundName = "Winners Finals";
                    break;

                case 4:
                    roundName = "Winners Semifinals";
                    break;

                default:
                    roundName = "Round of " + numCompetitors;
                    break;
                }
                break;

            case RoundType.Losers:
                roundName = "Losers Round " + losersRoundNum;
                break;

            case RoundType.GrandFinals:
                roundName = "Grand Finals";
                break;

            default:
                break;
            }

            return(roundName);
        }
示例#6
0
        private float Snap(float input, float increment, RoundType roundType = RoundType.Floor)
        {
            float output = input;

            switch (roundType)
            {
            case RoundType.Floor:
                output = Mathf.Floor(input / increment) * increment;
                break;

            case RoundType.Nearest:
                output = Mathf.Round(input / increment) * increment;
                break;

            case RoundType.Ceil:
                output = Mathf.Ceil(input / increment) * increment;
                break;

            default:
                throw new NotImplementedException("Does not support RoundType: " + roundType);
            }

            return(output);
        }
示例#7
0
        /// <summary>
        /// Returns the number rounded as defined by the <code>roundType</code>
        /// </summary>
        /// <param name="number">
        /// The <see cref="System.Double"/> to round
        /// </param>
        /// <param name="roundType">
        /// The way in which <code>number</code> should be rounded
        /// </param>
        /// <returns>
        /// The rounded <see cref="System.Double"/>
        /// </returns>
        public static double Round(double number, RoundType roundType)
        {
            double val;

            switch (roundType)
            {
            case RoundType.Up:
                val = Math.Ceiling(number);
                break;

            case RoundType.Down:
                val = Math.Floor(number);
                break;

            case RoundType.Banker:
                val = Math.Round(number);
                break;

            case RoundType.UpToHalf:
                val = CeilToHalf(number);
                break;

            case RoundType.DownToHalf:
                val = FloorToHalf(number);
                break;

            case RoundType.BankerToHalf:
                val = RoundToHalf(number);
                break;

            default:
                throw new InvalidOperationException("Unhandled round type: " + roundType);
            }

            return(val);
        }
示例#8
0
        //private void SnapAngle(float incrementSize)
        //{
        //    foreach (var t in Selection.transforms)
        //        t.transform.eulerAngles = Snap(t.transform.eulerAngles, incrementSize, RoundType.Nearest);
        //}

        private Vector3 Snap(Vector3 input, Vector3 increment, RoundType roundType = RoundType.Floor)
        {
            return(new Vector3(Snap(input.x, increment.x, roundType),
                               Snap(input.y, increment.y, roundType),
                               Snap(input.z, increment.z, roundType)));
        }
        private decimal EvalModificator(object modificator, FactorInfo factorInfo, Dictionary <FactorType, List <FactorInfo> > defenderFactors, Hero hero, Creature creature, TextWriter log, decimal i2, decimal r2 = 1)
        {
            // %HeroLevel%
            // %CreatureLevel%
            // %Immunity%
            // %CreatureAttack%
            // %CreatureDefense%
            // %I2%
            // %R2%
            // PARAMS

            string    value    = string.Empty;
            decimal   retValue = 0;
            RoundType round    = RoundType.None;

            // get value from modificator
            if (modificator is Modificator)
            {
                value = ((Modificator)modificator).Value;
                round = ((Modificator)modificator).RoundType;
            }
            else if (modificator is LevelModificator)
            {
                LevelModificator levelModificator = (LevelModificator)modificator;
                string           level            = string.Empty;
                if (factorInfo.ParentRef != null)
                {
                    level = factorInfo.ParentRef.Level;
                }
                if (string.IsNullOrEmpty(level) || level == "0")
                {
                    value = levelModificator.Level_0.Value;
                }
                else if (level == "1")
                {
                    value = levelModificator.Level_1.Value;
                }
                else if (level == "2")
                {
                    value = levelModificator.Level_2.Value;
                }
                else if (level == "3")
                {
                    value = levelModificator.Level_3.Value;
                }

                round = levelModificator.RoundType;
            }
            log.WriteLine("Evaluating value '{0}' for {1}", value, creature.Name);

            // replace standard values
            value = value.Replace("%HeroLevel%", hero.Level.ToString());
            value = value.Replace("%CreatureLevel%", creature.Level.ToString());
            value = value.Replace("%CreatureAttack%", creature.Attack.ToString());
            value = value.Replace("%CreatureDefense%", creature.Defense.ToString());

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            value = value.Replace("%I2%", i2.ToString(nfi));

            value = value.Replace("%R2%", i2.ToString(nfi));

            // check immunity
            if (factorInfo.Parent is CreatureAbility)
            {
                string          immunity = "0";
                CreatureAbility ability  = (CreatureAbility)factorInfo.Parent;
                if (defenderFactors.ContainsKey(FactorType.ImmuneToCreatureAbility))
                {
                    List <FactorInfo> immunityFactors = defenderFactors[FactorType.ImmuneToCreatureAbility];
                    foreach (FactorInfo immunityFactor in immunityFactors)
                    {
                        if (ability.Name == immunityFactor.Factor.CreatureAbility)
                        {
                            immunity = "1";
                        }
                    }
                }
                value = value.Replace("%Immunity%", immunity);
            }

            // params
            if (factorInfo.Parent is CreatureAbility)
            {
                CreatureAbility ability = (CreatureAbility)factorInfo.Parent;
                if (!string.IsNullOrEmpty(ability.Params))
                {
                    string [] abilityParams = ability.Params.Split(' ');
                    foreach (string param in abilityParams)
                    {
                        string val = "0";
                        if (factorInfo.Params != null && factorInfo.Params.ContainsKey(param))
                        {
                            Param refParam = factorInfo.Params[param];
                            val = refParam.Value.ToString();
                        }
                        value = value.Replace("%" + param + "%", val);
                    }
                }
            }

            // evaluate string
            log.WriteLine("Evaluating direct value '{0}' for {1}", value, creature.Name);

            DataTable dt = new DataTable();

            retValue = System.Convert.ToDecimal(dt.Compute(value, string.Empty));
            if (round == RoundType.Down)
            {
                retValue = System.Math.Floor(retValue);
            }
            else if (round == RoundType.Up)
            {
                retValue = System.Math.Ceiling(retValue);
            }
            else if (round == RoundType.Normal)
            {
                retValue = System.Math.Round(retValue);
            }

            log.WriteLine("Counted value '{0}' for {1}", retValue, creature.Name);

            return(retValue);
        }
示例#10
0
        public static Coord WorldToHeightmapCoord(this Terrain terrain, Vector3 worldPos, RoundType rounding)
        {
            var terrainSize = terrain.terrainData.size;
            var resolution  = terrain.terrainData.heightmapResolution - 1;

            worldPos -= terrain.GetPosition();
            //worldPos -= new Vector3(0, 0, terrainSize.z / resolution) / 2;
            worldPos = new Vector3(worldPos.x / terrainSize.x, worldPos.y / terrainSize.y, worldPos.z / terrainSize.z);
            worldPos = new Vector3(worldPos.x * resolution, 0, worldPos.z * resolution);

            int x = 0;
            int z = 0;

            switch (rounding)
            {
            case RoundType.Round:
                x = Mathf.RoundToInt(worldPos.x);
                z = Mathf.RoundToInt(worldPos.z);
                break;

            case RoundType.Floor:
                x = Mathf.FloorToInt(worldPos.x);
                z = Mathf.FloorToInt(worldPos.z);
                break;

            case RoundType.Ceil:
                x = Mathf.CeilToInt(worldPos.x);
                z = Mathf.CeilToInt(worldPos.z);
                break;
            }

            x = Math.Max(0, x);
            x = Math.Min(resolution, x);

            z = Math.Max(0, z);
            z = Math.Min(resolution, z);

            return(new Coord(x, z));
        }
示例#11
0
 public Round(Guid id, RoundType roundType)
 {
     ApplyChange(new RoundCreated(id, roundType));
 }
示例#12
0
    public void SetRound(RoundType roundType, int day)
    {
        vm.waitOtherPlayer.SetActive(false);
        this.roundType = roundType;
        this.day       = day;
        isOverRound    = false;
        switch (roundType)
        {
        case RoundType.None:
            break;

        case RoundType.Day:
            if (OnRoundChange != null)
            {
                OnRoundChange();
            }
            if (OnDayEvent != null)
            {
                OnDayEvent();
            }
            CreatFood();
            StartCoroutine(vm.ShowDayAndTime(day, roundType));
            break;

        case RoundType.DayMove:
            if (OnDayMoveEvent != null)
            {
                OnDayMoveEvent();
            }

            break;

        case RoundType.Twilight:
            if (OnRoundChange != null)
            {
                OnRoundChange();
            }
            if (OnTwilightEvent != null)
            {
                OnTwilightEvent();
            }
            StartCoroutine(vm.ShowDayAndTime(day, roundType));
            //第一天黄昏设置狼人
            if (day == 1)
            {
                SetWolf();
            }
            break;

        case RoundType.TwilightMove:
            if (OnTwilightMoveEvent != null)
            {
                OnTwilightMoveEvent();
            }

            break;

        case RoundType.Night:
            if (OnRoundChange != null)
            {
                OnRoundChange();
            }
            if (OnNightEvent != null)
            {
                OnNightEvent();
            }
            StartCoroutine(vm.ShowDayAndTime(day, roundType));
            break;

        case RoundType.NightMove:
            if (OnNightMoveEvent != null)
            {
                OnNightMoveEvent();
            }

            break;

        default:
            break;
        }
    }
示例#13
0
 public CreateRound(Guid roundId, RoundType type)
 {
     RoundId = roundId;
     RoundType = type;
 }
        private void UpdateBalancesAfterAction(IPlayer player, IDealer dealer, decimal initialPlayerBetAmount, RoundType roundType = RoundType.InitialBetClick)
        {
            switch (roundType)
            {
            case RoundType.unspecified:
                break;

            case RoundType.InitialBetClick:
                new InitialBetActionPerformed(player, dealer).UpdateBanks(initialPlayerBetAmount);
                CurrentPot = sumBets(player.BetAmount, dealer.BetAmount);
                break;

            case RoundType.DoubleDownClick:
                new DoubleDownActionPerformed(player, dealer).UpdateBanks(initialPlayerBetAmount);
                CurrentPot = sumBets(player.BetAmount, dealer.BetAmount);
                break;

            default:
                break;
            }
        }
示例#15
0
 public Number()
 {
     RoundingMethod = RoundType.Normal;
     value          = -0;
 }
示例#16
0
 public Number()
 {
     RoundingMethod = RoundType.Normal;
     value = -0;
 }
示例#17
0
        public JeoCategory <JeoQuestion> RandomCat(RoundType type, bool hasDouble, bool hasAVL)
        {
            JeoCategory <JeoQuestion> retCat = new JeoCategory <JeoQuestion>();

            if (!hasAVL)
            {
                //loop the find category logic until a category with an audio/visual/link quesiton is found
                do
                {
                    retCat = new JeoCategory <JeoQuestion>();
                    retCat = Categories[rando.Next(Categories.Count)];
                    //find new random category until parameters (correct round and/or presence of audio/visual/link questions) are met
                    //also verify if category has enough questions to fill a standard round (IsFull property)
                    if (type == RoundType.First)
                    {
                        if (hasDouble)
                        {
                            while (!retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                        else
                        {
                            while (retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                    }
                    else if (type == RoundType.Second)
                    {
                        if (hasDouble)
                        {
                            while (!retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                        else
                        {
                            while (retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                    }
                    else if (type == RoundType.Final)
                    {
                        {
                            if (hasDouble)
                            {
                                while (!retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                                {
                                    retCat = new JeoCategory <JeoQuestion>();
                                    retCat = Categories[rando.Next(Categories.Count)];
                                }
                            }
                            else
                            {
                                while (retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                                {
                                    retCat = new JeoCategory <JeoQuestion>();
                                    retCat = Categories[rando.Next(Categories.Count)];
                                }
                            }
                        }
                    }
                } while (retCat.HasAVL);
            }
            else
            {
                //find new random category until parameters (correct round and/or presence of audio/visual/link questions) are met
                //also verify if category has enough questions to fill a standard round (IsFull property)
                if (type == RoundType.First)
                {
                    if (hasDouble)
                    {
                        while (!retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                    else
                    {
                        while (retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                }
                else if (type == RoundType.Second)
                {
                    if (hasDouble)
                    {
                        while (!retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                    else
                    {
                        while (retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                }
                else if (type == RoundType.Final)
                {
                    if (hasDouble)
                    {
                        while (!retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                    else
                    {
                        while (retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                }
            }

            if (retCat.Count > 5 && type == RoundType.First)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();
                newCat.CatName   = retCat.CatName;
                newCat.HasFirst  = retCat.HasFirst;
                newCat.HasDouble = retCat.HasDouble;
                newCat.HasFinal  = retCat.HasFinal;
                newCat.HasAVL    = retCat.HasAVL;
                newCat.IsFull    = retCat.IsFull;
                newCat.Clear();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 200 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 600 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1000 && x.Round == RoundType.First));

                //if method call has a daily double, randomly replace one of the questions with it
                //todo: replace the value that the daily double was originally at. not possible?
                if (hasDouble)
                {
                    newCat[rando.Next(4)] = retCat.Find(x => x.Type == QType.Double);
                }

                retCat = newCat;
            }
            if (retCat.Count > 5 && type == RoundType.Second)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();
                newCat.CatName   = retCat.CatName;
                newCat.HasFirst  = retCat.HasFirst;
                newCat.HasDouble = retCat.HasDouble;
                newCat.HasFinal  = retCat.HasFinal;
                newCat.HasAVL    = retCat.HasAVL;
                newCat.IsFull    = retCat.IsFull;
                newCat.Clear();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1200 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1600 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 2000 && x.Round == RoundType.Second));

                //if method call has a daily double, randomly replace one of the questions with it
                //todo: replace the value that the daily double was originally at. not possible?
                if (hasDouble)
                {
                    newCat[rando.Next(4)] = retCat.Find(x => x.Type == QType.Double);
                }

                retCat = newCat;
            }

            return(retCat);
        }
示例#18
0
 public Modificator()
 {
     this.roundTypeField = RoundType.None;
 }
示例#19
0
        /// <summary>
        /// 指定された数値を金額フォーマットの文字列に変換します。
        /// </summary>
        /// <param name="numericValue">変換対象数値を指定して下さい。</param>
        /// <param name="currencyType">円記号の表示形式を指定して下さい。</param>
        /// <param name="addComma">3桁区切りを付与する場合、true。しない場合、falseを指定して下さい。</param>
        /// <param name="decimals">小数点以下の有効桁数を指定して下さい。</param>
        /// <param name="roundType">丸め区分を指定して下さい。</param>
        /// <exception cref="System.ArgumentNullException">numericValueがNullの場合、発生します。</exception>
        /// <exception cref="System.FormatException">numericValueが数値に変換できない場合、発生します。</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">decimalsに0未満、28より大きい値が設定された場合、発生します。</exception>
        /// <exception cref="System.ArgumentException">
        /// roundTypeに想定しない値が設定された場合、発生します。
        /// または、円記号の表示形式に想定しない値が設定された場合、発生します。
        /// </exception>
        /// <returns>金額フォーマット文字列</returns>
        public static string ConvertString(object numericValue, CurrencyType currencyType = CurrencyType.None, bool addComma = false, int decimals = 0, RoundType roundType = RoundType.RoundOff)
        {
            // Null値チェック
            if (null == numericValue)
            {
                throw new ArgumentNullException("numericValue");
            }

            // 丸め処理
            decimal value = Convert.ToDecimal(numericValue);
            value = MizuochiMath.Round(value, decimals, roundType);

            // 3ケタ区切り付与
            string format = String.Empty;
            if (true == addComma)
            {
                format = String.Format("{0}{1}", "N", decimals);
            }
            else
            {
                format = String.Format("{0}{1}", "F", decimals);
            }

            // 円記号付与
            string stringValue = value.ToString(format);
            switch (currencyType)
            {
                case CurrencyType.None:
                    break;

                case CurrencyType.Mark:
                    stringValue = @"\" + stringValue;
                    break;

                case CurrencyType.Kanji:
                    stringValue = stringValue + @"円";
                    break;

                default:
                    throw new InvalidEnumArgumentException("円記号の表示形式の値が不正です。");
            }

            return stringValue;
        }
示例#20
0
 public Round(int num, RoundType type, int limit)
 {
     RoundNumber = num;
     Type        = type;
     Limit       = limit;
 }
示例#21
0
 public JeoQuestion(string cat, string clu, string ans, int val, RoundType roun, QType typ)
 {
     Category = cat; Clue = clu; Answer = ans; Value = val; Round = roun; Type = typ;
 }
示例#22
0
 public static Double Round(Double number, RoundType roundType)
 {
     return(Round(number, 0, roundType));
 }
示例#23
0
        //return random category of specified RoundType. Alternate definition allows preference for Audio/Visual/Link quesitons
        //and/or daily doubles
        //todo: add a definition that respects AVL, but does not check hasDouble. How to do without duplicate method signatures?
        public JeoCategory <JeoQuestion> RandomCat(RoundType type)
        {
            JeoCategory <JeoQuestion> retCat = new JeoCategory <JeoQuestion>();

            retCat = Categories[rando.Next(Categories.Count)];

            //find new random category until parameters correct round type is found
            //also verify if category has enough questions to fill a standard round (IsFull property)
            if (type == RoundType.First)
            {
                while (!retCat.HasFirst || !retCat.IsFull)
                {
                    retCat = Categories[rando.Next(Categories.Count)];
                }
            }
            else if (type == RoundType.Second)
            {
                while (!retCat.HasSecond || !retCat.IsFull)
                {
                    retCat = Categories[rando.Next(Categories.Count)];
                }
            }
            else if (type == RoundType.Final)
            {
                while (!retCat.HasFinal || !retCat.IsFull)
                {
                    retCat = Categories[rando.Next(Categories.Count)];
                }
            }

            //if there are more than 5 questions in a category, randomly select one each of the correct value
            if (retCat.Count > 5 && type == RoundType.First)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 200 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 600 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1000 && x.Round == RoundType.First));

                retCat = newCat;
            }
            if (retCat.Count > 5 && type == RoundType.Second)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1200 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1600 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 2000 && x.Round == RoundType.Second));

                retCat = newCat;
            }

            return(retCat);
        }
示例#24
0
        public Rect2Int ConvertToInt(RoundType min_x_type, RoundType min_y_type, RoundType max_x_type, RoundType max_y_type)
        {
            int Convert(float v, RoundType type)
            {
                switch (type)
                {
                case RoundType.Nearest:
                    return((int)Math.Round(v));

                case RoundType.Ceil:
                    return((int)Math.Ceiling(v));

                case RoundType.Floor:
                    return((int)Math.Floor(v));

                default:
                    return(0);
                }
            }

            return(Rect2Int.FromBounds(
                       Convert(min_x, min_x_type),
                       Convert(min_y, min_y_type),
                       Convert(max_x, max_x_type),
                       Convert(max_y, max_y_type)
                       ));
        }
示例#25
0
 public RoundCreated(Guid id, RoundType roundType)
 {
     Id = id;
     RoundType = roundType;
 }
示例#26
0
        public JeoModel()
        {
            bool oldCat = false;

            using (StreamReader sr = new StreamReader(DBPATH))
            {
                string  json = sr.ReadToEnd();
                JObject db   = JObject.Parse(json);

                //iterate through each category
                int totalCount = 0;
                foreach (JProperty category in db.Properties())
                {
                    JeoCategory <JeoQuestion> catList = new JeoCategory <JeoQuestion>();
                    catList.CatName = category.Name.ToString().ToUpper();
                    oldCat          = false;
                    //iterate through each question within each category
                    foreach (JToken question in category)
                    {
                        //keeps track of how many questions in the category will fit into a standard round
                        int qCount = 0;

                        //create a JeoQuestion based on the entries in each quesiton
                        foreach (JToken entry in question.Children())
                        {
                            ++totalCount;
                            string clue   = entry["clue"].ToString();
                            string answer = entry["answer"].ToString();
                            string cat    = category.Name.ToString().ToUpper();

                            //check if the value has a dollar amount, else determine what kind of question it is
                            QType  type  = QType.Standard;
                            string value = entry["value"].ToString();
                            if (int.TryParse(value, out int val))
                            {
                                ;
                            }
                            else
                            {
                                if (value.Contains("Final"))
                                {
                                    type = QType.Final;
                                }
                                else if (value.Contains("Double"))
                                {
                                    type = QType.Double;
                                }
                                else
                                {
                                    type = QType.Special;
                                }
                            }

                            //determine and assign which round the question is from
                            string    roundStr = entry["round"].ToString();
                            RoundType round    = RoundType.Special;
                            if (int.TryParse(roundStr, out int roun))
                            {
                                if (roun == 1)
                                {
                                    round            = RoundType.First;
                                    catList.HasFirst = true;
                                }
                                if (roun == 2)
                                {
                                    round             = RoundType.Second;
                                    catList.HasSecond = true;
                                }
                            }
                            else
                            {
                                round = RoundType.Final;
                            }

                            //create the JeoQuestion object and check for special flags
                            JeoQuestion addQ = new JeoQuestion(cat, clue, answer, val, round, type);
                            if (clue.ToUpper().Contains("AUDIO DAILY DOUBLE"))
                            {
                                addQ.IsAudio = true;
                            }
                            if (clue.ToUpper().Contains("VIDEO DAILY DOUBLE"))
                            {
                                addQ.IsVideo = true;
                            }
                            if (clue.ToUpper().Contains("A HREF"))
                            {
                                addQ.HasLink = true;
                            }

                            //update category based on flags
                            if (addQ.IsAudio || addQ.IsVideo || addQ.HasLink)
                            {
                                catList.HasAVL = true;
                            }
                            if (addQ.Type == QType.Double)
                            {
                                catList.HasDouble = true;
                            }
                            if (addQ.Type == QType.Final)
                            {
                                catList.HasFinal = true;
                            }
                            if (addQ.Type == QType.Standard || addQ.Type == QType.Double)
                            {
                                ++qCount;
                            }

                            //jeopardy questions used to be worth half as much; for consistency, update older values to newer standard
                            if ((addQ.Round == RoundType.First) && ((addQ.Value % 200F) != 0) && (addQ.Value > 0))
                            {
                                oldCat = true;
                            }
                            if ((addQ.Round == RoundType.Second) && ((addQ.Value % 400F) != 0) && (addQ.Value > 0))
                            {
                                oldCat = true;
                            }
                            if (oldCat)
                            {
                                addQ.Value = addQ.Value * 2;
                            }
                            catList.Add(addQ);
                        }

                        if (qCount > 4)
                        {
                            catList.IsFull = true;
                        }
                        Categories.Add(catList);
                    }
                }
                sr.Dispose();
            }
        }
示例#27
0
        private Form BuildMain(RoundType round)
        {
            Form retForm = new Form();

            retForm.BackColor = Color.LightGray;

            viewPanel             = new TableLayoutPanel();
            viewPanel.Dock        = DockStyle.Fill;
            viewPanel.RowCount    = 2;
            viewPanel.ColumnCount = 6;
            viewPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F));
            viewPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));

            cashLabel = new Button();
            FormatButton(ref cashLabel);
            cashLabel.Text = "Your Current Winnings: $" + game.Cash.ToString();
            viewPanel.Controls.Add(cashLabel);
            viewPanel.SetColumnSpan(cashLabel, 4);

            Button newGame = new Button();

            FormatButton(ref newGame);
            newGame.Text   = "New Game";
            newGame.Click += new EventHandler(NewHandler);
            viewPanel.Controls.Add(newGame);

            Button exit = new Button();

            FormatButton(ref exit);
            exit.Click += new EventHandler(ExitHandler);
            exit.Text   = "Exit Game";
            viewPanel.Controls.Add(exit);

            List <JeoCategory <JeoQuestion> > iterateRound = new List <JeoCategory <JeoQuestion> >();

            if (round == RoundType.First)
            {
                iterateRound = game.FirstRound;
            }
            if (round == RoundType.Second)
            {
                iterateRound = game.SecondRound;
            }
            foreach (JeoCategory <JeoQuestion> category in iterateRound)
            {
                //panel that holds a single category
                TableLayoutPanel cat = new TableLayoutPanel();
                cat.Dock     = DockStyle.Fill;
                cat.RowCount = 6;
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));

                //category heading button
                Button catButton = new Button();
                catButton.Text = category.CatName;
                FormatButton(ref catButton);
                cat.Controls.Add(catButton);

                //handles different question values for each round
                int roundMultiplier = 0;
                if (round == RoundType.First)
                {
                    roundMultiplier = 200;
                }
                if (round == RoundType.Second)
                {
                    roundMultiplier = 400;
                }

                //try to add a question for each value. If one isn't found, add the category's daily double question
                JeoButton addButton = null;
                for (int i = 0; i < 5; i++)
                {
                    addButton = new JeoButton(category.Find(x => x.Value == (i * roundMultiplier) + roundMultiplier));
                    if (addButton.Question == null)
                    {
                        addButton = new JeoButton(category.Find(x => x.Type == QType.Double));
                    }

                    //format and register question button
                    addButton.Text = "$" + ((i * roundMultiplier) + roundMultiplier).ToString();
                    FormatButton(ref addButton);
                    addButton.Font   = new Font("Arial", VALUESIZE, FontStyle.Bold);
                    addButton.Click += new EventHandler(QChosen);
                    cat.Controls.Add(addButton);
                    if (round == RoundType.First)
                    {
                        game.FRQuestions.Add(addButton);
                    }
                    if (round == RoundType.Second)
                    {
                        game.SRQuestions.Add(addButton);
                    }
                }
                viewPanel.Controls.Add(cat);
            }
            retForm.Controls.Add(viewPanel);
            retForm.FormBorderStyle = FormBorderStyle.None;
            retForm.WindowState     = FormWindowState.Maximized;
            return(retForm);
        }
示例#28
0
 public void setRoundType(RoundType roundType)
 {
     slotType = roundType;
     setBackgroundColor(null, RoundState.Empty);
 }
示例#29
0
 public static string GetRoundTypeName(RoundType RoundType)
 {
     return(RoundType.ToString().ToUpper().Replace("PICK", "PICK "));
 }
示例#30
0
        public static Game PlayGame(Team homeTeam, Team awayTeam, RoundType roundType, bool giveHammerAdvantageToTeamWithBetterRecord = false)
        {
            var homeTeamLsd = DrawToTheButton(homeTeam, roundType);
            var awayTeamLsd = DrawToTheButton(awayTeam, roundType);

            bool homeHasHammer = GetHomeHasHammer(homeTeam, awayTeam, homeTeamLsd, awayTeamLsd, giveHammerAdvantageToTeamWithBetterRecord);

            double probabilityHomeBeatsAway = GetProbabilityOfHomeBeatingAway(homeTeam, awayTeam, homeHasHammer);
            var    random = new Random();


            if (random.NextDouble() < probabilityHomeBeatsAway)
            {
                if (roundType == RoundType.Qualifying)
                {
                    homeTeam.QualifyingRoundRecord.AddWin();
                    awayTeam.QualifyingRoundRecord.AddLoss();
                }
                if (roundType != RoundType.Playoff)
                {
                    homeTeam.RoundRobinRecord.AddWin();
                    awayTeam.RoundRobinRecord.AddLoss();
                }
                return(new Game()
                {
                    WinningTeam = homeTeam,
                    LosingTeam = awayTeam,
                    HomeTeam = homeTeam,
                    AwayTeam = awayTeam,
                    HomeTeamLsd = homeTeamLsd,
                    AwayTeamLsd = awayTeamLsd,
                    HomeTeamWon = true,
                    AwayTeamWon = false,
                    HomeHammer = homeHasHammer,
                    AwayHammer = !homeHasHammer
                });
            }
            else
            {
                if (roundType == RoundType.Qualifying)
                {
                    homeTeam.QualifyingRoundRecord.AddLoss();
                    awayTeam.QualifyingRoundRecord.AddWin();
                }
                if (roundType != RoundType.Playoff)
                {
                    homeTeam.RoundRobinRecord.AddLoss();
                    awayTeam.RoundRobinRecord.AddWin();
                }
                return(new Game()
                {
                    WinningTeam = awayTeam,
                    LosingTeam = homeTeam,
                    HomeTeam = homeTeam,
                    AwayTeam = awayTeam,
                    HomeTeamLsd = homeTeamLsd,
                    AwayTeamLsd = awayTeamLsd,
                    HomeTeamWon = false,
                    AwayTeamWon = true,
                    HomeHammer = homeHasHammer,
                    AwayHammer = !homeHasHammer
                });
            }
        }
示例#31
0
 private void Apply(RoundCreated e)
 {
     _id = e.Id;
     _roundType = e.RoundType;
 }
示例#32
0
        private async Task OpenRound(RoundType roundType)
        {
            var dealer = Context.Message.Author;
            var game   = new Game
            {
                Dealer    = dealer.ToString(),
                DealerId  = dealer.Id,
                RoundType = roundType
            };

            int?   roll1  = null;
            int?   roll2  = null;
            int?   roll3  = null;
            Random random = new Random();
            string pSalt1 = Utils.LongRandom(random).ToString();
            string pSalt2 = Utils.LongRandom(random).ToString();

            switch (roundType)
            {
            case RoundType.Pick1:
                roll1             = random.Next(0, 9);
                game.RoundTime    = _config.Secs1;
                game.MinSingleBet = _config.Min1;
                game.MinSingleWin = game.MinSingleBet * PICK1_MULTI_SINGLE;
                game.MaxSingleBet = _config.Max1;
                game.MaxSingleWin = game.MaxSingleBet * PICK1_MULTI_SINGLE;
                break;

            case RoundType.Pick2:
                roll1               = random.Next(0, 9);
                roll2               = random.Next(0, 9);
                game.RoundTime      = _config.Secs2;
                game.MinStraightBet = _config.Min2Str;
                game.MinStraightWin = game.MinStraightBet * PICK2_MULTI_STRAIGHT;
                game.MaxStraightBet = _config.Max2Str;
                game.MaxStraightWin = game.MaxStraightBet * PICK2_MULTI_STRAIGHT;
                game.MinAnyBet      = _config.Min2Any;
                game.MinAnyWin      = game.MinAnyBet * PICK2_MULTI_ANY;
                game.MaxAnyBet      = _config.Max2Any;
                game.MaxAnyWin      = game.MaxAnyBet * PICK2_MULTI_ANY;
                break;

            case RoundType.Pick3:
                roll1               = random.Next(0, 9);
                roll2               = random.Next(0, 9);
                roll3               = random.Next(0, 9);
                game.RoundTime      = _config.Secs3;
                game.MinStraightBet = _config.Min3Str;
                game.MinStraightWin = game.MinStraightBet * PICK3_MULTI_STRAIGHT;
                game.MaxStraightBet = _config.Max3Str;
                game.MaxStraightWin = game.MaxStraightBet * PICK3_MULTI_STRAIGHT;
                game.MinAnyBet      = _config.Min3Any;
                game.MinAnyWin      = game.MinAnyBet * PICK3_MULTI_ANY;
                game.MaxAnyBet      = _config.Max3Any;
                game.MaxAnyWin      = game.MaxAnyBet * PICK3_MULTI_ANY;
                break;
            }
            string salt = $"{roll1}{roll2}{roll3}-{pSalt1}.{pSalt2}";

            var r = new Round
            {
                DealerId    = dealer.Id,
                Created     = DateTime.Now,
                RoundStatus = RoundStatus.Open,
                Roll1       = roll1,
                Roll2       = roll2,
                Roll3       = roll3,
                RollHash    = Utils.SHA256Hash(salt),
                RollSalt    = salt,
                RoundType   = roundType
            };

            _db.Rounds.Add(r);
            await _db.SaveChangesAsync().ConfigureAwait(false);

            string roundTypeStr = Utils.GetRoundTypeName(roundType);
            var    client       = Context.Client as DiscordSocketClient;
            await client.SetGameAsync($"{roundTypeStr} LOTTO").ConfigureAwait(false);

            await RoundStart(r, game).ConfigureAwait(false);
            await UnmuteChannel().ConfigureAwait(false);
        }
示例#33
0
        public static Coord WorldToSplatCoord(this Terrain terrain, Vector3 worldPos, RoundType rounding = RoundType.Round)
        {
            var terrainSize = terrain.terrainData.size;
            var resolution  = terrain.terrainData.alphamapResolution;

            worldPos -= new Vector3((1f / (float)resolution) * terrainSize.x, 0, (1f / resolution) * terrainSize.z) / 2f;
            worldPos -= terrain.GetPosition();
            worldPos  = new Vector3(worldPos.x / terrainSize.x, worldPos.y / terrainSize.y, worldPos.z / terrainSize.z);
            worldPos  = new Vector3(worldPos.x * resolution, 0, worldPos.z * resolution);

            switch (rounding)
            {
            case RoundType.Round:
                return(new Coord(Mathf.RoundToInt(worldPos.x), Mathf.RoundToInt(worldPos.z)));

            case RoundType.Floor:
                return(new Coord(Mathf.FloorToInt(worldPos.x), Mathf.FloorToInt(worldPos.z)));

            default:
                return(new Coord(Mathf.CeilToInt(worldPos.x), Mathf.CeilToInt(worldPos.z)));
            }
        }
示例#34
0
 //private void SnapAngle(float incrementSize)
 //{
 //    foreach (var t in Selection.transforms)
 //        t.transform.eulerAngles = Snap(t.transform.eulerAngles, incrementSize, RoundType.Nearest);
 //}
 private Vector3 Snap(Vector3 input, Vector3 increment, RoundType roundType = RoundType.Floor)
 {
     return new Vector3( Snap(input.x, increment.x, roundType),
                         Snap(input.y, increment.y, roundType),
                         Snap(input.z, increment.z, roundType));
 }
示例#35
0
 /// <summary>
 /// 分币误差分 进位方式(0、不控制;1、五舍六入;2、四舍五入)
 /// </summary>
 /// <param name="inputMoney">输入金额.</param>
 /// <param name="returnMoney">返回金额 </param>
 /// <param name="roundMoney">分币誤差金额.</param>
 /// <param name="roundType">计算类型.</param>
 /// <returns>System.String.</returns>
 public static string GetFBWC(decimal inputMoney, out decimal returnMoney, out decimal roundMoney, RoundType roundType = RoundType._4S5R)
 {
     returnMoney = 0;
     roundMoney  = 0;
     try
     {
         decimal tempDoubleZje = 10 * inputMoney;
         int     tempIntZje    = 0;
         if (roundType == RoundType._4S5R)
         {
             tempIntZje = (int)(10 * (tempDoubleZje + Convert.ToDecimal(0.05)));
         }
         else if (roundType == RoundType._5S6R)
         {
             tempIntZje = (int)(10 * (tempDoubleZje + Convert.ToDecimal(0.04)));
         }
         returnMoney = tempIntZje / 10;
         roundMoney  = inputMoney - returnMoney;
         return(string.Format("{0:f4}", roundMoney));
     }
     catch
     {
         return("0");
     }
 }
示例#36
0
        private float Snap(float input, float increment, RoundType roundType = RoundType.Floor)
        {
            float output = input;

            switch (roundType)
            {
                case RoundType.Floor:
                    output = Mathf.Floor(input / increment) * increment;
                    break;
                case RoundType.Nearest:
                    output = Mathf.Round(input / increment) * increment;
                    break;
                case RoundType.Ceil:
                    output = Mathf.Ceil(input / increment) * increment;
                    break;
                default:
                    throw new NotImplementedException("Does not support RoundType: " + roundType);
            }

            return output;
        }
示例#37
0
 /// <summary>
 /// 保留decimal指定位数并且指定四舍五入的方式
 /// </summary>
 /// <param name="value"></param>
 /// <param name="keepCount">保留位数</param>
 /// <param name="roundType">四舍五入的方式</param>
 /// <returns></returns>
 public static decimal ToRound(this decimal value, int keepCount = 2, RoundType roundType = RoundType.Normal)
 {
     decimal result = 0m;
     switch (roundType)
     {
         case RoundType.BankerRound:
             result = Math.Round(value, keepCount);
             break;
         case RoundType.Normal:
             result = Math.Round(value, keepCount, MidpointRounding.AwayFromZero);
             break;
         case RoundType.None:
             int factor = 1;
             for (int i = 1; i <= keepCount; i++)
             {
                 factor = factor * 10;
             }
             int tempNum = (int)(value * factor);
             result = (decimal)(tempNum * 1.0) / factor;
             break;
     }
     return result;
 }
示例#38
0
        public JeoCategory <JeoQuestion> TestCat(RoundType type, bool hasDouble, bool hasAVL)
        {
            JeoCategory <JeoQuestion> retCat = new JeoCategory <JeoQuestion>();

            retCat = CatByName("HOUSES OF THE HOLY");

            if (retCat.Count > 5 && type == RoundType.First)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();
                newCat.CatName   = retCat.CatName;
                newCat.HasFirst  = retCat.HasFirst;
                newCat.HasDouble = retCat.HasDouble;
                newCat.HasFinal  = retCat.HasFinal;
                newCat.HasAVL    = retCat.HasAVL;
                newCat.IsFull    = retCat.IsFull;
                newCat.Clear();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 200 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 600 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1000 && x.Round == RoundType.First));

                //if method call has a daily double, randomly replace one of the questions with it
                //todo: replace the value that the daily double was originally at. not possible?
                if (hasDouble)
                {
                    newCat[rando.Next(4)] = retCat.Find(x => x.Type == QType.Double);
                }

                retCat = newCat;
            }
            if (retCat.Count > 5 && type == RoundType.Second)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();
                newCat.CatName   = retCat.CatName;
                newCat.HasFirst  = retCat.HasFirst;
                newCat.HasDouble = retCat.HasDouble;
                newCat.HasFinal  = retCat.HasFinal;
                newCat.HasAVL    = retCat.HasAVL;
                newCat.IsFull    = retCat.IsFull;
                newCat.Clear();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1200 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1600 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 2000 && x.Round == RoundType.Second));

                //if method call has a daily double, randomly replace one of the questions with it
                //todo: replace the value that the daily double was originally at. not possible?
                if (hasDouble)
                {
                    newCat[rando.Next(4)] = retCat.Find(x => x.Type == QType.Double);
                }

                retCat = newCat;
            }

            return(retCat);
        }