Beispiel #1
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();
            }
        }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     textToUpdate      = FindObjectOfType <TextMesh>();
     farmHandlerScript = GameObject.Find("FarmHandler").GetComponent <FarmHandler>();
 }
Beispiel #3
0
 public GameSocket(ISerializer serializer) : base(serializer)
 {
     _achievementHandler       = new AchievementHandler(this);
     _activityHandler          = new ActivityHandler(this);
     _activityFavorHandler     = new ActivityFavorHandler(this);
     _amuletHandler            = new AmuletHandler(this);
     _arenaHandler             = new ArenaHandler(this);
     _attendanceHandler        = new AttendanceHandler(this);
     _bagHandler               = new BagHandler(this);
     _battleHandler            = new BattleHandler(this);
     _cardHandler              = new CardHandler(this);
     _consignmentLineHandler   = new ConsignmentLineHandler(this);
     _crossServerHandler       = new CrossServerHandler(this);
     _dailyActivityHandler     = new DailyActivityHandler(this);
     _demonTowerHandler        = new DemonTowerHandler(this);
     _equipHandler             = new EquipHandler(this);
     _exchangeHandler          = new ExchangeHandler(this);
     _fashionHandler           = new FashionHandler(this);
     _fightLevelHandler        = new FightLevelHandler(this);
     _fleeHandler              = new FleeHandler(this);
     _friendHandler            = new FriendHandler(this);
     _functionHandler          = new FunctionHandler(this);
     _functionOpenHandler      = new FunctionOpenHandler(this);
     _giftOnlineHandler        = new GiftOnlineHandler(this);
     _goddessHandler           = new GoddessHandler(this);
     _guildBlessHandler        = new GuildBlessHandler(this);
     _guildBossHandler         = new GuildBossHandler(this);
     _guildDepotHandler        = new GuildDepotHandler(this);
     _guildHandler             = new GuildHandler(this);
     _guildShopHandler         = new GuildShopHandler(this);
     _guildTechHandler         = new GuildTechHandler(this);
     _hookSetHandler           = new HookSetHandler(this);
     _interactHandler          = new InteractHandler(this);
     _intergalMallHandler      = new IntergalMallHandler(this);
     _itemHandler              = new ItemHandler(this);
     _leaderBoardHandler       = new LeaderBoardHandler(this);
     _limitTimeActivityHandler = new LimitTimeActivityHandler(this);
     _mailHandler              = new MailHandler(this);
     _mapHandler               = new MapHandler(this);
     _masteryHandler           = new MasteryHandler(this);
     _medalHandler             = new MedalHandler(this);
     _messageHandler           = new MessageHandler(this);
     _mountHandler             = new MountHandler(this);
     _npcHandler               = new NpcHandler(this);
     _offlineAwardHandler      = new OfflineAwardHandler(this);
     _onlineGiftHandler        = new OnlineGiftHandler(this);
     _payGiftHandler           = new PayGiftHandler(this);
     _petHandler               = new PetHandler(this);
     _petNewHandler            = new PetNewHandler(this);
     _playerHandler            = new PlayerHandler(this);
     _prepaidHandler           = new PrepaidHandler(this);
     _rankHandler              = new RankHandler(this);
     _resourceDungeonHandler   = new ResourceDungeonHandler(this);
     _resourceHandler          = new ResourceHandler(this);
     _rewardHandler            = new RewardHandler(this);
     _saleHandler              = new SaleHandler(this);
     _shopMallHandler          = new ShopMallHandler(this);
     _skillHandler             = new SkillHandler(this);
     _skillKeysHandler         = new SkillKeysHandler(this);
     _soloHandler              = new SoloHandler(this);
     _stealHandler             = new StealHandler(this);
     _sysSetHandler            = new SysSetHandler(this);
     _taskHandler              = new TaskHandler(this);
     _teamHandler              = new TeamHandler(this);
     _tradeHandler             = new TradeHandler(this);
     _treasureHandler          = new TreasureHandler(this);
     _upLevelHandler           = new UpLevelHandler(this);
     _vipHandler               = new VipHandler(this);
     _vitalityHandler          = new VitalityHandler(this);
     _wingHandler              = new WingHandler(this);
     _activityRevelryHandler   = new ActivityRevelryHandler(this);
     _auctionHandler           = new AuctionHandler(this);
     _chatHandler              = new ChatHandler(this);
     _daoYouHandler            = new DaoYouHandler(this);
     _entryHandler             = new EntryHandler(this);
     _roleHandler              = new RoleHandler(this);
     _farmHandler              = new FarmHandler(this);
     _five2FiveHandler         = new Five2FiveHandler(this);
     _guildManagerHandler      = new GuildManagerHandler(this);
     _xianYuanHandler          = new XianYuanHandler(this);
 }