public override bool IsValidMove(int deck) { var thisCard = _gameContainer.DeckList !.GetSpecificItem(deck); if (thisCard.Value == EnumCardValueList.HighAce) { return(false); //ace is high } if (thisCard.Value == EnumCardValueList.Five && thisCard.Suit == EnumSuitList.Clubs) { return(false); //because the 5 of clubs is automatic planet. } var thisList = SaveRoot !.TrickList; if (thisList.Count == 0) { return(true); } var originalCard = thisList.First(); if (originalCard.Suit == thisCard.Suit) { return(true); } var tempList = SingleInfo !.MainHandList.Where(items => items.Value != EnumCardValueList.HighAce).ToRegularDeckDict(); tempList.RemoveAllAndObtain(items => items.Value == EnumCardValueList.Five && items.Suit == EnumSuitList.Clubs); return(!tempList.Any(items => items.Suit == originalCard.Suit)); }
public static DeckRegularDict <FluxxCardInformation> CardsForTaxation(FluxxGameContainer gameContainer) { int extras = gameContainer.IncreaseAmount(); int howMany = extras + 1; return(gameContainer.SingleInfo !.MainHandList.GetRandomList(true, howMany).ToRegularDeckDict()); //i think you do need to remove previous. }
public async Task PlayCardAsync() { int decks = _model.PlayerHand1.ObjectSelected(); if (decks == 0) { await UIPlatform.ShowMessageAsync("Must choose a card to play"); return; } var thisCard = _mainGame.SingleInfo !.MainHandList.GetSpecificItem(decks); if (_mainGame.CanPlayCard(thisCard) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.BasicData !.MultiPlayer) { await _mainGame.Network !.SendAllAsync("playcard", decks); } CommandContainer !.ManuelFinish = true; await _mainGame.PlayCardAsync(thisCard); }
async Task IOtherPlayerProcess.SelectCardAsync(int deck) { if (_gameContainer.SingleInfo !.CanSendMessage(_gameContainer.BasicData !) == true) { await _gameContainer.Network !.SendAllAsync("cardselected", deck); } if (_gameContainer !.OtherPlayer !.PlayerCategory == EnumPlayerCategory.Self) { _model.PlayerHand1 !.SelectOneFromDeck(deck); if (_gameContainer.Test !.NoAnimations == false) { await _gameContainer.Delay !.DelaySeconds(.75); } } _gameContainer.OtherPlayer.MainHandList.RemoveObjectByDeck(deck); var thisCard = _gameContainer.DeckList !.GetSpecificItem(deck); thisCard.IsUnknown = false; thisCard.IsSelected = false; SortOtherCards(); _gameContainer.SingleInfo !.MainHandList.Add(thisCard); if (_gameContainer.SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { thisCard.Drew = true; if (_gameContainer.SortCards == null) { throw new BasicBlankException("Nobody is handling sort cards. Rethink"); } _gameContainer.SortCards.Invoke(); } _gameContainer.SaveRoot !.AlreadyChoseOne = true; await _gameContainer.ContinueTurnAsync !.Invoke(); }
private async Task YourDefensePile_BoardClickedAsync() { if (_gameContainer !.OtherTurn > 0) { return; } if (_mainGame !.SingleInfo !.MainHandList.HasSelectedObject() == false) { return; } if (_mainGame.SingleInfo.DefenseList.HasSelectedObject() == true) { await UIPlatform.ShowMessageAsync("Cannot choose any defense cards on the board to add more defense cards"); return; } var tempDefenseList = _mainGame.SingleInfo.MainHandList.GetSelectedItems(); if (await _mainGame.CanPlayDefenseCardsAsync(tempDefenseList) == false) { return; } if (_mainGame.BasicData !.MultiPlayer == true) { await _mainGame.Network !.SendAllAsync("addtodefense", tempDefenseList.GetDeckListFromObjectList()); } tempDefenseList.UnselectAllObjects(); await _mainGame.AddCardsToDefensePileAsync(tempDefenseList); //hopefully this is correct. }
private async Task MainDefense1_BoardClickedAsync() { if (_gameContainer !.OtherTurn == 0) { throw new BasicBlankException("Should not have allowed the click for main defense because not the other turn to defend themselves"); } if (_mainGame !.SingleInfo !.MainHandList.HasSelectedObject() == false && _mainGame.SingleInfo.DefenseList.HasSelectedObject() == false) { await UIPlatform.ShowMessageAsync("Must choose at least a card from defense or at least a card from hand"); return; } if (_mainGame.SingleInfo.MainHandList.HasSelectedObject() && _mainGame.SingleInfo.DefenseList.HasSelectedObject()) { await UIPlatform.ShowMessageAsync("Cannot choose cards from both from hand and from defense piles"); return; } bool fromHand; DeckRegularDict <RegularSimpleCard> tempDefenseList; if (_mainGame.SingleInfo.MainHandList.HasSelectedObject()) { fromHand = true; tempDefenseList = _mainGame.SingleInfo.MainHandList.GetSelectedItems(); } else { fromHand = false; tempDefenseList = _mainGame.SingleInfo.DefenseList.GetSelectedItems(); if (tempDefenseList.Any(items => items.Color == EnumColorList.Red)) { throw new BasicBlankException("No red attack cards should have even been put to defense pile"); } } if (await _mainGame.CanPlayDefenseCardsAsync(tempDefenseList) == false) { return; } if (_model.MainDefense1 !.CanAddDefenseCards(tempDefenseList) == false) { await UIPlatform.ShowMessageAsync("This defense is not enough to prevent a goal from the attacker"); return; } if (_mainGame.BasicData !.MultiPlayer == true) { var deckList = tempDefenseList.GetDeckListFromObjectList(); if (fromHand == true) { await _mainGame.Network !.SendAllAsync("defensehand", deckList); } else { await _mainGame.Network !.SendAllAsync("defenseboard", deckList); } } tempDefenseList.UnselectAllObjects(); await _mainGame.PlayDefenseCardsAsync(tempDefenseList, fromHand); }
private void SetUpTeamPiles() { _mainGame !.SingleInfo = _gameContainer.PlayerList !.GetSelf(); if (_gameContainer.SingleInfo !.MainHandList.Any(items => items.CompleteCategory == EnumCompleteCategories.None)) { throw new BasicBlankException("Cannot have category of none. Rethink"); } _pileStack !.Children.Clear(); _gameContainer.TeamList.ForEach(thisTeam => { Grid tempGrid = new Grid(); tempGrid.Margin = new Thickness(0, 0, 0, 20); AddAutoRows(tempGrid, 2); AddAutoColumns(tempGrid, 2); TextBlock ThisLabel = new TextBlock(); ThisLabel.Text = thisTeam.Text; ThisLabel.Foreground = Brushes.Aqua; ThisLabel.FontWeight = FontWeights.Bold; AddControlToGrid(tempGrid, ThisLabel, 0, 0); Grid.SetColumnSpan(ThisLabel, 2); ThisLabel.HorizontalAlignment = HorizontalAlignment.Center; // try this BasicMultiplePilesWPF <MillebournesCardInformation, MillebournesGraphicsCP, CardGraphicsWPF> thisDis = new BasicMultiplePilesWPF <MillebournesCardInformation, MillebournesGraphicsCP, CardGraphicsWPF>(); thisDis.Init(thisTeam.CardPiles, ""); thisDis.StartAnimationListener("team" + thisTeam.TeamNumber); AddControlToGrid(tempGrid, thisDis, 1, 0); SafetiesWPF thisS = new SafetiesWPF(); thisS.Init(thisTeam, _mainGame, _gameContainer.Command); _disList.Add(thisDis); AddControlToGrid(tempGrid, thisS, 1, 1); _pileStack.Children.Add(tempGrid); }); }
private int ScorePlayer() { int nums = SingleInfo !.MainHandList.Sum(items => ScoreCard(items)); int temps = SingleInfo.TempSets.Sum(items => ScoreCard(items)); return(nums + temps); }
public CustomBasicList <YahtzeeResults> GetResults() { var tempComboList = _model !.ComboHandList !.HandList.ToRegularDeckDict(); var otherList = SingleInfo !.MainHandList.GetInterfaceList(); return(_yatz.GetResults(tempComboList, otherList)); }
public bool ForceSatisfy() { if (_model.TrainStation1 !.NeedDouble(out int numberNeeded) == false) { return(false); } if (SaveRoot !.CurrentPlayerDouble == true) { return(false); } if (numberNeeded < 0) { throw new BasicBlankException("The number neeed has to at least be 0"); } foreach (var thisPlayer in PlayerList !) { if (thisPlayer.ObjectCount < 5 && WhoTurn != thisPlayer.Id) { return(false); } } DeckRegularDict <MexicanDomino> tempList = SingleInfo !.MainHandList.ToRegularDeckDict(); tempList.AddRange(SingleInfo.LongestTrainList); return(tempList.Any(items => items.FirstNum == numberNeeded || items.SecondNum == numberNeeded)); }
private Task YourDefensePile_ObjectClickedAsync(RegularSimpleCard thisObject, int index) { if (_mainGame !.SingleInfo !.MainHandList.HasSelectedObject() == true) { return(Task.CompletedTask); } thisObject.IsSelected = !thisObject.IsSelected; return(Task.CompletedTask); }
public static DeckRegularDict <FluxxCardInformation> CardsToDiscardFromHand(FluxxGameContainer gameContainer, int howMany) { if (howMany <= 0) { throw new BasicBlankException("Must discard at least one card from hand"); } return(gameContainer.SingleInfo !.MainHandList.GetRandomList(false, howMany).ToRegularDeckDict()); }
protected override async Task ComputerTurnAsync() { if (Test !.NoAnimations == false) { await Delay !.DelaySeconds(.75); } SingleInfo = PlayerList !.GetWhoPlayer(); //just in case the turn is wrong for that player. can't take any chances. var thisCard = _model !.Pile1 !.GetCardInfo(); if (thisCard.Instructions == EnumInstructionList.Flip) { if (BasicData !.MultiPlayer) { await Network !.SendAllAsync("flipdeck"); } await FlipDeckAsync(); return; } if (thisCard.Instructions == EnumInstructionList.Cut) { await CutDeckAsync(); return; } if (_gameContainer.AlreadyDrew == true) { thisCard = SingleInfo !.MainHandList.Single(items => items.Drew); if (CanPlay(thisCard.Deck)) { await ProcessPlayAsync(thisCard.Deck); //hopefully okay. return; } if (BasicData !.MultiPlayer == true) { await Network !.SendEndTurnAsync(); } await EndTurnAsync(); return; } int decks = ComputerToPlay(); if (decks > 0) { await ProcessPlayAsync(decks); return; } SingleInfo !.MainHandList.UnhighlightObjects(); //so the computer knows which is the last one drawn. if (BasicData !.MultiPlayer == true) { await Network !.SendDrawAsync(); //i think. } await DrawAsync(); }
protected override async Task ComputerTurnAsync() { if (Test !.NoAnimations == false) { await Delay !.DelaySeconds(.75); } var moveList = SingleInfo !.MainHandList.Where(items => IsValidMove(items.Deck)).ToRegularDeckDict(); await PlayCardAsync(moveList.GetRandomItem().Deck); }
protected override async Task ComputerTurnAsync() { if (OtherTurn > 0) { await PassAsync(); return; } await DiscardAsync(SingleInfo !.MainHandList.GetRandomItem(true).Deck); //hopefully is not forced to remove that card from hand (?) }
private void PutBackHand(int decks) { var thisDomino = _mainGame !.SingleInfo !.MainHandList.GetSpecificItem(decks); _viewModel.PrivateTrain1 !.HandList.Add(thisDomino); _mainGame.SingleInfo.LongestTrainList.Add(thisDomino); thisDomino.IsSelected = false; _mainGame.SingleInfo.MainHandList.RemoveObjectByDeck(decks); _viewModel.UpdateCount(_mainGame.SingleInfo); }
private int ComputerToPlay() { var thisList = SingleInfo !.MainHandList.Where(items => CanPlay(items.Deck)).ToRegularDeckDict(); if (thisList.Count == 0) { return(0); } return(thisList.GetRandomItem().Deck); }
private DeckRegularDict <RegularSimpleCard> CardsForAttack() { if (_gameContainer.GetAttackStage == null) { throw new BasicBlankException("Nobody is handling get attack stage for computer ai. Rethink"); } var possibleList = _gameContainer.SingleInfo !.MainHandList.PossibleCombinations(EnumColorList.Red); var thisItem = possibleList.OrderByDescending(items => _gameContainer.GetAttackStage(items)).ThenByDescending(items => items.DistinctCount(temps => temps.Value)).Take(1).Single(); //hopefully using distinct count works. return(new DeckRegularDict <RegularSimpleCard>(thisItem)); }
private DeckRegularDict <RegularSimpleCard> CardsForFirstDefense() { if (_gameContainer.GetDefenseStage == null) { throw new BasicBlankException("Nobody is handling get defense stage for computer ai. Rethink"); } var thisList = _gameContainer.SingleInfo !.MainHandList.PossibleCombinations(EnumColorList.Black); var firstItem = thisList.OrderByDescending(items => _gameContainer.GetDefenseStage(items)).ThenByDescending(items => items.Sum(temps => (int)temps.Value)).Take(1).Single(); return(new DeckRegularDict <RegularSimpleCard>(firstItem)); }
public async Task AddToSetAsync(int whatSet, int deck, int position) { RummySet thisSet = _model !.MainSets1 !.GetIndividualSet(whatSet); SingleInfo !.MainHandList.RemoveObjectByDeck(deck); RegularRummyCard thisCard = _gameContainer.DeckList !.GetSpecificItem(deck); thisSet.AddCard(thisCard, position); UpdatePoints(); await ContinueTurnAsync(); }
public async Task ProcessPlayAsync(int deck1, int deck2) { SingleInfo !.MainHandList.RemoveObjectByDeck(deck1); RegularSimpleCard secondCard = SingleInfo.MainHandList.RemoveObjectByDeck(deck2); SingleInfo.Pairs++; secondCard.IsSelected = false; secondCard.Drew = false; if (_model !.Pile1 !.CardExist(secondCard.Deck) == false) { _model.Pile1.AddCard(secondCard); }
//anything else needed is here. protected override bool CanEnableDeck() { if (NeedsSpecial == true) { return(false); //otherwise, can't compile. } if (_mainGame !.SingleInfo !.MainHandList.Any(items => _mainGame.CanPlay(items.Deck)) && _mainGame.Test !.AllowAnyMove == false) { return(false); } return(!_gameContainer.AlreadyDrew); }
public async Task CreateNewSetAsync(IDeckDict <RegularRummyCard> thisCol, EnumWhatSets setType, bool useSecond) { DeckRegularDict <RegularRummyCard> newCol = new DeckRegularDict <RegularRummyCard>(); thisCol.ForEach(ThisCard => newCol.Add(SingleInfo !.MainHandList.GetSpecificItem(ThisCard.Deck))); SingleInfo !.MainHandList.RemoveGivenList(newCol, System.Collections.Specialized.NotifyCollectionChangedAction.Remove); RummySet thisSet = new RummySet(_gameContainer !); thisSet.CreateNewSet(thisCol, setType, useSecond); _model !.MainSets1 !.CreateNewSet(thisSet); UpdatePoints(); await ContinueTurnAsync(); }
public async Task PlayDominoAsync(int deck, int whichOne) { if (SingleInfo !.CanSendMessage(BasicData !)) { PlayInfo thisPlay = new PlayInfo(); thisPlay.Deck = deck; thisPlay.WhichOne = whichOne; await Network !.SendAllAsync("play", thisPlay); } SimpleDominoInfo thisDomino = SingleInfo !.MainHandList.GetSpecificItem(deck); await PlayDominoAsync(thisDomino, whichOne); }
public override async Task DiscardAsync(RackoCardInformation thisCard) { var newCard = _model !.OtherPile !.GetCardInfo(); newCard.WillKeep = thisCard.WillKeep; if (thisCard.Deck == newCard.Deck) { throw new BasicBlankException("Cannot be duplicate for discard. Rethink"); } if (SingleInfo !.MainHandList.Contains(thisCard) == true) { thisCard = SingleInfo.MainHandList.GetSpecificItem(thisCard.Deck); }
private async Task TrainClickedAsync(int index) { CommandContainer.StartExecuting(); int decks = DominoSelected(out bool train); if (decks == 0) { await UIPlatform.ShowMessageAsync("Sorry, must have one domino selected to put on the pile"); CommandContainer.StopExecuting(); CommandContainer.ManualReport(); return; } MexicanDomino thisDomino; if (train) { thisDomino = _viewModel.PrivateTrain1 !.HandList.GetSpecificItem(decks); } else { thisDomino = _viewModel.PlayerHand1.HandList.GetSpecificItem(decks); } if (_viewModel.TrainStation1 !.CanPlacePiece(thisDomino, index) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); CommandContainer.StopExecuting(); return; } if (_mainGame.BasicData !.MultiPlayer) { SendPlay output = new SendPlay(); output.Deck = decks; output.Section = index; await _mainGame.Network !.SendAllAsync("dominoplayed", output); } if (train) { _mainGame !.SingleInfo !.LongestTrainList.RemoveObjectByDeck(decks); _viewModel.PrivateTrain1 !.HandList.RemoveObjectByDeck(decks); } else { _mainGame !.SingleInfo !.MainHandList.RemoveObjectByDeck(decks); } _viewModel.UpdateCount(_mainGame.SingleInfo !); await _viewModel.TrainStation1.AnimateShowSelectedDominoAsync(index, thisDomino, _mainGame); //hopefully this simple. CommandContainer.StopExecuting(); //try this as well. }
public DeckRegularDict <MonopolyCardGameCardInformation> GetSelectedItems => HandList.GetSelectedItems(); //hopefully this simple public void GetNumberOfItems(int howMany) { howMany.Times(x => { var thisCard = HandList.Last(); thisCard.Drew = true; HandList.RemoveSpecificItem(thisCard); _gameContainer.SingleInfo !.MainHandList.Add(thisCard); }); if (_gameContainer.SingleInfo !.PlayerCategory == EnumPlayerCategory.Self) { _gameContainer.SingleInfo.MainHandList.Sort(); } }
public void SortOtherCards() { DeckRegularDict <RegularSimpleCard> output = new DeckRegularDict <RegularSimpleCard>(); _gameContainer !.OtherPlayer !.MainHandList.ForEach(thisCard => { RegularSimpleCard newCard = new RegularSimpleCard(); newCard.Populate(thisCard.Deck); newCard.IsUnknown = true; output.Add(newCard); }); output.ShuffleList(); _model.OpponentCards1 !.HandList.ReplaceRange(output); }
public MoveInfo MoveToMake() { CustomBasicList <MoveInfo> newList = new CustomBasicList <MoveInfo>(); _gameContainer.SingleInfo !.MainHandList.ForEach(thisCard => { newList.AddRange(MoveList(thisCard.Deck)); MoveInfo thisMove = new MoveInfo(); thisMove.ToDiscard = true; thisMove.Deck = thisCard.Deck; newList.Add(thisMove); }); return(newList.GetRandomItem()); }
public override bool CanEndTurn() { var thisCard = _model.Pile1 !.GetCardInfo(); if (thisCard.Instructions == EnumInstructionList.Flip || thisCard.Instructions == EnumInstructionList.Cut) { return(false); } if (_mainGame !.SingleInfo !.MainHandList.Any(items => _mainGame.CanPlay(items.Deck))) { return(false); } return(_gameContainer.AlreadyDrew); }