public static void enemyTurn(Player player, CharacterStats enemy) { int rollToHit = 0; int damageToPlayer = 0; int randomChoice; for (int i = 0; i < enemy.attackNum; i++) { randomChoice = randChoice.Next(1, 4); ChooseAttack: if (randomChoice == 1) // choose up to 3 different attacks at random { SlowText("The enemy attempts to hit you with its " + enemy.weaponName + "."); if (!enemy.isWeaponRanged) { rollToHit = RollDice(1, 20, enemy.meleeATKBonus); } if (enemy.isWeaponRanged) { rollToHit = RollDice(1, 20, enemy.rangedATKBonus); } Console.WriteLine(rollToHit + " ~ " + player.getCharacterStats().ac); if (rollToHit >= player.getCharacterStats().ac) { SlowText("It hits you!"); WriteRemark(Remark.ReturnRemark("enemyAttackHit")); if (!enemy.isWeaponRanged) { damageToPlayer = RollDice(enemy.damageDiceNumber, enemy.damageDiceMax, enemy.str); } if (enemy.isWeaponRanged) { damageToPlayer = RollDice(enemy.damageDiceNumber, enemy.damageDiceMax, enemy.dex); } if (damageToPlayer < 0) { damageToPlayer = 0; } SlowText("It deals " + damageToPlayer + " damage!"); player.getCharacterStats().health -= damageToPlayer; SlowText("Your health: " + player.getCharacterStats().health); if (damageToPlayer != 0) { WriteRemark(Remark.ReturnRemark("enemyAttackHit")); } } else { SlowText("It misses!"); WriteRemark(Remark.ReturnRemark("enemyAttackMiss")); } } else if (randomChoice == 2) { if (enemy.weaponName2 == "") { randomChoice = 1; goto ChooseAttack; } SlowText("The enemy attempts to hit you -" + enemy.weaponName2); if (!enemy.isWeapon2Ranged) { rollToHit = RollDice(1, 20, enemy.meleeATKBonus); } if (enemy.isWeapon2Ranged) { rollToHit = RollDice(1, 20, enemy.rangedATKBonus); } Console.WriteLine(rollToHit + " ~ " + player.getCharacterStats().ac); if (rollToHit >= player.getCharacterStats().ac) { SlowText("It hits you!"); if (!enemy.isWeapon2Ranged) { damageToPlayer = RollDice(enemy.damageDiceNumber2, enemy.damageDiceMax2, enemy.str); } if (enemy.isWeapon2Ranged) { damageToPlayer = RollDice(enemy.damageDiceNumber2, enemy.damageDiceMax2, enemy.dex); } if (damageToPlayer < 0) { damageToPlayer = 0; } SlowText("It deals " + damageToPlayer + " damage!"); player.getCharacterStats().health -= damageToPlayer; SlowText("Your health: " + player.getCharacterStats().health); if (damageToPlayer != 0) { WriteRemark(Remark.ReturnRemark("enemyAttackHit")); } } else { SlowText("It misses!"); WriteRemark(Remark.ReturnRemark("enemyAttackMiss")); } } else if (randomChoice == 3) { if (enemy.weaponName3 == "") { randomChoice = 1; goto ChooseAttack; } SlowText("The enemy attempts to hit you -" + enemy.weaponName3); if (!enemy.isWeapon3Ranged) { rollToHit = RollDice(1, 20, enemy.meleeATKBonus); } if (enemy.isWeapon3Ranged) { rollToHit = RollDice(1, 20, enemy.rangedATKBonus); } Console.WriteLine(rollToHit + " ~ " + player.getCharacterStats().ac); if (rollToHit >= player.getCharacterStats().ac) { SlowText("It hits you!"); if (!enemy.isWeapon3Ranged) { damageToPlayer = RollDice(enemy.damageDiceNumber3, enemy.damageDiceMax3, enemy.str); } if (enemy.isWeapon3Ranged) { damageToPlayer = RollDice(enemy.damageDiceNumber3, enemy.damageDiceMax3, enemy.dex); } if (damageToPlayer < 0) { damageToPlayer = 0; } SlowText("It deals " + damageToPlayer + " damage!"); player.getCharacterStats().health -= damageToPlayer; SlowText("Your health: " + player.getCharacterStats().health); if (damageToPlayer != 0) { WriteRemark(Remark.ReturnRemark("enemyAttackHit")); } } else { SlowText("It misses!"); WriteRemark(Remark.ReturnRemark("enemyAttackMiss")); } } else { WriteRemark(Remark.ReturnRemark("enemyTaunt")); } } }
public static void playerTurn(Player player, CharacterStats enemy) { int rollToHit = 0; int damageToEnemy = 0; playerTurnStart: Console.WriteLine(); SlowText("What would you like to do?"); SlowText("1 - Weapon Attack"); SlowText("2 - Cast Spell"); SlowText("3 - Insult"); SlowText("4 - View Player Stats"); int answer; if (DEBUG_MODE) { answer = 1; } else { try { answer = int.Parse(Console.ReadLine()); } catch { SlowText("That is not a valid input."); goto playerTurnStart; } } switch (answer) { case 1: for (int i = 0; i < player.getCharacterStats().attackNum; i++) { if (player.getCharacterStats().ammo == 0 && player.getCharacterStats().isWeaponRanged) { Console.WriteLine("You have no ammo left!"); break; } SlowText("You attempt to hit - "); if (!player.getCharacterStats().isWeaponRanged) { rollToHit = RollDice(1, 20, player.getCharacterStats().meleeATKBonus); } else if (player.getCharacterStats().isWeaponRanged) { rollToHit = RollDice(1, 20, player.getCharacterStats().rangedATKBonus); } Console.WriteLine(rollToHit + " ~ " + enemy.ac); if (rollToHit >= enemy.ac) { SlowText("You hit!"); if (!player.getCharacterStats().isWeaponRanged) { damageToEnemy = RollDice(player.getCharacterStats().damageDiceNumber, player.getCharacterStats().damageDiceMax, player.getCharacterStats().str); } if (player.getCharacterStats().isWeaponRanged) { damageToEnemy = RollDice(player.getCharacterStats().damageDiceNumber, player.getCharacterStats().damageDiceMax, player.getCharacterStats().dex); } SlowText("You deal " + damageToEnemy + " damage!"); if (player.getCharacterStats().isWeaponRanged) { player.getCharacterStats().ammo--; SlowText("You have " + player.getCharacterStats().ammo + " ammo left."); } WriteRemark(Remark.ReturnRemark("playerAttackHit")); enemy.health -= damageToEnemy; if (enemy.health < 0) { enemy.health = 0; } SlowText("Enemy health: " + enemy.health); } else { Console.WriteLine("You miss!"); WriteRemark(Remark.ReturnRemark("PlayerAttackMiss")); } Console.ReadLine(); } break; case 2: Spells[] spells = Spells.GetSpells(player); try { if (spells[0] != null) { } } catch { if (player.getCharacterStats().spellPoints == 0 && player.getCharacterStats().maxSpellPoints > 0) { SlowText("You're out of spell points."); } else { SlowText("You don't know any spells :("); } goto playerTurnStart; } SpellCastStart: SlowText("Choose a spell to cast!"); SlowText("You have " + player.getCharacterStats().spellPoints + " spell points!"); for (int i = 0; i < spells.Length; i++) { SlowText((i + 1) + " - " + spells[i].spellName + " : " + spells[i].spellPoints + " Spell Points.", 5, ConsoleColor.DarkGray); } int choice = int.Parse(Console.ReadLine()); if (choice > spells.Length) { SlowText("Uh, I don't think that's an option. Try again.", 15, ConsoleColor.DarkGray); goto SpellCastStart; } else { Spells spell = spells[choice - 1]; if (player.getCharacterStats().spellPoints < spell.spellPoints) { SlowText("You don't have enough spell points, choose again."); goto playerTurnStart; } if (spell.spellDamageDiceNumber > 0) { SlowText("Roll for accuracy!"); if (RollDice(1, 20, player.getCharacterStats().spellModifier) >= enemy.ac) { SlowText("You hit!"); RollDiceGraphic(spell.spellDiceMax); int magicDamageToEnemy = player.CastSpell(spell, enemy); enemy.health -= magicDamageToEnemy; SlowText("You dealt " + magicDamageToEnemy + " damage!"); } else { SlowText("You missed!"); WriteRemark(Remark.ReturnRemark("playerAttackMiss")); } player.getCharacterStats().spellPoints -= spell.spellPoints; if (spell.spellHealDiceNumber > 0) { goto healSpell; } else { break; } } healSpell: int totalHealed = player.CastSpell(spell, enemy); if (player.getCharacterStats().health > player.getCharacterStats().maxHealth) { SlowText("You are fully healed already!"); } else { if (spell.spellHealDiceNumber > 0) { player.getCharacterStats().health += totalHealed; } SlowText("You healed " + totalHealed + " health!"); if (player.getCharacterStats().health > player.getCharacterStats().maxHealth) { player.getCharacterStats().health = player.getCharacterStats().maxHealth; } } WriteRemark(Remark.ReturnRemark(spell.spellDamageType)); WriteRemark(Remark.ReturnRemark(spell.spellName)); player.getCharacterStats().spellPoints -= spell.spellPoints; } Console.WriteLine(); break; case 3: SlowText(Remark.PlayerInsult(), 10, ConsoleColor.Cyan); if (dice.Next(1, 4) == 1) { SlowText("The " + enemy.race + " was shooketh from your roast! It's your turn again!"); goto playerTurnStart; } else { SlowText(enemy.name + " is not impressed."); } break; case 4: player.getCharacterStats().DispStats(); Console.WriteLine(); goto playerTurnStart; default: SlowText("That is not a valid option. Try again."); goto playerTurnStart; } }