public void StartBattle(Player player, Enemy randomEnemy) { if (!randomEnemy.IsDead()) { Console.Clear(); Console.WriteLine(border); Console.WriteLine("|| FIGHTING ENEMY "); Console.WriteLine(border); Console.WriteLine("|| {0} appears!", randomEnemy.GetName()); Console.WriteLine(border); Console.Write("|| Element: "); Console.ForegroundColor = randomEnemy.GetElementColor(); Console.Write("{0}", randomEnemy.GetElementText()); Console.WriteLine(""); Console.ResetColor(); Console.WriteLine(border); Console.WriteLine("|| Enemy HP : {0} / {1}", randomEnemy.GetHP(), randomEnemy.GetMaxHP()); if (randomEnemy.GetEnemyType() == 2) { Console.WriteLine("|| Enemy Mana : {0} / {1}", randomEnemy.GetMana(), randomEnemy.GetMaxMana()); } Console.WriteLine(border); Console.Write("|| Player HP: "); Console.ForegroundColor = player.GetHPColor(); Console.Write("{0} / {1}", player.GetHealth(), player.GetMaxHealth()); Console.WriteLine(""); Console.ResetColor(); Console.WriteLine("|| Player Mana: {0} / {1} ", player.GetMana(), player.GetMaxMana()); Console.WriteLine(border); Console.WriteLine("|| What will you do?"); Console.WriteLine("|| [1] Attack"); Console.WriteLine("|| [2] Use Skill"); Console.WriteLine("|| [3] Use Item"); Console.WriteLine(border); string input = Console.ReadLine(); int slot; if (Int32.TryParse(input, out slot)) { slot = Convert.ToInt32(input); } else { Console.WriteLine("Pls enter a valid number!"); Console.ReadLine(); StartBattle(player, randomEnemy); } if (input == "1") { if (player.GetSpeed() > randomEnemy.GetSpeed()) { Attack(player.Attack(), 1, null, player, randomEnemy); if (!randomEnemy.IsDead()) { EnemyAttack(player, randomEnemy); } if (player.IsDead()) { GameOver(); } Console.WriteLine("|| Press Enter to Continue"); Console.ReadLine(); StartBattle(player, randomEnemy); } else { if (!randomEnemy.IsDead()) { EnemyAttack(player, randomEnemy); } if (player.IsDead()) { GameOver(); } else { Attack(player.Attack(), 1, null, player, randomEnemy); } Console.WriteLine("|| Press Enter to Continue"); Console.ReadLine(); if (gameOver) { return; } else { StartBattle(player, randomEnemy); } } } else if (input == "2") { ChooseSkill(player, randomEnemy); } else if (input == "3") { ChooseItem(player, randomEnemy); } else if (input == "9") { Attack(99999, 1, null, player, randomEnemy); Console.WriteLine("|| Press Enter to Continue"); Console.ReadLine(); StartBattle(player, randomEnemy); } else { Console.WriteLine("|| Pls enter a Valid number."); StartBattle(player, randomEnemy); } } else { Console.Clear(); if (randomEnemy.GetKillCount() <= 0) { Console.WriteLine(border); Console.WriteLine("|| VICTORY "); Console.WriteLine(border); randomEnemy.SetKillCount(randomEnemy.GetKillCount() + 1); player.GainExperience(randomEnemy.GetXP()); player.AddGold(randomEnemy.GetGold()); won = true; gameOver = false; Console.WriteLine("|| You got {0} Gold!", randomEnemy.GetGold()); Console.WriteLine("|| You got {0} Experience!", randomEnemy.GetXP()); if (randomEnemy.ItemDropped()) { Item it = randomEnemy.GetDroppedItem(); player.AddToInventory(it, it.GetAmount()); Console.WriteLine("|| You got {0}x {1}!", it.GetAmount(), it.GetName()); } if (player.LevelUp()) { Console.WriteLine(border); Console.WriteLine("|| You leveled up!"); Console.WriteLine("|| You are now Level {0} !", player.level); player.CheckForNewSkills(sm); Console.WriteLine("|| Choose a Stat to Level up!"); Console.WriteLine(border); string stam = "Increases your Max HP"; string def = "Reduces normal damage taken"; string str = "Increases physical damage dealt"; string inte = "Increases elemental damage dealt and your maximum Mana"; string spd = "If you have more speed than your enemy, you attack first"; Console.WriteLine(String.Format("|| [1] Stamina - {0,10}", stam)); Console.WriteLine(String.Format("|| [2] Defense - {0,10}", def)); Console.WriteLine(String.Format("|| [3] Strength - {0,10}", str)); Console.WriteLine(String.Format("|| [4] Intelligence - {0,10}", inte)); Console.WriteLine(String.Format("|| [5] Speed - {0,10}", spd)); Console.WriteLine(border); LevelUp: string input = Console.ReadLine(); if (input == "1") { Console.WriteLine("|| Stamina increased by 1. Max Health increased!"); player.ChooseStat(input); } else if (input == "2") { Console.WriteLine("|| Defense increased by 1!"); player.ChooseStat(input); } else if (input == "3") { Console.WriteLine("|| Strength increased by 1!"); player.ChooseStat(input); } else if (input == "4") { Console.WriteLine("|| Intelligence increased by 1. Max Mana increased!"); player.ChooseStat(input); } else if (input == "5") { Console.WriteLine("|| Speed increased by 1."); player.ChooseStat(input); } else { goto LevelUp; } } Console.WriteLine(border); Console.WriteLine("|| Press Enter to return to the Main Menu"); } else { Console.WriteLine(border); Console.WriteLine("|| No enemies are nearby..."); Console.WriteLine(border); Console.WriteLine("|| Press Enter to return to the Main Menu"); } Console.ReadLine(); EndBattle(); } }
static void Main(string[] args) { Console.Write("Player Name: "); Player player = new Player(Console.ReadLine()); Orc orc = new Orc(); bool end = false; // Preparations: bool stun_active = false; bool debuff_active = false; while (end == false) { // Player Move: Fail: Console.Write(">"); string command = Console.ReadLine(); if (command.ToLower() == "attack") { player.Attack(orc); PlayerAttackSound(); Thread.Sleep(2000); } else if (command.ToLower() == "fireball") { if (player.mana - player.costF >= 0) { player.Fireball(orc); PlayerFireballSound(); Thread.Sleep(2000); } else { Console.WriteLine("{0} failed Fireball spell due to lack of mana.", player.name); Thread.Sleep(2000); } } else if (command.ToLower() == "might") { if (player.mana - player.costM >= 0) { player.Might(); PlayerMightSound(); Thread.Sleep(2000); } else { Console.WriteLine("{0} failed Might spell due to lack of mana.", player.name); Thread.Sleep(2000); } } else if (command.ToLower() == "stun") { if (player.mana - player.costS >= 0) { player.Stun(orc); stun_active = true; PlayerStunSound(); Thread.Sleep(2000); } else { Console.WriteLine("{0} failed Stun spell due to lack of mana.", player.name); Thread.Sleep(2000); } } else if (command.ToLower() == "debuff") { if (player.mana - player.costD >= 0) { player.Debuff(orc); debuff_active = true; PlayerDebuffSound(); Thread.Sleep(2000); } else { Console.WriteLine("{0} failed Debuff spell due to lack of mana.", player.name); Thread.Sleep(2000); } } else if (command.ToLower() == "health potion") { if (player.healthPotions > 0) { player.HealthPotion(); player.healthPotions--; PlayerPotionSound(); Thread.Sleep(2000); } else { Console.WriteLine("{0} failed to drink health potion due to lack of such an item.", player.name); Thread.Sleep(2000); } } else if (command.ToLower() == "mana potion") { if (player.manaPotions > 0) { player.ManaPotion(); player.manaPotions--; PlayerPotionSound(); Thread.Sleep(2000); } else { Console.WriteLine("{0} failed to drink mana potion due to lack of such an item.", player.name); Thread.Sleep(2000); } } else if (command.ToLower() == "stats") { // Stats: Console.WriteLine("{0}: HP = {1}, ATK = {2}, MP = {3}", player.name, player.health, player.attack, player.mana); Console.WriteLine("Orc: HP = {0}, ATK = {1}, MP = {2}", orc.health, orc.attack, orc.mana); Console.WriteLine(new string('-', 25)); goto Fail; } else if (command.ToLower() == "rules") { // Open "Game Rules.txt" file: ReadRules(); PlayRulesSound(); Console.WriteLine(new string('-', 25)); goto Fail; } else { Console.WriteLine("Unknown command, try again!"); Console.WriteLine(new string('-', 25)); goto Fail; } // Extra effects from spells: if (debuff_active == true && player.durationD > 0) { player.durationD--; } else { debuff_active = false; orc.attack = 20; } if (stun_active == true && player.durationS > 0) { player.durationS--; } else { stun_active = false; orc.can_attack = true; } // Orc Move: orc.Attack(player); if (orc.can_attack != false) { if (orc.crit == true) { OrcAttackCritSound(); System.Threading.Thread.Sleep(2000); orc.crit = false; } else { OrcAttackSound(); System.Threading.Thread.Sleep(2000); } } // End if (orc.health <= 0) { Console.WriteLine("WINNER: " + player.name); PlayVictorySound(); Thread.Sleep(10000); end = true; } else if (player.health <= 0) { Console.WriteLine("WINNER: Orc"); PlayDefeatSound(); Thread.Sleep(1000); end = true; } } }