private static void monsterdisplay(GenerateMonster currentmonster) { Console.WriteLine(); Console.WriteLine("This Monster is a {0}", currentmonster.MonsterName); Console.WriteLine("The {0}'s HP is {1}", currentmonster.MonsterName, currentmonster.MonsterHP); Console.WriteLine("The {0}'s attack is between {1} and {2}", currentmonster.MonsterName, currentmonster.MonsterAttack[0], currentmonster.MonsterAttack[1]); }
private static int fighting(playerstats player, GenerateMonster currentmonster) { char response = 'q'; Random rand = new Random(); Random d20 = new Random(); int playerand; int monsterand; int deathcheck; do { Console.WriteLine("Do you want to attack the monster? Y/N"); Console.Write(">"); response = Convert.ToChar(Console.ReadLine()); response = char.ToUpper(response); if (response == 'Y') { playerand = rand.Next(player.PlayerAttack[0], (player.PlayerAttack[1] + 1)); if ((playerand + d20.Next(1, 21)) > (currentmonster.MonsterDefense + d20.Next(1, 21))) { Console.WriteLine(); Console.WriteLine("You have hit the monster for {0} damage!", playerand); currentmonster.MonsterHP -= playerand; Console.WriteLine("The monster's HP is currently {0}.", currentmonster.MonsterHP); } else { monsterand = rand.Next(currentmonster.MonsterAttack[0], (currentmonster.MonsterAttack[1] + 1)); Console.WriteLine(); Console.WriteLine("The monster has hit you for {0} damage!", monsterand); player.PlayerHP -= monsterand; Console.WriteLine("Your HP is currently {0}. ", player.PlayerHP); } deathcheck = checkfordead(player.PlayerHP, currentmonster.MonsterHP); switch (deathcheck) { case 1: Console.WriteLine("The monster has defeated you. You are forced to head back to town. You lose {0} XP", currentmonster.MonsterXP); player.PlayerHP = player.PlayerMaxHP; return(-currentmonster.MonsterXP); case 2: Console.WriteLine("The Monster is dead! {0} XP awarded!", currentmonster.MonsterXP); return(currentmonster.MonsterXP); default: break; } } else { Console.WriteLine("Entry not recognized, please use Y or N"); } } while (response != 'N'); return(0); }
private static void enterdungeon(playerstats player) { int monsterlevel = 0; char yesno = 'q'; do { monsterlevel = monstertext(); GenerateMonster newmonster = new GenerateMonster(monsterlevel); monsterdisplay(newmonster); player.PlayerTotalXP += fighting(player, newmonster); if (player.PlayerTotalXP < 0) { player.PlayerTotalXP = 0; } Console.WriteLine(); Console.WriteLine("Player's total XP is {0}", player.PlayerTotalXP); checkforlevelup(player); Console.WriteLine("Do you want to go futher in the dungeon?"); Console.Write(">"); yesno = Convert.ToChar(Console.ReadLine()); yesno = char.ToUpper(yesno); } while (yesno != 'N'); }