//----------------------------------NAME---------------------------------------- public void GetName()//name check { MainGame.Say("\n-So what you're callin yourself?\n", ConsoleColor.Yellow, 25); do { name = StrInput.CleanInput(); if (string.IsNullOrWhiteSpace(name)) { MainGame.Say("-Speak louder, I can't hear!\n", ConsoleColor.Yellow, 25); } } while (string.IsNullOrWhiteSpace(name)); name = name.Trim();//deleting space }
public static void LootRoom(Player player) { Room room = player.currentRoom; Say("You search room for loot\n", 25); room.ListItems(); if (player.InventoryIsFull) { MainGame.Say("Your inventory is full\n", 25); } else if (room.Loot.Count != 0 && !player.InventoryIsFull)//obvious cheking if room has looot and player's pockets aren't full(just because WE CAN check) { string choice; char[] items; //we will need them MainGame.Say("Which one you want to pick?(Write nums of items through space, 'A' to pick all, 'Enter' to move on)\n", 25); choice = StrInput.CleanInput(); //player writes item nums in string through space(but honestly we don't beacuse we wiil read as single num them anyway) items = ParseStringDigit(choice); //taking only digits from string that was submitted and putting them in char array Console.Write("\n"); if (choice == "" || items.Length == 0) { } //if player choses nothing he inputs emty string so we just move forward else if (items[0] == 'A' || items[0] == 'a') //if player wants to take all he submits a letter A in front of string and we procced { foreach (Item item in room.Loot) { player.GetItem(item); if (player.InventoryIsFull) { break; } } room.Loot.RemoveRange(0, room.Loot.Count); } else//else we just watchin what player submitted { foreach (char ch in items) { if (ch <= 48 || ch - 48 > room.Loot.Count || ch == 'a' || ch == 'A') { continue; } if (room.Loot[ch - 49] != null) { player.GetItem(room.Loot[ch - 49]); room.Loot[ch - 49] = null;//we make item place in list null so order in list doesn't change } } } room.EraseNulls();//erasing nulls because it may disrupt us } }