Пример #1
0
        public void ToHint(ushort ut, Base.VW.IVI vi,
            Func<IEnumerable<int>, string> withCode, Func<IEnumerable<int>, string> withoutCode)
        {
            bool ao = (ut > 0 && ut < 1000 && ut % 2 == 0);
            bool aka = (ut > 0 && ut < 1000 && ut % 2 == 1);
            List<int> dingR = (ao ? DingAo : DingAka).ToList();
            List<int> dingO = (ao ? DingAka : DingAo).ToList();
            List<int> banR = (ao ? BanAo : BanAka).ToList();
            List<int> banO = (ao ? BanAka : BanAo).ToList();

            if (!ao)
            {
                List<int> hinds = dingO.Intersect(Secrets).ToList();
                foreach (int h in hinds)
                {
                    dingO.Remove(h); dingO.Add(0);
                }
            }
            if (!aka)
            {
                List<int> hinds = dingR.Intersect(Secrets).ToList();
                foreach (int h in hinds)
                {
                    dingR.Remove(h); dingR.Add(0);
                }
            }

            List<int> x = Xuan.ToList();
            List<int> xhinds = x.Intersect(Secrets).ToList();
            foreach (int xh in xhinds)
            {
                x.Remove(xh); x.Add(0);
            }
            vi.Cout(ut, "当前可选角色-{0}.", withCode(x));
            if (dingR.Count > 0)
                vi.Cout(ut, "我方已选角色-{0}.", withoutCode(dingR));
            if (dingO.Count > 0)
                vi.Cout(ut, "对方已选角色-{0}.", withoutCode(dingO));
            if (banR.Count > 0)
                vi.Cout(ut, "我方已禁角色-{0}.", withoutCode(banR));
            if (banO.Count > 0)
                vi.Cout(ut, "对方已禁角色-{0}.", withoutCode(banO));
        }
Пример #2
0
 public void ToInputRequire(ushort ut, Base.VW.IVI vi)
 {
     vi.Cout(ut, "===> 选择您的角色{0}{1}.", Ding[ut] != 0 ? ",0为退回" : "",
          IsCaptain(ut) ? ",X为选将确定" : "");
 }
Пример #3
0
        private bool ConnectDoDirect(TcpClient client, bool watch, Base.VW.IVI vi)
        {
            NetworkStream tcpStream = client.GetStream();
            if (!watch)
                Base.VW.WHelper.SentByteLine(tcpStream, "C2CO,0," + name + "," + avatar + "," + hopeTeam);
            else
                Base.VW.WHelper.SentByteLine(tcpStream, "C2QI,0," + name);
            IDictionary<ushort, IchiPlayer> uidict = new Dictionary<ushort, IchiPlayer>();
            while (true)
            {
                string line = Base.VW.WHelper.ReadByteLine(tcpStream);
                if (line == null)
                    return false;
                else if (line.StartsWith("C2CN,") && !watch)
                {
                    ushort ut = ushort.Parse(line.Substring("C2CN,".Length));
                    if (ut == 0)
                        return false;
                    Uid = ut;
                }
                else if (line.StartsWith("C2QJ,") && watch)
                {
                    ushort ut = ushort.Parse(line.Substring("C2QJ,".Length));
                    if (ut == 0)
                        return false;
                    Uid = ut;
                }
                else if (line.StartsWith("C2RM,"))
                {
                    string[] blocks = line.Split(',');
                    for (int i = 1; i < blocks.Length; i += 3)
                    {
                        ushort ouid = ushort.Parse(blocks[i]);
                        IchiPlayer ip = new IchiPlayer()
                        {
                            Name = blocks[i + 1],
                            Avatar = int.Parse(blocks[i + 2]),
                            Uid = ouid
                        };
                        uidict.Add(ouid, ip);
                    }
                    vi.Cout(Uid, "Current other gamers: {0}", string.Join(",",
                        uidict.Values.Select(p => p.Name)));
                }
                else if (line.StartsWith("C2NW,"))
                {
                    int idx = line.IndexOf(',');
                    int jdx = line.IndexOf(',', idx + 1);
                    int kdx = line.LastIndexOf(',');

                    ushort ouid = ushort.Parse(Base.Utils.Algo.Substring(line, idx + 1, jdx));
                    IchiPlayer ip = new IchiPlayer()
                    {
                        Name = Base.Utils.Algo.Substring(line, jdx + 1, kdx),
                        Avatar = int.Parse(line.Substring(kdx + 1)),
                        Uid = ouid
                    };
                    uidict.Add(ouid, ip);
                    vi.Cout(Uid, "Newcomer: {0}", Base.Utils.Algo.Substring(line, jdx + 1, kdx));
                }
                else if (line.StartsWith("C2SA,"))
                {
                    stream = tcpStream;
                    StartListenTask(KeepOnListenRecv);
                    if (!watch)
                        StartListenTask(KeepOnListenSend);
                    return true;
                }
                else if (line.StartsWith("C"))
                    return false;
            }
        }
