public async Task ReactionAddedForOctoGameAsync(Cacheable <IUserMessage, ulong> cash, ISocketMessageChannel channel, SocketReaction reaction) { for (var i = 0; i < _global.OctopusGameMessIdList.Count; i++) { if (!_global.OctopusGameMessIdList[i].Any(x => x.PlayerDiscordAccount.Id == reaction.UserId && x.GamingWindowFromBot.Id == reaction.MessageId)) { continue; } var globalAccount = _global.Client.GetUser(reaction.UserId); var account = _accounts.GetAccount(globalAccount); var enemy = _accounts.GetAccount(account.CurrentEnemy); switch (reaction.Emote.Name) { case "🐙": await _gameFramework.UpdateTurn(account, enemy); break; case "⬅": await _octoGameUpdateMess.SkillPageLeft(reaction, reaction.Message.Value); break; case "➡": await _octoGameUpdateMess.SkillPageRight(reaction, reaction.Message.Value); break; case "📖": // await _octoGameUpdateMess.OctoGameLogs(reaction, // _global.OctopusGameMessIdList[i].bot_gaming_msg_1); account.MoveListPage = 5; await _octoGameUpdateMess.MainPage(reaction.UserId, reaction.Message.Value); break; case "❌": if (await _awaitForUserMessage.FinishTheGame(reaction)) { await _octoGameUpdateMess.EndGame(reaction, reaction.Message.Value); } break; case "1⃣": { if (account.PlayingStatus == 1) { await _octoGameUpdateMess.WaitMess(reaction.UserId, reaction.Message.Value); break; } if (account.PlayingStatus == 2) { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); } break; } case "2⃣": { if (account.PlayingStatus == 1) { await _octoGameUpdateMess.WaitMess(reaction.UserId, reaction.Message.Value); break; } if (account.PlayingStatus == 2) { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); } break; } case "3⃣": { if (account.PlayingStatus == 1) { await _octoGameUpdateMess.WaitMess(reaction.UserId, reaction.Message.Value); break; } if (account.PlayingStatus == 2) { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); } break; } case "4⃣": { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); break; } case "5⃣": { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); break; } case "6⃣": { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); break; } case "7⃣": { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); break; } case "8⃣": { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); break; } case "9⃣": { await _gameFramework.GetSkillDependingOnMoveList(account, enemy, reaction, i); break; } } } if (!(channel is IDMChannel)) { await reaction.Message.Value.RemoveReactionAsync(reaction.Emote, reaction.User.Value, RequestOptions.Default); } }
public async Task CreateFightV(SocketUser enemyUser) { var account = SetupOctopusStats(Context.User.Id); var enemy = SetupOctopusStats(enemyUser.Id); account.CurrentEnemy = enemyUser.Id; enemy.CurrentEnemy = Context.User.Id; // 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 || enemy.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 : ", $"Who are you?"); var messageToPlayer1 = _client.GetUser(Context.User.Id).GetOrCreateDMChannelAsync().Result.SendMessageAsync("", false, embed.Build()); var messageToPlayer2 = _client.GetUser(enemyUser.Id).GetOrCreateDMChannelAsync().Result.SendMessageAsync("", false, embed.Build()); var newOctoGame = _global.CreateNewGame(messageToPlayer1.Result, messageToPlayer2.Result, Context.User, enemyUser); 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; enemy.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); var someList = new List <ulong> { Context.User.Id, enemyUser.Id }; Parallel.For(0, someList.Count, async i => { if (someList[i] == Context.User.Id) { await _octoGameUpdateMess.WaitMess(Context.User.Id, messageToPlayer1.Result as RestUserMessage); } else { await _octoGameUpdateMess.WaitMess(enemyUser.Id, messageToPlayer2.Result as RestUserMessage); } }); } else { await SendMessAsync("У тебя нет осьминога! создай его командой **CreateOcto**"); } _accounts.SaveAccounts(Context.User); _accounts.SaveAccounts(enemyUser.Id); }