예제 #1
0
 public OutputData(string name, string motto, Colors color, string image, Fans fans, Players players)
 {
     this.Name    = name;
     this.Motto   = motto;
     this.color   = color;
     this.Image   = image;
     this.Fans    = fans;
     this.Players = players;
 }
예제 #2
0
        /*erstellen einer zufälligen aber validen Team-config*/
        public OutputData RandomTeamComposition()
        {
            Random random = new Random();

            TrikotColor[0] = Color.FromArgb(255, random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
            TrikotColor[1] = Color.FromArgb(255, 255 - TrikotColor[0].R, 255 - TrikotColor[0].G, 255 - TrikotColor[0].B);
            Colors colors = new Colors(TrikotColor[0], TrikotColor[1]);
            Image  image  = Logos[random.Next(0, Logos.Count)];

            int[] fans = new int[] { 1, 1, 1, 1 };

            for (int x = 0; x < 3; x++)
            {
                int ran = random.Next(0, 4);
                fans[ran] = fans[ran] + 1;
            }
            Fans   fan      = new Fans(fans[0], fans[1], fans[2], fans[3]);
            string teamname = Teamname[random.Next(0, Teamname.Count)];
            string motto    = Motto[random.Next(0, Motto.Count)];

            string[] name  = new string[7];
            string[] broom = new string[7];
            string[] sex   = new string[7];

            int offset      = random.Next(0, 10);
            int genderValid = 0;

            for (int x = 0; x < 7; x++)
            {
                int gender = random.Next(0, 2);
                if (genderValid > 1)
                {
                    gender = 1;
                }
                if (genderValid < 1)
                {
                    gender = 0;
                }
                if (gender == 0)
                {
                    genderValid++;
                    name[x]  = MaleNames[random.Next(0, MaleNames.Count)];
                    broom[x] = Brooms[(x + offset) % 5];
                    sex[x]   = "m";
                }
                else
                {
                    genderValid--;
                    name[x]  = FemaleNames[random.Next(0, FemaleNames.Count)];
                    broom[x] = Brooms[(x + offset) % 5];
                    sex[x]   = "f";
                }
            }

            Players pl = new Players(new Data(name, broom, sex));


            Bitmap im = new Bitmap(image, 256, 256);
            string base64;

            using (MemoryStream ms = new MemoryStream())
            {
                im.Save(ms, ImageFormat.Png);
                byte[] imageBytes = ms.ToArray();
                base64 = Convert.ToBase64String(imageBytes);
                ms.Close();
            }

            return(new OutputData(teamname, motto, colors, base64, fan, pl));
        }