Task IHandleAsync <LoadEventModel> .HandleAsync(LoadEventModel message)
        {
            GamePackageViewModelBinder.ManuelElements.Clear();             //often times i have to add manually.

            TileRummySaveInfo save = cons !.Resolve <TileRummySaveInfo>(); //usually needs this part for multiplayer games.

            _score !.LoadLists(save.PlayerList);                           // the data should come from the playeritem.
            _hand1 !.LoadList(_model !.PlayerHand1 !, "");
            _model.Pool1 !.MaxSize = new SKSize(1000, 1000);
            _model.Pool1.ScatterPieces();
            _pool1 !.LoadList(_model.Pool1, "");
            _tempG !.Init(_model.TempSets !, "");
            _mainG !.Init(_model.MainSets1 !, "");

            return(this.RefreshBindingsAsync(_aggregator));
        }
        public bool PlayedAtLeastOneFromHand()
        {
            CustomBasicList <int> tempList = new CustomBasicList <int>();

            SetList.ForEach(thisTemp =>
            {
                thisTemp.HandList.ForEach(thisTile =>
                {
                    tempList.Add(thisTile.Deck);
                });
            });
            TileRummySaveInfo saveRoot = cons !.Resolve <TileRummySaveInfo>();

            foreach (var thisIndex in saveRoot.YourTiles)
            {
                if (tempList.Any(items => items == thisIndex))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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);
        }