Example #1
0
        public async Task MemberRandom(Context ctx)
        {
            ctx.CheckSystem();

            var randGen = new global::System.Random();
            //Maybe move this somewhere else in the file structure since it doesn't need to get created at every command

            // TODO: don't buffer these, find something else to do ig

            var members = await _db.Execute(c =>
            {
                if (ctx.MatchFlag("all", "a"))
                {
                    return(_repo.GetSystemMembers(c, ctx.System.Id));
                }
                return(_repo.GetSystemMembers(c, ctx.System.Id)
                       .Where(m => m.MemberVisibility == PrivacyLevel.Public));
            }).ToListAsync();

            if (members == null || !members.Any())
            {
                throw Errors.NoMembersError;
            }
            var randInt = randGen.Next(members.Count);
            await ctx.Reply(embed : await _embeds.CreateMemberEmbed(ctx.System, members[randInt], ctx.Guild, ctx.LookupContextFor(ctx.System)));
        }
Example #2
0
            internal static void TestCorrectness()
            {
                global::System.Random rand = new global::System.Random();

                int[]  a      = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
                Select rs     = new Select();
                int    select = a[0];

                for (int i = 1; i < a.Length; ++i)
                {
                    if (rs.isSelected(rand.Next()))
                    {
                        select = a[i];
                    }
                }
                Console.WriteLine(select);

                rs.reset(0);
                select = -1;
                for (int i = 0; i < a.Length; ++i)
                {
                    if (rs.isSelected(rand.Next()))
                    {
                        select = a[i];
                    }
                }
                Console.WriteLine(select);
            }
Example #3
0
 /// <summary>Returns a random Vector3</summary>
 /// <param name="random">System.Random instance</param>
 /// <returns>The random Vector3</returns>
 public static Vector3D NextVector3(this global::System.Random random)
 {
     return(new Vector3D(
                (random.Next() - random.Next()) * (float)random.NextDouble(),
                (random.Next() - random.Next()) * (float)random.NextDouble(),
                (random.Next() - random.Next()) * (float)random.NextDouble()));
 }
Example #4
0
 protected override string ProcessChange()
 {
     if (TemplateNode.Name.ToLower() == "random")
     {
         if (TemplateNode.HasChildNodes)
         {
             // only grab <li> nodes
             List <XmlNode> listNodes = new List <XmlNode>();
             foreach (XmlNode childNode in TemplateNode.ChildNodes)
             {
                 if (childNode.Name == "li")
                 {
                     listNodes.Add(childNode);
                 }
             }
             if (listNodes.Count > 0)
             {
                 global::System.Random r = new global::System.Random();
                 XmlNode chosenNode      = listNodes[r.Next(listNodes.Count)];
                 return(chosenNode.InnerXml);
             }
         }
     }
     return(string.Empty);
 }
Example #5
0
 /// <summary>
 /// リストの要素をランダムに並び替える
 /// </summary>
 public static void Shuffle <T>(this Original.IList <T> list, Random random = null)
 {
     for (int indexA = 0; indexA < list.Count; ++indexA)
     {
         int indexB = list.RandomIndex(random);
         list.Swap(indexA, indexB);
     }
 }
Example #6
0
        public void OneOf()
        {
            var @this = new global::System.Random();

            var value1 = @this.OneOf(1, 2, 3, 4);
            var value2 = @this.OneOf("a", "b", "c", "d");
            var value3 = @this.OneOf(1, "a", global::System.DateTime.Now, new object());
        }
Example #7
0
 internal global::SWA.Ariadne.Gui.Mazes.ContourImage LoadImage(string imagePath, global::System.Random r)
 {
     object[] args = new object[] {
         imagePath,
         r};
     global::SWA.Ariadne.Gui.Mazes.ContourImage ret = ((global::SWA.Ariadne.Gui.Mazes.ContourImage)(m_privateObject.Invoke("LoadImage", new System.Type[] {
             typeof(string),
             typeof(global::System.Random)}, args)));
     return ret;
 }
Example #8
0
 internal System.Collections.Generic.List<string> FindImages(string folderPath, int count, bool quickSearch, global::System.Random r)
 {
     object[] args = new object[] {
         folderPath,
         count,
         quickSearch,
         r};
     System.Collections.Generic.List<string> ret = ((System.Collections.Generic.List<string>)(m_privateObject.Invoke("FindImages", new System.Type[] {
             typeof(string),
             typeof(int),
             typeof(bool),
             typeof(global::System.Random)}, args)));
     return ret;
 }
Example #9
0
public void @this(int n1){
//XMLVM_BEGIN_WRAPPER[Compatlib.System.Random: void <init>(int)]
    random = new global::System.Random(n1);
//XMLVM_END_WRAPPER[Compatlib.System.Random: void <init>(int)]
}
Example #10
0
 public void Reset(int seed)
 {
     random = new System.Random(seed);
 }
Example #11
0
        public void @this(int n1)
        {
//XMLVM_BEGIN_WRAPPER[Compatlib.System.Random: void <init>(int)]
            random = new global::System.Random(n1);
//XMLVM_END_WRAPPER[Compatlib.System.Random: void <init>(int)]
        }
Example #12
0
 /// <summary>
 /// Creates a generator with initial seed.
 /// </summary>
 /// <param name="seed"></param>
 public NativeGenerator(int seed)
 {
     random = new System.Random(seed);
 }
Example #13
0
 /// <summary>
 /// Creates a generator with automatic (time based) seed.
 /// </summary>
 public NativeGenerator()
 {
     random = new System.Random();
 }
Example #14
0
 /// <summary>
 /// ランダムなindexを返します。
 /// </summary>
 public static int RandomIndex <T>(this Original.IList <T> list, Random random)
 {
     return(random.Next(list.Count));
 }
Example #15
0
        /// <summary>
        /// ランダムな位置の項目を削除し、削除された項目を返します。
        /// </summary>
        public static T PopRandom <T>(this Original.IList <T> list, Random random = null)
        {
            var index = list.RandomIndex(random);

            return(list.Pop(index));
        }
Example #16
0
 public void Reset()
 {
     random = new System.Random();
 }
        public void CoinToss()
        {
            var @this = new global::System.Random();

            var value = @this.CoinToss();
        }
Example #18
0
            internal static void TestCorrectness() {
                global::System.Random rand = new global::System.Random();

                int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
                Select rs = new Select();
                int select = a[0];

                for (int i = 1; i < a.Length; ++i) {
                    if (rs.isSelected(rand.Next())) { select = a[i]; }
                }
                Console.WriteLine(select);

                rs.reset(0);
                select = -1;
                for (int i = 0; i < a.Length; ++i) {
                    if (rs.isSelected(rand.Next())) { select = a[i]; }
                }
                Console.WriteLine(select);
            }