Ejemplo n.º 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}");
            }
        }
Ejemplo n.º 2
0
        public async Task CompletePhaseAsync()
        {
            bool rets;

            rets = _mainGame !.DidCompletePhase(out int Manys);
            if (Manys == _model.TempSets !.TotalObjects + _mainGame.SingleInfo !.MainHandList.Count)
            {
                await UIPlatform.ShowMessageAsync("Cannot complete the phase.  Otherwise; there is no card to discard");

                return;
            }
            if (rets == false)
            {
                await UIPlatform.ShowMessageAsync("Sorry, you did not complete the phase");

                return;
            }
            var thisCol = _mainGame.ListValidSets();

            if (thisCol.Count > 2)
            {
                throw new BasicBlankException("Can not have more than 2 sets");
            }
            CustomBasicList <string> newList = new CustomBasicList <string>();
            await thisCol.ForEachAsync(async thisTemp =>
            {
                if (_mainGame.BasicData !.MultiPlayer == true)
                {
                    SendNewSet thisSend   = new SendNewSet();
                    thisSend.CardListData = await js.SerializeObjectAsync(thisTemp.CardList.GetDeckListFromObjectList());
                    thisSend.WhatSet      = thisTemp.WhatSet;
                    string newStr         = await js.SerializeObjectAsync(thisSend);
                    newList.Add(newStr);
                }
                _mainGame.CreateNewSet(thisTemp);
            });

            if (_mainGame.BasicData !.MultiPlayer == true)
            {
                await _mainGame.Network !.SendSeveralSetsAsync(newList, "phasecompleted");
            }
            await _mainGame.ProcessCompletedPhaseAsync();
        }
Ejemplo n.º 3
0
        public async Task CreateSetAsync()
        {
            var thisCol = _model.PlayerHand1.ListSelectedObjects();

            if (thisCol.Count == _model.PlayerHand1.HandList.Count)
            {
                await UIPlatform.ShowMessageAsync("Sorry, you must have one card left over to discard");

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

                return;
            }
            if (_mainGame !.IsValidRummy(thisCol, out EnumWhatSets settype, out bool seconds) == false)
            {
                await UIPlatform.ShowMessageAsync("This is not a valid rummy");

                _model.PlayerHand1.UnselectAllObjects();
                return;
            }
            if (thisCol.Count == 1)
            {
                if (thisCol.Single().Deck == _gameContainer.PreviousCard)
                {
                    await UIPlatform.ShowMessageAsync("Sorry, since the last card left is the card picked up, then cannot put down the rummy");

                    return;
                }
            }
            if (_gameContainer.BasicData !.MultiPlayer == true)
            {
                SendNewSet thisNew = new SendNewSet();
                thisNew.DeckList  = thisCol.GetDeckListFromObjectList();
                thisNew.SetType   = settype;
                thisNew.UseSecond = seconds;
                await _gameContainer.Network !.SendAllAsync("newset", thisNew);
            }
            await _mainGame.CreateNewSetAsync(thisCol, settype, seconds);
        }