Esempio n. 1
0
        public void OnAllowedActions(MsgAllowPlayerAction msg)
        {
            HideAllActionButtons();
            CurrentAllowPlayerAction   = msg;
            CurrentAllowPlayerReAction = null;

            var actions = msg.allowedActions;

            if ((actions & (int)ActionType.enumActionType_DISCARD) != 0)
            {
                BtnAction5.Visibility = Visibility.Visible;
                BtnAction5.Content    = "出牌";
                BtnAction5.Tag        = (int)ActionType.enumActionType_DISCARD;

                if (MyOwner.CheckBoxAutoAction.IsChecked == false && IsAutoX)
                {
                    //var handTips = msg.tipsForAction;
                    //// 自动打牌
                    //if ((actions & (int)ActionType.enumActionType_FirstReadyHand) != 0)
                    //{
                    //    if (!IsBandker)
                    //    {
                    //        // 绝对不听牌
                    //        OnNonBankerTakeActionFirstHand(0);
                    //    }
                    //    else
                    //    {
                    //        OnTakeActionDiscardTile(handTips[0].targetTile, 0);
                    //    }
                    //}
                    //else if ((actions & (int)ActionType.enumActionType_DISCARD) != 0)
                    //{
                    //    OnTakeActionDiscardTile(handTips[0].targetTile);
                    //}

                    int specialCardID = -1;
                    if (CurrentAllowPlayerAction.timeoutInSeconds > 255)
                    {
                        specialCardID = (int)pokerface.CardID.R3H;
                    }

                    var current = AgariIndex.SearchLongestDiscardCardHand(TilesHandList, specialCardID);
                    if (current == null)
                    {
                        MessageBox.Show("auto discard: BIG BIG WORLD");
                        throw new System.Exception("Huge bug, darling");
                    }

                    OnTakeActionDiscardTile(current.cards);

                    HideAllActionButtons();
                }
            }
        }
Esempio n. 2
0
        private void OnDiscard_Button_Clicked(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            if (SelectedTiles.Count < 0)
            {
                MessageBox.Show(this, "please select a tile to discard");
                return;
            }

            if (specialCardID >= 0)
            {
                var found = false;
                foreach (var c in SelectedTiles)
                {
                    if (c == specialCardID)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    var cardName = this.MyOwner.MyOwner.IdNames[specialCardID];
                    MessageBox.Show(this, $"please select a hand that include {cardName} to discard");
                    return;
                }
            }

            var current = AgariIndex.agariConvertMsgCardHand(SelectedTiles.ToArray());

            if (current == null)
            {
                MessageBox.Show(this, "please select a valid hand");
                return;
            }

            if (prevCardHand != null && !AgariIndex.agariGreatThan(prevCardHand, current))
            {
                MessageBox.Show(this, "please select a hand great than prev");
                return;
            }

            DialogResult = true;
        }
Esempio n. 3
0
        public void OnAllowedReActions(MsgAllowPlayerReAction msg)
        {
            HideAllActionButtons();
            CurrentAllowPlayerReAction = msg;
            CurrentAllowPlayerAction   = null;

            var actions = msg.allowedActions;


            //if ((actions & (int)ActionType.enumActionType_KONG_Exposed) != 0)
            //{
            //    BtnAction1.Visibility = Visibility.Visible;
            //    BtnAction1.Content = "明杠";
            //    BtnAction1.Tag = (int)ActionType.enumActionType_KONG_Exposed;
            //}

            if ((actions & (int)ActionType.enumActionType_DISCARD) != 0)
            {
                BtnAction2.Visibility = Visibility.Visible;
                BtnAction2.Content    = "出牌";
                BtnAction2.Tag        = (int)ActionType.enumActionType_DISCARD;
            }

            //if ((actions & (int)ActionType.enumActionType_PONG) != 0)
            //{
            //    BtnAction3.Visibility = Visibility.Visible;
            //    BtnAction3.Content = "碰";
            //    BtnAction3.Tag = (int)ActionType.enumActionType_PONG;
            //}

            if ((actions & (int)ActionType.enumActionType_SKIP) != 0)
            {
                BtnAction4.Visibility = Visibility.Visible;
                BtnAction4.Content    = "过";
                BtnAction4.Tag        = (int)ActionType.enumActionType_SKIP;
            }

            //if ((actions & (int)ActionType.enumActionType_WIN_Chuck) != 0)
            //{
            //    BtnAction5.Visibility = Visibility.Visible;
            //    BtnAction5.Content = "胡";
            //    BtnAction5.Tag = (int)ActionType.enumActionType_WIN_Chuck;
            //}

            if (MyOwner.CheckBoxAutoAction.IsChecked == false && IsAutoX)
            {
                // 自动打牌
                //if ((actions & (int)ActionType.enumActionType_SKIP) != 0)
                //{
                //    OnTakeActionSkip();
                //}
                if ((actions & (int)ActionType.enumActionType_DISCARD) != 0)
                {
                    int specialCardID = -1;
                    if (CurrentAllowPlayerReAction.timeoutInSeconds > 255)
                    {
                        specialCardID = (int)pokerface.CardID.R3H;
                    }

                    var currents = AgariIndex.FindGreatThanCardHand(CurrentAllowPlayerReAction.prevActionHand, TilesHandList, specialCardID);
                    if (null == currents || currents.Count == 0)
                    {
                        MessageBox.Show("auto discard:oh shit, a huge bug");
                        throw new System.Exception("huge bug");
                    }

                    OnTakeActionDiscardTile(currents[0].cards);

                    HideAllActionButtons();
                }
            }
        }
Esempio n. 4
0
        public static bool ShowDialog(List <int> tileDiscarded, pokerface.MsgCardHand prevCardHand, int specialCardID, TileStackWnd owner)
        {
            var tiles2Discarded = owner.TilesHandList;

            tileDiscarded.Clear();

            var x = new DiscardWnd();

            x.SetOwner(owner);
            x.BtnExtra.Visibility   = Visibility.Hidden;
            x.BtnExtraXX.Visibility = Visibility.Hidden;
            x.SetReadyHandTips(tiles2Discarded);
            x.prevCardHand  = prevCardHand;
            x.specialCardID = specialCardID;

            if (prevCardHand != null)
            {
                var currents = AgariIndex.FindGreatThanCardHand(prevCardHand, tiles2Discarded, specialCardID);
                if (null == currents || currents.Count == 0)
                {
                    MessageBox.Show("oh shit, a huge bug");
                    throw new System.Exception("huge bug");
                }

                if (currents.Count > 1)
                {
                    x.BtnExtra.Visibility = Visibility.Visible;
                    x.BtnExtra.Content    = "下一个提示";
                }

                var current = currents[0];
                x.SelectedTiles.AddRange(current.cards);
                foreach (var c in current.cards)
                {
                    x.HandTiles.Remove(c);
                }

                x.discardAbleTips      = currents;
                x.discardAbleTipsIndex = 0;

                x.Hand2UI();
                x.Selected2UI();
            }
            else
            {
                var current = AgariIndex.SearchLongestDiscardCardHand(tiles2Discarded, specialCardID);
                x.SelectedTiles.AddRange(current.cards);
                foreach (var c in current.cards)
                {
                    x.HandTiles.Remove(c);
                }

                x.Hand2UI();
                x.Selected2UI();
            }

            var result = x.ShowDialog();

            if (result == null || !result.Value)
            {
                // snip
                return(false);
            }

            tileDiscarded.AddRange(x.SelectedTiles);
            return(true);
        }