public Result Affect(Hero hero) { var restore = Math.Min(hero.MaxHealth - hero.Health, Health); hero.Health += restore; return(Result.Action($"You feel invigorated. The {Name} restored {restore} health points")); }
public Result Affect(Hero hero) { int x, y; do { x = R.Next(map.Width); y = R.Next(map.Height); } while (map.IsWall(x, y) && map.Cell(x, y).Monster == null); hero.X = x; hero.Y = y; return(Result.Action("The room spins around you and when it stops you feel relocated")); }
private void AcceptSelect(Result result) { if (!resultCtrl.Dirty && result != null) { if (result.Action != null) { bool hideWindow = result.Action(new ActionContext() { SpecialKeyState = new GlobalHotkey().CheckModifiers() }); if (hideWindow) { HideWox(); } UserSelectedRecordStorage.Instance.Add(result); } } }
private void SelectResult(Result result) { if (result != null) { if (result.Action != null) { bool hideWindow = result.Action(new ActionContext() { SpecialKeyState = globalHotkey.CheckModifiers() }); if (hideWindow) { HideWox(); } UserSelectedRecordStorage.Instance.Add(result); } } }
public Result Drop(Item item, Cell cell) { if (cell.Item != null) { return(Result.NoAction($"You can't drop the {item.Name}, there's already stuff here")); } cell.Item = item; if (Backpack.Contains(item)) { Backpack.Remove(item); } if (Wielding == item) { Wielding = null; } return(Result.Action($"You dropped the {item.Name}")); }
public ResultViewModel(Result result) { if (result != null) { RawResult = result; OpenResultListBoxItemCommand = new RelayCommand(_ => { bool hideWindow = result.Action(new ActionContext { SpecialKeyState = GlobalHotkey.Instance.CheckModifiers() }); if (hideWindow) { App.API.HideApp(); UserSelectedRecordStorage.Instance.Add(RawResult); QueryHistoryStorage.Instance.Add(RawResult.OriginQuery.RawQuery); } }); OpenContextMenuItemCommand = new RelayCommand(_ => { var actions = PluginManager.GetContextMenusForPlugin(result); var pluginMetaData = PluginManager.GetPluginForId(result.PluginID).Metadata; actions.ForEach(o => { o.PluginDirectory = pluginMetaData.PluginDirectory; o.PluginID = result.PluginID; o.OriginQuery = result.OriginQuery; }); actions.Add(GetTopMostContextMenu(result)); App.API.ShowContextMenu(pluginMetaData, actions); }); } }
public Result PickUpItem(Cell cell) { var item = cell.Item; if (item == null) { return(Result.NoAction("There is nothing to pick up here")); } if (Wielding == null && item is Weapon) { cell.Item = null; return(Wield((Weapon)item)); } var stack = item as IStackable; if (stack != null) { var bpStack = (IStackable)Backpack.FirstOrDefault(i => i.GetType() == stack.GetType() && i.Name == item.Name); if (bpStack != null) { bpStack.Stack(stack); cell.Item = null; return(Result.Action($"You pick up the {item.Name}.")); } } if (Backpack.IsFull) { return(Result.Action($"The backpack is full, so you couldn't pick up the {item.Name}.")); } Backpack.Add(item); cell.Item = null; return(Result.Action($"You pick up the {item.Name}.")); }
private Result Wield(Weapon weapon) { Wielding = weapon; return(Result.Action($"You wield the {weapon.Name}")); }
private void InitializeKeyCommands() { EscCommand = new RelayCommand(_ => { if (!ResultsSelected()) { SelectedResults = Results; MainWindowVisibility = Visibility.Collapsed; } else { MainWindowVisibility = Visibility.Collapsed; } }); SelectNextItemCommand = new RelayCommand(_ => { SelectedResults.SelectNextResult(); }); SelectPrevItemCommand = new RelayCommand(_ => { SelectedResults.SelectPrevResult(); }); SelectNextPageCommand = new RelayCommand(_ => { SelectedResults.SelectNextPage(); }); SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); }); StartHelpCommand = new RelayCommand(_ => { Process.Start("http://doc.wox.one/"); }); OpenResultCommand = new RelayCommand(index => { ResultsViewModel results = SelectedResults; if (index != null) { results.SelectedIndex = int.Parse(index.ToString()); } Result result = results.SelectedItem?.Result; if (result != null) // SelectedItem returns null if selection is empty. { bool hideWindow = result.Action != null && result.Action(new ActionContext { SpecialKeyState = GlobalHotkey.Instance.CheckModifiers() }); if (hideWindow) { MainWindowVisibility = Visibility.Collapsed; } if (ResultsSelected()) { _userSelectedRecord.Add(result); _history.Add(result.OriginQuery.RawQuery); if (result.historySave != null) { addSearchHistory(result.PluginID, result.historySave); } } } }); LoadContextMenuCommand = new RelayCommand(_ => { if (ResultsSelected()) { SelectedResults = ContextMenu; } else { SelectedResults = Results; } }); LoadHistoryCommand = new RelayCommand(_ => { if (ResultsSelected()) { SelectedResults = History; History.SelectedIndex = _history.Items.Count - 1; } else { SelectedResults = Results; } }); }