Example #1
0
        /// <summary>
        /// Method used to handle the request from the client.
        /// </summary>
        /// <param name="request">The request from the client. Must be CSV and atleast two values.</param>
        /// <returns>Returns the response to the client</returns>
        private string Handle(string request)
        {
            var    splittedRequest = request.Split(',');
            string response        = "";

            if (VerifyRequest(splittedRequest))
            {
                StatisticHandler SH = new StatisticHandler();
                switch (int.Parse(splittedRequest[0]))
                {
                case 1:
                    //Do some calls to the logic
                    response = SH.GetAllAcceptedReservations().ToString();
                    break;

                case 2:
                    //Do some calls to the logic
                    //Dummy code
                    response = "Not implemented.";
                    break;

                default:
                    response = "Error, wrong method call";
                    break;
                }
                return(response);
            }
            return($"'{splittedRequest[0]}' is not a correct input.");
        }
Example #2
0
        public List <SPair> HandleStatistics()
        {
            List <SPair> pairs = new List <SPair>();

            foreach (Statistic statistic in m_statistics)
            {
                pairs.Add(StatisticHandler.Average(statistic));
            }

            return(pairs);
        }
 public Controller()
 {
     NewBooking        = new Booking();
     _BookingRepo      = BookingRepository.GetInstance();
     NewMember         = new Member();
     CalendarDates     = Calendar.GetInstance();
     Shift             = new Shift();
     Instructor        = new Instructor();
     _StatisticHandler = StatisticHandler.GetInstance();
     StatisticRepoUpdate();
     IntitialRepoUpdate();
     _StatisticHandler.AddToExcellFromStatisticRepo();
 }
Example #4
0
        public ActionResult StatisticsBuyLike(string orderBy1 = "", string orderBy2 = "", string orderBy3 = "", string tab = "f1", string count = "10")//async
        {
            IEnumerable <StatisticsBuyLike> buyLikes = new StatisticHandler().GetStatisticBuyLikes(User.Identity.GetUserId(), orderBy1, orderBy2, orderBy3, tab, count);

            //если есть упорядочивание

            switch (tab)
            {
            case "f2":
                switch (orderBy1)
                {
                case "По дате":
                    ViewBag.th2 = "Дата"; ViewBag.th3 = "Кол-во скачиваний"; ViewBag.th4 = "Скачано на сумму"; ViewBag.th5 = "Последнее из них:"; ViewBag.count = 3;
                    break;

                case "По e-mail":
                    ViewBag.th2 = "E-mail"; ViewBag.th3 = "Количество картинок"; ViewBag.th4 = "Кол-во скачиваний"; ViewBag.th5 = "Дата посл. покупки"; ViewBag.count = 5;
                    break;

                default:
                    ViewBag.th2 = "Категория"; ViewBag.th3 = "Стоимость"; ViewBag.th4 = "Кол-во скачиваний"; ViewBag.th5 = "Дата посл. покупки"; ViewBag.count = 5;
                    break;
                }
                break;

            case "f3":
                switch (orderBy3)
                {
                case "По ID картинки":
                    ViewBag.th2 = "Категория"; ViewBag.th3 = "Кол-во лайков"; ViewBag.th4 = "Дата посл.лайка"; ViewBag.count = 4;
                    break;

                case "По категориям":
                    ViewBag.th2 = "Категория"; ViewBag.th3 = "Кол-во лайков"; ViewBag.th4 = "Дата посл.лайка"; ViewBag.count = 4;
                    break;

                default:
                    ViewBag.th2 = "Категория"; ViewBag.th3 = "Дата лайка"; ViewBag.count = 2;
                    break;
                }
                break;

            default:
                ViewBag.count = 5; ViewBag.th2 = "Размер"; ViewBag.th3 = "E-mail"; ViewBag.th4 = "Стоимость"; ViewBag.th5 = "Дата покупки";
                break;
            }

            return(PartialView(buyLikes));
        }
Example #5
0
    public void RPCPawnDead(int viewId)
    {
        if (!photonView.isMine)
        {
            return;
        }
        Score.Death++;
        if (viewId != 0)
        {
            Player killer = PhotonView.Find(viewId).GetComponent <Player> ();

            StatisticHandler.SendPlayerKillbyPlayer(UID, PlayerName, killer.UID, killer.PlayerName);
        }
        else
        {
            StatisticHandler.SendPlayerKillbyNPC(UID, PlayerName);
        }
    }
