public Command Use(IBeing being) { //0.2: Next, usability in context? Or good enough? var inv_usables = being.Inventory.Where(i => i.IsUsable).ToList(); //var reach_usables = actor.ReachableItems().Where(i => i.IsUsable).ToList(); if (inv_usables.Count == 0) { return(CancelMultiStep("Nothing usable on me.")); } thisUsedItem ??= priorUsedItem ?? being.WieldedTool; if (thisUsedItem == null) { if (!Messager.IsInputReady()) { ShowInventory(being, i => i.IsUsable); } return(NextStepIs(Use_Pick_Item, "Use item: ", being)); } return(NextStepIs( Use_Has_Item, $"Direction to use the {Describer.Describe(thisUsedItem)}, or [a-z?] to choose item: ", being)); }
public Command Use_Pick_Item(AsciiKey press, IBeing being) { if (press.Key == Keys.Escape) { return(CancelMultiStep("cancelled.")); } var selectedIndex = AlphaIndexOfKeyPress(press); if (selectedIndex < 0 || being.Inventory.Count() <= selectedIndex) { return(SameStep($"The key [{PressRep(press)}] does not match an inventory item. Pick another.")); } var item = being.Inventory.ElementAt(selectedIndex); if (!item.IsUsable) { return(SameStep($"The {Describer.Describe(item)} is not a usable item. Pick another.")); } thisUsedItem = item; return(NextStepIs( Use_Has_Item, $"Direction to use the {Describer.Describe(thisUsedItem)}, or [a-z?] to choose item: ", being)); }
public Command Consume_main(AsciiKey press, IBeing being) { if (press.Key == Keys.Escape) { return(CancelMultiStep("cancelled.")); } if (press.Character == '?') { return(ShowInventory <IIngestible>(being)); } var item = ItemInInventoryLocation(press, being); if (item == null) { return(SameStep($"Nothing in inventory slot {press.Character}.")); } if (!item.IsIngestible) { return(SameStep($"I can't eat or drink {Describer.Describe(item, DescMods.Article)}.")); } return(FinishedCommand(CmdAction.Consume, CmdDirection.None, item)); }