Beispiel #1
0
        async Task IMiscDataNM.MiscDataReceived(string status, string content)
        {
            switch (status) //can't do switch because we don't know what the cases are ahead of time.
            {
            case "pickupfromdiscard":
                await PickupFromDiscardAsync(int.Parse(content));

                break;

            case "addtoset":
                SendAddSet sendAdd = await js.DeserializeObjectAsync <SendAddSet>(content);
                await AddToSetAsync(sendAdd.Index, sendAdd.Deck, sendAdd.Position);

                break;

            case "newset":
                SendNewSet sendNew = await js.DeserializeObjectAsync <SendNewSet>(content);

                var newList = sendNew.DeckList.GetNewObjectListFromDeckList(_gameContainer.DeckList !);
                await CreateNewSetAsync(newList, sendNew.SetType, sendNew.UseSecond);

                break;

            default:
                throw new BasicBlankException($"Nothing for status {status}  with the message of {content}");
            }
        }
Beispiel #2
0
        private async Task MainSets1_SetClickedAsync(int setNumber, int section, int deck)
        {
            var newcol = _model.PlayerHand1 !.ListSelectedObjects();

            if (newcol.Count == 0)
            {
                await UIPlatform.ShowMessageAsync("There is no card selected");

                return;
            }
            if (newcol.Count > 1)
            {
                await UIPlatform.ShowMessageAsync("Only can expand one card at a time");

                return;
            }
            if (_model.PlayerHand1.HandList.Count == 1)
            {
                await UIPlatform.ShowMessageAsync("Sorry, must have a card left for discard");

                return;
            }
            if (_mainGame.NeedsExpansion(newcol))
            {
                await UIPlatform.ShowMessageAsync("Needs to use the extra card picked up first before anything else");

                return;
            }

            var      thisCard = newcol.First();
            RummySet thisSet  = _model.MainSets1 !.GetIndividualSet(setNumber);
            int      pos      = thisSet.PositionToPlay(thisCard);

            if (pos == 0)
            {
                await UIPlatform.ShowMessageAsync("This cannot be used to expand upto");

                return;
            }
            var thisCol = _model.MainSets1.SetList.ToCustomBasicList();
            int x       = 0;
            int nums    = 0;

            thisCol.ForEach(newSet =>
            {
                x++;
                if (newSet.Equals(thisSet))
                {
                    nums = x;
                }
            });
            if (nums == 0)
            {
                throw new BasicBlankException("Cannot find the rummy set that matches");
            }
            if (_gameContainer.BasicData !.MultiPlayer == true)
            {
                SendAddSet thisSend = new SendAddSet();
                thisSend.Deck     = thisCard.Deck;
                thisSend.Position = pos;
                thisSend.Index    = nums;
                await _gameContainer.Network !.SendAllAsync("addtoset", thisSend);
            }
            await _mainGame !.AddToSetAsync(nums, thisCard.Deck, pos);
        }