// Constructor to assign information gathered public Room(int id, string roomName, string description, int north, int south, int east, int west, int up, int down, int mobRoll) { ID = id; RoomName = roomName; Description = description; North = north; South = south; East = east; West = west; Up = up; Down = down; // Allows for the mob to be randomly generated. if (mobRoll > -1) { if (mobRoll < 1) { int rolledMob = RandomNumGenerator.NumberBetween(0, 6); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll < 2) { int rolledMob = RandomNumGenerator.NumberBetween(7, 14); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll < 3) { int rolledMob = RandomNumGenerator.NumberBetween(15, 24); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll < 4) { int rolledMob = RandomNumGenerator.NumberBetween(25, 32); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll < 5) { int rolledMob = RandomNumGenerator.NumberBetween(33, 39); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll < 6) { int rolledMob = RandomNumGenerator.NumberBetween(40, 40); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll == 7) { int rolledMob = RandomNumGenerator.NumberBetween(41, 41); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll == 8) { int rolledMob = RandomNumGenerator.NumberBetween(42, 42); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else if (mobRoll == 9) { int rolledMob = RandomNumGenerator.NumberBetween(43, 43); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } else { int rolledMob = RandomNumGenerator.NumberBetween(44, 44); CurrentMob = new Mob(GameAttributes.mobs[rolledMob]); } } }
// Allows the player to gain xp after killing a mob //TODO figure out how to add stat increases after player level increases. public static void AddPlayerXP(Player player, Mob mob) { player.XP += mob.XP; player.PlayerLevel = player.XP / 100; }
public static void RunCombat(Player player, string noun) { bool exit = false; int playerDamage; int mobDamage; Mob mob = player.CurrentRoom.CurrentMob; // Keeps the do while going as long as the mob/player hasn't died. do { if (player.CurrentRoom.CurrentMob != null) { if (noun == mob.Name.ToLower()) { // Checks to make sure the mob isn't dead if (mob.IsDead == false) { // Rolls the players attack Console.ForegroundColor = ConsoleColor.Green; int playerAttack = RandomNumGenerator.NumberBetween(1, 20); Console.WriteLine($"You attack with a {player.Equipment.Name} and roll a {playerAttack}"); if (playerAttack >= mob.AC) { playerDamage = RollDice.PlayerDiceRoll(player); Console.WriteLine($"You hit {mob.Name} for {playerDamage} damage!"); mob.HP -= playerDamage; Console.WriteLine($"The {mob.Name} has {mob.HP} HP!"); // Once mob dies all items are automatically given to player //TODO add a display of what the player gained (xp, gold, items, etc) if (mob.HP <= 0) { Console.ForegroundColor = ConsoleColor.Cyan; CombatResults(player, mob); exit = true; Console.ForegroundColor = ConsoleColor.White; } } else { Console.WriteLine("You Missed!!!"); } Console.ForegroundColor = ConsoleColor.Red; // Mobs turn to attack if it is still alive, rolls the mobs attacks and continues combat until the player or mob dies if (mob.IsDead == false) { int monsterAttack = RandomNumGenerator.NumberBetween(1, 20); if (monsterAttack > player.AC) { mobDamage = RollDice.MonsterDiceRoll(mob); Console.WriteLine($"The {mob.Name} attacks and rolls a {monsterAttack}"); Console.WriteLine($"The {mob.Name} hits for {mobDamage} damage!"); player.HP -= mobDamage; Console.WriteLine($"The {player.PlayerName} has {player.HP} HP!"); if (player.HP < 0) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("You have died!"); LoadPlayerFromFile.LoadPlayer(player.PlayerName); exit = true; Console.ForegroundColor = ConsoleColor.White; } } else { Console.WriteLine($"The {mob.Name} Missed!"); } } else { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine($"You have won!"); exit = true; } Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"Press enter to continue!"); Console.ReadLine(); } else { Console.WriteLine($"The monster is dead"); exit = true; } } else { Console.WriteLine($"You do not see a {noun}"); exit = true; } } else { Console.WriteLine("There is nothing to attack here."); exit = true; } } while (exit == false); }