public int PositionToPlay(Phase10CardInformation thisCard, int position)
        {
            if (thisCard.CardCategory == EnumCardCategory.Skip)
            {
                return(0);
            }
            if (thisCard.CardCategory == EnumCardCategory.Wild)
            {
                if (_whatSet != EnumWhatSets.Runs)
                {
                    return(position);
                }
                if (HandList.Count == 12)
                {
                    return(0); //this can only contain 12 at the most period.
                }
                if (HandList.First().Number == 1)
                {
                    return(2);
                }
                if (HandList.Last().Number == 12)
                {
                    return(1);
                }
                return(position);
            }
            if (_whatSet == EnumWhatSets.Colors)
            {
                EnumColorTypes thisColor = HandList.First(Items => Items.CardCategory == EnumCardCategory.None).Color;
                if (thisColor == thisCard.Color)
                {
                    return(position);
                }
                return(0); //you can't expand because wrong color.
            }
            if (_whatSet == EnumWhatSets.Kinds)
            {
                int thisNumber = HandList.First(Items => Items.CardCategory == EnumCardCategory.None).Number;
                if (thisNumber == thisCard.Number)
                {
                    return(position);
                }
                return(0); //can't expand because wrong number.
            }
            int popNumber    = HandList.First().Number;
            int bottomNumber = HandList.Last().Number;

            if (thisCard.Number == popNumber - 1)
            {
                return(1);
            }
            if (thisCard.Number == bottomNumber + 1)
            {
                return(2);
            }
            return(0);
        }
示例#2
0
        public int PositionToPlay(TileInfo thisTile, int position)
        {
            if (_setType == EnumWhatSets.Kinds)
            {
                return(position);
            }
            if (thisTile.IsJoker == true)
            {
                return(position);
            }
            int newPos;

            if (position == 1)
            {
                newPos = 2;
            }
            else
            {
                newPos = 1;
            }
            TileInfo newTile;

            if (newPos == 1)
            {
                newTile = HandList.First();
            }
            else
            {
                newTile = HandList.Last();
            }
            if (newTile.Number == 13)
            {
                return(1);
            }
            if (newTile.Number == 1)
            {
                return(2);
            }
            if (((newTile.Number + 1) == thisTile.Number) & (newPos == 2))
            {
                return(newPos);
            }
            if (newTile.Number == 1)
            {
                return(2);
            }
            if (((newTile.Number - 1) == thisTile.Number) & (newPos == 1))
            {
                return(newPos);
            }
            return(position);
        }
