protected override async Task <bool> OnApply(IGameState gameState) { var cards = new List <Card> { gameState.VineDeck.Draw(), gameState.SummerVisitorDeck.Draw(), gameState.OrderDeck.Draw(), gameState.WinterVisitorDeck.Draw() }; var options = cards.Select(p => new Option <Card>(p, p.DisplayText)).ToList(); var selectedCards = (await PlayerSelection.SelectMany(options, 2)).OfType <Option <Card> >() .Select(p => p.WrappedObject) .ToList(); if (selectedCards.Count != 2) { return(false); } selectedCards.ForEach(p => p.TakeToHand()); cards.Except(selectedCards).ForEach(p => p.Discard()); return(true); }
protected override async Task <bool> OnApply(IGameState gameState) { var options = gameState.Workers.Where(p => p.HasBeenUsed).Select(p => new Option <Worker>(p, p.UsedAction.Text)); var selectedWorkers = (await PlayerSelection.SelectMany(options, 2, SelectionRequirement.AtLeastOne)).OfType <Option <Worker> >() .Select(p => p.WrappedObject).ToList(); if (!selectedWorkers.Any()) { return(false); } foreach (var selectedWorker in selectedWorkers) { if (gameState.Grande.UsedAction != selectedWorker.UsedAction) { selectedWorker.UsedAction.HasBeenUsed = false; } selectedWorker.UsedAction = null; selectedWorker.HasBeenUsed = false; } return(true); }
private async Task <bool> SelectCardsToDiscard(IGameState gameState, int numberOfCardsToDiscard) { var options = gameState.Hand.VisitorCards.Select(p => new Option <Card>(p, p.DisplayText)); var selectedCards = (await PlayerSelection.SelectMany(options, numberOfCardsToDiscard)).OfType <Option <Card> >().ToList(); if (!selectedCards.Any()) { return(false); } selectedCards.ForEach(p => p.WrappedObject.Discard()); return(true); }
protected override async Task <bool> OnApply(IGameState gameState) { var selections = (await PlayerSelection.SelectMany(Options, RequiredSelections)).ToList(); if (selections.Count != RequiredSelections) { return(false); } foreach (var selection in selections) { if (!await selection.Apply(gameState)) { return(false); } } return(true); }
protected override async Task <bool> OnApply(IGameState gameState) { var options = gameState.Decks.Select(p => p.TopCardOnDiscardPile) .Where(p => p != null) .Select(p => new Option <Card>(p, p.Name)).ToList(); var selectedCards = (await PlayerSelection.SelectMany(options, 2)).OfType <Option <Card> >() .Select(p => p.WrappedObject) .ToList(); if (selectedCards.Count != 2) { return(false); } foreach (var selectedCard in selectedCards) { selectedCard.TakeToHand(); } return(true); }
protected override async Task <bool> ApplyOption2(IGameState gameState) { var options = new List <VineCardOption>(); foreach (var field in gameState.Fields) { foreach (var vineCard in field.Vines) { options.Add(new VineCardOption($"F{field.Value}: {vineCard.DisplayText}", state => Task.FromResult(true), state => true, vineCard)); } } var selections = (await PlayerSelection.SelectMany(options, 2)).OfType <VineCardOption>().ToList(); if (selections.Count != 2) { return(false); } var firstVine = selections[0].VineCard; var firstVineField = gameState.Fields.First(p => p.Vines.Any(v => v == firstVine)); var secondVine = selections[1].VineCard; var secondVineField = gameState.Fields.First(p => p.Vines.Any(v => v == secondVine)); firstVineField.UprootVine(firstVine); secondVineField.UprootVine(secondVine); if (!firstVineField.CanPlant(secondVine) || !secondVineField.CanPlant(firstVine)) { return(false); } firstVineField.PlantVine(secondVine); secondVineField.PlantVine(firstVine); return(true); }