示例#1
0
        private bool HandleHMessage(string cop, string cmdrst)
        {
            bool cinCalled = false;
            switch (cop)
            {
                //case "H1NW":
                //    {
                //        int idx = cmdrst.IndexOf(',');
                //        ushort who = ushort.Parse(cmdrst.Substring(0, idx));
                //        string name = cmdrst.Substring(idx + 1);
                //        if (Z0D.ContainsKey(who))
                //            Z0D[who] = new ZeroPlayer(name, this) { Uid = who };
                //        else
                //            Z0D.Add(who, new ZeroPlayer(name, this) { Uid = who });
                //    }
                //    break;
                case "H0SD":
                    {
                        string[] blocks = Algo.Splits(cmdrst, ",");
                        for (int i = 0; i < blocks.Length; i += 3)
                        {
                            ushort ut = ushort.Parse(blocks[i]);
                            ushort aut = ushort.Parse(blocks[i + 1]);
                            string name = blocks[i + 2];
                            if (Z0D.ContainsKey(ut))
                            {
                                if (Z0D[ut].Name != name)
                                    Z0D[ut] = new ZeroPlayer(name, this) { Uid = ut };
                            }
                            else
                                Z0D.Add(ut, new ZeroPlayer(name, this) { Uid = ut });
                            if (aut == auid)
                                Uid = ut;
                        }
                        string members = "";
                        for (ushort i = 1; i <= totalPlayer; ++i)
                        {
                            if (i == Uid)
                                members += (",[" + i + "#:" + Z0D[i].Name + "]");
                            else
                                members += ("," + i + "#:" + Z0D[i].Name);
                        }
                        if (members != "")
                            VI.Cout(Uid, "座位排序如下:" + members.Substring(1));
                    }
                    break;
                case "H0SM":
                    {
                        string[] blocks = cmdrst.Split(',');
                        SelMode = int.Parse(blocks[0]);
                        LevelCode = int.Parse(blocks[1]);
                    }
                    break;
                case "H0SW":
                    {
                        string[] splits = cmdrst.Split(',');
                        ushort type = ushort.Parse(splits[0]);
                        List<ushort> pys = Algo.TakeRange(splits, 1, splits.Length)
                            .Select(p => ushort.Parse(p)).ToList();
                        pys.Remove(Uid);
                        if (pys.Count > 0)
                        {
                            string[] words = new string[] { "选择", "禁选" };
                            VI.Cout(Uid, "等待玩家{0}{1}人物...", "{" + string.Join(",", pys) + "}", words[type]);
                        }
                    }
                    break;
                //case "H1LV":
                //    Z0D.Remove(ushort.Parse(cmdrst));
                //    break;
                //case "H1CN":
                //    VI.Cout(uid, "游戏开始啦!");
                //    break;
                case "H0RT":
                    casting = new Base.Rules.CastingPick(); break;
                case "H0RM":
                    {
                        List<int> cands = cmdrst.Split(',').Select(p => int.Parse(p)).ToList();
                        bool randomed = false;
                        var cp = casting as Base.Rules.CastingPick;
                        if (cands.Count > 0 && cands.Last() == 0)
                        {
                            cands.RemoveAt(cands.Count - 1);
                            randomed = true;
                        }
                        cp.Init(Uid, cands, randomed ? new int[] { 0 }.ToList() : null);
                        cinCalled = StartCinEtc();
                        while (true)
                        {
                            string input = VI.Cin(Uid, "您可选角色-{0}{1}", zd.HeroWithCode(cp.Xuan[Uid]),
                                (cp.Huan.ContainsKey(Uid) && cp.Huan[Uid].Count > 0 ? "(按0随机替换1人)" : ""));
                            int hero;
                            if (int.TryParse(input, out hero))
                            {
                                if ((hero != 0 && cp.Xuan[Uid].Contains(hero)) || cp.Huan[Uid].Count > 0)
                                {
                                    WI.Send("H0RN," + hero, Uid, 0);
                                    break;
                                }
                            }
                        }
                        VI.CloseCinTunnel(Uid);
                    }
                    break;
                case "H0RO":
                    {
                        string[] args = cmdrst.Split(',');
                        int code = int.Parse(args[0]);
                        if (code == 0)
                        {
                            ushort puid = ushort.Parse(args[1]);
                            VI.Cout(Uid, "玩家{0}#已经选定角色.", puid);
                        }
                        else if (code == 1)
                        {
                            ushort puid = ushort.Parse(args[1]);
                            int heroCode = int.Parse(args[2]);
                            if ((casting as Base.Rules.CastingPick).Pick(puid, heroCode))
                            {
                                if (puid == Uid)
                                    VI.Cout(Uid, "确认您的选择为{0}.", zd.Hero(heroCode));
                                else
                                    VI.Cout(Uid, "玩家{0}#已选择了角色{1}.", puid, zd.Hero(heroCode));
                                Z0D[puid].SelectHero = heroCode;
                                Z0D[puid].IsAlive = true;
                            }
                        }
                    }
                    break;
                case "H0RS":
                    {
                        int jdx = cmdrst.IndexOf(',');
                        int from = int.Parse(cmdrst.Substring(0, jdx));
                        int to = int.Parse(cmdrst.Substring(jdx + 1));
                        Base.Rules.CastingPick cp = casting as Base.Rules.CastingPick;
                        if (cp.SwitchTo(Uid, from, to) != 0)
                        {
                            cinCalled = StartCinEtc();
                            while (true)
                            {
                                string input = VI.Cin(Uid, "您可选角色-{0}.", zd.HeroWithCode(cp.Xuan[Uid]));
                                int hero;
                                if (int.TryParse(input, out hero))
                                {
                                    if ((hero != 0 && cp.Xuan[Uid].Contains(hero)))
                                    {
                                        WI.Send("H0RN," + hero, Uid, 0);
                                        break;
                                    }
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                    }
                    break;
                case "H0TT":
                    {
                        string[] args = cmdrst.Split(',');
                        int xsz = int.Parse(args[0]);
                        List<int> x = Algo.TakeRange(args, 1, 1 + xsz)
                            .Select(p => int.Parse(p)).ToList();
                        int bsz1 = int.Parse(args[xsz + 1]);
                        List<int> b1 = Algo.TakeRange(args, 2 + xsz, 2 + xsz + bsz1)
                            .Select(p => int.Parse(p)).ToList();
                        int bsz2 = int.Parse(args[xsz + bsz1 + 2]);
                        List<int> b2 = Algo.TakeRange(args, 3 + xsz + bsz1, 3 + xsz + bsz1 + bsz2)
                            .Select(p => int.Parse(p)).ToList();

                        Base.Rules.CastingTable ct = new Base.Rules.CastingTable(x, b1, b2);
                        casting = ct;
                        VI.Cout(Uid, "当前可选角色-{0}.", zd.HeroWithCode(ct.Xuan));
                    }
                    break;
                case "H0TX":
                    {
                        // Verify whether these lists are the same.
                        //string[] args = cmdrst.Split(',');
                        //List<int> cands = Algo.TakeRange(args, 0, args.Length)
                        //    .Select(p => int.Parse(p)).ToList();
                        //selCandidates.Clear(); selCandidates.AddRange(cands);
                        cinCalled = StartCinEtc();
                        Base.Rules.CastingTable ct = casting as Base.Rules.CastingTable;
                        while (true)
                        {
                            string input = VI.Cin(Uid, "请选择一名角色,当前可选角色:\n{0}",
                                zd.HeroWithCode(ct.Xuan));
                            int hero;
                            if (int.TryParse(input, out hero) && ct.Xuan.Contains(hero))
                            {
                                WI.Send("H0TN," + hero, Uid, 0);
                                break;
                            }
                        }
                        VI.CloseCinTunnel(Uid);
                    }
                    break;
                case "H0TO":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        int heroCode = int.Parse(args[1]);
                        if (puid == Uid)
                            VI.Cout(Uid, "确认您的选择为{0}.", zd.Hero(heroCode));
                        else
                            VI.Cout(Uid, "玩家{0}#已选择了角色{1}.", puid, zd.Hero(heroCode));
                        Z0D[puid].SelectHero = heroCode;
                        Z0D[puid].IsAlive = true;
                        (casting as Base.Rules.CastingTable).Pick(puid, heroCode);
                    }
                    break;
                case "H0TA":
                    {
                        Base.Rules.CastingTable ct = casting as Base.Rules.CastingTable;
                        string[] args = cmdrst.Split(',');
                        cinCalled = StartCinEtc();
                        while (true)
                        {
                            bool canGiveup = args.Contains("0");
                            string input = VI.Cin(Uid, "请禁选一名角色" + (canGiveup ? "(0为不禁选)" : "") +
                                 ",当前可选角色:\n{0}", zd.HeroWithCode(ct.Xuan));
                            int hero;
                            if (int.TryParse(input, out hero) && (ct.Xuan.Contains(hero) || canGiveup && hero == 0))
                            {
                                WI.Send("H0TB," + hero, Uid, 0);
                                break;
                            }
                        }
                        VI.CloseCinTunnel(Uid);
                    }
                    break;
                case "H0TC":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        List<int> hrs = Algo.TakeRange(args, 1, args.Length)
                            .Select(p => int.Parse(p)).ToList();
                        Base.Rules.CastingTable ct = casting as Base.Rules.CastingTable;
                        if (hrs.Count == 0 && hrs[0] == 0)
                            VI.Cout(Uid, "玩家{0}#未禁选.", puid, zd.Hero(hrs));
                        else
                        {
                            VI.Cout(Uid, "玩家{0}#禁选了角色{1}.", puid, zd.Hero(hrs));
                            foreach (int heroCode in hrs)
                                ct.Ban(puid, heroCode);
                        }
                        if (ct.Xuan.Count > 0)
                            VI.Cout(Uid, "当前剩余角色:\n{0}.", zd.HeroWithCode(ct.Xuan));
                    }
                    break;
                case "H0TJ":
                    {
                        string[] args = cmdrst.Split(',');
                        List<int> hrs = Algo.TakeRange(args, 0, args.Length)
                            .Select(p => int.Parse(p)).ToList();
                        VI.Cout(Uid, "新增了角色{0}.", zd.Hero(hrs));
                        Base.Rules.CastingTable ct = casting as Base.Rules.CastingTable;
                        foreach (int heroCode in hrs)
                            ct.PutBack(heroCode);
                        if (ct.Xuan.Count > 0)
                            VI.Cout(Uid, "当前剩余角色:\n{0}.", zd.HeroWithCode(ct.Xuan));
                    }
                    break;
                case "H0PT":
                    {
                        string[] args = cmdrst.Split(',');
                        int idx = 0;
                        int xsz = int.Parse(args[idx]); ++idx;
                        List<int> x = Algo.TakeRange(args, idx, idx + xsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += xsz;
                        int drsz = int.Parse(args[idx]); ++idx;
                        List<int> dr = Algo.TakeRange(args, idx, idx + drsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += drsz;
                        int dbsz = int.Parse(args[idx]); ++idx;
                        List<int> db = Algo.TakeRange(args, idx, idx + dbsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += dbsz;
                        int brsz = int.Parse(args[idx]); ++idx;
                        List<int> br = Algo.TakeRange(args, idx, idx + brsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += brsz;
                        int bbsz = int.Parse(args[idx]); ++idx;
                        List<int> bb = Algo.TakeRange(args, idx, idx + bbsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += bbsz;

                        Base.Rules.CastingPublic cp = new Base.Rules.CastingPublic(x, dr, db, br, bb);
                        casting = cp;
                        cp.ToHint(Uid, VI, zd.HeroWithCode, zd.Hero);
                    }
                    break;
                case "H0PA":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort who = ushort.Parse(args[0]);
                        if (who == Uid)
                        {
                            Base.Rules.CastingPublic cp = casting as Base.Rules.CastingPublic;
                            cinCalled = StartCinEtc();
                            while (true)
                            {
                                string input = VI.Cin(Uid, "请禁选一名角色,当前可选角色:\n{0}",
                                    zd.HeroWithCode(cp.Xuan));
                                int hero;
                                if (int.TryParse(input, out hero) && cp.Xuan.Contains(hero))
                                {
                                    WI.Send("H0PB," + hero, Uid, 0);
                                    break;
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                        else
                            VI.Cout(Uid, "请等待{0}#禁将.", who);
                    }
                    break;
                case "H0PC":
                    {
                        string[] args = cmdrst.Split(',');
                        int team = int.Parse(args[0]);
                        int selAva = int.Parse(args[1]);
                        Base.Rules.CastingPublic cp = casting as Base.Rules.CastingPublic;
                        cp.Ban(team == 1, selAva);
                        VI.Cout(Uid, "{0}方禁选{1}.", team == 1 ? "红" : "蓝", zd.Hero(selAva));
                    }
                    break;
                case "H0PM":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort who = ushort.Parse(args[0]);
                        if (who == Uid)
                        {
                            Base.Rules.CastingPublic cp = casting as Base.Rules.CastingPublic;
                            cinCalled = StartCinEtc();
                            while (true)
                            {
                                string input = VI.Cin(Uid, "请选择一名角色,当前可选角色:\n{0}",
                                    zd.HeroWithCode(cp.Xuan));
                                int hero;
                                if (int.TryParse(input, out hero) && cp.Xuan.Contains(hero))
                                {
                                    WI.Send("H0PN," + hero, Uid, 0);
                                    break;
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                        else
                            VI.Cout(Uid, "请等待{0}#选将.", who);
                    }
                    break;
                case "H0PO":
                    {
                        string[] args = cmdrst.Split(',');
                        int team = int.Parse(args[0]);
                        int selAva = int.Parse(args[1]);
                        Base.Rules.CastingPublic cp = casting as Base.Rules.CastingPublic;
                        cp.Pick(team == 1, selAva);
                        VI.Cout(Uid, "{0}方选择了{1}.", team == 1 ? "红" : "蓝", zd.Hero(selAva));
                    }
                    break;
                case "H0CT":
                    {
                        string[] args = cmdrst.Split(',');
                        int xsz1 = int.Parse(args[0]);
                        List<int> x1 = Algo.TakeRange(args, 1, 1 + xsz1)
                            .Select(p => int.Parse(p)).ToList();
                        int xsz2 = int.Parse(args[xsz1 + 1]);
                        List<int> x2 = Algo.TakeRange(args, 2 + xsz1, 2 + xsz1 + xsz2)
                            .Select(p => int.Parse(p)).ToList();
                        Base.Rules.CastingCongress cc = new Base.Rules.CastingCongress(x1, x2, new List<int>());
                        casting = cc;
                        cc.CaptainMode = false;
                        for (int i = xsz1 + xsz2 + 2; i < args.Length; i += 2)
                            cc.Init(ushort.Parse(args[i]), int.Parse(args[i + 1]));

                        cc.ToHint(Uid, VI, zd.HeroWithCode, zd.Hero);
                        cinCalled = StartCinEtc();
                        while ((Uid % 2 == 0 && !cc.DecidedAo) || (Uid % 2 == 1 && !cc.DecidedAka))
                        {
                            List<int> xuanR = (Uid % 2 == 0) ? cc.XuanAo : cc.XuanAka;
                            if (VI is ClientZero.VW.Ayvi)
                            {
                                string op = VI.Cin(Uid, null);
                                op = op.Trim().ToUpper();
                                int selAva;
                                bool has = cc.Ding[Uid] != 0;
                                if (op == "X" && cc.IsCaptain(Uid))
                                    WI.Send("H0CD,0", Uid, 0);
                                else if (op == "0" && has)
                                    WI.Send("H0CB," + cc.Ding[Uid], Uid, 0);
                                else if (int.TryParse(op, out selAva) && xuanR.Contains(selAva))
                                    WI.Send("H0CN," + Uid + "," + selAva, Uid, 0);
                            }
                        }
                        VI.CloseCinTunnel(Uid);
                    }
                    break;
                case "H0CI":
                    {
                        string[] args = cmdrst.Split(',');
                        int xsz1 = int.Parse(args[0]);
                        List<int> x1 = Algo.TakeRange(args, 1, 1 + xsz1)
                            .Select(p => int.Parse(p)).ToList();
                        int xsz2 = int.Parse(args[xsz1 + 1]);
                        List<int> x2 = Algo.TakeRange(args, 2 + xsz1, 2 + xsz1 + xsz2)
                            .Select(p => int.Parse(p)).ToList();
                        Base.Rules.CastingCongress cc = new Base.Rules.CastingCongress(x1, x2, new List<int>());
                        casting = cc;
                        cc.CaptainMode = true;
                        for (int i = xsz1 + xsz2 + 2; i < args.Length; i += 2)
                            cc.Init(ushort.Parse(args[i]), int.Parse(args[i + 1]));

                        cc.ToHint(Uid, VI, zd.HeroWithCode, zd.Hero);
                        if (cc.IsCaptain(Uid)) // Captain Only
                        {
                            VI.Cout(Uid, "===> 选择目标玩家与角色,以逗号分隔;0为退回,X为选将确定.");
                            cinCalled = StartCinEtc();
                            bool isAka = (Uid % 2 == 1);
                            while ((isAka && !cc.DecidedAka) || (!isAka && !cc.DecidedAo))
                            {
                                //List<int> xuanR = (Uid % 2 == 0) ? cc.XuanAo : cc.XuanAka;
                                if (VI is ClientZero.VW.Ayvi)
                                {
                                    string op = VI.Cin(Uid, null);
                                    op = op.Trim().ToUpper();
                                    //bool has = cc.Ding[Uid] != 0;
                                    if (op == "X")
                                        WI.Send("H0CD,0", Uid, 0);
                                    else
                                    {
                                        int idx = op.IndexOf(',');
                                        if (idx >= 0)
                                        {
                                            ushort who; int selAva;
                                            if (ushort.TryParse(op.Substring(0, idx), out who) &&
                                                int.TryParse(op.Substring(idx + 1), out selAva))
                                            {
                                                if (selAva == 0 && cc.Ding[who] != 0)
                                                    WI.Send("H0CB," + cc.Ding[who], Uid, 0);
                                                else
                                                    WI.Send("H0CN," + who + "," + selAva, Uid, 0);
                                            }
                                        }
                                    }
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                    }
                    break;
                case "H0CO":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        int heroCode = int.Parse(args[1]);
                        int backCode = int.Parse(args[2]);
                        ushort backTo = ushort.Parse(args[3]);
                        if (puid == Uid)
                            VI.Cout(Uid, "您预选了{0}.", zd.Hero(heroCode));
                        else
                            VI.Cout(Uid, "玩家{0}#已预选了{1}.", puid, zd.Hero(heroCode));
                        if (backTo != 0)
                            VI.Cout(Uid, "玩家{0}#已预选了{1}.", backTo, zd.Hero(backCode));
                        Base.Rules.CastingCongress cc = casting as Base.Rules.CastingCongress;
                        cc.Set(puid, heroCode);
                        cc.ToHint(Uid, VI, zd.HeroWithCode, zd.Hero);
                        if (!cc.CaptainMode || cc.IsCaptain(Uid))
                            cc.ToInputRequire(Uid, VI);
                    }
                    break;
                case "H0CC":
                    {
                        string[] args = cmdrst.Split(',');
                        //ushort puid = ushort.Parse(args[0]);
                        int heroCode = int.Parse(args[1]);
                        VI.Cout(Uid, "{0}被放回选将池中.", zd.Hero(heroCode));
                        Base.Rules.CastingCongress cc = casting as Base.Rules.CastingCongress;
                        cc.Set(0, heroCode);
                        cc.ToHint(Uid, VI, zd.HeroWithCode, zd.Hero);
                        if (!cc.CaptainMode || cc.IsCaptain(Uid))
                            cc.ToInputRequire(Uid, VI);
                    }
                    break;
                case "H0CE":
                    {
                        string[] args = cmdrst.Split(',');
                        int code = int.Parse(args[0]);
                        if (code == 0)
                            VI.Cout(Uid, "抱歉,您队伍角色尚未全部选定。");
                        else if (code == 1)
                        { // The Opponent
                            int team = int.Parse(args[1]);
                            if (IsUtTeam(team))
                                VI.Cout(Uid, "我方已经选定角色.");
                            else if (!IsUtOpp(team))
                                VI.Cout(Uid, "对方已经选定角色.");
                            else
                                VI.Cout(Uid, "{0}方已经选定角色.", team == 2 ? "蓝" : "红");
                        }
                        else if (code == 2)
                        {
                            Base.Rules.CastingCongress cc = casting as Base.Rules.CastingCongress;
                            if (IsUtAo())
                                cc.DecidedAo = true;
                            else
                                cc.DecidedAka = true;
                            // VI.TerminCinTunnel(Uid);
                            string msg = "我方选择结果为:";
                            for (int i = 1; i < args.Length; i += 2)
                            {
                                ushort ut = ushort.Parse(args[i]);
                                int ava = int.Parse(args[i + 1]);
                                Z0D[ut].SelectHero = ava;
                                Z0D[ut].IsAlive = true;
                                msg += (ut + ":" + zd.Hero(ava) + ",");
                            }
                            VI.Cout(Uid, "{0}.", msg.Substring(0, msg.Length - 1));
                        }
                    }
                    break;
                case "H0SL":
                    {
                        string[] args = cmdrst.Split(',');
                        for (int i = 0; i < args.Length; i += 2)
                        {
                            ushort puid = ushort.Parse(args[i]);
                            int heroCode = ushort.Parse(args[i + 1]);
                            //msg += (puid + ":" + zd.Hero(heroCode) + ",");
                            Z0D[puid].SelectHero = heroCode;
                            Z0D[puid].ParseFromHeroLib();
                        }
                        VI.Cout(Uid, "选择结果为-" + string.Join(",", Z0D.Values
                            .Where(p => p.SelectHero != 0)
                            .Select(p => p.Uid + ":" + zd.Hero(p.SelectHero))));
                        Z0F = new ZeroField(this);
                        Z0M = new ZeroMe(this);
                        if (Uid > 0 && Uid < 1000) // not watcher
                            Z0M.SelectHero = Z0D[Uid].SelectHero;
                    }
                    break;
                case "H0DP":
                    {
                        string[] args = cmdrst.Split(',');
                        Z0P = new ZeroPiles(this)
                        {
                            TuxCount = int.Parse(args[0]),
                            MonCount = int.Parse(args[1]),
                            EveCount = int.Parse(args[2]),
                            TuxDises = 0,
                            MonDises = 0,
                            EveDises = 0
                        };
                    }
                    break;
                case "H0SN":
                    break;
                case "H0ST":
                    if (cmdrst.StartsWith("0"))
                    {
                        VI.Cout(Uid, "游戏开始阶段开始...");
                        //VI.ReleaseCin(uid);
                    }
                    else if (cmdrst.StartsWith("1"))
                    {
                        VI.Cout(Uid, "游戏开始阶段结束...");
                        //VI.ReleaseCin(uid);
                    }
                    break;
                case "H0TM":
                    VI.Cout(Uid, "游戏结束啦。");
                    break;
                case "H09N":
                    {
                        string[] blocks = cmdrst.Split(',');
                        for (int idx = 0; idx < blocks.Length; idx += 2)
                        {
                            ushort who = ushort.Parse(blocks[idx]);
                            string name = blocks[idx + 1];
                            Z0D[who] = new ZeroPlayer(name, this);
                        }
                        break;
                    }
                case "H09G":
                    Algo.LongMessageParse(("H09G," + cmdrst).Split(','), (who) => { Z0D[who].Uid = who; },
                        (who, key, value) =>
                        {
                            ZeroPlayer zp = Z0D[who];
                            switch (key)
                            {
                                case "hero": zp.SelectHero = (int)value; break;
                                case "state":
                                    zp.IsAlive = (((int)value & 1) != 0);
                                    zp.IsLoved = (((int)value & 2) != 0);
                                    zp.Immobilized = (((int)value & 4) != 0);
                                    zp.PetDisabled = (((int)value & 8) != 0); break;
                                case "hp": zp.HP = (ushort)value; break;
                                case "hpa": zp.HPa = (ushort)value; break;
                                case "str": zp.STR = (ushort)value; break;
                                case "stra": zp.STRa = (ushort)value; break;
                                case "dex": zp.DEX = (ushort)value; break;
                                case "dexa": zp.DEXa = (ushort)value; break;
                                case "tuxCount": zp.TuxCount = (int)value; break;
                                case "wp": zp.Weapon = (ushort)value; break;
                                case "am": zp.Armor = (ushort)value; break;
                                case "tr": zp.Trove = (ushort)value; break;
                                case "exq": zp.ExEquip = (ushort)value; break;
                                case "lug":
                                {
                                    string[] lugs = (string[])value;
                                    if (lugs.Length > 0 && zp.Trove != 0)
                                    {
                                        if (!zp.Treasures.ContainsKey(zp.Trove))
                                            zp.Treasures[zp.Trove] = new List<string>();
                                        zp.Treasures[zp.Trove].AddRange(lugs);
                                    }
                                    break;
                                }
                                case "guard": zp.Guardian = (ushort)value; break;
                                case "coss": zp.Coss = (ushort)value; break;
                                case "pet":
                                    zp.Pets.Clear(); zp.Pets.AddRange((ushort[])value); break;
                                case "excard":
                                    zp.ExCards.Clear(); zp.ExCards.AddRange((ushort[])value); break;
                                case "token": zp.Token = (int)value; break;
                                case "fakeq":
                                    for (int i = 0; i < ((string[])value).Length; i += 2)
                                        zp.Fakeq[ushort.Parse(((string[])value)[i])] = ((string[])value)[i + 1];
                                    break;
                                case "rune":
                                    zp.Runes.Clear(); zp.Runes.AddRange((ushort[])value); break;
                                case "excl":
                                    zp.SpecialCards.Clear(); zp.SpecialCards.AddRange((string[])value); break;
                                case "tar":
                                    zp.PlayerTars.Clear(); zp.PlayerTars.AddRange((ushort[])value); break;
                                case "awake":
                                    zp.AwakeSignal = (ushort)value == 1; break;
                                case "foldsz": zp.FolderCount = (int)value; break;
                                case "escue":
                                    zp.Escue.Clear(); zp.Escue.AddRange((ushort[])value); break;
                            }
                        }, Board.StatusKey);
                    break;
                case "H09P":
                    {
                        Z0M = new ZeroMe(this);
                        Z0F = new ZeroField(this);
                        Z0P = new ZeroPiles(this);

                        string[] blocks = cmdrst.Split(',');
                        Z0P.TuxCount = int.Parse(blocks[0]);
                        Z0P.MonCount = int.Parse(blocks[1]);
                        Z0P.EveCount = int.Parse(blocks[2]);

                        Z0P.TuxDises = int.Parse(blocks[3]);
                        Z0P.MonDises = int.Parse(blocks[4]);
                        Z0P.EveDises = int.Parse(blocks[5]);

                        ushort rounder = ushort.Parse(blocks[6]);
                        ushort supporter = ushort.Parse(blocks[7]);
                        //bool shit = blocks[8] == "1";
                        ushort hinder = ushort.Parse(blocks[9]);
                        //bool hhit = blocks[10] == "1";

                        Z0F.Hinder = hinder;
                        Z0F.Supporter = supporter;

                        int idx = 11;
                        ushort[] drums = Algo.TakeArrayWithSize(blocks, idx, out idx, 2);
                        for (int i = 0; i < drums.Length; i += 2)
                            Z0F.Drums.Add(drums[i]);
                        //ushort wang = ushort.Parse(blocks[idx]);
                        ushort mon1 = ushort.Parse(blocks[idx + 1]);
                        ushort mon2 = ushort.Parse(blocks[idx + 2]);
                        ushort eve1 = ushort.Parse(blocks[idx + 3]);
                        Z0F.Monster1 = mon1; Z0F.Monster2 = mon2; Z0F.Eve1 = eve1;

                        for (int i = idx + 4; i < Math.Min(blocks.Length, idx + 8); i += 2)
                        {
                            if (blocks[i] == "1")
                            {
                                if (rounder % 2 == 0) Z0F.RPool = int.Parse(blocks[i + 1]);
                                else Z0F.OPool = int.Parse(blocks[i + 1]);
                            }
                            else if (blocks[i] == "2")
                            {
                                if (rounder % 2 == 0) Z0F.OPool = int.Parse(blocks[i + 1]);
                                else Z0F.RPool = int.Parse(blocks[i + 1]);
                            }
                        }
                        for (int i = idx + 8; i < blocks.Length; i += 2)
                            Z0P.Score[int.Parse(blocks[i])] = int.Parse(blocks[i + 1]);
                    }
                    break;
                case "H0LT":
                    if (!GameGraceEnd) {
                        ushort who = ushort.Parse(cmdrst);
                        if (who != 0)
                            VI.Cout(Uid, "玩家{0}#逃跑,游戏终结。", who);
                        else
                            VI.Cout(Uid, "服务器被延帝抓走啦,游戏结束。", who);
                    }
                    break;
                case "H0WT":
                    if (!GameGraceEnd)
                    {
                        ushort who = ushort.Parse(cmdrst);
                        if (who != 0)
                            VI.Cout(Uid, "玩家{0}#断线,请耐心等待其重连~", who);
                    }
                    break;
                case "H0WD":
                    if (!GameGraceEnd) {
                        int secLeft = int.Parse(cmdrst);
                        VI.Cout(Uid, "房间将在{0}秒后彻底关闭。", secLeft);
                    }
                    break;
                case "H0BK":
                    {
                        ushort who = ushort.Parse(cmdrst);
                        if (who != 0)
                            VI.Cout(Uid, "玩家{0}#恢复连接。", who);
                    }
                    break;
                case "H0RK":
                    VI.Cout(Uid, "房间已恢复正常。");
                    break;
                case "H09F":
                    {
                        string[] blocks = cmdrst.Split(',');
                        int idx = 0;
                        int tuxCount = int.Parse(blocks[idx]);
                        ++idx;
                        List<ushort> tuxes = Algo.TakeRange(blocks, idx, idx + tuxCount)
                            .Select(p => ushort.Parse(p)).ToList();
                        Z0M.Tux = tuxes;
                        idx += tuxCount;
                        int folderCount = int.Parse(blocks[idx]);
                        ++idx;
                        List<ushort> folders = Algo.TakeRange(blocks, idx, idx + folderCount)
                            .Select(p => ushort.Parse(p)).ToList();
                        Z0M.Folder = folders;
                        idx += folderCount;
                        int skillCount = int.Parse(blocks[idx]);
                        ++idx;
                        //List<string> skills = Algo.TakeRange(blocks, idx, idx + skillCount).ToList();
                        //Z0M.Skills = skills;
                        idx += skillCount;
                    }
                    break;
            }
            return cinCalled;
        }
示例#2
0
文件: XIVisi.cs 项目: palome06/psd48
        private bool HandleHMessage(string cop, string cmdrst)
        {
            bool cinCalled = false;
            switch (cop)
            {
                //case "H1NW":
                //    {
                //        int idx = cmdrst.IndexOf(',');
                //        ushort who = ushort.Parse(cmdrst.Substring(0, idx));
                //        string name = cmdrst.Substring(idx + 1);
                //        if (Z0D.ContainsKey(who))
                //            Z0D[who] = new ZeroPlayer(name, this) { Uid = who };
                //        else
                //            Z0D.Add(who, new ZeroPlayer(name, this) { Uid = who });
                //    }
                //    break;
                case "H0SD":
                    {
                        string[] blocks = Algo.Splits(cmdrst, ",");
                        for (int i = 0; i < blocks.Length; i += 3)
                        {
                            ushort aut = ushort.Parse(blocks[i + 1]);
                            if (aut == auid)
                            {
                                Uid = ushort.Parse(blocks[i]);
                                break;
                            }
                        }
                        int[] delta; ushort besu;
                        AoPlayer[] players = new AoPlayer[] {ad.yfPlayerR2.AoPlayer,
                            ad.yfPlayerO2.AoPlayer, ad.yfPlayerR3.AoPlayer, ad.yfPlayerO3.AoPlayer,
                            ad.yfPlayerR1.AoPlayer, ad.yfPlayerO1.AoPlayer};
                        if (IsUtAo())
                        {
                            besu = Uid;
                            delta = new int[] { 0, -1, 2, 1, 4, 3 };
                        }
                        else if (IsUtAka())
                        {
                            besu = Uid;
                            delta = new int[] { 0, 1, 2, 3, 4, 5 };
                        }
                        else
                        {
                            besu = 1;
                            delta = new int[] { 0, 1, 2, 3, 4, 5 };
                        }

                        for (int i = 0; i < totalPlayer; ++i)
                            A0P.Add(RoundUid(besu, delta[i]), players[i]);

                        for (int i = 0; i < blocks.Length; i += 3)
                        {
                            ushort ut = ushort.Parse(blocks[i]);
                            string name = blocks[i + 2];
                            A0P[ut].Nick = name; A0P[ut].Rank = ut;
                        }
                    }
                    break;
                case "H0SM":
                    {
                        string[] blocks = cmdrst.Split(',');
                        SelMode = int.Parse(blocks[0]);
                        LevelCode = int.Parse(blocks[1]);
                    }
                    break;
                case "H0SW":
                    {
                        string[] splits = cmdrst.Split(',');
                        ushort type = ushort.Parse(splits[0]);
                        List<ushort> pys = Algo.TakeRange(splits, 1, splits.Length)
                            .Select(p => ushort.Parse(p)).ToList();
                        pys.Remove(Uid);
                        if (pys.Count > 0)
                        {
                            string[] words = new string[] { "选择", "禁选" };
                            VI.ShowTip("等待其它玩家{0}人物...", words[type]);
                            foreach (ushort ut in pys)
                                ad.ShowProgressBar(ut);
                        }
                    }
                    break;
                //        case "H1LV":
                //            //Z0D.Remove(ushort.Parse(cmdrst));
                //            break;
                //        case "H1CN":
                //            VI.Cout(uid, "游戏开始啦!");
                //            break;
                //        case "H0ST":
                //            if (cmdrst.StartsWith("0"))
                //            {
                //                VI.Cout(uid, "游戏开始阶段开始...");
                //                //VI.ReleaseCin(uid);
                //            }
                //            else if (cmdrst.StartsWith("1"))
                //            {
                //                VI.Cout(uid, "游戏开始阶段结束...");
                //                //VI.ReleaseCin(uid);
                //            }
                //            break;
                case "H0RT":
                    ad.yfArena.AoArena.Casting = new Base.Rules.CastingPick(); break;
                case "H0RM":
                    {
                        List<int> cands = cmdrst.Split(',').Select(p => int.Parse(p)).ToList();
                        bool randomed = false;

                        var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPick;
                        if (cands.Count > 0 && cands.Last() == 0)
                        {
                            cands.RemoveAt(cands.Count - 1);
                            randomed = true;
                        }
                        cp.Init(Uid, cands, randomed ? new int[] { 0 }.ToList() : null);
                        string hint = randomed ? "请选择您的角色,空白牌为随机替换。"
                            : "请选择您的角色。";
                        ad.yfArena.AoArena.Show();
                        if (!isReplay)
                        {
                            cinCalled = StartCinEtc();
                            ad.ShowProgressBar(Uid);
                            while (true)
                            {
                                string input = VI.Cin48(Uid, hint);
                                int hero;
                                if (input == VI.CinSentinel)
                                    break;
                                if (int.TryParse(input, out hero))
                                {
                                    if ((hero != 0 && cp.Xuan[Uid].Contains(hero)) || cp.Huan[Uid].Count > 0)
                                    {
                                        WI.Send("H0RN," + hero, Uid, 0);
                                        break;
                                    }
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                    }
                    break;
                case "H0RO":
                    {
                        string[] args = cmdrst.Split(',');
                        int code = int.Parse(args[0]);
                        if (code == 0)
                        {
                            ushort puid = ushort.Parse(args[1]);
                            VI.Cout(Uid, "玩家{0}#已经选定角色.", puid);
                            ad.HideProgressBar(puid);
                        }
                        else if (code == 1)
                        {
                            ushort puid = ushort.Parse(args[1]);
                            int heroCode = int.Parse(args[2]);
                            var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPick;
                            if (cp.Pick(puid, heroCode))
                            {
                                if (puid == Uid)
                                {
                                    VI.Cout(Uid, "确认您的选择为{0}.", zd.Hero(heroCode));
                                    ad.yfArena.AoArena.Shutdown();
                                }
                                else
                                    VI.Cout(Uid, "玩家{0}#已选择了角色{1}.", puid, zd.Hero(heroCode));
                                ad.HideProgressBar(puid);
                                A0P[puid].SelectHero = heroCode;
                                A0P[puid].IsAlive = true;
                            }
                        }
                    }
                    break;
                case "H0RS":
                    {
                        int jdx = cmdrst.IndexOf(',');
                        int from = int.Parse(cmdrst.Substring(0, jdx));
                        int to = int.Parse(cmdrst.Substring(jdx + 1));
                        var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPick;
                        if (cp.SwitchTo(Uid, from, to) != 0)
                        {
                            ad.yfArena.AoArena.Switch(from, to);
                            if (!isReplay)
                            {
                                cinCalled = StartCinEtc();
                                while (true)
                                {
                                    string input = VI.Cin48(Uid, "请选择您的角色。");
                                    int hero;
                                    if (input == VI.CinSentinel)
                                        break;
                                    if (int.TryParse(input, out hero))
                                    {
                                        if ((hero != 0 && cp.Xuan[Uid].Contains(hero)))
                                        {
                                            WI.Send("H0RN," + hero, Uid, 0);
                                            break;
                                        }
                                    }
                                }
                                VI.CloseCinTunnel(Uid);
                            }
                        }
                    }
                    break;
                case "H0TT":
                    {
                        string[] args = cmdrst.Split(',');
                        int xsz = int.Parse(args[0]);
                        List<int> x = Algo.TakeRange(args, 1, 1 + xsz)
                            .Select(p => int.Parse(p)).ToList();
                        int bsz1 = int.Parse(args[xsz + 1]);
                        List<int> b1 = Algo.TakeRange(args, 2 + xsz, 2 + xsz + bsz1)
                            .Select(p => int.Parse(p)).ToList();
                        int bsz2 = int.Parse(args[xsz + bsz1 + 2]);
                        List<int> b2 = Algo.TakeRange(args, 3 + xsz + bsz1, 3 + xsz + bsz1 + bsz2)
                            .Select(p => int.Parse(p)).ToList();

                        Base.Rules.CastingTable ct = new Base.Rules.CastingTable(x, b1, b2);
                        ad.yfArena.AoArena.Casting = ct;
                        ad.yfArena.AoArena.Show();
                    }
                    break;
                case "H0TX":
                    {
                        // Verify whether these lists are the same.
                        //string[] args = cmdrst.Split(',');
                        //List<int> cands = Algo.TakeRange(args, 0, args.Length)
                        //    .Select(p => int.Parse(p)).ToList();
                        //selCandidates.Clear(); selCandidates.AddRange(cands);
                        cinCalled = StartCinEtc();
                        var ct = ad.yfArena.AoArena.Casting as Base.Rules.CastingTable;
                        ad.yfArena.AoArena.Active(null, false);
                        if (!isReplay)
                        {
                            while (true)
                            {
                                string input = VI.Cin48(Uid, "请选择一名角色.");
                                int hero;
                                if (input == VI.CinSentinel)
                                    break;
                                if (int.TryParse(input, out hero) && ct.Xuan.Contains(hero))
                                {
                                    WI.Send("H0TN," + hero, Uid, 0);
                                    break;
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                    }
                    break;
                case "H0TO":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        int heroCode = int.Parse(args[1]);
                        var ct = ad.yfArena.AoArena.Casting as Base.Rules.CastingTable;
                        if (ct.Pick(puid, heroCode))
                        {
                            if (puid == Uid)
                            {
                                VI.Cout(Uid, "确认您的选择为{0}.", zd.Hero(heroCode));
                                ad.yfArena.AoArena.Disactive(null);
                            }
                            else
                                VI.Cout(Uid, "玩家{0}#已选择了角色{1}.", puid, zd.Hero(heroCode));
                            ad.HideProgressBar(puid);
                            A0P[puid].SelectHero = heroCode;
                            A0P[puid].IsAlive = true;
                            ad.yfArena.AoArena.Remove(heroCode);
                        }
                    }
                    break;
                case "H0TA":
                    {
                        cinCalled = StartCinEtc();
                        string[] args = cmdrst.Split(',');
                        var ct = ad.yfArena.AoArena.Casting as Base.Rules.CastingTable;
                        if (!isReplay)
                        {
                            while (true)
                            {
                                bool canGiveup = args.Contains("0");
                                ad.yfArena.AoArena.Active(null, canGiveup);
                                string input = VI.Cin48(Uid, "请禁选一名角色.");
                                int hero;
                                if (input == VI.CinSentinel)
                                    break;
                                if (input == "0" && canGiveup)
                                {
                                    WI.Send("H0TB,0", Uid, 0); break;
                                }
                                else if (int.TryParse(input, out hero) && ct.Xuan.Contains(hero))
                                {
                                    WI.Send("H0TB," + hero, Uid, 0); break;
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                    }
                    break;
                case "H0TC":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        List<int> hrs = Algo.TakeRange(args, 1, args.Length)
                            .Select(p => int.Parse(p)).ToList();
                        if (hrs.Count == 0 && hrs[0] == 0)
                            VI.Cout(Uid, "玩家{0}#未禁选.", puid, zd.Hero(hrs));
                        else
                        {
                            var ct = ad.yfArena.AoArena.Casting as Base.Rules.CastingTable;
                            foreach (int heroCode in hrs)
                            {
                                if (ct.Ban(puid, heroCode))
                                    ad.yfArena.AoArena.BanBy(puid, heroCode);
                            }
                            VI.Cout(Uid, "玩家{0}#禁选了角色{1}.", puid, zd.Hero(hrs));
                        }
                        ad.HideProgressBar(puid);
                        if (Uid == puid)
                            ad.yfArena.AoArena.Disactive(null);
                        //if (ct.Xuan.Count > 0)
                        //    VI.Cout(Uid, "当前剩余角色:\n{0}.", zd.HeroWithCode(ct.Xuan));
                    }
                    break;
                case "H0TJ":
                    {
                        string[] args = cmdrst.Split(',');
                        List<int> hrs = Algo.TakeRange(args, 0, args.Length)
                            .Select(p => int.Parse(p)).ToList();
                        VI.Cout(Uid, "新增了角色{0}.", zd.Hero(hrs));
                        var ct = ad.yfArena.AoArena.Casting as Base.Rules.CastingTable;
                        foreach (int heroCode in hrs)
                        {
                            if (ct.PutBack(heroCode))
                                ad.yfArena.AoArena.PuckBack(heroCode);
                        }
                        ad.yfArena.AoArena.Disactive(null);
                        //if (ct.Xuan.Count > 0)
                        //    VI.Cout(Uid, "当前剩余角色:\n{0}.", zd.HeroWithCode(ct.Xuan));
                    }
                    break;
                case "H0PT":
                    {
                        string[] args = cmdrst.Split(',');
                        int idx = 0;
                        int xsz = int.Parse(args[idx]); ++idx;
                        List<int> x = Algo.TakeRange(args, idx, idx + xsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += xsz;
                        int drsz = int.Parse(args[idx]); ++idx;
                        List<int> dr = Algo.TakeRange(args, idx, idx + drsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += drsz;
                        int dbsz = int.Parse(args[idx]); ++idx;
                        List<int> db = Algo.TakeRange(args, idx, idx + dbsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += dbsz;
                        int brsz = int.Parse(args[idx]); ++idx;
                        List<int> br = Algo.TakeRange(args, idx, idx + brsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += brsz;
                        int bbsz = int.Parse(args[idx]); ++idx;
                        List<int> bb = Algo.TakeRange(args, idx, idx + bbsz)
                            .Select(p => int.Parse(p)).ToList();
                        idx += bbsz;

                        if (ad.yfArena.AoArena.Casting as Base.Rules.CastingPublic == null)
                        {
                            Base.Rules.CastingPublic cp = new Base.Rules.CastingPublic(x, dr, db, br, bb);
                            ad.yfArena.AoArena.Casting = cp;
                            ad.yfArena.AoArena.Show();
                        }
                        //else
                        //    ad.yfArena.AoArena.Check();
                    }
                    break;
                case "H0PA":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort who = ushort.Parse(args[0]);
                        if (who == Uid)
                        {
                            var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPublic;
                            if (!isReplay)
                            {
                                cinCalled = StartCinEtc();
                                while (true)
                                {
                                    ad.yfArena.AoArena.Active(new int[] { 1, 2 }, false);
                                    string input = VI.Cin(Uid, "请禁选一名角色.");
                                    int hero;
                                    if (input == VI.CinSentinel)
                                        break;
                                    if (int.TryParse(input, out hero) && cp.Xuan.Contains(hero))
                                    {
                                        WI.Send("H0PB," + hero, Uid, 0);
                                        break;
                                    }
                                }
                                VI.CloseCinTunnel(Uid);
                            }
                        }
                        else
                            VI.Cout(Uid, "请等待{0}#禁将.", who);
                    }
                    break;
                case "H0PC":
                    {
                        string[] args = cmdrst.Split(',');
                        int team = int.Parse(args[0]);
                        int selAva = int.Parse(args[1]);
                        var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPublic;
                        if (cp.Ban(team == 1, selAva))
                        {
                            VI.Cout(Uid, "{0}方禁选{1}.", team == 1 ? "红" : "蓝", zd.Hero(selAva));
                            ad.yfArena.AoArena.BanBy((ushort)team, selAva);
                            ad.yfArena.AoArena.Disactive(new int[] { 1, 2 });
                        }
                    }
                    break;
                case "H0PM":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort who = ushort.Parse(args[0]);
                        if (who == Uid)
                        {
                            var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPublic;
                            if (!isReplay)
                            {
                                cinCalled = StartCinEtc();
                                while (true)
                                {
                                    ad.yfArena.AoArena.Active(new int[] { 1, 2 }, false);
                                    string input = VI.Cin(Uid, "请选择一名角色.",
                                        zd.HeroWithCode(cp.Xuan));
                                    if (input == VI.CinSentinel)
                                        break;
                                    int hero;
                                    if (int.TryParse(input, out hero))
                                        if (cp.Xuan.Contains(hero) || (hero == 0 && cp.SilencedIdx < cp.Secrets.Count))
                                        {
                                            WI.Send("H0PN," + hero, Uid, 0);
                                            break;
                                        }
                                }
                                VI.CloseCinTunnel(Uid);
                            }
                        }
                        else
                            VI.Cout(Uid, "请等待{0}#选将.", who);
                    }
                    break;
                case "H0PO":
                    {
                        string[] args = cmdrst.Split(',');
                        int team = int.Parse(args[0]);
                        int selAva = int.Parse(args[1]);
                        var cp = ad.yfArena.AoArena.Casting as Base.Rules.CastingPublic;

                        bool real = cp.PickReport(team == 1, selAva);
                        if (selAva == 0)
                        {
                            VI.Cout(Uid, "{0}方选择了未知人物.", team == 1 ? "红" : "蓝");
                            ad.yfArena.AoArena.PickBy((ushort)team, 0);
                            ad.yfArena.AoArena.Disactive(new int[] { 1, 2 });
                        }
                        else
                        {
                            VI.Cout(Uid, "{0}方选择了{1}.", team == 1 ? "红" : "蓝", zd.Hero(selAva));
                            ad.yfArena.AoArena.PickBy((ushort)team, selAva);
                            ad.yfArena.AoArena.Disactive(new int[] { 1, 2 });
                        }
                    }
                    break;
                case "H0CT":
                    {
                        string[] args = cmdrst.Split(',');
                        int xsz1 = int.Parse(args[0]);
                        List<int> x1 = Algo.TakeRange(args, 1, 1 + xsz1)
                            .Select(p => int.Parse(p)).ToList();
                        int xsz2 = int.Parse(args[xsz1 + 1]);
                        List<int> x2 = Algo.TakeRange(args, 2 + xsz1, 2 + xsz1 + xsz2)
                            .Select(p => int.Parse(p)).ToList();
                        Base.Rules.CastingCongress cc = new Base.Rules.CastingCongress(x1, x2, new List<int>());
                        ad.yfArena.AoArena.Casting = cc;
                        cc.CaptainMode = false;
                        for (int i = xsz1 + xsz2 + 2; i < args.Length; i += 2)
                            cc.Init(ushort.Parse(args[i]), int.Parse(args[i + 1]));
                        ad.yfArena.AoArena.Show();
                        //cc.ToHint(Uid, VI, zd.HeroWithCode, zd.Hero);
                        cinCalled = StartCinEtc();
                        bool isAka = (Uid % 2 == 1);
                        if (!isReplay)
                        {
                            while ((!isAka && !cc.DecidedAo) || (isAka && !cc.DecidedAka))
                            {
                                List<int> xuanR = isAka ? cc.XuanAka : cc.XuanAo;
                                if (VI is VW.Cyvi)
                                {
                                    string op = (VI as VW.Cyvi).Cin48(Uid, "请选择您的角色。");
                                    op = op.Trim().ToUpper();
                                    int selAva;
                                    bool has = cc.Ding[Uid] != 0;
                                    if (op == "X" && cc.IsCaptain(Uid))
                                        WI.Send("H0CD,0", Uid, 0);
                                    else if (op == "0" && has)
                                        WI.Send("H0CB," + cc.Ding[Uid], Uid, 0);
                                    else if (int.TryParse(op, out selAva) && xuanR.Contains(selAva))
                                        WI.Send("H0CN," + Uid + "," + selAva, Uid, 0);
                                }
                            }
                        }
                        VI.CloseCinTunnel(Uid);
                    }
                    break;
                case "H0CI":
                    {
                        string[] args = cmdrst.Split(',');
                        int xsz1 = int.Parse(args[0]);
                        List<int> x1 = Algo.TakeRange(args, 1, 1 + xsz1)
                            .Select(p => int.Parse(p)).ToList();
                        int xsz2 = int.Parse(args[xsz1 + 1]);
                        List<int> x2 = Algo.TakeRange(args, 2 + xsz1, 2 + xsz1 + xsz2)
                            .Select(p => int.Parse(p)).ToList();
                        Base.Rules.CastingCongress cc = new Base.Rules.CastingCongress(x1, x2, new List<int>());
                        ad.yfArena.AoArena.Casting = cc;
                        cc.CaptainMode = true;
                        for (int i = xsz1 + xsz2 + 2; i < args.Length; i += 2)
                            cc.Init(ushort.Parse(args[i]), int.Parse(args[i + 1]));
                        ad.yfArena.AoArena.Show();
                        if (cc.IsCaptain(Uid) && !isReplay) // Captain Only
                        {
                            cinCalled = StartCinEtc();
                            bool isAka = (Uid % 2 == 1);
                            while ((isAka && !cc.DecidedAka) || (!isAka && !cc.DecidedAo))
                            {
                                List<int> xuanR = isAka ? cc.XuanAka : cc.XuanAo;
                                if (VI is VW.Cyvi)
                                {
                                    string op = (VI as VW.Cyvi).Cin48(Uid, "请为我方玩家分配角色.");
                                    op = op.Trim().ToUpper();
                                    bool has = cc.Ding[Uid] != 0;
                                    if (op == "X")
                                        WI.Send("H0CD,0", Uid, 0);
                                    else
                                    {
                                        int idx = op.IndexOf(',');
                                        if (idx >= 0)
                                        {
                                            ushort who; int selAva;
                                            if (ushort.TryParse(op.Substring(0, idx), out who) &&
                                                int.TryParse(op.Substring(idx + 1), out selAva))
                                            {
                                                if (selAva == 0 && cc.Ding[who] != 0)
                                                    WI.Send("H0CB," + cc.Ding[who], Uid, 0);
                                                else
                                                    WI.Send("H0CN," + who + "," + selAva, Uid, 0);
                                            }
                                        }
                                    }
                                }
                            }
                            VI.CloseCinTunnel(Uid);
                        }
                    }
                    break;
                case "H0CO":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        int heroCode = int.Parse(args[1]);
                        int backCode = int.Parse(args[2]);
                        ushort backTo = ushort.Parse(args[3]);
                        var cc = ad.yfArena.AoArena.Casting as Base.Rules.CastingCongress;
                        cc.Set(puid, heroCode);
                        if (puid == Uid)
                            VI.Cout(Uid, "您预选了{0}.", zd.Hero(heroCode));
                        else
                            VI.Cout(Uid, "玩家{0}#已预选了{1}.", puid, zd.Hero(heroCode));
                        ad.yfArena.AoArena.CongressDing(puid, heroCode, cc.CaptainMode);
                        if (backCode != 0)
                        {
                            if (backTo != 0)
                            {
                                VI.Cout(Uid, "玩家{0}#已预选了{1}.", backTo, zd.Hero(backCode));
                                ad.yfArena.AoArena.CongressDing(backTo, backCode, cc.CaptainMode);
                            }
                            else
                            {
                                VI.Cout(Uid, "{0}被放回选将池中.", zd.Hero(backCode));
                                ad.yfArena.AoArena.CongressBack(backCode);
                            }
                        }
                        //if (!cc.CaptainMode || (Uid == 1 || Uid == 2))
                        //    cc.ToInputRequire(Uid, VI);
                    }
                    break;
                case "H0CC":
                    {
                        string[] args = cmdrst.Split(',');
                        ushort puid = ushort.Parse(args[0]);
                        int heroCode = int.Parse(args[1]);
                        VI.Cout(Uid, "{0}被放回选将池中.", zd.Hero(heroCode));
                        var cc = ad.yfArena.AoArena.Casting as Base.Rules.CastingCongress;
                        cc.Set(0, heroCode);
                        ad.yfArena.AoArena.CongressBack(heroCode);
                        //if (!cc.CaptainMode || (Uid == 1 || Uid == 2))
                        //    cc.ToInputRequire(Uid, VI);
                    }
                    break;
                case "H0CE":
                    {
                        string[] args = cmdrst.Split(',');
                        int code = int.Parse(args[0]);
                        if (code == 0)
                            VI.Cout(Uid, "抱歉,您队伍角色尚未全部选定。");
                        else if (code == 1)
                        { // The Opponent
                            int team = int.Parse(args[1]);
                            if (IsUtTeam(team))
                                VI.Cout(Uid, "我方已经选定角色.");
                            else if (!IsUtOpp(team))
                                VI.Cout(Uid, "对方已经选定角色.");
                            else
                                VI.Cout(Uid, "{0}方已经选定角色.", team == 2 ? "蓝" : "红");
                        }
                        else if (code == 2)
                        {
                            var cc = ad.yfArena.AoArena.Casting as Base.Rules.CastingCongress;
                            if (IsUtAo())
                                cc.DecidedAo = true;
                            else
                                cc.DecidedAka = true;
                            // VI.TerminCinTunnel(Uid);
                            ad.yfArena.AoArena.Shutdown();
                            string msg = "我方选择结果为:";
                            for (int i = 1; i < args.Length; i += 2)
                            {
                                ushort ut = ushort.Parse(args[i]);
                                int ava = int.Parse(args[i + 1]);
                                A0P[ut].SelectHero = ava;
                                A0P[ut].IsAlive = true;
                                msg += (ut + ":" + zd.Hero(ava) + ",");
                            }
                            VI.Cout(Uid, "{0}.", msg.Substring(0, msg.Length - 1));
                        }
                    }
                    break;

                case "H0SN":
                    ad.yfArena.AoArena.Shutdown(); break;

                case "H0SL":
                    {
                        string[] args = cmdrst.Split(',');
                        for (int i = 0; i < args.Length; i += 2)
                        {
                            ushort puid = ushort.Parse(args[i]);
                            int heroCode = ushort.Parse(args[i + 1]);
                            //msg += (puid + ":" + zd.Hero(heroCode) + ",");
                            A0P[puid].SelectHero = heroCode;
                            A0P[puid].ParseFromHeroLib();
                        }
                        VI.Cout(Uid, "选择结果为-" + string.Join(",", A0P.Values
                            .Where(p => p.SelectHero != 0)
                            .Select(p => p.Rank + ":" + zd.Hero(p.SelectHero))));
                    }
                    break;
                case "H0DP":
                    {
                        string[] args = cmdrst.Split(',');
                        A0F.TuxCount = int.Parse(args[0]); A0F.TuxDises = 0;
                        A0F.MonCount = int.Parse(args[1]); A0F.MonDises = 0;
                        A0F.EveCount = int.Parse(args[2]); A0F.TuxDises = 0;
                    }
                    break;
                case "H0ST":
                    if (cmdrst.StartsWith("0"))
                    {
                        VI.Cout(Uid, "游戏开始阶段开始...");
                        //VI.ReleaseCin(uid);
                    }
                    else if (cmdrst.StartsWith("1"))
                    {
                        VI.Cout(Uid, "游戏开始阶段结束...");
                        //VI.ReleaseCin(uid);
                    }
                    break;
                case "H0TM":
                    VI.Cout(Uid, "游戏结束啦。");
                    break;
                case "H09N":
                    {
                        A0P.Clear();
                        AoPlayer[] players = new AoPlayer[] {ad.yfPlayerR2.AoPlayer,
                            ad.yfPlayerO2.AoPlayer, ad.yfPlayerR3.AoPlayer, ad.yfPlayerO3.AoPlayer,
                            ad.yfPlayerR1.AoPlayer, ad.yfPlayerO1.AoPlayer};
                        ushort besu; int[] delta;
                        if (IsUtAo())
                        {
                            besu = Uid;
                            delta = new int[] { 0, -1, 2, 1, 4, 3 };
                        }
                        else if (IsUtAka())
                        {
                            besu = Uid;
                            delta = new int[] { 0, 1, 2, 3, 4, 5 };
                        }
                        else
                        {
                            besu = WATCHER_1ST_PERSPECT;
                            delta = new int[] { 0, 1, 2, 3, 4, 5 };
                        }

                        for (int i = 0; i < totalPlayer; ++i)
                            A0P.Add(RoundUid(besu, delta[i]), players[i]);

                        string[] blocks = cmdrst.Split(',');
                        for (int idx = 0; idx < blocks.Length; idx += 2)
                        {
                            ushort who = ushort.Parse(blocks[idx]);
                            string name = blocks[idx + 1];
                            A0P[who].Nick = name; A0P[who].Rank = who;
                        }
                        break;
                    }
                case "H09R":
                    if (WI is VW.Eywi)
                    {
                        Uid = ushort.Parse(cmdrst);
                    }
                    break;
                case "H09G":
                    Algo.LongMessageParse(("H09G," + cmdrst).Split(','), InitPlayerPositionFromLongMessage,
                        InitPlayerFullFromLongMessage, Board.StatusKey);
                    break;
                case "H09P":
                    {
                        //Z0M = new ZeroMe(this);
                        //Z0F = new ZeroField(this);
                        //Z0P = new ZeroPiles(this);
                        string[] blocks = cmdrst.Split(',');
                        A0F.TuxCount = int.Parse(blocks[0]);
                        A0F.MonCount = int.Parse(blocks[1]);
                        A0F.EveCount = int.Parse(blocks[2]);

                        A0F.TuxDises = int.Parse(blocks[3]);
                        A0F.MonDises = int.Parse(blocks[4]);
                        A0F.EveDises = int.Parse(blocks[5]);

                        //A0F.Rounder
                        ushort rounder = ushort.Parse(blocks[6]);
                        ushort supporter = ushort.Parse(blocks[7]);
                        bool shit = blocks[8] == "1";
                        ushort hinder = ushort.Parse(blocks[9]);
                        bool hhit = blocks[10] == "1";
                        foreach (AoPlayer ap in A0P.Values)
                            ap.SetAsClear();
                        if (rounder != 0)
                            A0P[rounder].SetAsRounder();
                        A0F.Supporter = supporter;
                        if (supporter != 0 && supporter < 1000)
                        {
                            if (shit) { A0P[supporter].SetAsSpSucc(); }
                            else { A0P[supporter].SetAsSpFail(); }
                        }
                        A0F.Hinder = hinder;
                        if (hinder != 0 && hinder < 1000)
                        {
                            if (hhit) { A0P[hinder].SetAsSpSucc(); }
                            else { A0P[hinder].SetAsSpFail(); }
                        }

                        int idx = 11;
                        ushort[] drums = Algo.TakeArrayWithSize(blocks, idx, out idx, 2);
                        for (int i = 0; i < drums.Length; i += 2)
                        {
                            ushort d = drums[i];
                            if (d != 0)
                            {
                                A0F.Drums.Add(d);
                                if (d < 1000)
                                {
                                    if (drums[i + 1] == 1) A0P[d].SetAsSpSucc();
                                    else A0P[d].SetAsSpFail();
                                }
                            }
                        }

                        ushort wang = ushort.Parse(blocks[idx]);
                        ushort mon1 = ushort.Parse(blocks[idx + 1]);
                        ushort mon2 = ushort.Parse(blocks[idx + 2]);
                        ushort eve1 = ushort.Parse(blocks[idx + 3]);
                        A0F.Eve1 = eve1; A0F.Wang = wang;
                        A0F.Monster1 = mon1; A0F.Monster2 = mon2;

                        for (int i = idx + 4; i < Math.Min(blocks.Length, idx + 8); i += 2)
                        {
                            if (blocks[i] == "1")
                                A0F.PoolAka = int.Parse(blocks[i + 1]);
                            else if (blocks[i] == "2")
                                A0F.PoolAo = int.Parse(blocks[i + 1]);
                        }
                        for (int i = idx + 8; i < blocks.Length; i += 2)
                        {
                            if (blocks[i] == "1")
                                A0F.ScoreAka = int.Parse(blocks[i + 1]);
                            else if (blocks[i] == "2")
                                A0F.ScoreAo = int.Parse(blocks[i + 1]);
                        }
                    }
                    break;
                case "H0LT":
                    if (!GameGraceEnd)
                    {
                        ushort who = ushort.Parse(cmdrst);
                        if (who != 0)
                            VI.Cout(Uid, "玩家{0}#断线,游戏结束。", who);
                        else
                            VI.Cout(Uid, "服务器被延帝抓走啦,游戏结束。");
                        ad.SetCanan(CananPaint.CananSignal.FAIL_CONNECTION);
                        GameInDanger = true;
                    }
                    break;
                case "H0WT":
                    if (!GameGraceEnd)
                    {
                        ushort who = ushort.Parse(cmdrst);
                        if (who != 0)
                        {
                            VI.Cout(Uid, "玩家{0}#断线,请耐心等待其重连~", who);
                            A0P[who].SetAsLoser();
                        }
                        ReportConnectionLost();
                    }
                    break;
                case "H0WD":
                    if (!GameGraceEnd)
                    {
                        int secLeft = int.Parse(cmdrst);
                        VI.Cout(Uid, "房间将在{0}秒后彻底关闭。", secLeft);
                        if (secLeft == 180)
                            ad.SetCanan(CananPaint.CananSignal.LOSE_COUNTDOWN_48);
                        else if (secLeft == 60)
                            ad.SetCanan(CananPaint.CananSignal.LOSE_COUNTDOWN_12);
                        GameInDanger = true;
                    }
                    break;
                case "H0BK":
                    {
                        ushort who = ushort.Parse(cmdrst);
                        if (who != 0 && who != Uid)
                        {
                            VI.Cout(Uid, "玩家{0}#恢复连接。", who);
                            if (A0P.ContainsKey(who))
                                A0P[who].SetAsBacker();
                        }
                    }
                    break;
                case "H0RK":
                    VI.Cout(Uid, "房间已恢复正常。");
                    GameInDanger = false;
                    ad.SetCanan(CananPaint.CananSignal.NORMAL);
                    break;
                case "H09F":
                    {
                        A0M.Reset();
                        string[] blocks = cmdrst.Split(',');
                        int idx = 0;
                        int tuxCount = int.Parse(blocks[idx]);
                        ++idx;
                        List<ushort> tuxes = Algo.TakeRange(blocks, idx, idx + tuxCount)
                            .Select(p => ushort.Parse(p)).ToList();
                        A0M.insTux(tuxes);
                        idx += tuxCount;
                        int folderCount = int.Parse(blocks[idx]);
                        ++idx;
                        List<ushort> folders = Algo.TakeRange(blocks, idx, idx + folderCount)
                            .Select(p => ushort.Parse(p)).ToList();
                        A0P[Uid].InsMyFolder(folders);
                        //A0M.InsMyFolder(folders);
                        idx += folderCount;
                        int skillCount = int.Parse(blocks[idx]);
                        ++idx;
                        if (skillCount > 0)
                        {
                            List<string> skills = Algo.TakeRange(blocks, idx, idx + skillCount).ToList();
                            A0P[Uid].ClearSkill();
                            A0P[Uid].GainSkill(skills);
                        }
                        idx += skillCount;
                    }
                    break;
            }
            return cinCalled;
        }