// Persuade // Pick pocket // Decorate weapon public bool DecorateWeapon(WeaponDecorator wpnDecorator, AbstractWeapon weapon) { AbstractWeapon newWeapon; if (weapon is WeaponDecorator) { //cant decorate return(false); } else if (wpnDecorator is RedGem) { //// Decorate fire weapon //newWeapon = new RedGem(weapon); //Inventory.Push(newWeapon); //Render.UpdateItemFeed(this); Inventory = new Stack <IItem>(); // Decorate fire weapon newWeapon = new RedGem(weapon); Inventory.Push(newWeapon); Render.UpdateItemFeed(this); return(true); // Add other items to inventory } else if (wpnDecorator is BlueGem) { Inventory = new Stack <IItem>(); newWeapon = new BlueGem(weapon); Inventory.Push(newWeapon); Render.UpdateItemFeed(this); return(true); // Add other items to inventory } else if (wpnDecorator is GreenGem) { Inventory = new Stack <IItem>(); newWeapon = new GreenGem(weapon); Inventory.Push(newWeapon); Render.UpdateItemFeed(this); return(true); // Add the deleted items } // Other decorations return(false); }
// Print Inventory -- returns true if are decoratables public void InventoryInteractions(Player p) { string choice; string invAction; string action; string itemName; string[] split; string[] split2; // Display inventory items ShowInventoryItems(p); invAction = Console.ReadLine().ToLower(); // Close inventory if (invAction == "close") { Console.WriteLine("You closed the inventory"); } else { try { split = invAction.Split(' '); // Assign action in inventory and item name action = split[0]; itemName = split[1]; for (int i = 2; i < split.Length; i++) { itemName += split[i]; } if (action == "merge") { foreach (IItem i in p.Inventory) { if (itemName == i.inEngineName && i is WeaponDecorator) { WeaponDecorator wd = i as WeaponDecorator; // Select the weapon decorator Console.WriteLine("Whats the weapon you" + " want to enpower?"); Console.Write("-> "); choice = Console.ReadLine(); split2 = choice.Split(' '); choice = split2[0]; // Append code for (int k = 1; k < split2.Length; k++) { choice += split2[k]; } // Decorate if valid foreach (IItem j in p.Inventory) { if (choice == j.inEngineName && j is AbstractWeapon) { AbstractWeapon w = j as AbstractWeapon; // Call decoration method if (p.DecorateWeapon(wd, w)) { return; } } } } else { Console.WriteLine($"That's not something" + $" you can merge!"); } } } else if (action == "stats") { foreach (IItem i in p.Inventory) { if (itemName == i.inEngineName) { ShowItemStats(i); } } } else { Console.WriteLine("That is not a valid option"); } } catch (Exception e) { Console.WriteLine("The Inventory does not " + "recognize those words\n"); Console.WriteLine(e); } } }