public DeckRegularDict <TileInfo> GetSelectedList() { DeckRegularDict <TileInfo> output = new DeckRegularDict <TileInfo>(); var thisList = _model !.PlayerHand1 !.ListSelectedObjects(); output.AddRange(thisList); var newList = _model.TempSets !.ListSelectedObjects(); output.AddRange(newList); return(output); }
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)); }
public static void ScrambleKeepers(this PlayerCollection <FluxxPlayerItem> playerList) { var thisList = playerList.Where(items => items.KeeperList.Count > 0).Select(items => items.KeeperList.Count).ToCustomBasicList(); if (thisList.Count < 2) { throw new BasicBlankException("Cannot scramble the keepers"); } var firstKeeperTempList = playerList.Select(items => items.KeeperList).ToCustomBasicList(); DeckRegularDict <KeeperCard> output = new DeckRegularDict <KeeperCard>(); firstKeeperTempList.ForEach(thisItem => output.AddRange(thisItem)); output.ShuffleList(); if (output.Count != thisList.Sum(items => items)) { throw new BasicBlankException("Numbers don't match"); } playerList.ForEach(thisPlayer => { int nums = thisList[thisPlayer.Id - 1]; //because 0 based thisPlayer.KeeperList.ReplaceRange(output.Take(nums)); if (thisPlayer.KeeperList.Count != thisList[thisPlayer.Id - 1]) { throw new BasicBlankException("Numbers don't match"); } output = output.Skip(nums).ToRegularDeckDict(); }); }
private int CalculatePoints(DominosMexicanTrainPlayerItem thisPlayer) { DeckRegularDict <MexicanDomino> tempList = thisPlayer.MainHandList.ToRegularDeckDict(); tempList.AddRange(thisPlayer.LongestTrainList); return(tempList.Sum(items => items.Points)); }
private int HowManyPairs(IDeckDict <CribbageCard> thisCol) { var newCol = thisCol.ToRegularDeckDict(); int output = 0; CribbageCard newCard; DeckRegularDict <CribbageCard> finals = new DeckRegularDict <CribbageCard>(); newCol.Add(StartCard()); newCol.RemoveAllOnly(items => items.HasUsed); var whatNewRummy = _rummys !.WhatNewRummy(newCol, 2, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false); if (whatNewRummy.Count == 0) { return(0); } if (whatNewRummy.Count > 2) { finals.AddRange(newCol); newCard = whatNewRummy.First(); finals.KeepConditionalItems(items => items.Value != newCard.Value); newCol.Clear(); newCol.AddRange(finals); whatNewRummy = _rummys.WhatNewRummy(newCol, 2, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false); if (whatNewRummy.Count == 0) { return(0); } finals.Clear(); } output++; newCard = whatNewRummy.First(); finals.Clear(); finals.AddRange(newCol); finals.KeepConditionalItems(items => items.Value != newCard.Value); //i think newCol.Clear(); newCol.AddRange(finals); whatNewRummy = _rummys.WhatNewRummy(newCol, 2, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false); if (whatNewRummy.Count == 0) { return(output); } if (whatNewRummy.Count > 2) { return(output); } return(output + 1); }
public DeckRegularDict <RegularRummyCard> AppendDiscardList(IDeckDict <RegularRummyCard> thisCol) { DeckRegularDict <RegularRummyCard> output = new DeckRegularDict <RegularRummyCard>(); output.AddRange(thisCol); output.AddRange(SingleInfo !.MainHandList); return(output); }
public DeckRegularDict <D> GetPlayerCards() { var firstList = PlayerList.Select(Items => Items.MainHandList).ToCustomBasicList(); DeckRegularDict <D> output = new DeckRegularDict <D>(); firstList.ForEach(items => output.AddRange(items)); return(output); }
public DeckRegularDict <R> ListAllObjects() { DeckRegularDict <R> output = new DeckRegularDict <R>(); SetList.ForEach(thisTemp => { output.AddRange(thisTemp.HandList); }); return(output); }
public DeckRegularDict <R> ListSelectedObjects(bool alsoRemove = false) { DeckRegularDict <R> output = new DeckRegularDict <R>(); SetList.ForEach(thisTemp => { output.AddRange(thisTemp.ListSelectedObjects(alsoRemove)); }); if (alsoRemove == true) { PublicCount(); } return(output); }
public int Find15Combos(IDeckDict <CribbageCard> thisCol) { DeckRegularDict <CribbageCard> newCol = new DeckRegularDict <CribbageCard>(); newCol.AddRange(thisCol); newCol.Add(StartCard()); int firstNumber; int secondNumber; int output = 0; CribbageCard secondCard; int x = 0; newCol.ForEach(firstCard => { if (firstCard.Value >= EnumCardValueList.Ten) { firstNumber = 10; } else { firstNumber = (int)firstCard.Value; } var loopTo = newCol.Count - 1; // because 0 based for (int y = x + 1; y <= loopTo; y++) { secondCard = newCol[y]; if (secondCard.Value >= EnumCardValueList.Ten) { secondNumber = 10; } else { secondNumber = (int)secondCard.Value; } if (firstNumber + secondNumber == 15) { output++; } } x += 1; }); return(output); }
public bool HadProperKind(IDeckDict <CribbageCard> thisCol, CribbageCombos thisCombo) { var newCol = thisCol.ToRegularDeckDict(); DeckRegularDict <CribbageCard> finals = new DeckRegularDict <CribbageCard>(); newCol.Add(StartCard()); finals.AddRange(newCol); finals.KeepConditionalItems(items => items.HasUsed == false); newCol.Clear(); newCol.AddRange(finals); var whatNewRummy = _rummys !.WhatNewRummy(newCol, thisCombo.NumberForKind, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false); if (whatNewRummy.Count == 0) { return(false); } if (whatNewRummy.Count > thisCombo.NumberForKind) { return(false); } whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true); return(true); }
public bool HasInitialSets(out CustomBasicList <TempInfo> newList) { IDeckDict <TileInfo> tempCollection; //hopefully still works (?) DeckRegularDict <TileInfo> thisCollection; newList = new CustomBasicList <TempInfo>(); int totalPoints = 0; for (int x = 1; x <= 4; x++) { tempCollection = WhatSet(x); thisCollection = new DeckRegularDict <TileInfo>(); if (tempCollection.Count > 0) { thisCollection.AddRange(tempCollection); } if (HasValidSet(thisCollection, out int firsts, out int seconds)) { TempInfo thisTemp = new TempInfo(); thisTemp.CardList = thisCollection; totalPoints += thisTemp.CardList.Sum(items => items.Points); thisTemp.TempSet = x; if (firsts == -1) { thisTemp.WhatSet = EnumWhatSets.Kinds; } else { thisTemp.WhatSet = EnumWhatSets.Runs; thisTemp.FirstNumber = firsts; thisTemp.SecondNumber = seconds; } newList.Add(thisTemp); } } return(totalPoints >= 30); //brenden said the total points has to be 30 or over for the initial sets. }
protected override void AfterShuffleCards() { var firstKing = CardList.First(items => items.Value == EnumCardValueList.King); var thisList = new DeckRegularDict <SolitaireCard> { firstKing }; CardList !.RemoveSpecificItem(firstKing); var nextKing = CardList.First(items => items.Value == EnumCardValueList.King && items.Color == firstKing.Color); CardList.RemoveSpecificItem(nextKing); thisList.Add(nextKing); var nextList = CardList.Where(items => items.Value == EnumCardValueList.LowAce && items.Color != firstKing.Color).ToRegularDeckDict(); CardList.RemoveGivenList(nextList); thisList.AddRange(nextList); if (thisList.Count != 4) { throw new BasicBlankException("Must have 4 cards for foundation"); } AfterShuffle(thisList); CardList.Clear(); }
public DeckRegularDict <MonasteryCardInfo> NeedList(int position) { var thisCard = HandList.First(); if (thisCard.Value == EnumCardValueList.LowAce && _setType == EnumWhatSets.DoubleRun) { thisCard = HandList[1]; } var entireList = _gameContainer.Rummys !.EntireList; DeckRegularDict <MonasteryCardInfo> output = new DeckRegularDict <MonasteryCardInfo>(); if (_setType == EnumWhatSets.RegularSuits) { output.AddRange(entireList.Where(items => items.Suit == thisCard.Suit)); return(output); } if (_setType == EnumWhatSets.EvenOdd) { var temps = (int)thisCard.Value; bool isOdd = temps.IsNumberOdd(); output.AddRange(entireList.Where(items => { if (items.Value == EnumCardValueList.HighAce || items.Value == EnumCardValueList.LowAce) { return(true); } var xx = (int)items.Value; return(xx.IsNumberOdd() == isOdd); })); return(output); //hopefully this simple. } var numberNeeded = (int)thisCard.Value; var colorNeeded = thisCard.Color; if (_setType == EnumWhatSets.KindColor) { output.AddRange(entireList.Where(items => { if (items.Color != colorNeeded) { return(false); } var temps = (int)items.Value; if (temps == numberNeeded) { return(true); } return(items.Value == EnumCardValueList.HighAce || items.Value == EnumCardValueList.LowAce); })); return(output); } if (_setType == EnumWhatSets.RegularKinds) //colors don't matter this time. { output.AddRange(entireList.Where(items => { var temps = (int)items.Value; if (temps == numberNeeded) { return(true); } return(items.Value == EnumCardValueList.HighAce || items.Value == EnumCardValueList.LowAce); })); return(output); } void SendRunOutput(int needs) { output.AddRange(entireList.Where(items => { if (_setType == EnumWhatSets.SuitRuns && items.Suit != thisCard.Suit) { return(false); } if (_setType == EnumWhatSets.RunColors && items.Color != thisCard.Color) { return(false); } var temps = (int)items.Value; if (temps == needs) { return(true); } return(items.Value == EnumCardValueList.HighAce || items.Value == EnumCardValueList.LowAce); })); //don't return yet. } if (numberNeeded > 1 && numberNeeded < 14 && position == 1) { numberNeeded--; SendRunOutput(numberNeeded); } thisCard = HandList.Last(); numberNeeded = (int)thisCard.Value; if (numberNeeded < 13 && position == 2) { numberNeeded++; SendRunOutput(numberNeeded); } return(output); }