示例#3
0
 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();
     }
 }
        protected override bool CanSelectSingleObject(SnagCardGameCardInformation thisObject)
        {
            if (thisObject.Equals(HandList.Last()))
            {
                return(true);
            }
            if (HandList.Count() == 1)
            {
                return(false); //i think.
            }
            int index = HandList.Count - 2;

            return(thisObject.Equals(HandList[index]));
        }
        public int CardNeeded(int position)
        {
            RegularRummyCard thisCard;

            if (_setType == EnumWhatSets.kinds || position == 1)
            {
                thisCard = HandList.First();
            }
            else
            {
                thisCard = HandList.Last();
            }
            int x;

            if (_setType == EnumWhatSets.kinds)
            {
                if (HandList.Count == 4)
                {
                    return(0); //because all 4 are taken.
                }
                for (x = 1; x <= 4; x++)
                {
                    if (HandList.Any(y => y.Suit == (EnumSuitList)x) == false)
                    {
                        return(_gameContainer.DeckList.Single(y => y.Suit == (EnumSuitList)x && y.Value == thisCard.Value).Deck);
                    }
                }
                throw new BasicBlankException("Cannot find the card needed for kinds");
            }
            if (position == 1)
            {
                if (thisCard.SecondNumber == EnumCardValueList.LowAce) //since i don't know which is which.  needs to cover both cases.
                {
                    return(0);
                }
                EnumCardValueList LowerValue;
                LowerValue = thisCard.Value - 1;
                return(_gameContainer.DeckList.Single(x => x.SecondNumber == LowerValue && x.Suit == thisCard.Suit).Deck);
            }
            if (thisCard.Value == EnumCardValueList.HighAce) //has to lean towards low.  if i do something else, i risk breaking other rummy games.
            {
                return(0);                                   //because nothing higher than high ace.
            }
            EnumCardValueList higherValue = thisCard.Value + 1;

            return(_gameContainer.DeckList.Single(Items => Items.Value == higherValue && Items.Suit == thisCard.Suit).Deck); //hopefully this simple.
        }
        public bool CanExpand(GalaxyCardGameCardInformation thisCard)
        {
            var originalCard = HandList.First();

            if (WhatSet == EnumWhatSets.Kinds)
            {
                return(thisCard.Value == originalCard.Value);
            }
            if (originalCard.Suit != thisCard.Suit)
            {
                return(false);
            }
            if ((int)thisCard.Value == (int)originalCard.Value - 1)
            {
                return(true);
            }
            originalCard = HandList.Last();
            return((int)thisCard.Value == (int)originalCard.Value + 1);
        }
        public ChinazoCard CardNeeded(int position)
        {
            ChinazoCard?thisCard = null;

            if (position == 1 || _whatSet == RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Sets)
            {
                if (_whatSet == RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Sets)
                {
                    thisCard = HandList.First(items => items.IsObjectWild == false);
                }
                else
                {
                    thisCard = HandList.First();
                }
            }
            else
            {
                thisCard = HandList.Last();
            }
            if (_whatSet == RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Sets)
            {
                return(thisCard);
            }

            if (position == 1)
            {
                if (thisCard.Value == EnumCardValueList.HighAce || thisCard.Value == EnumCardValueList.LowAce)
                {
                    return(new ChinazoCard()); //because you are finished
                }
                if (thisCard.Value == EnumCardValueList.Two)
                {
                    return(_gameContainer.DeckList.First(items => items.SecondNumber == EnumCardValueList.LowAce && items.Suit == thisCard.Suit));
                }
                return(_gameContainer.DeckList.First(items => (int)items.Value == thisCard.UsedAs - 1 && items.Suit == thisCard.Suit));
            }
            if (thisCard.Value == EnumCardValueList.HighAce || thisCard.Value == EnumCardValueList.LowAce)
            {
                return(new ChinazoCard());
            }
            return(_gameContainer.DeckList.First(items => (int)items.SecondNumber == thisCard.UsedAs + 1 && items.Suit == thisCard.Suit));
        }
        public void AddCard(ChinazoCard thisCard, int position)
        {
            thisCard.IsSelected = false;
            thisCard.Drew       = false;
            int newPosition = PositionToPlay(thisCard, position);

            if (newPosition == 1)
            {
                if (_whatSet == RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Runs)
                {
                    if (thisCard.IsObjectWild == true)
                    {
                        thisCard.UsedAs = HandList.First().UsedAs - 1;
                    }
                    if (thisCard.UsedAs == 14)
                    {
                        throw new BasicBlankException("Ace cannot be used as 14 when its low.");
                    }
                    _firstNumber = thisCard.UsedAs;
                }
                HandList.InsertBeginning(thisCard);
            }
            else
            {
                if (_whatSet == RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Runs)
                {
                    if (thisCard.IsObjectWild == true)
                    {
                        thisCard.UsedAs = HandList.Last().UsedAs + 1;
                        if (thisCard.UsedAs > 14)
                        {
                            throw new BasicBlankException("Use as can never be higher than 14 ever");
                        }
                    }
                }
                HandList.Add(thisCard);
            }
            if (_whatSet == RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Runs)
            {
                RepopulateCards();
            }
        }
 public void AddCard(Phase10CardInformation thisCard, int position)
 {
     thisCard.IsSelected = false;
     thisCard.Drew       = false;
     if (position == 1)
     {
         if (_whatSet == EnumWhatSets.Runs && thisCard.CardCategory == EnumCardCategory.Wild)
         {
             thisCard.Number = HandList.First().Number - 1;
         }
         HandList.InsertBeginning(thisCard);
     }
     else
     {
         if (_whatSet == EnumWhatSets.Runs && thisCard.CardCategory == EnumCardCategory.Wild)
         {
             thisCard.Number = HandList.Last().Number + 1;
         }
         HandList.Add(thisCard);
     }
 }
