Example #1
0
        private static void PrintAccountInfo(account account)
        {
            Console.WriteLine("Account name: " + account.DisplayName + "\n");
            Console.WriteLine(" Account Email: " + account.Email);
            Console.WriteLine(" User Full Name: " + account.Firstname + " " + account.LastName);

            Console.WriteLine(" Friends: " + account.friendship.Count + "\n");

            account.friendship.ToList().ForEach(f => Console.WriteLine("    *" + f.account1.DisplayName));

            Console.WriteLine("________________________________________________\n");

            PrintTrainersInfo(account);


            Console.WriteLine("________________________________________________\n");
        }
Example #2
0
        private static void PrintTrainersInfo(account account)
        {
            Console.WriteLine(account.DisplayName + " has " + account.trainer.Count + " trainer(s)...\n");

            foreach (var trainer in account.trainer.ToList())
            {
                Console.WriteLine(" Trainer name: " + trainer.TrainerName + "\n");

                int battlesTotal = trainer.trainer_battle.Count + trainer.trainer_battle1.Count;
                int battlesWon   = trainer.trainer_battle2.Count();
                int battlesLost  =
                    (trainer.trainer_battle.Where(b => b.trainer2 != trainer).Count() +
                     trainer.trainer_battle1.Where(b => b.trainer2 != trainer).Count());

                Console.WriteLine(" Total Battles: " + battlesTotal + "\n");
                Console.WriteLine(" Battles Won: " + battlesWon + "\n");
                Console.WriteLine(" Battles Lost: " + battlesLost + "\n");

                Console.WriteLine("     Creatures Caught: " + trainer.caughtcreature.ToList().Count + "\n");

                PrintCreaturesInfo(trainer);
            }
        }
Example #3
0
        public static void MakeRandomWhispers(int amount)
        {
            using (creaturesEntities db = new creaturesEntities())
            {
                for (int i = 0; i < amount; i++)
                {
                    account from = db.account.ToList()[rnd.Next(db.account.Count())];
                    account to;
                    while (true)
                    {
                        to = db.account.ToList()[rnd.Next(db.account.Count())];

                        if (to != null && to.AccountID != from.AccountID)
                        {
                            break;
                        }
                    }

                    whisper w = new entityFrameworkMariaDB.whisper()
                    {
                        FromId    = from.AccountID,
                        ToId      = to.AccountID,
                        Text      = whisper[rnd.Next(whisper.Length)],
                        TimeStamp = DateTime.Now
                    };
                    db.whisper.Add(w);

                    db.SaveChanges();

                    Console.WriteLine(w.FromId);
                    Console.WriteLine(w.ToId);
                    Console.WriteLine(w.Text);

                    System.Threading.Thread.Sleep(rnd.Next(2000));
                }
            }
        }
Example #4
0
        public static void GenerateFriendships(int idGraterthan)
        {
            using (creaturesEntities db = new creaturesEntities())
            {
                List <account> accounts = db.account.Where(x => x.AccountID > idGraterthan).ToList();

                foreach (account account in accounts)
                {
                    int amountOfFriends = rnd.Next(0, 10);

                    for (int i = 0; i < amountOfFriends; i++)
                    {
                        while (true)
                        {
                            account rndAcount = db.account.ToList()[rnd.Next(db.account.Count())];


                            if (rndAcount.AccountID == account.AccountID)
                            {
                                continue;
                            }

                            if (db.friendship.Find(account.AccountID, rndAcount.AccountID) != null)
                            {
                                continue;
                            }
                            if (db.friendship.Find(rndAcount.AccountID, account.AccountID) != null)
                            {
                                continue;
                            }

                            /*
                             * {
                             *  foreach (friendship friendship in account.friendship)
                             *  {
                             *      if (friendship.account1.AccountID == rndAcount.AccountID)
                             *      {
                             *          //friendship exists
                             *          success = false;
                             *          break;
                             *      }
                             *
                             *      foreach (friendship otherfriendship in rndAcount.friendship)
                             *      {
                             *          if (otherfriendship.account1.AccountID == account.AccountID)
                             *          {
                             *              success = false;
                             *
                             *          }
                             *      }
                             *
                             *  }
                             *
                             * }
                             */


                            if (account.AccountID == rndAcount.AccountID)
                            {
                                break;
                            }

                            db.friendship.Add(new friendship()
                            {
                                AccountId = account.AccountID,
                                FriendId  = rndAcount.AccountID,
                                StartDate = DateTime.Today
                            });

                            db.SaveChanges();

                            Console.WriteLine(account.DisplayName + " added " + rndAcount.DisplayName);

                            if (rnd.Next(10) > 1)
                            {
                                db.AcceptFriendRequestProcedure(rndAcount.AccountID, account.AccountID);
                            }
                            break;
                        }
                    }
                }
            }
        }