public static bool GetRoomEvent(ref Player player, ref string[,,] theMap) { Random rand = new Random(); Console.WriteLine($"You are at Level {player.location[0] + 1} Row {player.location[1] + 1} Column {player.location[2] + 1}"); Console.WriteLine($"You are a {player.sex} {player.race}"); Console.WriteLine($"Dexterity={player.dexterity} Intelligence={player.intelligence} Strength={player.strength}"); Console.WriteLine($"Gold={player.gold} Flares={player.flares} Armor={player.armor} Weapon={player.weapon}"); if (player.treasures.Count > 0) { Console.WriteLine($"Treasures='{string.Join(",", player.treasures)}'"); } if (player.blind || player.bookStuck || player.forgetfulness || player.leech || player.lethargy) { Console.WriteLine($"Cursed with='{string.Join(" ", new string[] {player.blind ? "Blind": "", player.bookStuck ? "Book-Stuck-To-Hands" : "", player.forgetfulness ? "Forgetfulness" : "", player.leech ? "Leech" : "", player.lethargy ? "Lethargy" : ""}).Trim().Replace(" "," ")}'"); } Console.WriteLine($"\nHere you find '{theMap[player.location[0], player.location[1], player.location[2]]}'"); switch (theMap[player.location[0], player.location[1], player.location[2]]) { case "Flares": int flaresFound = rand.Next(1, 11); Console.WriteLine("You've found {0} flares", flaresFound); player.flares += flaresFound; theMap[player.location[0], player.location[1], player.location[2]] = "-"; break; case "Gold": int goldFound = rand.Next(1, 1001); Console.WriteLine("You've found {0} Gold Pieces", goldFound); player.gold += goldFound; theMap[player.location[0], player.location[1], player.location[2]] = "-"; break; case string _ when GameCollections.Monsters.Contains(theMap[player.location[0], player.location[1], player.location[2]]): Monster monster = Monster.GetOrCreateMonster(theMap, player, string.Join(string.Empty, new[] { player.location[0], player.location[1], player.location[2] })); if (monster.mad) { Console.WriteLine($"\n{Monster.MonsterMadMessage(monster)}\n"); Battle.BattleSequence(ref player, ref monster, theMap); } else { Console.WriteLine($"\nThe {monster.race} doesn't seem to notice you.\n"); } if (monster.strength < 1) { theMap[player.location[0], player.location[1], player.location[2]] = "-"; } if (!player.location.SequenceEqual(monster.location)) { return(true); } //*** Testing *** Console.WriteLine($"race={monster.race}, dexerity={monster.dexterity}, intelligence={monster.intelligence}, strength={monster.strength}, mad={monster.mad}, runeStaff={monster.runeStaff}, treasures={string.Join("+", player.treasures)}"); break; case "Vendor": if (GameCollections.AllVendorMad) { Vendor vendor = Vendor.GetOrCreateVendor(theMap, player, string.Join(string.Empty, new[] { player.location[0], player.location[1], player.location[2] })); vendor.mad = true; Console.WriteLine($"\n{Vendor.VendorMadMessage(vendor)}\n"); BattleVendor.BattleSequence(ref player, ref vendor, theMap); if (vendor.strength < 1) { theMap[player.location[0], player.location[1], player.location[2]] = "-"; } if (!player.location.SequenceEqual(vendor.location)) { return(true); } //*** Testing *** Console.WriteLine($"race={monster.race}, dexerity={monster.dexterity}, intelligence={monster.intelligence}, strength={monster.strength}, mad={monster.mad}, runeStaff={monster.runeStaff}, treasures={string.Join("+", player.treasures)}"); } break; case "SinkHole": player.Sink(); for (int i = 0; i < 30; i++) { Console.Write("."); Thread.Sleep(100); } return(true); case string caseMatch when GameCollections.Treasures.Contains(theMap[player.location[0], player.location[1], player.location[2]]): Console.WriteLine("You've found the {0}, it's yours!", caseMatch); player.treasures.Add(caseMatch); theMap[player.location[0], player.location[1], player.location[2]] = "-"; break; case "Warp": player.Warp(theMap); for (int i = 0; i < 30; i++) { Console.Write("."); Thread.Sleep(100); } return(true); case "Zot": if (!(YWMenu.playerDirection.ToString().ToUpper() == "T")) { switch (YWMenu.playerDirection.ToString().ToUpper()) { case "N": player.North(theMap); return(true); case "S": player.South(theMap); return(true); case "E": player.East(theMap); return(true); case "W": player.West(theMap); return(true); } return(true); } else { Console.Write("\n\t\t"); Console.BackgroundColor = ConsoleColor.DarkGray; Console.Write("YOU'VE FOUND THE ORB OF ZOT"); Thread.Sleep(1000); Console.BackgroundColor = ConsoleColor.Black; Console.WriteLine("\n"); player.orbOfZot = true; theMap[player.location[0], player.location[1], player.location[2]] = "-"; break; } } return(false); }
public static void Action(ref Player player, string[] action, ref string[,,] knownMap, ref string[,,] theMap) { YWMenu menu = new YWMenu(); switch (action[0]) { case "M": Map.DisplayLevel(knownMap, player); SharedMethods.WaitForKey(); break; case "N": if (player.location[0] == 0 && player.location[1] == 0 && player.location[2] == 3) { Program.PlayerExit(player); break; } else { player.North(knownMap); break; } case "S": player.South(knownMap); break; case "E": player.East(knownMap); break; case "W": player.West(knownMap); break; case "F": if (player.flares > 0) { if (!player.blind) { Map.RevealMap(player.location, theMap, ref knownMap); player.flares -= 1; Map.DisplayLevel(knownMap, player); } else { Console.WriteLine("Lighting a flare won't do you any good since you are BLIND!"); } } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); } SharedMethods.WaitForKey(); break; case "T": string teleportTo; int[] teleCoordinates = new int[3]; if (player.runeStaff == true) { do { Console.Clear(); Console.WriteLine(); Console.Write("\rTeleport where (Example: For Level 3, Row 5, Column 2 type: 3,5,2): "); teleportTo = Console.ReadLine(); teleportTo = teleportTo.Replace(" ", ""); try { teleCoordinates = Array.ConvertAll(teleportTo.Split(','), int.Parse); if (teleCoordinates[0] - 1 < theMap.GetLength(0) && teleCoordinates[1] - 1 < theMap.GetLength(1) && teleCoordinates[2] - 1 < theMap.GetLength(2)) { player.location[0] = teleCoordinates[0] - 1; player.location[1] = teleCoordinates[1] - 1; player.location[2] = teleCoordinates[2] - 1; } else { teleportTo = ""; Console.WriteLine("* Invalid * Coordinates"); SharedMethods.WaitForKey(); } } catch (Exception) { teleportTo = ""; Console.WriteLine("* Invalid * Coordinates"); SharedMethods.WaitForKey(); } } while (teleportTo.Length < 1); Console.WriteLine($"\n\tTeleporting to: ({teleCoordinates[0]}, {teleCoordinates[1]}, {teleCoordinates[2]})"); for (int i = 0; i < 30; i++) { Console.Write("."); Thread.Sleep(100); } } else { Console.WriteLine($"\nSorry, {player.race}, but you need the RuneStaff to teleport!\n"); SharedMethods.WaitForKey(); } break; case "L": if (player.lamp == true) { if (!player.blind) { string[] choice = menu.Menu("Shine lamp which direction", new Dictionary <char, string> { { 'N', "North" }, { 'S', "South" }, { 'E', "East" }, { 'W', "West" } }, ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)); Map.RevealRoom(choice[1], player.location, theMap, ref knownMap); Map.DisplayLevel(knownMap, player); } else { Console.WriteLine($"You're BLIND and can't see anything, silly {player.race}."); SharedMethods.WaitForKey(); } } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); } SharedMethods.WaitForKey(); break; case "D": if (knownMap[player.location[0], player.location[1], player.location[2]] == "DownStairs") { player.Down(); } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); SharedMethods.WaitForKey(); } break; case "U": if (knownMap[player.location[0], player.location[1], player.location[2]] == "UpStairs") { player.Up(); } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); SharedMethods.WaitForKey(); } break; case "G": if (knownMap[player.location[0], player.location[1], player.location[2]] == "Orb") { if (!player.blind) { Console.WriteLine(Orb.OrbEvent(ref player, ref theMap)); } else { Console.WriteLine("The only thing you see is darkness because you are blind"); } SharedMethods.WaitForKey(); } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); SharedMethods.WaitForKey(); } break; case "O": if (knownMap[player.location[0], player.location[1], player.location[2]] == "Book") { if (!player.blind) { Console.WriteLine(Book.BookEvent(ref player, ref theMap)); } else { Console.WriteLine($"Sorry, {player.race}, it's not written in Braille!"); } SharedMethods.WaitForKey(); } else if (knownMap[player.location[0], player.location[1], player.location[2]] == "Chest") { Console.WriteLine(Chest.ChestEvent(ref player, ref theMap, ref knownMap)); SharedMethods.WaitForKey(); } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); SharedMethods.WaitForKey(); } break; case "P": if (knownMap[player.location[0], player.location[1], player.location[2]] == "Pool") { Console.WriteLine(Pool.PoolEvent(ref player)); SharedMethods.WaitForKey(); } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); } break; case "Z": if (knownMap[player.location[0], player.location[1], player.location[2]] == "Vendor") { Vendor vendor = Vendor.GetOrCreateVendor(theMap, player, string.Join(string.Empty, new[] { player.location[0], player.location[1], player.location[2] })); VendorTrade.Trade(ref player, ref vendor); } else { Console.WriteLine($"\nSorry, {player.race}, there's no vendor in the room."); SharedMethods.WaitForKey(); } break; case "A": if (knownMap[player.location[0], player.location[1], player.location[2]] == "Vendor") { Vendor vendor = Vendor.GetOrCreateVendor(theMap, player, string.Join(string.Empty, new[] { player.location[0], player.location[1], player.location[2] })); GameCollections.AllVendorMad = true; vendor.mad = true; Console.WriteLine($"\n{Vendor.VendorMadMessage(vendor)}\n"); BattleVendor.BattleSequence(ref player, ref vendor, theMap); if (vendor.strength < 1) { theMap[player.location[0], player.location[1], player.location[2]] = "-"; SharedMethods.WaitForKey(); } } else if (GameCollections.Monsters.Contains(theMap[player.location[0], player.location[1], player.location[2]])) { Monster monster = Monster.GetOrCreateMonster(theMap, player, string.Join(string.Empty, new[] { player.location[0], player.location[1], player.location[2] })); monster.mad = true; Console.WriteLine($"\n{Monster.MonsterMadMessage(monster)}\n"); Battle.BattleSequence(ref player, ref monster, theMap); if (monster.strength < 1) { theMap[player.location[0], player.location[1], player.location[2]] = "-"; } SharedMethods.WaitForKey(); } else { Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); SharedMethods.WaitForKey(); } break; case "V": Instructions.ViewInstructions(); break; case "Q": break; default: Console.WriteLine("\n{0}\n", ManipulateListObjects.ReplaceRandomMonster(GameCollections.ErrorMesssages)[new Random().Next(0, GameCollections.ErrorMesssages.Count)]); SharedMethods.WaitForKey(); break; } }