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 SpecialCard(DeckRegularDict <UnoCardInformation> moveList, string whatLabel) { var tempList = moveList.ToRegularDeckDict(); if (whatLabel == "Draw 2") { tempList.KeepConditionalItems(x => x.WhichType == EnumCardTypeList.Draw2); } else if (whatLabel == "Skip") { tempList.KeepConditionalItems(x => x.WhichType == EnumCardTypeList.Skip); } else if (whatLabel == "Reverse") { tempList.KeepConditionalItems(x => x.WhichType == EnumCardTypeList.Reverse); } else if (whatLabel == "Wild Draw 4") { tempList.KeepConditionalItems(x => x.Draw == 4); } else if (whatLabel == "Wild") { tempList.KeepConditionalItems(x => x.Draw == 0 && x.WhichType == EnumCardTypeList.Wild); } else { throw new BasicBlankException($"Cannot find any special card to attempt for {whatLabel}"); } if (tempList.Count == 0) { return(0); } return(tempList.GetRandomItem().Deck); }
public void LoadBarCards(IDeckDict <SnagCardGameCardInformation> thisList) { if (_wasSaved == false && thisList.Count != 5) { throw new BasicBlankException("Must have 5 cards for the bar."); } if (_wasSaved == true && thisList.Count > 5) { throw new BasicBlankException("The bar can never have more than 5 cards"); } bool rets = NeedsReverse(); if (rets == true) { thisList.Reverse(); } DeckRegularDict <SnagCardGameCardInformation> tempList = new DeckRegularDict <SnagCardGameCardInformation>(); thisList.ForEach(thisCard => { var newCard = new SnagCardGameCardInformation(); newCard.Populate(thisCard.Deck); newCard.Angle = EnumRotateCategory.RotateOnly90; tempList.Add(newCard); }); HandList.ReplaceRange(tempList); }
private async Task ReshuffleMailAsync(DeckRegularDict <MailCard> list) { await UIPlatform.ShowMessageAsync("Mail is being reshuffled"); _gameContainer.SaveRoot !.MailListLeft = list; _gameContainer.SaveRoot.OutCards.RemoveAllOnly(items => items.Deck <= 24); }
private int BonusPoints(RackoPlayerItem thisPlayer) { RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> thisInfo = new RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation>(); thisInfo.HasSecond = false; thisInfo.HasWild = false; thisInfo.NeedMatch = false; //try this too. thisInfo.LowNumber = 1; RackoDeckCount temps = MainContainer.Resolve <RackoDeckCount>(); thisInfo.HighNumber = temps.GetDeckCount(); DeckRegularDict <RackoCardInformation> tempCol = thisPlayer.MainHandList.ToRegularDeckDict(); var newColls = thisInfo.WhatNewRummy(tempCol, 6, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true); if (newColls.Count > 0) { return(400); } newColls = thisInfo.WhatNewRummy(tempCol, 5, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true); if (newColls.Count > 0) { return(200); } newColls = thisInfo.WhatNewRummy(tempCol, 4, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true); if (newColls.Count > 0) { return(100); } newColls = thisInfo.WhatNewRummy(tempCol, 3, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true); if (newColls.Count > 0) { return(50); } return(0); }
private DeckRegularDict <HeapSolitaireCardInfo> GetFirstList() { DeckRegularDict <HeapSolitaireCardInfo> output = new DeckRegularDict <HeapSolitaireCardInfo>(); EnumColorList newColor = (EnumColorList)_rs.GetRandomNumber(2); int newNumber = 7; do { if (output.Count < 13) { if (newColor == EnumColorList.Black) { newColor = EnumColorList.Red; } else { newColor = EnumColorList.Black; } var finalCard = _cardList.First(items => (int)items.Value == newNumber && items.Color == newColor); output.Add(finalCard); _cardList.RemoveSpecificItem(finalCard); if (output.Count == 13) { return(output); } newNumber++; if (newNumber > 13) { newNumber = 1; } } } while (true); }
public void AddTempCardsToCrib(DeckRegularDict <CribbageCard> thisList) { var thisScore = _model !.HandScores.Single(items => items.HandCategory == EnumHandCategory.Crib); thisList.UnhighlightObjects(); thisScore.TempList.AddRange(thisList); }
public void ProcessNewCards(DeckRegularDict <RegularRummyCard> thisCol) { if (ObjectList.Count != 8) { throw new BasicBlankException("Must have 8 cards"); } if (thisCol.Count > 2) { throw new BasicBlankException("There cannot be more than 2 new cards added"); } var newList = ObjectList.Where(items => items.Visible == false).ToRegularDeckDict(); int x = 0; newList.ForEach(oldCard => { RegularRummyCard newCard = new RegularRummyCard(); newCard.Populate(thisCol[x].Deck); TradeObject(oldCard.Deck, newCard); x++; }); if (ObjectList.Any(items => items.Visible == false)) { throw new BasicBlankException("The card was not changed. Find out what happened"); } }
public static int CardToTry(ConcentrationMainGameClass mainGame, ConcentrationVMData model) { DeckRegularDict <RegularSimpleCard> computerList = mainGame.SaveRoot !.ComputerList; DeckRegularDict <RegularSimpleCard> output; if (computerList.Count == 0) { output = model.GameBoard1 !.CardsLeft(); return(output.GetRandomItem().Deck); } output = PairToTry(computerList); if (output.Count == 0) { output = model.GameBoard1 !.CardsLeft(); return(output.GetRandomItem().Deck); } bool rets1 = model.GameBoard1 !.WasSelected(output.First().Deck); bool rets2 = model.GameBoard1.WasSelected(output.Last().Deck); if (rets1 == true && rets2 == true) { throw new BasicBlankException("Both items cannot be selected"); } if (rets1 == true) { return(output.Last().Deck); } return(output.First().Deck); }
void ILoadActionProcesses.LoadDoAgainCards() { _actionContainer.ActionCategory = EnumActionCategory.DoAgain; var firstList = _model.Pile1 !.DiscardList(); DeckRegularDict <FluxxCardInformation> secondList = new DeckRegularDict <FluxxCardInformation>(); firstList.ForEach(x => { if (x.Deck == 0) { throw new BasicBlankException("Deck cannot be 0 for load action again. Rethink"); } var card = FluxxDetailClass.GetNewCard(x.Deck); card.Populate(x.Deck); //maybe this is needed too. secondList.Add(card); }); var tempList = secondList.Where(items => items.CanDoCardAgain()).Select(items => items.Text()).ToCustomBasicList(); if (tempList.Count == 0) { throw new BasicBlankException("Must have at least one card to do again. Otherwise; can't do again"); } _actionContainer.IndexCard = -1; _actionContainer.CardList1 !.LoadTextList(tempList); }
public async Task OpenSavedGameAsync() { _opened = true; DeckList.OrderedObjects(); //i think SaveRoot = await _thisState.RetrieveSinglePlayerGameAsync <S>(); S tempRoot = SaveRoot.AutoMap <S>(); _score.Score = SaveRoot.Score; //i think. SaveRoot = tempRoot; //hopefully this simple so more efficient. //SaveRoot = await _thisState.RetrieveSinglePlayerGameAsync<S>(); //try to repeat again just in case. await _thisMod !.MainPiles1 !.LoadGameAsync(SaveRoot.MainPileData); _thisMod.MainDiscardPile !.SavedDiscardPiles(SaveRoot.Discard); await _thisMod.WastePiles1 !.LoadGameAsync(SaveRoot.WasteData); if (SaveRoot.IntDeckList.Count > 0) { var newList = SaveRoot.IntDeckList.GetNewObjectListFromDeckList(DeckList); _thisMod.DeckPile !.OriginalList(newList); } _thisMod.MainPiles1.SetSavedScore(SaveRoot.Score); //i think. CardList = DeckList.ToRegularDeckDict(); NoCardsToShuffle = false; HowManyCards = CardList.Count; await ContinueOpenSavedAsync(); //sometimes you need something else. AfterInit(); }
protected override Task StartSetUpAsync(bool isBeginning) { LoadControls(); PlayerList !.ForEach(thisPlayer => { thisPlayer.WonLastRound = ""; thisPlayer.ScoreRound = 0; thisPlayer.TotalScore = 0; }); DeckRegularDict <ComboCardInfo> tempList = new DeckRegularDict <ComboCardInfo>(); 6.Times(x => { ComboCardInfo thisCard = new ComboCardInfo(); thisCard.Populate(x); if (Test !.DoubleCheck == false || x == 6) { tempList.Add(thisCard); } }); _model !.ComboHandList !.HandList.ReplaceRange(tempList); _gameContainer.AlreadyDrew = false; SaveRoot !.ExtraTurns = 0; SaveRoot.FirstPlayerWentOut = 0; _chanceList.Clear(); 12.Times(x => { ChanceCardInfo thisCard = new ChanceCardInfo(); thisCard.Populate(x); _chanceList.Add(thisCard); }); _chanceList.ShuffleList(); return(base.StartSetUpAsync(isBeginning)); }
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 int CalculatePoints(DominosMexicanTrainPlayerItem thisPlayer) { DeckRegularDict <MexicanDomino> tempList = thisPlayer.MainHandList.ToRegularDeckDict(); tempList.AddRange(thisPlayer.LongestTrainList); return(tempList.Sum(items => items.Points)); }
public void AddSeveralCards(IDeckDict <D> whatList) { if (whatList.Count == 0) { return; } DeckRegularDict <D> newList = new DeckRegularDict <D>(); if (CurrentCard.Deck > 0) { newList.Add(CurrentCard); } CurrentCard = whatList.Last(); CurrentCard.IsUnknown = false; CurrentCard.IsSelected = false; CurrentCard.Drew = false; int x; for (x = whatList.Count - 1; x >= 1; x += -1) { whatList[x - 1].IsSelected = false; whatList[x - 1].Drew = false; // i think newList.Add(whatList[x - 1]); } _objectList.AddRange(newList); _previousNum = _objectList.Count; // i think }
private async Task ProcessPlayAsync(DeckRegularDict <RegularSimpleCard> thisCol) { if (IsValidMove(thisCol) == true) { if (Test !.NoAnimations == false) { await Delay !.DelaySeconds(1); } RemoveComputer(thisCol); _model !.GameBoard1 !.SelectedCardsGone(); SingleInfo !.Pairs++; if (_model.GameBoard1.CardsGone == true || Test.ImmediatelyEndGame == true) { await GameOverAsync(); return; } await ContinueTurnAsync(); return; } if (Test !.NoAnimations == false) { await Delay !.DelaySeconds(5); } _model !.GameBoard1 !.UnselectCards(); AddComputer(thisCol); await EndTurnAsync(); }
public void Redeal() { TempList = new DeckRegularDict <SolitaireCard>(); if (DealNumber == 3) { throw new BasicBlankException("There are only 3 deals allowed. Therefore, there is a problem"); } var thisCol = new DeckRegularDict <SolitaireCard>(); DealNumber++; Piles.PileList.ForEach(thisPile => { thisPile.CardList.ForEach(thisCard => thisCol.Add(thisCard)); }); Piles.ClearBoard(); thisCol.ShuffleList(); int y = 0; 8.Times(x => { foreach (var thisPile in Piles.PileList) { if (y == thisCol.Count) { break; } var tempCard = thisCol[y]; thisPile.CardList.Add(tempCard); y++; } }); PreviousSelected = -1; }
public virtual void LoadGame() { var tempList = OrderList.ToRegularDeckDict(); ClearBoard(); if (tempList.Count == 0) { return; } int index; int tempTurn; T lastCard; tempTurn = _gameContainer.WhoTurn; DeckRegularDict <T> otherList = new DeckRegularDict <T>(); tempList.ForEach(thisCard => { if (thisCard.Player == 0) { throw new BasicBlankException("The Player Cannot Be 0"); } _gameContainer.WhoTurn = thisCard.Player; _gameContainer.SingleInfo = _gameContainer.PlayerList !.GetWhoPlayer(); index = GetCardIndex(); lastCard = _gameContainer.GetBrandNewCard(thisCard.Deck); lastCard.Player = thisCard.Player; TradeCard(index, lastCard); otherList.Add(lastCard); //i think }); OrderList.ReplaceRange(otherList); //i think we have to do it this way this tiem. _gameContainer.WhoTurn = tempTurn; }
public int CardToPlay(CrazyEightsSaveInfo saveroot) { CrazyEightsPlayerItem player = saveroot.PlayerList.GetWhoPlayer(); DeckRegularDict <RegularSimpleCard> list = player.MainHandList.Where(x => x.Value != EnumCardValueList.Eight && x.Suit == saveroot.CurrentSuit).ToRegularDeckDict(); if (list.Count != 0) { return(list.GetRandomItem().Deck); } list = player.MainHandList.Where(x => x.Value != EnumCardValueList.Eight && x.Value == saveroot.CurrentNumber).ToRegularDeckDict(); if (list.Count == 1) { return(list.Single().Deck); } if (list.Count != 0) { return(FindBestCard(list)); } list = player.MainHandList.Where(x => x.Value == EnumCardValueList.Eight).ToRegularDeckDict(); if (list.Count != 0) { return(list.GetRandomItem().Deck); } return(0);//0 means needs to draw. }
} = true; //has to be proven false. public override async Task FinishGetSavedAsync() { LoadControls(); LoadVM(); //if (_model!.WinUI == null) // throw new BasicBlankException("You must hook up the win ui"); //if this causes problem because ui not there yet, rethink. //anything else needed is here. //SaveRoot!.LoadWin(_model.WinUI); //may require rethinking (?) PlayerList !.ForEach(thisPlayer => thisPlayer.LoadPiles(this, _model, _command)); //_model.WinUI.ShowNewCard(); //i think this time. if not, iffy. await PlayerList.ForEachAsync(async thisPlayer => { DeckRegularDict <GalaxyCardGameCardInformation> thisList = await js.DeserializeObjectAsync <DeckRegularDict <GalaxyCardGameCardInformation> >(thisPlayer.PlanetData); thisPlayer.PlanetHand !.HandList.ReplaceRange(thisList); thisPlayer.MainHandList.ForEach(thisCard => { thisCard.Visible = true; thisCard.IsUnknown = false; }); int x = thisPlayer.SavedMoonList.Count; //the first time, actually load manually. x.Times(Items => { MoonClass thisSet = new MoonClass(_command); thisPlayer.Moons !.CreateNewSet(thisSet); }); thisPlayer.Moons !.LoadSets(thisPlayer.SavedMoonList); //hopefully this works (?) }); await base.FinishGetSavedAsync(); _aTrick !.LoadGame(); }
public static DeckRegularDict <SolitaireCard> ListValidCardsAlternateColors(this IDeckDict <SolitaireCard> givenList) { int x; int previousNumber = 0; DeckRegularDict <SolitaireCard> output = new DeckRegularDict <SolitaireCard>(); EnumColorList previousColor = EnumColorList.None; for (x = givenList.Count; x >= 1; x += -1) { var thisCard = givenList[x - 1]; if (x == givenList.Count) { previousColor = thisCard.Color; previousNumber = (int)thisCard.Value; output.Add(thisCard); } else { if (previousNumber + 1 == (int)thisCard.Value && thisCard.Color != previousColor) //i think this was the problem. { output.Add(thisCard); } else { return(output); } previousNumber = (int)thisCard.Value; previousColor = thisCard.Color; } } return(output); }
public static DeckRegularDict <SolitaireCard> ListValidCardsSameSuit(this IDeckDict <SolitaireCard> givenList) { int x; int previousNumber = 0; DeckRegularDict <SolitaireCard> output = new DeckRegularDict <SolitaireCard>(); EnumSuitList previousSuit = EnumSuitList.None; for (x = givenList.Count; x >= 1; x += -1) { var thisCard = givenList[x - 1]; if (x == givenList.Count) { previousSuit = thisCard.Suit; previousNumber = (int)thisCard.Value; output.Add(thisCard); } else { if (previousNumber + 1 == (int)thisCard.Value && thisCard.Suit == previousSuit) { output.Add(thisCard); } else { return(output); } previousNumber = (int)thisCard.Value; } } return(output); }
public DeckRegularDict <RegularRummyCard> DiscardListSelected(int deck) { if (deck == 0) { throw new BasicBlankException("Deck cannot be 0 for the discard selected. Rethink"); } DeckRegularDict <RegularRummyCard> output = new DeckRegularDict <RegularRummyCard>(); bool didStart = false; HandList.ForEach(thisCard => { if (thisCard.Deck == deck) { didStart = true; } if (didStart == true) { output.Add(thisCard); } }); if (output.Count == 0) { throw new BasicBlankException("No cards for discard list. Rethink"); } return(output); }
private void ResetField() { if (SingleInfo !.PlayerCategory == EnumPlayerCategory.Self) { _model !.TempSets !.ClearBoard(); //i think } DeckRegularDict <TileInfo> tempList = new DeckRegularDict <TileInfo>(); SaveRoot !.YourTiles.ForEach(thisIndex => { var thisTile = _model !.Pool1 !.GetTile(thisIndex); tempList.Add(thisTile); }); SingleInfo.MainHandList.ReplaceRange(tempList); SaveRoot.TilesFromField.Clear(); int x = SaveRoot.BeginningList.Count; //the first time, actually load manually. _model !.MainSets1 !.SetList.Clear(); //try this way. x.Times(y => { TileSet set = new TileSet(_command, _rummys); _model.MainSets1.CreateNewSet(set); }); _model.MainSets1.LoadSets(SaveRoot.BeginningList); _model.MainSets1.RedoSets(); //i think. SingleInfo.MainHandList.ForEach(thisCard => thisCard.WhatDraw = EnumDrawType.IsNone); if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { SingleInfo.MainHandList.Sort(); } }
public DeckRegularDict <MonasteryCardInfo> EvenOddList(DeckRegularDict <MonasteryCardInfo> thisCol) { var tempCol = PopulateTempCol(thisCol, out DeckRegularDict <MonasteryCardInfo> aceList); DeckRegularDict <MonasteryCardInfo> output = new DeckRegularDict <MonasteryCardInfo>(); if (aceList.Count == 0) { return(thisCol); } if (tempCol.Count == 0) { return(aceList); } var thisCard = tempCol.First(); int numberNeeded = (int)thisCard.Value; //i like the idea that even if aces are there it will hide them even in this case. aceList.Count.Times(x => { thisCard = EntireList.First(items => items.Suit == EnumSuitList.Diamonds && (int)items.Value == numberNeeded); var nextCard = new MonasteryCardInfo(); nextCard.Populate(thisCard.Deck); nextCard.Temp = thisCard.Deck; nextCard.Deck = aceList[x - 1].Deck; //to stop the linking problems. tempCol.Add(nextCard); }); return(tempCol); }
public DeckRegularDict <MonasteryCardInfo> RunList(DeckRegularDict <MonasteryCardInfo> thisCol, EnumRunType runType) { var tempCol = PopulateTempCol(thisCol, out DeckRegularDict <MonasteryCardInfo> aceList); DeckRegularDict <MonasteryCardInfo> output = new DeckRegularDict <MonasteryCardInfo>(); var thisCard = tempCol.First(); int minNumber = (int)thisCard.Value; int maxNumber = minNumber + thisCol.Count - 1; if (maxNumber > 13) { thisCard = tempCol.Last(); maxNumber = (int)thisCard.Value; minNumber = maxNumber - thisCol.Count + 1; } EnumSuitList suitNeeded; if (runType == EnumRunType.Color) { if (thisCard.Color == EnumColorList.Red) { suitNeeded = EnumSuitList.Diamonds; } else { suitNeeded = EnumSuitList.Clubs; } } else if (runType == EnumRunType.Suit) { suitNeeded = thisCard.Suit; } else { suitNeeded = EnumSuitList.Diamonds; } int currentNum = minNumber; thisCol.Count.Times(x => { if (tempCol.Any(items => (int)items.Value == currentNum) == false) { thisCard = EntireList.First(items => items.Suit == suitNeeded && (int)items.Value == currentNum); var nextCard = new MonasteryCardInfo(); nextCard.Populate(thisCard.Deck); nextCard.Temp = thisCard.Deck; //this too i think. nextCard.Deck = aceList.First().Deck; //this is what i had to do now. aceList.RemoveFirstItem(); //has to use the deck of the ace to stop the id problems. output.Add(nextCard); } else { thisCard = tempCol.Single(items => (int)items.Value == currentNum); tempCol.RemoveSpecificItem(thisCard); output.Add(thisCard); } currentNum++; }); return(output); }
public DeckRegularDict <RegularRummyCard> AppendDiscardList(IDeckDict <RegularRummyCard> thisCol) { DeckRegularDict <RegularRummyCard> output = new DeckRegularDict <RegularRummyCard>(); output.AddRange(thisCol); output.AddRange(SingleInfo !.MainHandList); return(output); }
public bool IsValidMove(DeckRegularDict <RegularSimpleCard> thisCol) { if (Test !.AllowAnyMove == true) { return(true); } return(thisCol.First().Value == thisCol.Last().Value); }
private int FindBestCard(DeckRegularDict <RegularSimpleCard> list) { var bestsuit = list.GroupBy(x => x.Suit).OrderByDescending(Temps => Temps.Count()); var suituse = bestsuit.First().Key; list.KeepConditionalItems(Items => Items.Suit == suituse); return(list.GetRandomItem().Deck); }
public bool IsSuit(DeckRegularDict <MonasteryCardInfo> thisCol, int required) { if (thisCol.Count < required) { return(false); } return(thisCol.GroupBy(items => items.Suit).Count() == 1); }