Beispiel #1
0
        static void CreatePaifu(string Hash, List<Argument> ArgList, List<Search.Result> Results)
        {
            string Dir = "paifu";
            string FN = null;
            int Round = -1;
            int ShowShanten = 0;
            int ShowYaku = 1;
            int ShowNames = 1;
            int ShowDanger = 1;
            int ShowColor = 1;
            int ShowSex = 0;

            if (Hash.CompareTo("") == 0)
            {
                Console.WriteLine("Error: Hash not defined.");
                return;
            }

            Hash = new Tenhou.TenhouHash(Hash).DecodedHash;

            // Parse options
            foreach (Argument A in ArgList)
            {
                switch (A.Name)
                {
                    case "tileset":
                        Paifu.PaifuTileImage.TilesDirectory = A.Value;
                        break;
                    case "dir":
                        Dir = A.Value;
                        break;
                    case "round":
                        Round = Convert.ToInt32(A.Value);
                        break;
                    case "filename":
                        FN = A.Value;
                        break;
                    case "shanten":
                        ShowShanten = ParseBoolArg(A.Value, "shanten");
                        break;
                    case "yaku":
                        ShowYaku = ParseBoolArg(A.Value, "yaku");
                        break;
                    case "nickname":
                        ShowNames = ParseBoolArg(A.Value, "nickname");
                        break;
                    case "danger":
                        ShowDanger = ParseBoolArg(A.Value, "danger");
                        break;
                    case "color":
                        ShowColor = ParseBoolArg(A.Value, "color");
                        break;
                    case "sex":
                        ShowSex = ParseBoolArg(A.Value, "sex");
                        break;
                }
            }

            Mahjong.Replay R = new Mahjong.Replay();
            R.LoadXml(Hash);

            for (int i = 0; i < R.Rounds.Count; i++)
            {
                if ((Round != -1) && (Round != i)) continue;

                Paifu.PaifuGenerator P = new Paifu.PaifuGenerator(R, i);

                string FileName;

                if (FN == null)
                {
                    if (!Directory.Exists(Dir)) Directory.CreateDirectory(Dir);
                    FileName = String.Format("./{0:s}/{1:s}_{2:d}.png", Dir, Hash, i);
                }
                else
                {
                    FileName = (Round == -1) ? String.Format("{0:s}_{1:d}.png", FN, i) : String.Format("{0:s}.png", FN);
                }

                P.ShowShanten = ShowShanten;
                P.ShowDanger = ShowDanger;
                P.ShowYakuInfo = ShowYaku;
                P.ShowNames = ShowNames;
                P.ShowColor = ShowColor;
                P.ShowSex = ShowSex;

                P.Generate();
                P.Save(FileName);
            }
        }
Beispiel #2
0
        static void CreateDiscard(string Hash, List<Argument> ArgList, List<Search.Result> Results)
        {
            int Round = -1;
            int Player = -1;
            bool RiichiLimit = false;
            bool NakiHL = false;
            bool TsumogiriHL = false;
            bool ShowHand = false;

            string FN = null;
            string Dir = "discard";

            if (Hash.CompareTo("") == 0)
            {
                Console.WriteLine("Error: Hash not defined.");
                return;
            }

            Hash = new Tenhou.TenhouHash(Hash).DecodedHash;

            // Parse options
            foreach (Argument A in ArgList)
            {
                switch (A.Name)
                {
                    case "tileset":
                        Paifu.PaifuTileImage.TilesDirectory = A.Value;
                        break;
                    case "dir":
                        Dir = A.Value;
                        break;
                    case "round":
                        Round = Convert.ToInt32(A.Value);
                        break;
                    case "player":
                        Player = Convert.ToInt32(A.Value);
                        break;
                    case "filename":
                        FN = A.Value;
                        break;
                    case "riichi":
                        RiichiLimit = true;
                        break;
                    case "naki":
                        NakiHL = true;
                        break;
                    case "tsumogiri":
                        TsumogiriHL = true;
                        break;
                    case "hand":
                        ShowHand = true;
                        break;
                    default:
                        break;
                }
            }

            Mahjong.Replay R = new Mahjong.Replay();
            R.LoadXml(Hash);

            for (int i = 0; i < R.Rounds.Count; i++)
            {
                if ((Round != -1) && (Round != i)) continue;

                for (int p = 0; p < R.PlayerCount; p++)
                {
                    if ((Player != -1) && (Player != p)) continue;

                    Discarder.Discard D = new Discarder.Discard(R, i, p);
                    string FileName, HandFileName;
                    if (FN == null)
                    {
                        if (!Directory.Exists(Dir)) Directory.CreateDirectory(Dir);
                        FileName = String.Format("./{0:s}/{1:s}_{2:d}_{3:d}.png", Dir, Hash, Round, p);
                        HandFileName = String.Format("./{0:s}/{1:s}_{2:d}_{3:d}_hand.png", Dir, Hash, Round, p);
                    }
                    else
                    {
                        FileName = (Round == -1) ? String.Format("{0:s}_{1:d}_{2:d}.png", FN, i, p) : String.Format("{0:s}.png", FN);
                        HandFileName = (Round == -1) ? String.Format("{0:s}_{1:d}_{2:d}_hand.png", FN, i, p) : String.Format("{0:s}_hand.png", FN);
                    }

                    D.RiichiLimit = RiichiLimit;
                    D.HighlightNaki = NakiHL;
                    D.HighlightTsumogiri = TsumogiriHL;

                    D.Generate();
                    D.Save(FileName);

                    if (ShowHand)
                    {
                        Discarder.HandOutput HO = new Discarder.HandOutput(R, i, p);
                        HO.Generate();
                        HO.Save(HandFileName);
                    }
                }
            }
        }