public async Task Attack() { var user = UserHandler.GetUser(Context.User.Id); ContextIds idList = new ContextIds(Context); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.ValidCharacterLocation(idList); } catch (InvalidCharacterStateException) { return; } if (user.Char.Combat == null) { await MessageHandler.SendMessage(idList, $"{user.Mention} aren't in combat right now!"); } else { await CombatHandler.Attack(user.Char.Combat); } }
void choosePlayerAction(CharacterAction action, CombatHandler handler) { switch (action) { case CharacterAction.Attack: handler.Attack(); break; case CharacterAction.Skill: handler.UseSkill(); break; } }
public void RotateCharacterWhenActiveCharacterDefeated() { Character leadCpuCharacter = cpuparty.GetRotatedInCharacter(); Character switchedInPlayerCharacterBeforeDefeat = playerparty.GetRotatedInCharacter(); while (switchedInPlayerCharacterBeforeDefeat.RemainingHealth > 0) { combatHandler.Attack(); } Character switchedInPlayerCharacterAfterDefeat = playerparty.GetRotatedInCharacter(); Assert.True(switchedInPlayerCharacterBeforeDefeat.Fainted == true); Assert.True(switchedInPlayerCharacterAfterDefeat.Name != switchedInPlayerCharacterBeforeDefeat.Name); }
public async Task ReactionReceived(Cacheable <IUserMessage, ulong> cacheMessage, ISocketMessageChannel channel, SocketReaction reaction) { if (reaction.User.Value.IsBot) { return; } var message = await cacheMessage.GetOrDownloadAsync(); var user = UserHandler.GetUser(reaction.UserId); ContextIds idList = new ContextIds() { UserId = reaction.UserId, ChannelId = reaction.Channel.Id, GuildId = 0 }; if (user.ReactionMessages.ContainsKey(message.Id)) { var messageType = user.ReactionMessages[message.Id]; //Attack Screen Main if (messageType == 0) { //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.CharacterInCombat(idList); } catch (InvalidCharacterStateException) { return; } if (reaction.Emote.Name == "⚔") { Console.WriteLine("1"); await MessageHandler.MoveScreen(user.UserId); Console.WriteLine("2"); user.ReactionMessages.Remove(message.Id); Console.WriteLine("3"); } else if (reaction.Emote.Name == "👜") { await MessageHandler.SendDm(user.UserId, "BAG not implemented yet!"); } else if (reaction.Emote.Name == "🔁") { await MessageHandler.SendDm(user.UserId, "SWITCH not implemented yet!"); } else if (reaction.Emote.Name == "🏃") { await MessageHandler.SendDm(user.UserId, "RUN not implemented yet!"); } } //Move Screen else if (messageType == 1) { Console.WriteLine("4"); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.CharacterInCombat(idList); } catch (InvalidCharacterStateException) { return; } if (reaction.Emote.Name == "1\u20E3") { if (user.Char.Combat.ActiveMon.ActiveMoves[0].Name != "None") { user.Char.Combat.SelectedMove = user.Char.Combat.ActiveMon.ActiveMoves[0]; user.ReactionMessages.Remove(message.Id); await CombatHandler.Attack(user.Char.Combat); await MessageHandler.SendDm(user.UserId, $"Selected **{user.Char.Combat.SelectedMove.Name}**!"); } } else if (reaction.Emote.Name == "2\u20E3") { if (user.Char.Combat.ActiveMon.ActiveMoves[1].Name != "None") { user.Char.Combat.SelectedMove = user.Char.Combat.ActiveMon.ActiveMoves[1]; user.ReactionMessages.Remove(message.Id); await CombatHandler.Attack(user.Char.Combat); await MessageHandler.SendDm(user.UserId, $"Selected **{user.Char.Combat.SelectedMove.Name}**!"); } } else if (reaction.Emote.Name == "3\u20E3") { if (user.Char.Combat.ActiveMon.ActiveMoves[2].Name != "None") { user.Char.Combat.SelectedMove = user.Char.Combat.ActiveMon.ActiveMoves[2]; user.ReactionMessages.Remove(message.Id); await CombatHandler.Attack(user.Char.Combat); await MessageHandler.SendDm(user.UserId, $"Selected **{user.Char.Combat.SelectedMove.Name}**!"); } } else if (reaction.Emote.Name == "4\u20E3") { if (user.Char.Combat.ActiveMon.ActiveMoves[3].Name != "None") { user.Char.Combat.SelectedMove = user.Char.Combat.ActiveMon.ActiveMoves[3]; user.ReactionMessages.Remove(message.Id); await CombatHandler.Attack(user.Char.Combat); await MessageHandler.SendDm(user.UserId, $"Selected **{user.Char.Combat.SelectedMove.Name}**!"); } } } } }
private void AttackBehaviour() { suspicionTimer = 0; combatant.Attack(playerTarget); }