Пример #4
0
 public void ToHint(ushort ut, Base.VW.IVI vi,
     Func<IEnumerable<int>, string> withCode, Func<int, string> withoutCode)
 {
     bool isAo = (ut > 0 && ut < 1000 && ut % 2 == 0);
     List<int> xuanR = isAo ? XuanAo : XuanAka;
     List<int> xuanO = isAo ? XuanAka : XuanAo;
     vi.Cout(ut, "对方可选角色-{0}.", withCode(xuanO));
     vi.Cout(ut, "我方可选角色-{0}.", withCode(xuanR));
     if (Ding.Any(p => p.Value != 0))
         vi.Cout(ut, "当前已选角色-{0}.", string.Join(",", Ding.Where(
             p => p.Value != 0).Select(p => p.Key + ":" + withoutCode(p.Value))));
 }
Пример #5
0
        private bool ConnectDoDirect(TcpClient client, bool watch, Base.VW.IVI vi)
        {
            NetworkStream tcpStream = client.GetStream();
            VW.Cyvi cvi = vi as VW.Cyvi;
            if (!watch)
                Base.VW.WHelper.SentByteLine(tcpStream, "C2CO,0," + name + "," + avatar + "," + hopeTeam);
            else
                Base.VW.WHelper.SentByteLine(tcpStream, "C2QI,0," + name);
            IDictionary<ushort, IchiPlayer> uidict = new Dictionary<ushort, IchiPlayer>();
            while (true)
            {
                string line = Base.VW.WHelper.ReadByteLine(tcpStream);
                if (line.StartsWith("C2CN,") && !watch)
                {
                    ushort ut = ushort.Parse(line.Substring("C2CN,".Length));
                    if (ut == 0)
                        return false;
                    Uid = ut;
                    cvi.SetNick(1, name, avatar);
                }
                else if (line.StartsWith("C2QJ,") && watch)
                {
                    ushort ut = ushort.Parse(line.Substring("C2QJ,".Length));
                    if (ut == 0)
                        return false;
                    Uid = ut;
                }
                else if (line.StartsWith("C2RM,"))
                {
                    string[] blocks = line.Split(',');
                    for (int i = 1; i < blocks.Length; i += 3)
                    {
                        ushort ouid = ushort.Parse(blocks[i]);
                        IchiPlayer ip = new IchiPlayer()
                        {
                            Name = blocks[i + 1],
                            Avatar = int.Parse(blocks[i + 2]),
                            Uid = ouid
                        };
                        uidict.Add(ouid, ip);
                        cvi.SetNick(1 + uidict.Count, ip.Name, ip.Avatar);
                    }
                }
                else if (line.StartsWith("C2NW,"))
                {
                    int idx = line.IndexOf(',');
                    int jdx = line.IndexOf(',', idx + 1);
                    int kdx = line.LastIndexOf(',');

                    ushort ouid = ushort.Parse(Algo.Substring(line, idx + 1, jdx));
                    IchiPlayer ip = new IchiPlayer()
                    {
                        Name = Algo.Substring(line, jdx + 1, kdx),
                        Avatar = int.Parse(line.Substring(kdx + 1)),
                        Uid = ouid
                    };
                    uidict.Add(ouid, ip);
                    cvi.SetNick(1 + uidict.Count, ip.Name, ip.Avatar);
                    vi.Cout(Uid, "Newcomer: {0}", Algo.Substring(line, jdx + 1, kdx));
                }
                else if (line.StartsWith("C2SA,"))
                {
                    stream = tcpStream;
                    recvThread = new Thread(() => ZI.SafeExecute(() => KeepOnListenRecv(),
                        delegate(Exception e) { Log.Logg(e.ToString()); }));
                    recvThread.Start();
                    if (!watch)
                    {
                        sendThread = new Thread(() => ZI.SafeExecute(() => KeepOnListenSend(),
                            delegate(Exception e) { Log.Logg(e.ToString()); }));
                        sendThread.Start();
                    }
                    return true;
                }
                else if (line.StartsWith("C"))
                    return false;
            }
        }