private void Nagare_Click()
 {
     if (nagareBtn.Text == "流局")
     {
         if (RunningOtherProgram)
         {
             return;
         }
         RunningOtherProgram = true;
         UpdateText.Set(ControlTextView, "谁听牌?");
         Element.Session.IsNagareMode = true;
         foreach (var player in Element.Players)
         {
             if (player.IsReach)
             {
                 player.IsReachLockOn = true;
             }
         }
         UpdateText.Set(nagareBtn, "取消流局");
     }
     else
     {
         foreach (var player in Element.Players)
         {
             player.IsReach       = false;
             player.IsReachLockOn = false;
         }
         Element.Session.IsNagareMode = false;
         UpdateText.Set(ControlTextView, "(OvO)");
         UpdateText.Set(nagareBtn, "流局");
         RunningOtherProgram = false;
     }
 }
 private void NewGame_Click()
 {
     RunningOtherProgram = true;
     UpdateText.Set(InpuTextView, "");
     UpdateText.Set(ControlTextView, "谁是起家?");
     Element.Session.Flag      = 0;
     Element.Session.IsNewGame = true;
 }
Exemple #3
0
 private static bool IsSpecialInput(ref string txt, IReadOnlyDictionary <string, string> dic)
 {
     if (dic.ContainsKey(txt))
     {
         UpdateText.Set(MainActivity.ControlTextView, "符翻点数为" + dic[txt]);
         return(true);
     }
     return(false);
 }
 public override bool OnKeyDown(Keycode keyCode, KeyEvent e)//重写返回键
 {
     if (keyCode == Keycode.Back)
     {
         UpdateText.Set(InpuTextView, "");
         return(true);
     }
     return(base.OnKeyDown(keyCode, e));
 }
 private static void DoubleRonPrepare()//双响准备
 {
     UpdateText.Set(MainActivity.DoubleRonCheckBox, false);
     if (BenChangTemp == 0)//三响的时候不交换
     {
         BenChangTemp = Element.Session.BenChang;
     }
     Element.Session.BenChang = 0;
     Element.Session.QianBang = 0;
     IsOyaAgareFirst          = _isOyaAgare || IsOyaAgareFirst;
     UpdateText.Set(MainActivity.InpuTextView, "");
 }
        private static void ShowGameLog()
        {
            Activity activity = MainActivity.Context as Activity;
            string   txt      = "";

            foreach (var d in Element.GameLogDictionary)
            {
                txt += d.Value[5] + "\n";
            }
            //MessageBox.Show(txt);
            UpdateText.Set(activity?.FindViewById <TextView>(Resource.Id.textViewShowLog), txt);
        }
Exemple #7
0
        public void GetFlag()
        {
            //定义变量
            int  changBang = Element.Session.BenChang;
            int  qianBang  = Element.Session.QianBang;
            bool isOyaAgare;
            bool isOyaAgareFirst = false;//双响时第一遍是否为亲和牌

            MainActivity.Flag = 0;

            Thread th = new Thread(() =>
            {
                //第一遍和牌运算不执行场棒++和风位变换,记录是否是亲和牌,第二遍和牌运算时场棒=0,执行完场棒恢复正常值

                DoubleRon:
                //选择铳家与和家
                SelectPlayer(out isOyaAgare);
                //胡牌计算
                if (_flagUp == _flagDown)
                {
                    TsumoMethod(MainActivity.InpuTextView.Text, qianBang, changBang, ref isOyaAgare);
                }
                else
                {
                    AgareMethod(MainActivity.InpuTextView.Text, qianBang, changBang, ref isOyaAgare);
                }
                //双响处理
                if (MainActivity.DoubleRonCheckBox.Checked)//判断是否双响
                {
                    UpdateText.Set(MainActivity.DoubleRonCheckBox, false);
                    _afterDoubleRon = true;
                    isOyaAgareFirst = isOyaAgare;
                    _temp           = changBang;
                    changBang       = 0;
                    qianBang        = 0;
                    goto DoubleRon;
                }
                if (_afterDoubleRon)//双响时执行的额外操作
                {
                    changBang       = _temp;
                    _afterDoubleRon = false;
                }
                //胡牌后处理
                AfterAgare(isOyaAgare, isOyaAgareFirst);
            });

            th.IsBackground = true;
            th.Start();
        }
        private static void AfterAgare()//胡牌后处理
        {
            //双响后交换场棒
            if (BenChangTemp != 0)
            {
                Element.Session.BenChang = BenChangTemp;
            }

            //判断是否亲家和牌
            MainActivity.IsOyaAgare = _isOyaAgare || IsOyaAgareFirst;
            //判断连庄还是流庄
            if (_isOyaAgare || IsOyaAgareFirst)
            {
                Element.Session.BenChang++;
                foreach (var player in Element.Players)
                {
                    player.IsReach = false;
                }
            }
            else
            {
                Element.Session.BenChang = 0;
                Element.Session.NowSession++;
                //Element.Session.IsNagareMode = true;
                foreach (var player in Element.Players)
                {
                    if (player.Wind == 0)
                    {
                        player.Wind = WindEnum.北;
                    }
                    else
                    {
                        player.Wind--;
                    }
                    player.IsReach = false;
                }
            }

            UpdateText.Set(MainActivity.ControlTextView, "(OvO)");
            UpdateText.Set(MainActivity.AgareBtn, "和牌");
            Element.Session.IsAgareMode = false;
            Element.Session.QianBang    = 0;
            UpdateText.Set(MainActivity.InpuTextView, "");
            MainActivity.NowSessionNum++;
            Game.Save(_situation);
            End.IsOwari();
            MainActivity.RunningOtherProgram = false;
        }
        public static void Method(int flagUp, int flagDown)
        {
            #region 初始化
            _flagUp       = flagUp;
            _flagDown     = flagDown;
            _upPlayer     = null;
            _downPlayer   = null;
            _downPlayers  = null;
            _targetPoint  = null;
            _upPoint      = null;
            _downOyaPoint = null;
            _downKoPoint  = null;
            _isOyaAgare   = false;
            _isTsumo      = false;
            #endregion

            //对号入座
            _upPlayer    = Element.Players[_flagUp - 1];
            _downPlayer  = Element.Players[_flagDown - 1];
            _downPlayers = Element.Players.Where(p => p.Name != _upPlayer.Name).Select(p => p);
            MainActivity.RunningOtherProgram = true;
            //判断是否亲和牌
            _isOyaAgare = Element.Players[_flagUp - 1].Name == Element.Session.OyaName;
            //判断是否自摸
            _isTsumo = _flagUp == _flagDown;
            //标准化点数
            StandardizePoint();
            if (_targetPoint == null)
            {
                MessageBox.Show("输入点数出错");
                UpdateText.Set(MainActivity.ControlTextView, "谁胡牌?");
            }
            else
            {
                AgareMethod(); //进行点数交换
                if (MainActivity.DoubleRonCheckBox.Checked)
                {
                    DoubleRonPrepare(); //双响准备
                }
                else
                {
                    AfterAgare(); //胡牌后处理
                }
            }
        }
