Exemple #1
0
        public async Task CreateFight(SocketUser enemyUser = null)
        {
            var account = SetupOctopusStats(Context.User.Id);
            var enemy   = SetupOctopusStats(enemyUser?.Id ?? account.CurrentEnemy);


            // tis is a test of logging system. it does work btw
            _loggingSystem.CreateNewLog(account.Id, enemy.DiscordId);
            _loggingSystem.SaveCurrentFightLog(account.Id, enemy.DiscordId);
            _loggingSystem.SaveCompletedFight(account.Id, enemy.DiscordId);

            if (account.PlayingStatus >= 1)
            {
                //  await ReplyAsync("you are already playing");
                // return;
            }

            if (account.Attack_Tree == null && account.Defensive_Tree == null &&
                account.Agility_Tree == null && account.Magic_Tree == null)
            {
                await SendMessAsync("You dont have any moves. You can get them using **boole** command");

                return;
            }

            if (account.OctoInfo != null)
            {
                account.PlayingStatus = 1;
                _accounts.SaveAccounts(Context.User);

                var embed = new EmbedBuilder();
                embed.WithAuthor(Context.User);
                embed.WithFooter("Enemy choice");
                embed.WithColor(Color.DarkGreen);
                embed.AddField("Choose enemy lvl : ",
                               $"{new Emoji("1⃣")} Enemy {account.OctoLvL - 1} LvL\n" +
                               $"{new Emoji("2⃣")} Enemy {account.OctoLvL} LvL\n" +
                               $"{new Emoji("3⃣")} Enemy {account.OctoLvL + 1} LvL\n" +
                               $"{new Emoji("❌")} - End Fight.");


                var message = await Context.Channel.SendMessageAsync("", false, embed.Build());

                await message.AddReactionAsync(new Emoji("1⃣"));

                await message.AddReactionAsync(new Emoji("2⃣"));

                await message.AddReactionAsync(new Emoji("3⃣"));

                await message.AddReactionAsync(new Emoji("❌"));

                var newOctoGame = _global.CreateNewGame(message, null, Context.User, null);

                foreach (var c in  _global.OctopusGameMessIdList)
                {
                    if (c.Any(x => x.PlayerDiscordAccount.Id == Context.User.Id || x.PlayerDiscordAccount.Id == enemy.DiscordId))
                    {
                        _global.OctopusGameMessIdList.Remove(c);
                        break;
                    }
                }

                _global.OctopusGameMessIdList.Add(newOctoGame);
                _global.OctoGamePlaying += 1;
                account.PlayingStatus    = 1;
                account.MessageIdInList  = _global.OctopusGameMessIdList.Count - 1;


                //twice for a reason
                await _gameFramework.CheckForPassivesAndUpdateStats(account, enemy);

                await _gameFramework.CheckForPassivesAndUpdateStats(enemy, account);

                await _gameFramework.CheckForPassivesAndUpdateStats(account, enemy);

                await _gameFramework.CheckForPassivesAndUpdateStats(enemy, account);

                _accounts.SaveAccounts(Context.User);
            }
            else
            {
                await SendMessAsync("У тебя нет осьминога! создай его командой **CreateOcto**");
            }

            _accounts.SaveAccounts(Context.User);
            if (enemyUser != null)
            {
                _accounts.SaveAccounts(enemyUser.Id);
            }
        }