Exemplo n.º 1
0
        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
        }
Exemplo n.º 2
0
        public void CreateSet(IDeckDict <TileInfo> thisCol, EnumWhatSets whatType)
        {
            _setType = whatType;
            _isNew   = true;
            TileRummySaveInfo saveRoot = cons !.Resolve <TileRummySaveInfo>();

            if (thisCol.Count == 0)
            {
                throw new BasicBlankException("There must be at least one item to create a new set");
            }
            foreach (var tempTile in thisCol)
            {
                saveRoot.TilesFromField.RemoveSpecificItem(tempTile.Deck);// if not there, ignore
            }
            if (_setType == EnumWhatSets.Kinds)
            {
                HandList.ReplaceRange(thisCol);
                return;
            }
            var wildCol = GetWildList(thisCol);
            int VeryFirst;

            VeryFirst = thisCol.First().Number;
            int veryLast;

            veryLast = thisCol.Last().Number;
            int firstNum;
            int lastNum;

            firstNum = VeryFirst;
            lastNum  = veryLast;
            int x;
            int y;
            int WildNum = default;

            y = 1;
            var loopTo = thisCol.Count;

            for (x = 2; x <= loopTo; x++)
            {
                y        += 1;
                firstNum += 1;
                var thisTile = thisCol[y - 1];
                if (thisTile.Number != firstNum)
                {
                    WildNum        += 1;
                    thisTile        = wildCol[WildNum - 1];
                    thisTile.Number = firstNum;
                    if (thisTile.Number == 14)
                    {
                        thisTile.Number = VeryFirst - 1;
                    }
                    y -= 1;
                }
            }
            var Temps = (from items in thisCol
                         orderby items.Number
                         select items).ToList();

            HandList.ReplaceRange(Temps);
        }
        //private readonly BasicData _thisData;
        public void CreateSet(IDeckDict <Phase10CardInformation> thisCol, EnumWhatSets whatType)
        {
            _whatSet = whatType;
            thisCol.ForEach(items =>
            {
                items.Drew       = false;
                items.IsSelected = false;
            });
            if (_whatSet != EnumWhatSets.Runs)
            {
                HandList.ReplaceRange(thisCol);
                return;
            }
            DeckRegularDict <Phase10CardInformation> tempList = thisCol.ToRegularDeckDict();
            DeckRegularDict <Phase10CardInformation> wildCol  = thisCol.Where(items => items.CardCategory == EnumCardCategory.Wild).ToRegularDeckDict();

            thisCol.KeepConditionalItems(items => items.CardCategory == EnumCardCategory.None);
            int firstNum  = thisCol.First().Number;
            int whatFirst = firstNum;
            int lastNum   = thisCol.Last().Number;
            int x;
            var loopTo = thisCol.Count;
            Phase10CardInformation thisCard;

            for (x = 2; x <= loopTo; x++)
            {
                firstNum += 1;
                thisCard  = thisCol[x - 1];
                if (thisCard.Number != firstNum)
                {
                    thisCard        = wildCol.First();
                    thisCard.Number = firstNum; // will put back when new round (?)
                    wildCol.RemoveSpecificItem(thisCard);
                    x -= 1;
                }
            }
            if (wildCol.Count > 0)
            {
                lastNum += 1;
                for (x = lastNum; x <= 11; x++)
                {
                    if (wildCol.Count == 0)
                    {
                        break;
                    }
                    thisCard        = wildCol.First();
                    thisCard.Number = x;
                    wildCol.RemoveSpecificItem(thisCard);
                }
                whatFirst -= 1;
                for (x = whatFirst; x >= 2; x += -1)
                {
                    if (wildCol.Count == 0)
                    {
                        break;
                    }
                    thisCard        = wildCol.First();
                    thisCard.Number = x;
                    wildCol.RemoveSpecificItem(thisCard);
                }
            }
            var Fins = tempList.OrderBy(Items => Items.Number);

            HandList.ReplaceRange(Fins);
        }