コード例 #1
0
ファイル: YgopotStruct.cs プロジェクト: 247321453/YgoServer
        public static GameConfig Build(this CtosCreateGame roomconfig)
        {
            GameConfig config = new GameConfig();
            config.Parse(roomconfig.info);
            config.Name = new string(roomconfig.name).Split('\0')[0];
            config.RoomString = config.Name;
            try
            {
                char[] chs = new char[roomconfig.pass.Length];
                for(int i = 0; i < roomconfig.pass.Length; i++)
                {
                    chs[i] = (char)roomconfig.pass[i];
                }
                string pwd = new string(chs).Split('\0')[0];
                if (!string.IsNullOrEmpty(pwd))
                {
                    config.RoomString = config.Name + '$' + pwd;
                }
            }
            catch
            {

            }
            return config;
        }
        public static GameConfig Build(this CtosCreateGame roomconfig)
        {
            GameConfig config = new GameConfig();

            config.Parse(roomconfig.info);
            config.Name       = new string(roomconfig.name).Split('\0')[0];
            config.RoomString = config.Name;
            try
            {
                char[] chs = new char[roomconfig.pass.Length];
                for (int i = 0; i < roomconfig.pass.Length; i++)
                {
                    chs[i] = (char)roomconfig.pass[i];
                }
                string pwd = new string(chs).Split('\0')[0];
                if (!string.IsNullOrEmpty(pwd))
                {
                    config.RoomString = config.Name + '$' + pwd;
                }
            }
            catch
            {
            }
            return(config);
        }
        public static GameConfig Build(string gameinfo)
        {
            //The default value
            GameConfig config = new GameConfig();

            config.IsRandom       = true;
            config.LfList         = 0;
            config.BanList        = BanlistManager.GetName(0);
            config.Rule           = 2;
            config.Mode           = 0;
            config.EnablePriority = false;
            config.NoCheckDeck    = false;
            config.NoShuffleDeck  = false;
            config.StartLp        = 8000;
            config.StartHand      = 5;
            config.DrawCount      = 1;
            config.GameTimer      = 120;
            if (!string.IsNullOrEmpty(gameinfo))
            {
                gameinfo = gameinfo.Trim();
            }
            gameinfo          = gameinfo.Replace("*", "");
            gameinfo          = gameinfo.Replace(":", "");
            config.RoomString = gameinfo;
            if (string.IsNullOrEmpty(gameinfo) || gameinfo == "random" || gameinfo == "#")
            {
                //random
                config.Name = RoomManager.RandomRoomName();
                Logger.Debug("random:" + config.Name);
                return(config);
            }
            config.Parse(gameinfo);
            config.BanList = BanlistManager.GetName(config.LfList);
            if (string.IsNullOrEmpty(config.Name))
            {
                if (gameinfo.EndsWith("#"))
                {
                    string _name = RoomManager.RandomRoomName(gameinfo);
                    if (_name == null)
                    {
                        //# Random room,the condition name not found,Create
                        config.Name = gameinfo + RoomManager.NewRandomRoomName();
                    }
                    else
                    {
                        //Conditional random room # name,Entered ,Probably repeat watching
                        config.Name = _name;
                        Logger.Debug("1," + config.Name);
                    }
                }
                else
                {
                    config.IsRandom = false;
                    config.Name     = gameinfo;
                }
            }
            Logger.Debug("2," + config.Name);
            return(config);
        }
コード例 #4
0
 public static GameConfig Build(string gameinfo)
 {
     //默认值
     GameConfig config = new GameConfig();
     config.IsRandom = true;
     config.LfList = 0;
     config.BanList = BanlistManager.GetName(0);
     config.Rule = 2;
     config.Mode = 0;
     config.EnablePriority = false;
     config.NoCheckDeck = false;
     config.NoShuffleDeck = false;
     config.StartLp = 8000;
     config.StartHand = 5;
     config.DrawCount = 1;
     config.GameTimer = 120;
     if (!string.IsNullOrEmpty(gameinfo))
     {
         gameinfo = gameinfo.Trim();
     }
     gameinfo = gameinfo.Replace("*", "");
     gameinfo = gameinfo.Replace(":", "");
     config.RoomString = gameinfo;
     if (string.IsNullOrEmpty(gameinfo) || gameinfo == "random" || gameinfo == "#")
     {
         //random
         config.Name = RoomManager.RandomRoomName();
         Logger.Debug("random:" + config.Name);
         return config;
     }
     config.Parse(gameinfo);
     config.BanList = BanlistManager.GetName(config.LfList);
     if (string.IsNullOrEmpty(config.Name))
     {
         if (gameinfo.EndsWith("#"))
         {
             string _name = RoomManager.RandomRoomName(gameinfo);
             if (_name == null)
             {
                 //条件#的随机房间名没找到,则创建一个
                 config.Name = gameinfo + RoomManager.NewRandomRoomName();
             }
             else
             {
                 //条件#的随机房间名存在,则进去,可能重复观战
                 config.Name = _name;
                 Logger.Debug("1," + config.Name);
             }
         }
         else
         {
             config.IsRandom = false;
             config.Name = gameinfo;
         }
     }
     Logger.Debug("2,"+config.Name);
     return config;
 }
コード例 #5
0
ファイル: ServerEvent.cs プロジェクト: 247321453/YgoServer
		private static void OnRoomCreate(DuelServer server, PacketReader packet){
			string name = packet.ReadUnicode(20);
			string info = packet.ReadUnicode(20);
			string banlist=packet.ReadUnicode(50);
			GameConfig config=new GameConfig();
            config.RoomString = info;
            config.Parse(info);
			config.Name=name;
			config.BanList=banlist;
            
			Logger.Debug("OnRoomCreate:"+server.Port+","+name+"|"+info);
			lock(server.Rooms){
                server.Rooms[name] = config;
			}
            if (server.Server != null)
            {
                server.Server.server_OnRoomCreate(server, name, banlist, info);
            }
		}
コード例 #6
0
ファイル: Server.cs プロジェクト: 247321453/YgoServer
		private void RoomCreate(string name,string banlist,string gameinfo){
			GameConfig config = new GameConfig();
			config.Parse(gameinfo);
			config.Name = gameinfo;
			config.BanList = banlist;
			lock(Rooms){
				if(Rooms.ContainsKey(name)){
					Rooms[name] = config;
				}else{
					Rooms.Add(name, config);
				}
			}
			if(OnRoomCreate!=null){
				OnRoomCreate(this, name, banlist, gameinfo);
			}
		}