public override async Task <bool> OnExecute() { var orderSelectionViewModel = _mefContainer.GetExportedValue <IOrderSelectionViewModel>(); var selectedOrder = await _metroDialog.ShowDialog(orderSelectionViewModel); if (selectedOrder == null) { return(false); } var wineSelectionViewModel = _mefContainer.GetExportedValue <IWineSelectionViewModel>(); wineSelectionViewModel.Initialize(selectedOrder); var selectedWines = await _metroDialog.ShowDialog(wineSelectionViewModel); if (selectedWines == null) { return(false); } foreach (var selectedWine in selectedWines) { selectedWine.IsBought = false; } GameState.VictoryPoints += selectedOrder.VictoryPoints; GameState.ResidualMoney += selectedOrder.Residual; return(true); }
public async Task <T> Select <T>(string title, string message, IEnumerable <T> selections) where T : class, IHasDescription { var selectionDialogViewModel = _mefContainer.GetExportedValue <ISelectionDialogViewModel <T> >(); selectionDialogViewModel.Title = title; selectionDialogViewModel.Message = message; selectionDialogViewModel.Selections = selections; var selection = await _metroDialog.ShowDialog(selectionDialogViewModel); return(selection); }
private async Task <bool> SellGrape() { var dialogViewModel = _mefContainer.GetExportedValue <IGrapesSelectionViewModel>(); var result = (await _metroDialog.ShowDialog(dialogViewModel)).ToList(); if (result.Any()) { foreach (var grape in result) { GameState.Money += grape.SellValue; grape.IsBought = false; } return(true); } return(false); }
public override async Task <bool> OnExecute() { var vineSelectionViewModel = _mefContainer.GetExportedValue <IVineSelectionViewModel>(); var selectedVine = await _metroDialog.ShowDialog(vineSelectionViewModel); if (selectedVine == null) { IgnoreMaxValue = false; IgnoreRequirements = false; return(false); } var fieldSelectionViewModel = _mefContainer.GetExportedValue <IFieldSelectionViewModel>(); fieldSelectionViewModel.IgnoreMaxValue = IgnoreMaxValue; fieldSelectionViewModel.VineToPlant = selectedVine; var selectedField = await _metroDialog.ShowDialog(fieldSelectionViewModel); if (selectedField == null) { IgnoreMaxValue = false; IgnoreRequirements = false; return(false); } selectedField.PlantVine(selectedVine); GameState.Hand.RemoveCard(selectedVine); if (GameState.Windmill.IsBought && !GameState.Windmill.HasBeenUsed) { GameState.Windmill.HasBeenUsed = true; GameState.VictoryPoints++; } IgnoreMaxValue = false; IgnoreRequirements = false; return(true); }
private async Task <bool> SelectStructure() { var dialogViewModel = _mefContainer.GetExportedValue <IBuildStructureViewModel>(); dialogViewModel.BuildingBonus = BuildingBonus; var selectedStructure = await _metroDialog.ShowDialog(dialogViewModel); if (selectedStructure == null) { return(false); } selectedStructure.IsBought = true; GameState.Money -= Math.Max(selectedStructure.Cost - BuildingBonus, 0); BuildingBonus = 0; return(true); }
private async Task <bool> ChooseAndPlayCard() { var cardSelectionViewModel = _mefContainer.GetExportedValue <ICardSelectionViewModel>(); cardSelectionViewModel.Initialize(Cards.Where(p => p.CanPlay(GameState))); var selectedCard = await _metroDialog.ShowDialog(cardSelectionViewModel); if (selectedCard == null) { return(false); } var result = await selectedCard.Apply(GameState); if (!result) { return(false); } selectedCard.Discard(); return(true); }
public async Task <bool> MakeWine() { var dialogViewModel = _mefContainer.GetExportedValue <IGrapesSelectionViewModel>(); var selectedGrapes = (await _metroDialog.ShowDialog(dialogViewModel)).ToList(); if (!selectedGrapes.Any()) { return(false); } int value = selectedGrapes.Sum(p => p.Value); WineType type; if (selectedGrapes.Count == 1) { type = selectedGrapes.First().GrapeColor == GrapeColor.Red ? WineType.Red : WineType.White; } else if (selectedGrapes.Count == 2) { type = WineType.Blush; } else { type = WineType.Sparkling; } var firstAvailableSpotInCellar = GetFirstAvailableSpotInCellar(value, type); if (firstAvailableSpotInCellar == null) { await _metroDialog.ShowMessage("Make wine", "No room in cellar for selected wine or two low value"); return(false); } firstAvailableSpotInCellar.IsBought = true; selectedGrapes.ForEach(p => p.IsBought = false); return(true); }