public ZeroField(XIClient xic) : base(xic) { Monster1 = 0; Monster2 = 0; RPool = 0; OPool = 0; Supporter = 0; Hinder = 0; Drums = new List<ushort>(); Eve1 = 0; }
public bool StartWatchHall() { TcpClient client = new TcpClient(server, port); NetworkStream tcpStream = client.GetStream(); Base.VW.WHelper.SentByteLine(tcpStream, "C0QI," + name); while (true) { string line = Base.VW.WHelper.ReadByteLine(tcpStream); if (line.StartsWith("C0QJ,")) { string[] splits = line.Split(','); uid = ushort.Parse(splits[1]); List<int> crooms = new List<int>(); for (int i = 2; i < splits.Length; ++i) crooms.Add(int.Parse(splits[i])); if (crooms.Count > 0) { do { Console.WriteLine("=>请选择您将旁观的房间(" + string.Join(",", crooms) + ")"); string inputHouse = Console.ReadLine().Trim(); int house = int.Parse(inputHouse); if (crooms.Contains(house)) { Base.VW.WHelper.SentByteLine(tcpStream, "C0QS," + house); break; } } while (true); } else { Console.WriteLine("<=== 当前没有正在游戏的房间。"); client.Close(); return false; } } else if (line.StartsWith("C1SQ,")) { room = ushort.Parse(line.Substring("C1SQ,".Length)); if (room != 0) { Console.WriteLine("Start XIClient For Watcher"); VW.Ayvi ayvi = new VW.Ayvi(); VI = ayvi; VI.Init(); XIClient xic = new XIClient(uid, name, teamCode, VI, server, room, record, msglog, true); //client.Close(); xic.RunAsync(); return true; } else { Console.WriteLine("<=== 申请旁观失败。"); client.Close(); return false; } } } }
public void StartHall() { VW.Ayvi ayvi = new VW.Ayvi(); VI = ayvi; VI.Init(); VI.SetInGame(false); TcpClient client = new TcpClient(server, port); NetworkStream tcpStream = client.GetStream(); int version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision; string trainerjoin = (this.trainer != null && trainer.Length > 0) ? ("," + string.Join(",", trainer)) : ""; Base.VW.WHelper.SentByteLine(tcpStream, "C0CO," + name + "," + avatar + "," + teamCode + "," + selCode + "," + levelCode + "," + version + trainerjoin); Thread msgThread = new Thread(delegate() { try { //string readLine = Console.ReadLine(); string readLine = VI.RequestTalk(uid); while (readLine != null) { lock (tcpStream) Base.VW.WHelper.SentByteLine(tcpStream, "C0TK," + uid + "," + readLine); readLine = VI.RequestTalk(uid); //readLine = Console.ReadLine(); } } catch (System.IO.IOException) { } }); bool done = false; while (!done) { string line = Base.VW.WHelper.ReadByteLine(tcpStream); if (line.StartsWith("G0XV,")) { string expectVersion = line.Substring("C0XV,".Length); VI.Cout(uid, "Version Missmatch. Expect " + expectVersion + ", please get updated.", uid); } else if (line.StartsWith("C0CN,")) { uid = ushort.Parse(line.Substring("C1CO,".Length)); VI.Cout(uid, "Allocated with uid {0}", uid); } else if (line.StartsWith("C1RM,")) { string[] splits = line.Split(','); room = int.Parse(splits[1]); for (int i = 2; i < splits.Length; i += 3) roomMates.Add(new IchiPlayer() { Uid = ushort.Parse(splits[i]), Name = splits[i + 1], Avatar = int.Parse(splits[i + 2]) }); if (roomMates.Count > 0) VI.Cout(uid, "您进入{0}#房间,其它成员为:{1}", room, string.Join(",", roomMates.Select(p => "[" + p.Uid + "]" + p.Name))); else VI.Cout(uid, "您进入{0}#房间并成为房主。", room); msgThread.Start(); } else if (line.StartsWith("C1NW,")) { string[] splits = line.Split(','); IchiPlayer ip = new IchiPlayer() { Uid = ushort.Parse(splits[1]), Name = splits[2], Avatar = int.Parse(splits[3]) }; roomMates.Add(ip); VI.Cout(uid, "新成员{0}加入房间{1}#。", "[" + ip.Uid + "]" + ip.Name, room); } else if (line.StartsWith("C1LV,")) { ushort ut = ushort.Parse(line.Substring("C1LV,".Length)); foreach (IchiPlayer ip in roomMates) { if (ip.Uid == ut) { roomMates.Remove(ip); VI.Cout(uid, "{0}离开房间。", "[" + ip.Uid + "]" + ip.Name); break; } } } else if (line.StartsWith("C1SA,")) { Base.VW.WHelper.SentByteLine(tcpStream, "C1ST," + uid); Console.WriteLine("Start XIClient"); //VI.Init(); VI.SetInGame(true); XIClient xic = new XIClient(uid, name, teamCode, VI, server, room, record, msglog, false); xic.RunAsync(); //client.Close(); done = true; } else if (line.StartsWith("C1TK,")) // Talk case { int idx = line.IndexOf(',', "C1TK,".Length); string nick = Algo.Substring(line, "C1TK,".Length, idx); string content = Algo.Substring(line, idx + 1, -1); VI.Chat(content, nick); } } if (msgThread != null && msgThread.IsAlive) msgThread.Abort(); }
public ZeroDisplay(XIClient xic) { this.xic = xic; this.tuple = xic.Tuple; }
public ZeroPlayer(string name, XIClient xic) : base(xic) { Name = name; Pets = new List<ushort>(); TuxCount = 0; Weapon = 0; Armor = 0; Trove = 0; ExCards = new List<ushort>(); Escue = new List<ushort>(); Fakeq = new Dictionary<ushort, string>(); Treasures = new Dictionary<ushort, List<string>>(); Runes = new List<ushort>(); //Skills = new List<string>(); Token = 0; SpecialCards = new List<string>(); PlayerTars = new List<ushort>(); AwakeSignal = false; FolderCount = 0; Guardian = 0; Coss = 0; }
public ZeroPiles(XIClient xic) : base(xic) { TuxCount = 0; MonCount = 0; EveCount = 0; TuxDises = 0; MonDises = 0; EveDises = 0; Score = new Dictionary<int, int>(); }
protected ZeroBase(XIClient xic) { this.xic = xic; }
public ZeroMe(XIClient xic) : base(xic) { Tux = new List<ushort>(); Folder = new List<ushort>(); }
private void StartRoom(string[] args) { VI = new VW.Djvi(6, Log); string netMode = GetValue(args, 1, "联机模式(SF:单机/NT:联网)").Trim().ToUpper(); if (netMode != "SF") netMode = "NT"; string sel = GetValue(args, 2, "选人模式(31:三选一/RM:随机/" + "BP:禁选/RD:轮选/ZY:昭鹰/CP:协同/SS:北软/CJ:召唤/TC:明暗)").Trim().ToUpper(); int selCode = RuleCode.CastMode(sel); int levelCode = RuleCode.LEVEL_ALL; string[] trainer = null; if (netMode == "SF") { //IsGameCompete = false; VW.Djwi djwi = new VW.Djwi(playerCapacity, this.Log); WI = djwi; Board.Garden = new Dictionary<ushort, Player>(); List<VW.Neayer> neayers = new List<VW.Neayer>(); string[] xingsen = new string[] { "撞仙", "笑犬", "翼君", "失影", "厌凉", "彰危" }; while (neayers.Count < playerCapacity) { string py = xingsen[neayers.Count]; ushort pv = (ushort)(neayers.Count * neayers.Count); VW.Neayer neayer = new VW.Neayer(py, pv); neayers.Add(neayer); } VI.Init(); // setup finish, re-newed player's uid List<int> uidList = new List<int>(Enumerable.Range(1, playerCapacity)); uidList.Shuffle(); for (ushort i = 0; i < neayers.Count; ++i) { Player player = new Player(neayers[i].Name, neayers[i].Avatar, (ushort)uidList[i]) { Team = (uidList[i] % 2 == 1) ? 1 : 2, IsAlive = true }; Board.Garden.Add(player.Uid, player); } Log.Start(); IDictionary<ushort, PSD.ClientZero.XIClient> xiclients = new Dictionary<ushort, PSD.ClientZero.XIClient>(); foreach (Player player in Board.Garden.Values) { XIClient xc = new XIClient(player.Uid, djwi, VI); xiclients.Add(player.Uid, xc); xc.RunAsync(); } Thread.Sleep(100); WI.BCast("H0SD," + string.Join(",", Board.Garden.Values.Select( p => p.Uid + "," + p.AUid + "," + p.Name))); foreach (Player player in Board.Garden.Values) VI.Cout(0, "player " + player.Uid + "# belongs to Team " + player.Team + "."); isFinished = false; levelCode = RuleCode.LEVEL_ALL; //trainer = new string[] { "HL003", "HL011", "HL012" }; } else if (netMode == "NT") { string teamModeStr = GetValue(args, 3, "请选择是否支持选队(YJ:选队/NJ:不允许选队)"); bool teamMode = (teamModeStr == "YJ") ? true : false; string level = GetValue(args, 4, "房间等级,(1:新手场/2:标准场/3:高手场/4:至尊场/5:界限突破场,后附+为特训"); bool isTrain = level.Contains("+"); trainer = isTrain ? Base.Utils.Algo.Substring(level, level.IndexOf('+') + 1, -1).Split(',') : null; if (isTrain) level = level.Substring(0, level.IndexOf('+')); if (!int.TryParse(level, out levelCode) || levelCode < 0 || levelCode > RuleCode.LEVEL_IPV) levelCode = RuleCode.LEVEL_RCM; else if (levelCode == 0) levelCode = RuleCode.DEF_CODE; else levelCode = (levelCode << 1) | (isTrain ? RuleCode.LEVEL_TRAIN_MASK : 0); //string gameModeStr = GetValue(args, 5, "请选择游戏模式(JY:休闲模式/CT:竞技模式)"); //IsGameCompete = (gameModeStr == "CT") ? true : false; // true -> CT string portStr = GetValue(args, 5, "请输入房间编号(0为默认值)"); int port; if (!int.TryParse(portStr, out port)) port = 0; port += Base.NetworkCode.DIR_PORT; if (port >= 65535 || port < 1024) port = Base.NetworkCode.DIR_PORT; IPAddress[] ipHost = Dns.GetHostAddresses(Dns.GetHostName()); if (ipHost.Length > 0) { Console.WriteLine("本机IP合法地址为:"); foreach (IPAddress ip in ipHost) { string ipt = ip.ToString(); if (ipt.StartsWith("10.") || ipt.StartsWith("127.0.") || ipt.StartsWith("192.168.")) Console.WriteLine(" [内网地址]" + ipt); else Console.WriteLine(" " + ipt); } } else Console.WriteLine("本机目前网卡异常,仅支持本地模式。"); VW.Aywi aywi = new VW.Aywi(port, 6, Log, HandleYMessage); WI = aywi; VI.Cout(0, "Wait for others players joining"); VI.Init(); Log.Start(); aywi.TcpListenerStart(); Board.Garden = aywi.Connect(VI, teamMode, null); int count = Board.Garden.Count; while (count > 0) { Base.VW.Msgs msg = WI.RecvInfRecv(); if (msg.Msg.StartsWith("C2ST,")) --count; } isFinished = false; WI.BCast("H0SD," + string.Join(",", Board.Garden.Values.Select( p => p.Uid + "," + p.AUid + "," + p.Name))); } Board.RoundIN = "H0PR"; if (WI is VW.Aywi) HoldRoomTunnel(); VI.SetInGame(true); if (selCode == RuleCode.MODE_00) levelCode = 0; SelectHero(selCode, levelCode, trainer); Run(levelCode, selCode == Base.Rules.RuleCode.MODE_00); }