Example #6
0
        public async Task Fight(SocketGuildUser user)
        {
            await Context.Message.DeleteAsync();

            UserAccount authorAccount     = UserManager.GetAccount(Context.Message.Author);
            UserAccount socketUserAccount = UserManager.GetAccount(user);

            authorAccount.BattleStatistics.PvpStatistics.PvPChallengesRequests++;

            //get player properties too check for current health if health bool from any player lower then 0 create a message
            float player1Health  = authorAccount.BattleStatistics.CurrentHealth;
            float player1Defense = authorAccount.BattleStatistics.Defense;
            float player1Damage  = authorAccount.BattleStatistics.Damage;
            bool  player1IsDead  = authorAccount.BattleStatistics.IsDead;

            float player2Health  = socketUserAccount.BattleStatistics.CurrentHealth;
            float player2Defense = socketUserAccount.BattleStatistics.Defense;
            float player2Damage  = socketUserAccount.BattleStatistics.Damage;
            bool  player2IsDead  = socketUserAccount.BattleStatistics.IsDead;

            //check player`s CurrentHealth
            if (!player1IsDead)
            {
                if (!player2IsDead)
                {
                    //if player health >0 create a DM Message channel
                    var channel = await user.GetOrCreateDMChannelAsync();

                    await channel.SendMessageAsync($"{Context.Message.Author} want to fight with you!Do you want to accept the challenge?");

                    await Task.Delay(5000);

                    var messages = await channel.GetMessagesAsync(1).FlattenAsync();

                    uint messageCount = 1;
                    foreach (var message in messages)
                    {
                        if (message.Content.Equals("yes"))
                        {
                            authorAccount.BattleStatistics.PvpStatistics.PvPBattlesFought++;
                            socketUserAccount.BattleStatistics.PvpStatistics.PvPBattlesFought++;
                            socketUserAccount.BattleStatistics.PvpStatistics.PvPBattlesAccepted++;
                            await ReplyAsync("Battle was accepted");

                            await channel.SendMessageAsync("Battle was accepted");

                            bool authorIsWinner  = true;
                            bool isFighting      = true;
                            bool leveledUp       = false;
                            bool isNewKillstreak = false;
                            bool isNewWinStreak  = false;


                            //StartFight();
                            await ReplyAsync("Battle Beginns");

                            messageCount++;
                            await channel.SendMessageAsync("Battle Beginns");

                            do
                            {
                                await Task.Delay(3000);

                                player1Health -= player2Damage - player1Defense;
                                if (player1Health <= 0)
                                {
                                    await ReplyAsync("You died!");

                                    messageCount++;
                                    isFighting     = false;
                                    authorIsWinner = false;
                                    continue;
                                }

                                player2Health -= player1Damage - player2Defense;
                                await ReplyAsync($"{authorAccount}´s current Health is {player1Health}!");
                                await ReplyAsync($"{socketUserAccount}´s current Health is {player2Health}!");

                                messageCount += 2;
                                isFighting    = !(player1Health <= 0 || player2Health <= 0);
                            } while (isFighting);

                            if (authorIsWinner)
                            {
                                await ReplyAsync("You won this Fight");

                                messageCount++;
                                await channel.SendMessageAsync("You lost this Fight sorry!");

                                authorAccount.BattleStatistics.PvpStatistics.AmountOfPlayersKilled++;
                                authorAccount.BattleStatistics.PvpStatistics.PvPBattlesWon++;
                                socketUserAccount.BattleStatistics.PvpStatistics.PvPBattlesLost++;
                                socketUserAccount.BattleStatistics.PvpStatistics.CurrentPvpWinStreak  = 0;
                                socketUserAccount.BattleStatistics.PvpStatistics.CurrentPvpKillStreak = 0;

                                uint oldLevel = authorAccount.BattleStatistics.Level;
                                authorAccount.BattleStatistics.Xp += 50;
                                uint newLevel = authorAccount.BattleStatistics.Level;

                                var levelResult = await StatisticHandler.CheckForLevelUp(oldLevel, newLevel, Context, authorAccount, messageCount);

                                leveledUp    = levelResult.leveledUp;
                                messageCount = levelResult.messageCount;

                                uint currentPlayerKillStreak = authorAccount.BattleStatistics.PvpStatistics.CurrentPvpKillStreak;
                                authorAccount.BattleStatistics.PvpStatistics.CurrentPvpKillStreak++;
                                uint highestPlayerKillStreak = authorAccount.BattleStatistics.PvpStatistics.HighestPvpKillStreak;
                                isNewKillstreak = await StatisticHandler.CheckForPlayerKills(currentPlayerKillStreak, highestPlayerKillStreak, Context, authorAccount);

                                if (isNewKillstreak)
                                {
                                    messageCount++;
                                }

                                uint currentWinStreak = authorAccount.BattleStatistics.PvpStatistics.CurrentPvpWinStreak;
                                authorAccount.BattleStatistics.PvpStatistics.CurrentPvpWinStreak++;
                                uint highestWinStreak = authorAccount.BattleStatistics.PvpStatistics.HighestPvpWinStreak;
                                isNewWinStreak = await StatisticHandler.CheckForPvpWinstreak(currentWinStreak, highestWinStreak, Context, authorAccount);

                                if (isNewWinStreak)
                                {
                                    messageCount++;
                                }
                            }
                            else
                            {
                                await channel.SendMessageAsync("You won this Fight!");
                                await ReplyAsync("You lost Sorry!");

                                messageCount++;

                                socketUserAccount.BattleStatistics.PvpStatistics.AmountOfPlayersKilled++;
                                socketUserAccount.BattleStatistics.PvpStatistics.PvPBattlesWon++;
                                authorAccount.BattleStatistics.PvpStatistics.PvPBattlesLost++;
                                authorAccount.BattleStatistics.PvpStatistics.CurrentPvpWinStreak  = 0;
                                authorAccount.BattleStatistics.PvpStatistics.CurrentPvpKillStreak = 0;

                                uint oldLevel = socketUserAccount.BattleStatistics.Level;
                                socketUserAccount.BattleStatistics.Xp += 50;
                                uint newLevel = socketUserAccount.BattleStatistics.Level;

                                var levelResult = await StatisticHandler.CheckForLevelUp(oldLevel, newLevel, Context, authorAccount, messageCount);

                                leveledUp    = levelResult.leveledUp;
                                messageCount = levelResult.messageCount;

                                uint currentPlayerKillStreak = socketUserAccount.BattleStatistics.PvpStatistics.CurrentPvpKillStreak;
                                socketUserAccount.BattleStatistics.PvpStatistics.CurrentPvpKillStreak++;
                                uint highestPlayerKillStreak = socketUserAccount.BattleStatistics.PvpStatistics.HighestPvpKillStreak;
                                isNewKillstreak = await StatisticHandler.CheckForCreepKillStreak(currentPlayerKillStreak, highestPlayerKillStreak, Context, socketUserAccount);

                                if (isNewKillstreak)
                                {
                                    messageCount++;
                                }

                                uint currentWinStreak = socketUserAccount.BattleStatistics.PvpStatistics.CurrentPvpWinStreak;
                                socketUserAccount.BattleStatistics.PvpStatistics.CurrentPvpWinStreak++;
                                uint highestWinStreak = socketUserAccount.BattleStatistics.PvpStatistics.HighestPvpWinStreak;
                                isNewWinStreak = await StatisticHandler.CheckForPvpWinstreak(currentWinStreak, highestWinStreak, Context, socketUserAccount);

                                if (isNewWinStreak)
                                {
                                    messageCount++;
                                }
                            }

                            UserManager.SaveAccounts();
                            var message1 = await Context.Channel.GetMessagesAsync((int)messageCount).FlattenAsync();

                            var messageList = message1.ToList();
                            if (leveledUp)
                            {
                                messageList.RemoveAt(0);
                            }
                            foreach (var text in messageList)
                            {
                                await Task.Delay(60000);

                                await text.DeleteAsync();
                            }
                        }
                        else
                        {
                            var botMsg = await ReplyAsync("Battle was declined");

                            await Task.Delay(30000);

                            await botMsg.DeleteAsync();

                            await channel.SendMessageAsync("Battle was declined");

                            socketUserAccount.BattleStatistics.PvpStatistics.PvPBattlesDeclined++;
                            UserManager.SaveAccounts();
                        }
                    }
                }
                else
                {
                    var botMsg = await ReplyAsync("player is not alive yet!!");

                    await Task.Delay(30000);

                    await botMsg.DeleteAsync();
                }
            }
            else
            {
                var botMsg = await ReplyAsync("You are not alive!!");

                await Task.Delay(30000);

                await botMsg.DeleteAsync();
            }
        }