示例#10
0
        public void AddTile(TileInfo thisTile, int position)
        {
            TileRummySaveInfo saveRoot = cons !.Resolve <TileRummySaveInfo>();

            thisTile.Drew       = true; // this should be okay so others can tell something was added to it.
            thisTile.IsSelected = false;
            saveRoot.TilesFromField.RemoveSpecificItem(thisTile.Deck);
            if (((int)_setType == (int)EnumWhatSets.Runs) & (thisTile.IsJoker == true))
            {
                TileInfo newTile;
                if (position == 1)
                {
                    newTile         = HandList.First();
                    thisTile.Number = newTile.Number - 1;
                    HandList.InsertBeginning(thisTile);
                }
                else
                {
                    newTile         = HandList.Last();
                    thisTile.Number = newTile.Number + 1;
                    HandList.Add(thisTile);
                }
            }
            else
            {
                HandList.Add(thisTile);
            }

            if ((int)_setType == (int)EnumWhatSets.Runs)
            {
                var TempList = (from Items in HandList
                                orderby Items.Number
                                select Items).ToList();
                HandList.ReplaceRange(TempList);
            }
        }
        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);
        }
        private MonasteryCardInfo GetCard(MonasteryCardInfo thisCard, int position)
        {
            var tempCard = HandList.First();

            if (tempCard.Value == EnumCardValueList.LowAce && _setType == EnumWhatSets.DoubleRun)
            {
                tempCard = HandList[1];
            }
            if (_setType == EnumWhatSets.RegularSuits)
            {
                return(thisCard);
            }
            if (thisCard.Value != EnumCardValueList.HighAce && thisCard.Value != EnumCardValueList.LowAce)
            {
                return(thisCard);
            }
            if (position == 1)
            {
                if (thisCard.Value == EnumCardValueList.Two)
                {
                    if (_setType == EnumWhatSets.RegularRuns || _setType == EnumWhatSets.SuitRuns || _setType == EnumWhatSets.RunColors)
                    {
                        return(thisCard);
                    }
                }
            }
            var entireList = _gameContainer.Rummys !.EntireList;

            if (_setType == EnumWhatSets.RegularKinds | _setType == EnumWhatSets.KindColor & tempCard.Color == EnumColorList.Red)
            {
                return(entireList.First(items => items.Value == tempCard.Value && items.Suit == EnumSuitList.Diamonds));
            }
            if (_setType == EnumWhatSets.KindColor)
            {
                return(entireList.First(items => items.Value == tempCard.Value && items.Suit == EnumSuitList.Clubs));
            }
            if (_setType == EnumWhatSets.EvenOdd)
            {
                int nums = (int)tempCard.Value;
                if (nums.IsNumberOdd())
                {
                    return(thisCard);
                }
                return(entireList.First(items => items.Value == tempCard.Value && items.Suit == EnumSuitList.Diamonds));
            }
            if (position == 2)
            {
                tempCard = HandList.Last();
            }
            if (_setType == EnumWhatSets.DoubleRun)
            {
                int nums = HandList.Count; //could be iffy.
                if (nums.IsNumberOdd())
                {
                    if (tempCard.Value == EnumCardValueList.LowAce || tempCard.Value == EnumCardValueList.HighAce)
                    {
                        return(thisCard);
                    }
                    return(entireList.First(items => items.Value == tempCard.Value && items.Suit == EnumSuitList.Diamonds));
                }
            }
            int numberNeeded;

            if (position == 2)
            {
                numberNeeded = (int)tempCard.Value + 1;
            }
            else
            {
                numberNeeded = (int)tempCard.Value - 1;
            }
            if (numberNeeded == 1)
            {
                return(thisCard);
            }
            EnumSuitList suitNeeded;

            if (_setType == EnumWhatSets.RegularRuns)
            {
                suitNeeded = EnumSuitList.Diamonds;
            }
            else if (_setType == EnumWhatSets.SuitRuns)
            {
                suitNeeded = tempCard.Suit;
            }
            else if (tempCard.Color == EnumColorList.Red)
            {
                suitNeeded = EnumSuitList.Diamonds;
            }
            else
            {
                suitNeeded = EnumSuitList.Clubs;
            }
            return(entireList.First(items => (int)items.Value == numberNeeded && items.Suit == suitNeeded));
        }