/// <summary> /// Executes the player's turn, either attacking the enemy /// or using a potion /// </summary> /// <param name="player"></param> /// <param name="enemy"></param> /// <param name="input"></param> /// <returns>Whether the player actually completed their turn</returns> private bool playerTurn(Player player, Enemy enemy, int input) { bool playerTurnCompleted = false; if (input == 1) { Attack playerAttack = player.Attack(); int oldHP = enemy.Health; int defence = enemy.Defend(playerAttack.Damage); double percentageLost = calcPercentageHPLost(oldHP, enemy.Health, enemy.MaxHealth); view.DisplayAttack(player.Name, enemy.Name, playerAttack.Description, playerAttack.Damage); view.DisplayDefence(enemy.Name, defence, oldHP - enemy.Health, percentageLost); playerTurnCompleted = true; } else { if (player.Potions.Count == 0) { view.DisplayWarning("You don't have any potions!"); } else { input = SelectFromList <Potion>(player.Potions, view); var potion = player.RemovePotion(input); int effect = potion.Use(); // - is healing // + is damage if (effect < 0) { player.Health += -effect; view.DisplayHeal(player.Name, -effect, player.Health); } else { var oldHP = enemy.Health; int defence = enemy.Defend(effect, true); double percentageLost = calcPercentageHPLost(oldHP, enemy.Health, enemy.MaxHealth); view.DisplayAttack(player.Name, enemy.Name, potion.Name, effect); view.DisplayDefence(enemy.Name, defence, oldHP - enemy.Health, percentageLost); } playerTurnCompleted = true; } } return(playerTurnCompleted); }