public async Task PlayerPileClickedAsync(MilkRunPlayerItem thisPlayer, PileInfo pileData)
        {
            int newDeck = _model !.PlayerHand1 !.ObjectSelected();

            if (newDeck == 0)
            {
                await UIPlatform.ShowMessageAsync("Sorry, must choose a card to play");

                return;
            }
            if (SaveRoot !.CardsDrawn < 2)
            {
                await UIPlatform.ShowMessageAsync("Sorry, must draw the 2 cards first before playing");

                return;
            }
            int index = thisPlayer.Id;

            if (CanMakeMove(index, newDeck, pileData.Pile, pileData.Milk) == false)
            {
                await UIPlatform.ShowMessageAsync("Illegal Move");

                return;
            }
            if (BasicData !.MultiPlayer == true)
            {
                SendPlay thisSend = new SendPlay();
                thisSend.Deck   = newDeck;
                thisSend.Player = index;
                thisSend.Milk   = pileData.Milk;
                thisSend.Pile   = pileData.Pile;
                await Network !.SendAllAsync("play", thisSend);
            }
            await ProcessPlayAsync(index, newDeck, pileData.Pile, pileData.Milk);
        }
        protected override async Task ComputerTurnAsync()
        {
            var thisMove = _ai.ComputerMove();

            if (thisMove.WillThrowAway == true && thisMove.Team > 0)
            {
                throw new BasicBlankException("The computer cannot play a card on a pile plus throw away a card");
            }
            if (thisMove.WillThrowAway == false && thisMove.Team == 0)
            {
                throw new BasicBlankException("The computer must either throw away a card or play on a pile");
            }
            if (Test !.NoAnimations == false)
            {
                await Delay !.DelaySeconds(1);
            }
            if (thisMove.WillThrowAway)
            {
                await ThrowawayCardAsync(thisMove.Deck);

                return;
            }
            if (BasicData !.MultiPlayer == true)
            {
                SendPlay thisSend = new SendPlay();
                thisSend.Deck = thisMove.Deck;
                thisSend.Pile = thisMove.WhichPile;
                thisSend.Team = thisMove.Team;
                await Network !.SendAllAsync("regularplay", thisSend);
            }
            await PlayAsync(thisMove.Deck, thisMove.WhichPile, thisMove.Team, false);
        }
        private async Task TrainClickedAsync(int index)
        {
            CommandContainer.StartExecuting();
            int decks = DominoSelected(out bool train);

            if (decks == 0)
            {
                await UIPlatform.ShowMessageAsync("Sorry, must have one domino selected to put on the pile");

                CommandContainer.StopExecuting();
                CommandContainer.ManualReport();
                return;
            }
            MexicanDomino thisDomino;

            if (train)
            {
                thisDomino = _viewModel.PrivateTrain1 !.HandList.GetSpecificItem(decks);
            }
            else
            {
                thisDomino = _viewModel.PlayerHand1.HandList.GetSpecificItem(decks);
            }
            if (_viewModel.TrainStation1 !.CanPlacePiece(thisDomino, index) == false)
            {
                await UIPlatform.ShowMessageAsync("Illegal Move");

                CommandContainer.StopExecuting();
                return;
            }
            if (_mainGame.BasicData !.MultiPlayer)
            {
                SendPlay output = new SendPlay();
                output.Deck    = decks;
                output.Section = index;
                await _mainGame.Network !.SendAllAsync("dominoplayed", output);
            }
            if (train)
            {
                _mainGame !.SingleInfo !.LongestTrainList.RemoveObjectByDeck(decks);
                _viewModel.PrivateTrain1 !.HandList.RemoveObjectByDeck(decks);
            }
            else
            {
                _mainGame !.SingleInfo !.MainHandList.RemoveObjectByDeck(decks);
            }
            _viewModel.UpdateCount(_mainGame.SingleInfo !);
            await _viewModel.TrainStation1.AnimateShowSelectedDominoAsync(index, thisDomino, _mainGame); //hopefully this simple.

            CommandContainer.StopExecuting();                                                            //try this as well.
        }
        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 "play":
                SendPlay thisSend = await js.DeserializeObjectAsync <SendPlay>(content);
                await ProcessPlayAsync(thisSend.Player, thisSend.Deck, thisSend.Pile, thisSend.Milk);

                break;

            default:
                throw new BasicBlankException($"Nothing for status {status}  with the message of {content}");
            }
        }
Ejemplo n.º 5
0
        public async Task CoupeAsync()
        {
            _model.Stops !.PauseTimer();
            await CloseCoupeAsync();

            _gameContainer !.SingleInfo = _gameContainer.PlayerList !.GetSelf();
            _gameContainer.CurrentCP    = _gameContainer.FindTeam(_gameContainer.SingleInfo.Team);
            bool     rets = _mainGame.HasCoupe(out int newDeck);
            SendPlay thisSend;

            if (rets == false)
            {
                await UIPlatform.ShowMessageAsync("No Coup Foures Here");

                if (_gameContainer.BasicData !.MultiPlayer == true)
                {
                    thisSend        = new SendPlay();
                    thisSend.Player = _gameContainer.SingleInfo.Id;
                    thisSend.Team   = _gameContainer.SingleInfo.Team;
                    await _gameContainer.Network !.SendAllAsync("nocoupe", thisSend); //looks like multiplayer has a bug with no coupe.  has to be fixed.
                }
                _gameContainer.CurrentCP.IncreaseWrongs();
                _mainGame.UpdateGrid(_gameContainer.SingleInfo.Team);
                if (_mainGame.BasicData.MultiPlayer == false)
                {
                    await _mainGame.EndPartAsync(false);

                    return;
                }
                await _mainGame.EndCoupeAsync(_mainGame.SingleInfo !.Id);

                return;
            }
            if (_mainGame.BasicData !.MultiPlayer == false)
            {
                await _mainGame.ProcessCoupeAsync(newDeck, _mainGame.SingleInfo !.Id);

                return;
            }
            thisSend        = new SendPlay();
            thisSend.Player = _mainGame.SingleInfo !.Id;
            thisSend.Deck   = newDeck; //i guess that team may not have mattered.
            await _mainGame.Network !.SendAllAsync("hascoupe", thisSend);

            _gameContainer.CurrentCoupe.Player = _gameContainer.SingleInfo.Id;
            _gameContainer.CurrentCoupe.Card   = newDeck;
            await _mainGame.EndCoupeAsync(_mainGame.SingleInfo.Id);
        }
Ejemplo n.º 6
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 "dominoplayed":
                SendPlay output = await js.DeserializeObjectAsync <SendPlay>(content);

                MexicanDomino thisDomino = SingleInfo !.MainHandList.GetSpecificItem(output.Deck);
                SingleInfo.MainHandList.RemoveObjectByDeck(output.Deck);
                await _model.TrainStation1 !.AnimateShowSelectedDominoAsync(output.Section, thisDomino, this);
                return;

            default:
                throw new BasicBlankException($"Nothing for status {status}  with the message of {content}");
            }
        }
        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 "discardnew":
                SendDiscard discard = await js.DeserializeObjectAsync <SendDiscard>(content);
                await AddToDiscardAsync(discard.Pile, discard.Deck);

                return;

            case "play":
                SendPlay play = await js.DeserializeObjectAsync <SendPlay>(content);
                await PlayOnPileAsync(play.Pile, play.Deck, play.WhichType, play.Discard);

                return;

            default:
                throw new BasicBlankException($"Nothing for status {status}  with the message of {content}");
            }
        }