Exemple #10
0
        private void SelectPlayer(out bool isOyaAgare)//获得铳家与和家
        {
            MainActivity.Flag = 0;
            UpdateText.Set(MainActivity.ControlTextView, "谁出铳?");
            while (MainActivity.Flag == 0)
            {
            }
            _flagDown = MainActivity.Flag;

            MainActivity.Flag = 0;
            UpdateText.Set(MainActivity.ControlTextView, "谁和牌?");
            while (MainActivity.Flag == 0)
            {
            }
            _flagUp = MainActivity.Flag;

            UpdateText.Set(MainActivity.ControlTextView, "(OvO)");
            isOyaAgare = false;
        }
Exemple #11
0
        private static void AfterAgare(bool isOyaAgare, bool isOyaAgareFirst)//胡牌完后处理
        {
            MainActivity.IsOyaAgare = isOyaAgare || isOyaAgareFirst;

            if (isOyaAgare || isOyaAgareFirst)
            {
                Element.Session.BenChang++;
                foreach (var player in Element.Players)
                {
                    player.IsReach = false;
                }
            }
            else
            {
                Element.Session.BenChang = 0;
                Element.Session.NowSession++;
                foreach (var player in Element.Players)
                {
                    if (player.Wind == 0)
                    {
                        player.Wind = WindEnum.北;
                    }
                    else
                    {
                        player.Wind--;
                    }
                    player.IsReach = false;
                }
            }

            Element.Session.QianBang = 0;
            UpdateText.Set(MainActivity.InpuTextView, "");
            MainActivity.NowSessionNum++;
            Game.Save();
            End.IsOwari();
            MainActivity.RunningOtherProgram = false;
        }
 private void AgareBtn_Click()
 {
     if (AgareBtn.Text == "和牌")
     {
         if (RunningOtherProgram)
         {
             return;
         }
         Element.Session.IsAgareMode = true;
         foreach (var player in Element.Players)
         {
             if (player.IsReach == true)
             {
                 player.IsReachLockOn = true;
             }
         }
         PlayerCondition.AgareJudge();
         foreach (var player in Element.Players)
         {
             player.IsReachLockOn = false;
         }
         Element.Session.IsNewAgare = true;
         Element.Session.Save       = 0;
         UpdateText.Set(ControlTextView, "谁出铳?");
         RunningOtherProgram = true;
         UpdateText.Set(AgareBtn, "取消和牌");
     }
     else
     {
         Element.Session.IsAgareMode = false;
         UpdateText.Set(ControlTextView, "(OvO)");
         UpdateText.Set(InpuTextView, "");
         UpdateText.Set(AgareBtn, "和牌");
         RunningOtherProgram = false;
     }
 }
Exemple #13
0
 private void ThrowInputPointError()
 {
     MessageBox.Show("点数输入出错\n请重新输入");
     UpdateText.Set(MainActivity.InpuTextView, "");
     GetFlag();
 }