Ejemplo n.º 1
0
        private static string Generate(List <ItemData> types, Func <ItemData, bool> filter, PlayerClass c)
        {
            double sum   = 0;
            var    datas = GeneratePool(types, filter, c);

            foreach (var chance in datas)
            {
                sum += chance.Chance.Calculate(c);
            }

            var value = Rnd.Double(sum);

            sum = 0;

            foreach (var t in datas)
            {
                sum += t.Chance.Calculate(c);

                if (value < sum)
                {
                    return(t.Id);
                }
            }

            return(PlaceholderItem);
        }
Ejemplo n.º 2
0
        public void CanDeploy_JobDefinition_WithProps()
        {
            WithExpectedUnsupportedCSOMnO365RunnerExceptions(() =>
            {
                var jobDef = ModelGeneratorService.GetRandomDefinition <JobDefinition>(def =>
                {
                    def.Properties.Add(new JobDefinitionProperty
                    {
                        Key   = string.Format("string_prop_{0}", Rnd.String()),
                        Value = string.Format("value_{0}", Rnd.String()),
                    });

                    def.Properties.Add(new JobDefinitionProperty
                    {
                        Key   = string.Format("int_prop_{0}", Rnd.String()),
                        Value = Rnd.Int()
                    });

                    def.Properties.Add(new JobDefinitionProperty
                    {
                        Key   = string.Format("double_prop_{0}", Rnd.String()),
                        Value = Math.Floor(Rnd.Double())
                    });
                });

                var model = SPMeta2Model.NewWebApplicationModel(webApp =>
                {
                    webApp.AddJob(jobDef);
                });

                TestModel(model);
            });
        }
Ejemplo n.º 3
0
        public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action)
        {
            return(WithEmptyDefinition(def =>
            {
                //def.FieldId = BuiltInFieldId.Order;

                // FieldId is not supported by CSOM, so we use field name
                // http://officespdev.uservoice.com/forums/224641-general/suggestions/6411772-expose-guid-field-value-indexer-for-microsoft-shar

                def.FieldName = "Order";
                def.Value = Math.Ceiling(Rnd.Double(100));
            }));
        }
Ejemplo n.º 4
0
        public static string GenerateAndRemove(List <ItemData> datas, Func <ItemData, bool> filter = null, bool removeFromFloor = false)
        {
            double sum = 0;

            foreach (var chance in datas)
            {
                if (filter == null || filter(chance))
                {
                    sum += chance.Chance.Calculate(PlayerClass.Any);
                }
            }

            var value = Rnd.Double(sum);

            sum = 0;

            string   id   = null;
            ItemData data = null;

            foreach (var t in datas)
            {
                if (filter == null || filter(t))
                {
                    sum += t.Chance.Calculate(PlayerClass.Any);

                    if (value < sum)
                    {
                        id   = t.Id;
                        data = t;
                        break;
                    }
                }
            }

            if (id != null)
            {
                if (removeFromFloor)
                {
                    GeneratedOnFloor.Add(id);
                }

                datas.Remove(data);
                return(id);
            }

            return(PlaceholderItem);
        }
Ejemplo n.º 5
0
 public void DoubleTest()
 {
     Assert.AreNotEqual(Rnd.Double(), Rnd.Double());
     Assert.AreEqual(1, Rnd.Double(1, 1));
 }