Example #7
0
 public void  SetUid(string uid)
 {
     UID = uid;
     Debug.Log("BIG STATS SEND " + UID + " " + PlayerName);
     StatisticHandler.StartStats(UID, PlayerName);
 }
Example #8
0
        public async Task Battle()
        {
            await Context.Message.DeleteAsync();

            uint messageCount = 1;
            bool leveledUp    = false;

            //Getting Playerstats and creating creeps
            UserAccount account = UserManager.GetAccount(Context.Message.Author);

            if (account.BattleStatistics.IsDead)
            {
                await Context.Channel.SendMessageAsync($"you are dead!");

                messageCount++;
            }
            else
            {
                //Getting a list of enemies form the EnemyUtilites class with the level of the user
                List <IEnemy> enemies = SpawnHandler.SpawnEnemies(account.BattleStatistics.Level, account.BattleStatistics.Damage, false);

                var embed = new EmbedBuilder();
                embed.WithColor(Color.Blue)
                .WithTitle("Creepwave Statistics");

                if (enemies.Count == 1)
                {
                    embed.AddField("CreepCount", $"A Wild {enemies[0].Name} appeared!");
                }
                else
                {
                    embed.AddField("Creepwave", "-");
                    for (int i = 0; i < enemies.Count; i++)
                    {
                        embed.AddField($"{enemies[i].Name}", $"{enemies[i].GettingGold} Gold, {enemies[i].GettingXp} XP", true);
                    }
                }
                var builtEmbed = embed.Build();

                await ReplyAsync(embed : builtEmbed);


                var fightResult = await FarmHandler.SimulateFight(enemies, account, Context.Channel, messageCount);

                bool isWinner = fightResult.isWinner;
                messageCount = fightResult.messageCount;

                bool isNewCreepWinStreak;
                bool isNewHighestCreepKillStreak;

                //Adding Xp and Rewards (?)
                if (isWinner)
                {
                    await ReplyAsync($"{account.Name} Won this Fight and earned 20 XP for it!");

                    messageCount++;

                    //Increase properties
                    account.BattleStatistics.CreepStatistics.CreepBattlesWon++;
                    account.BattleStatistics.CreepStatistics.CurrentCreepWinStreak++;

                    //Check for creep winstreak
                    uint currentCreepWinStreak = account.BattleStatistics.CreepStatistics.CurrentCreepWinStreak;
                    uint highestCreepWinStreak = account.BattleStatistics.CreepStatistics.HighestCreepWinStreak;
                    isNewCreepWinStreak = await StatisticHandler.CheckForCreepWinstreak(currentCreepWinStreak, highestCreepWinStreak, Context, account);

                    if (isNewCreepWinStreak)
                    {
                        messageCount++;
                    }

                    //Check for highest creep kills
                    uint currentCreepKills = account.BattleStatistics.CreepStatistics.CurrentCreepKillStreak;
                    uint highestCreepKills = account.BattleStatistics.CreepStatistics.HighestCreepKillStreak;
                    isNewHighestCreepKillStreak = await StatisticHandler.CheckForCreepKillStreak(currentCreepKills, highestCreepKills, Context, account);

                    if (isNewHighestCreepKillStreak)
                    {
                        messageCount++;
                    }

                    //Levelup check
                    uint oldLevel = account.BattleStatistics.Level;
                    account.BattleStatistics.Xp += 20;
                    uint newLevel = account.BattleStatistics.Level;

                    var levelResult = await StatisticHandler.CheckForLevelUp(oldLevel, newLevel, Context, account, messageCount);

                    leveledUp    = levelResult.leveledUp;
                    messageCount = await ItemHandler.CheckForItemDrop(account, Context, messageCount);

                    if (leveledUp)
                    {
                        messageCount++;
                    }
                }
                else
                {
                    await ReplyAsync("Good luck next time.");

                    messageCount++;
                    account.BattleStatistics.CreepStatistics.CreepBattlesLost++;
                    account.BattleStatistics.CreepStatistics.CurrentCreepKillStreak = 0;
                    account.BattleStatistics.CreepStatistics.CurrentCreepWinStreak  = 0;
                }

                account.BattleStatistics.CreepStatistics.CreepBattlesFought++;
                UserManager.SaveAccounts();
                StatisticHandler.RewriteHighscores();
            }

            await Task.Delay(1000);

            var messages = await Context.Channel.GetMessagesAsync((int)messageCount).FlattenAsync();

            var messageList = messages.ToList();

            if (leveledUp)
            {
                messageList.RemoveAt(0);
            }
            foreach (var message in messageList)
            {
                await message.DeleteAsync();
            }
        }
Example #9
0
        public ActionResult StatisticsDownloaders()//async
        {
            StatisticsDownloaders statisticsDownloaders = new StatisticHandler().GetStatisticDownloaders(User.Identity.GetUserId());

            return(PartialView(statisticsDownloaders));
        }