Ejemplo n.º 1
0
 /// <summary>
 /// Игрок сбросил тайл
 /// </summary>
 /// <param name="Player"></param>
 /// <param name="Tile"></param>
 /// <returns></returns>
 private Mahjong.Step DiscardTilePlayer(int Player, int Tile)
 {
     var Step = new Mahjong.Step(Player);
     Step.DiscardTile(Tile);
     CurrentRound.StepCount[Player]++;
     CheckDealer(Player);
     return Step;
 }
Ejemplo n.º 2
0
        private void REACH(XmlReader Reader)
        {
            // Riichi!
            int Who = Convert.ToInt16(Reader.GetAttribute("who"));
            int S = Convert.ToInt16(Reader.GetAttribute("step"));
            Mahjong.Step Step = new Mahjong.Step(Who);

            switch (S)
            {
                case 1: // declare riichi
                    Step.DeclareRiichi();
                    break;
                case 2: // pay 1k
                    Step.PayRiichi();
                    CurrentRound.Riichi[Who] = CurrentRound.Steps.Count + 1;
                    break;
            }

            CurrentRound.Steps.Add(Step);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Игрок взял тайл со стены
        /// </summary>
        /// <param name="Player"></param>
        /// <param name="Tile"></param>
        /// <returns></returns>
        private Mahjong.Step DrawTilePlayer(int Player, int Tile)
        {
            var Step = new Mahjong.Step(Player);
            Step.DrawTile(Tile);

            return Step;
        }
Ejemplo n.º 4
0
        private void AGARI(XmlReader Reader)
        {
            // Ron or tsumo!
            int Who = Convert.ToInt16(Reader.GetAttribute("who"));
            int fromWho = Convert.ToInt16(Reader.GetAttribute("fromWho"));

            Mahjong.Step Step = new Mahjong.Step(Who);

            if (Who == fromWho)
            {
                // Tsumo!
                Step.Tsumo();
                CurrentRound.Steps.Add(Step);

                CurrentRound.Result = Mahjong.RoundResult.Tsumo;
            }
            else
            {
                // Ron!
                Step.Ron(fromWho);
                CurrentRound.Steps.Add(Step);

                CurrentRound.Result = Mahjong.RoundResult.Ron;
                CurrentRound.Loser[fromWho] = true;
            }

            CurrentRound.Winner[Who] = true;

            // Sticks count
            {
                int[] Ba = DecompositeIntList(Reader.GetAttribute("ba"));

               // CurrentRound.RenchanStick = Ba[0];
               // CurrentRound.RiichiStick = Ba[1];
            }

            // Hand and waiting
            {
                // hai - tiles
                // machi - waiting
                string Hai = Reader.GetAttribute("hai");
                int Machi = Convert.ToInt16(Reader.GetAttribute("machi"));
            }

            // Dora
            {
                int[] Dora = DecompositeIntList(Reader.GetAttribute("doraHai"));
                int[] UraDora = DecompositeIntList(Reader.GetAttribute("doraHaiUra"));

                for (int i = 0; i < Dora.Length; i++) CurrentRound.Dora.Add(Dora[i]);

                if(UraDora != null)
                    for (int i = 0; i < UraDora.Length; i++) CurrentRound.UraDora.Add(UraDora[i]);
            }

            // Hand cost
            {
                int[] Ten = DecompositeIntList(Reader.GetAttribute("ten"));

                int Fu = Ten[0];
                int Cost = Ten[1];

                CurrentRound.FuCount[Who] = Fu;
                CurrentRound.Cost[Who] = Cost;
            }

            // Yaku list
            {
                bool Yakuman = false;
                string YakuList = Reader.GetAttribute("yaku");
                if (YakuList == null)
                {
                    YakuList = Reader.GetAttribute("yakuman");
                    Yakuman = true;
                }

                int[] Yaku = DecompositeIntList(YakuList);

                if (Yakuman)
                {
                    for (int i = 0; i < Yaku.Length; i++)
                    {
                        int YakuIndex = Yaku[i];
                        int YakuCost = 13;

                        CurrentRound.HanCount[Who] += YakuCost;
                        CurrentRound.Yaku[Who].Add(new Mahjong.Yaku(YakuIndex, YakuCost));
                    }
                }
                else
                {
                    for (int i = 0; i < Yaku.Length / 2; i++)
                    {
                        int YakuIndex = Yaku[i * 2];
                        int YakuCost = Yaku[i * 2 + 1];

                        if (YakuCost > 0)
                        {
                            CurrentRound.HanCount[Who] += YakuCost;
                            CurrentRound.Yaku[Who].Add(new Mahjong.Yaku(YakuIndex, YakuCost));
                        }
                    }
                }
            }

            CheckScore(Reader);
            CheckEnd(Reader);
        }
Ejemplo n.º 5
0
        private void DORA(XmlReader Reader)
        {
            // Open dora indicator
            Mahjong.Step Step = new Mahjong.Step(-1);

            int Hai = Convert.ToInt32(Reader.GetAttribute("hai"));

            Step.NewDora(Hai);
            CurrentRound.Steps.Add(Step);

            CurrentRound.DoraCount++;
        }
Ejemplo n.º 6
0
        private void N(XmlReader Reader)
        {
            // Naki
            int Who = Convert.ToInt32(Reader.GetAttribute("who"));
            int m = Convert.ToInt32(Reader.GetAttribute("m"));

            NakiDecoder Naki = new NakiDecoder(m);
            Mahjong.Step Step = new Mahjong.Step(Who);

            Step.Naki(Naki.GetNaki());

            CurrentRound.Steps.Add(Step);

            CurrentRound.Naki[Who]++;
            // Ignore chakan and nuki naki
            if (!((Step.NakiData.Type == Mahjong.NakiType.CHAKAN) || (Step.NakiData.Type == Mahjong.NakiType.NUKI)))
                CurrentRound.OpenedSets[Who]++;
        }
Ejemplo n.º 7
0
        private void RYUUKYOKU(XmlReader Reader)
        {
            // Draw
            Mahjong.Step Step = new Mahjong.Step(-1);

            string RyuuType = Reader.GetAttribute("type");
            int Reason = -1;

            switch (RyuuType)
            {
                case "yao9": // 9 terminals/honors
                    Reason = 0;
                    break;
                case "reach4": // 4 consecutive riichi calls
                    Reason = 1;
                    break;
                case "ron3": // three simultaneous ron calls (triple ron)
                    Reason = 2;
                    break;
                case "kan4": // four declared kans
                    Reason = 3;
                    break;
                case "kaze4": // same wind discard on first round
                    Reason = 4;
                    break;
                case "nm": // nagashi mangan (all terminal/honor discards)
                    Reason = 5;
                    break;
            }

            Step.Draw(Reason);
            CurrentRound.Steps.Add(Step);
            CurrentRound.Result = Mahjong.RoundResult.Draw;
            CurrentRound.DrawReason = Reason;

            CheckScore(Reader);
            CheckEnd(Reader);
        }
Ejemplo n.º 8
0
        private void BYE(XmlReader Reader)
        {
            // Player goes offline
            int Who = Convert.ToInt16(Reader.GetAttribute("who"));

            Mahjong.Step Step = new Mahjong.Step(Who);
            Step.Disconnect();

            if(CurrentRound != null) CurrentRound.Steps.Add(Step);
        }