private static void CheckRoomStatus() { using (PlayerBussiness db = new PlayerBussiness()) { MarryRoomInfo[] roomInfos = db.GetMarryRoomInfo(); MarryRoomInfo[] array = roomInfos; for (int i = 0; i < array.Length; i++) { MarryRoomInfo roomInfo = array[i]; if (roomInfo.ServerID == GameServer.Instance.Config.ServerID) { TimeSpan usedTime = DateTime.Now - roomInfo.BeginTime; int timeLeft = roomInfo.AvailTime * 60 - (int)usedTime.TotalMinutes; if (timeLeft > 0) { MarryRoomMgr.CreateMarryRoomFromDB(roomInfo, timeLeft); } else { db.DisposeMarryRoomInfo(roomInfo.ID); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(roomInfo.GroomID); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(roomInfo.BrideID); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(roomInfo.GroomID, false, roomInfo); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(roomInfo.BrideID, false, roomInfo); } } } } }
private static void CheckRoomStatus() { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { MarryRoomInfo[] marryRoomInfo = playerBussiness.GetMarryRoomInfo(); MarryRoomInfo[] array = marryRoomInfo; for (int i = 0; i < array.Length; i++) { MarryRoomInfo marryRoomInfo2 = array[i]; if (marryRoomInfo2.ServerID == GameServer.Instance.Configuration.ServerID) { TimeSpan timeSpan = DateTime.Now - marryRoomInfo2.BeginTime; int num = marryRoomInfo2.AvailTime * 60 - (int)timeSpan.TotalMinutes; if (num > 0) { MarryRoomMgr.CreateMarryRoomFromDB(marryRoomInfo2, num); } else { playerBussiness.DisposeMarryRoomInfo(marryRoomInfo2.ID); if (GameServer.Instance.LoginServer != null) { Console.WriteLine(marryRoomInfo2.Name); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(marryRoomInfo2.GroomID); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(marryRoomInfo2.BrideID); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(marryRoomInfo2.GroomID, false, marryRoomInfo2); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(marryRoomInfo2.BrideID, false, marryRoomInfo2); } } } } } }
public static MarryRoom CreateMarryRoom(GamePlayer player, MarryRoomInfo info) { if (!player.PlayerCharacter.IsMarried) { return(null); } MarryRoom marryRoom = null; DateTime now = DateTime.Now; info.PlayerID = player.PlayerCharacter.ID; info.PlayerName = player.PlayerCharacter.NickName; if (player.PlayerCharacter.Sex) { info.GroomID = info.PlayerID; info.GroomName = info.PlayerName; info.BrideID = player.PlayerCharacter.SpouseID; info.BrideName = player.PlayerCharacter.SpouseName; } else { info.BrideID = info.PlayerID; info.BrideName = info.PlayerName; info.GroomID = player.PlayerCharacter.SpouseID; info.GroomName = player.PlayerCharacter.SpouseName; } info.BeginTime = now; info.BreakTime = now; using (PlayerBussiness playerBussiness = new PlayerBussiness()) { if (playerBussiness.InsertMarryRoomInfo(info)) { marryRoom = new MarryRoom(info, MarryRoomMgr._processor); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(info.GroomID); GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(info.BrideID); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(info.GroomID, true, info); GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(info.BrideID, true, info); } } if (marryRoom != null) { MarryRoomMgr._locker.AcquireWriterLock(); try { MarryRoomMgr._Rooms.Add(marryRoom.Info.ID, marryRoom); } finally { MarryRoomMgr._locker.ReleaseWriterLock(); } if (marryRoom.AddPlayer(player)) { marryRoom.BeginTimer(3600000 * marryRoom.Info.AvailTime); return(marryRoom); } } return(null); }
public MarryRoom(MarryRoomInfo info, IMarryProcessor processor) { this.Info = info; this._processor = processor; this._guestsList = new List <GamePlayer>(); this._count = 0; this._roomState = eRoomState.FREE; this._userForbid = new List <int>(); this._userRemoveList = new List <int>(); }
//private bool _isHymeneal; //public bool IsHymeneal //{ // get { return _isHymeneal; } // set { _isHymeneal = value; } //} public MarryRoom(MarryRoomInfo info, IMarryProcessor processor) { Info = info; _processor = processor; _guestsList = new List <GamePlayer>(); _count = 0; //_isHymeneal = false; _roomState = eRoomState.FREE; _userForbid = new List <int>(); _userRemoveList = new List <int>(); }
public static MarryRoom CreateMarryRoomFromDB(MarryRoomInfo roomInfo, int timeLeft) { MarryRoomMgr._locker.AcquireWriterLock(); try { MarryRoom marryRoom = new MarryRoom(roomInfo, MarryRoomMgr._processor); if (marryRoom != null) { MarryRoomMgr._Rooms.Add(marryRoom.Info.ID, marryRoom); marryRoom.BeginTimer(60000 * timeLeft); return(marryRoom); } } finally { MarryRoomMgr._locker.ReleaseWriterLock(); } return(null); }
public void SendMarryRoomInfoToPlayer(int playerId, bool state, MarryRoomInfo info) { GSPacketIn pkg = new GSPacketIn((byte)eChatServerPacket.MARRY_ROOM_INFO_TO_PLAYER); pkg.WriteInt(playerId); pkg.WriteBoolean(state); if (state) { pkg.WriteInt(info.ID); pkg.WriteString(info.Name); pkg.WriteInt(info.MapIndex); pkg.WriteInt(info.AvailTime); pkg.WriteInt(info.PlayerID); pkg.WriteInt(info.GroomID); pkg.WriteInt(info.BrideID); pkg.WriteDateTime(info.BeginTime); pkg.WriteBoolean(info.IsGunsaluteUsed); } SendTCP(pkg); }
public void SendMarryRoomInfoToPlayer(int playerId, bool state, MarryRoomInfo info) { GSPacketIn pkg = new GSPacketIn(26); pkg.WriteInt(playerId); pkg.WriteBoolean(state); if (state) { pkg.WriteInt(info.ID); pkg.WriteString(info.Name); pkg.WriteInt(info.MapIndex); pkg.WriteInt(info.AvailTime); pkg.WriteInt(info.PlayerID); pkg.WriteInt(info.GroomID); pkg.WriteInt(info.BrideID); pkg.WriteDateTime(info.BeginTime); pkg.WriteBoolean(info.IsGunsaluteUsed); } this.SendTCP(pkg); }
public static MarryRoom CreateMarryRoomFromDB(MarryRoomInfo roomInfo, int timeLeft) { MarryRoom room = null; _locker.AcquireWriterLock(); try { room = new MarryRoom(roomInfo, _processor); if (room != null) { _Rooms.Add(room.Info.ID, room); room.BeginTimer(60 * 1000 * timeLeft); return(room); } } finally { _locker.ReleaseWriterLock(); } return(null); }
public GSPacketIn SendMarryRoomInfoToPlayer(GamePlayer player, bool state, MarryRoomInfo info) { throw new NotImplementedException(); }
public int HandlePacket(GameClient client, GSPacketIn packet) { MarryRoom marryRoom = null; string text = ""; int num = packet.ReadInt(); string text2 = packet.ReadString(); int marryMap = packet.ReadInt(); if (num != 0) { marryRoom = MarryRoomMgr.GetMarryRoombyID(num, (text2 == null) ? "" : text2, ref text); } else { if (client.Player.PlayerCharacter.IsCreatedMarryRoom) { MarryRoom[] allMarryRoom = MarryRoomMgr.GetAllMarryRoom(); MarryRoom[] array = allMarryRoom; for (int i = 0; i < array.Length; i++) { MarryRoom marryRoom2 = array[i]; if (marryRoom2.Info.GroomID == client.Player.PlayerCharacter.ID || marryRoom2.Info.BrideID == client.Player.PlayerCharacter.ID) { marryRoom = marryRoom2; break; } } } if (marryRoom == null && client.Player.PlayerCharacter.SelfMarryRoomID != 0) { client.Player.Out.SendMarryRoomLogin(client.Player, false); MarryRoomInfo marryRoomInfo = null; using (PlayerBussiness playerBussiness = new PlayerBussiness()) { marryRoomInfo = playerBussiness.GetMarryRoomInfoSingle(client.Player.PlayerCharacter.SelfMarryRoomID); } if (marryRoomInfo != null) { client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.RoomExist", new object[] { marryRoomInfo.ServerID, client.Player.PlayerCharacter.SelfMarryRoomID })); return(0); } } } if (marryRoom != null) { if (marryRoom.CheckUserForbid(client.Player.PlayerCharacter.ID)) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MarryRoomLoginHandler.Forbid", new object[0])); client.Player.Out.SendMarryRoomLogin(client.Player, false); return(1); } if (marryRoom.RoomState == eRoomState.FREE) { if (marryRoom.AddPlayer(client.Player)) { client.Player.MarryMap = marryMap; client.Player.Out.SendMarryRoomLogin(client.Player, true); marryRoom.SendMarryRoomInfoUpdateToScenePlayers(marryRoom); return(0); } } else { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.AlreadyBegin", new object[0])); } client.Player.Out.SendMarryRoomLogin(client.Player, false); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation(string.IsNullOrEmpty(text) ? "MarryRoomLoginHandler.Failed" : text, new object[0])); client.Player.Out.SendMarryRoomLogin(client.Player, false); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { //if (client.Player.CurrentGame != null) //{ // client.Player.CurrentGame.RemovePlayer(client.Player); //} //if(client.Player.CurrentMarryRoom != null) //{ // client.Player.CurrentMarryRoom.RemovePlayer(client.Player); //} MarryRoom room = null; string msg = ""; int id = packet.ReadInt(); string pwd = packet.ReadString(); int sceneID = packet.ReadInt(); if (id != 0) { room = MarryRoomMgr.GetMarryRoombyID(id, pwd == null ? "" : pwd, ref msg); } else { if (client.Player.PlayerCharacter.IsCreatedMarryRoom) { MarryRoom[] rooms = MarryRoomMgr.GetAllMarryRoom(); foreach (MarryRoom r in rooms) { if (r.Info.GroomID == client.Player.PlayerCharacter.ID || r.Info.BrideID == client.Player.PlayerCharacter.ID) { room = r; break; } } } if (room == null && client.Player.PlayerCharacter.SelfMarryRoomID != 0) { client.Player.Out.SendMarryRoomLogin(client.Player, false); MarryRoomInfo info = null; using (PlayerBussiness db = new PlayerBussiness()) { info = db.GetMarryRoomInfoSingle(client.Player.PlayerCharacter.SelfMarryRoomID); } if (info != null) { client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.RoomExist", info.ServerID, client.Player.PlayerCharacter.SelfMarryRoomID)); return(0); } } } if (room != null) { if (room.CheckUserForbid(client.Player.PlayerCharacter.ID)) { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MarryRoomLoginHandler.Forbid")); client.Player.Out.SendMarryRoomLogin(client.Player, false); return(1); } if (room.RoomState == eRoomState.FREE) { if (room.AddPlayer(client.Player)) { client.Player.MarryMap = sceneID; GSPacketIn pkg = client.Player.Out.SendMarryRoomLogin(client.Player, true); room.SendMarryRoomInfoUpdateToScenePlayers(room); return(0); } } else { client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.AlreadyBegin")); } client.Player.Out.SendMarryRoomLogin(client.Player, false); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation(string.IsNullOrEmpty(msg) ? "MarryRoomLoginHandler.Failed" : msg)); client.Player.Out.SendMarryRoomLogin(client.Player, false); } return(1); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { MarryRoom room = null; string msg = ""; int id = packet.ReadInt(); string pwd = packet.ReadString(); int sceneID = packet.ReadInt(); int result; if (id != 0) { room = MarryRoomMgr.GetMarryRoombyID(id, (pwd == null) ? "" : pwd, ref msg); } else { if (player.PlayerCharacter.IsCreatedMarryRoom) { MarryRoom[] rooms = MarryRoomMgr.GetAllMarryRoom(); MarryRoom[] array = rooms; for (int i = 0; i < array.Length; i++) { MarryRoom r = array[i]; if (r.Info.GroomID == player.PlayerCharacter.ID || r.Info.BrideID == player.PlayerCharacter.ID) { room = r; break; } } } if (room == null && player.PlayerCharacter.SelfMarryRoomID != 0) { player.Out.SendMarryRoomLogin(player, false); MarryRoomInfo info = null; using (PlayerBussiness db = new PlayerBussiness()) { info = db.GetMarryRoomInfoSingle(player.PlayerCharacter.SelfMarryRoomID); } if (info != null) { player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.RoomExist", new object[] { info.ServerID, player.PlayerCharacter.SelfMarryRoomID })); result = 0; return(result); } } } if (room != null) { if (room.CheckUserForbid(player.PlayerCharacter.ID)) { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MarryRoomLoginHandler.Forbid", new object[0])); player.Out.SendMarryRoomLogin(player, false); result = 1; return(result); } if (room.RoomState == eRoomState.FREE) { if (room.AddPlayer(player)) { player.MarryMap = sceneID; GSPacketIn pkg = player.Out.SendMarryRoomLogin(player, true); room.SendMarryRoomInfoUpdateToScenePlayers(room); result = 0; return(result); } } else { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.AlreadyBegin", new object[0])); } player.Out.SendMarryRoomLogin(player, false); } else { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation(string.IsNullOrEmpty(msg) ? "MarryRoomLoginHandler.Failed" : msg, new object[0])); player.Out.SendMarryRoomLogin(player, false); } result = 1; return(result); }
public GSPacketIn SendContinuation(GamePlayer player, MarryRoomInfo info) { throw new NotImplementedException(); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int result; if (!player.PlayerCharacter.IsMarried) { result = 1; } else { if (player.PlayerCharacter.IsCreatedMarryRoom) { result = 1; } else { if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); result = 0; } else { if (player.CurrentRoom != null) { player.CurrentRoom.RemovePlayerUnsafe(player); } if (player.CurrentMarryRoom != null) { player.CurrentMarryRoom.RemovePlayer(player); } MarryRoomInfo info = new MarryRoomInfo(); info.Name = packet.ReadString().Replace(";", ""); info.Pwd = packet.ReadString(); info.MapIndex = packet.ReadInt(); info.AvailTime = packet.ReadInt(); info.MaxCount = packet.ReadInt(); info.GuestInvite = packet.ReadBoolean(); info.RoomIntroduction = packet.ReadString(); info.ServerID = GameServer.Instance.Config.ServerID; info.IsHymeneal = false; string[] array = new string[] { "1", "2", "3" }; string[] money = "2000,2700,3400".Split(new char[] { ',' }); if (money.Length < 3) { MarryRoomCreateHandler.log.Error("MarryRoomCreateMoney node in configuration file is wrong"); result = 1; } else { int needMoney; switch (info.AvailTime) { case 2: needMoney = int.Parse(money[0]); break; case 3: needMoney = int.Parse(money[1]); break; case 4: needMoney = int.Parse(money[2]); break; default: needMoney = int.Parse(money[2]); info.AvailTime = 4; break; } if (player.PlayerCharacter.Money >= needMoney) { MarryRoom room = MarryRoomMgr.CreateMarryRoom(player, info); if (room != null) { player.RemoveMoney(needMoney, LogMoneyType.Marry, LogMoneyType.Marry_Room); GSPacketIn pkg = player.Out.SendMarryRoomInfo(player, room); player.Out.SendMarryRoomLogin(player, true); room.SendToScenePlayer(pkg); CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, needMoney, 0, 0, 0); } result = 0; } else { player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0])); result = 1; } } } } } return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (!client.Player.PlayerCharacter.IsMarried) { return(1); } if (client.Player.PlayerCharacter.IsCreatedMarryRoom) { //client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomCreateHandler.Msg1")); return(1); } if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked")); return(0); } if (client.Player.CurrentRoom != null) { client.Player.CurrentRoom.RemovePlayerUnsafe(client.Player); } if (client.Player.CurrentMarryRoom != null) { client.Player.CurrentMarryRoom.RemovePlayer(client.Player); } //GamePlayer tempPlayer = WorldMgr.GetPlayerById(client.Player.PlayerCharacter.SpouseID); //if(tempPlayer != null) //{ // if (tempPlayer.IsMarryRommCreating) // { // client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomCreateHandler.IsCreating")); // return 1; // } //} //client.Player.IsMarryRommCreating = true; MarryRoomInfo info = new MarryRoomInfo(); info.Name = packet.ReadString().Replace(";", ""); info.Pwd = packet.ReadString(); info.MapIndex = packet.ReadInt(); info.AvailTime = packet.ReadInt(); info.MaxCount = packet.ReadInt(); info.GuestInvite = packet.ReadBoolean(); info.RoomIntroduction = packet.ReadString(); info.ServerID = GameServer.Instance.Configuration.ServerID; info.IsHymeneal = false; string[] money = GameProperties.PRICE_MARRY_ROOM.Split(','); if (money.Length < 3) { if (log.IsErrorEnabled) { log.Error("MarryRoomCreateMoney node in configuration file is wrong"); } return(1); } int needMoney = 0; switch (info.AvailTime) { case 2: needMoney = int.Parse(money[0]); break; case 3: needMoney = int.Parse(money[1]); break; case 4: needMoney = int.Parse(money[2]); break; default: needMoney = int.Parse(money[2]); info.AvailTime = 4; break; } if (client.Player.PlayerCharacter.Money >= needMoney) { MarryRoom room = MarryRoomMgr.CreateMarryRoom(client.Player, info); if (room != null) { client.Player.RemoveMoney(needMoney); LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Room, client.Player.PlayerCharacter.ID, needMoney, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", ""); GSPacketIn pkg = client.Player.Out.SendMarryRoomInfo(client.Player, room); client.Player.Out.SendMarryRoomLogin(client.Player, true); room.SendToScenePlayer(pkg); CountBussiness.InsertSystemPayCount(client.Player.PlayerCharacter.ID, needMoney, 0, (int)eConsumerType.Marry, (int)eSubConsumerType.Marry_MarryRoom); } return(0); } else { client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough")); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (!client.Player.PlayerCharacter.IsMarried) { return(1); } if (client.Player.PlayerCharacter.IsCreatedMarryRoom) { return(1); } if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0])); return(0); } if (client.Player.CurrentRoom != null) { client.Player.CurrentRoom.RemovePlayerUnsafe(client.Player); } if (client.Player.CurrentMarryRoom != null) { client.Player.CurrentMarryRoom.RemovePlayer(client.Player); } MarryRoomInfo marryRoomInfo = new MarryRoomInfo(); marryRoomInfo.Name = packet.ReadString().Replace(";", ""); marryRoomInfo.Pwd = packet.ReadString(); marryRoomInfo.MapIndex = packet.ReadInt(); marryRoomInfo.AvailTime = packet.ReadInt(); marryRoomInfo.MaxCount = packet.ReadInt(); marryRoomInfo.GuestInvite = packet.ReadBoolean(); marryRoomInfo.RoomIntroduction = packet.ReadString(); marryRoomInfo.ServerID = GameServer.Instance.Configuration.ServerID; marryRoomInfo.IsHymeneal = false; string[] array = GameProperties.PRICE_MARRY_ROOM.Split(new char[] { ',' }); if (array.Length < 3) { if (MarryRoomCreateHandler.log.IsErrorEnabled) { MarryRoomCreateHandler.log.Error("MarryRoomCreateMoney node in configuration file is wrong"); } return(1); } int num; switch (marryRoomInfo.AvailTime) { case 2: num = int.Parse(array[0]); break; case 3: num = int.Parse(array[1]); break; case 4: num = int.Parse(array[2]); break; default: num = int.Parse(array[2]); marryRoomInfo.AvailTime = 4; break; } if (client.Player.PlayerCharacter.Money >= num) { MarryRoom marryRoom = MarryRoomMgr.CreateMarryRoom(client.Player, marryRoomInfo); if (marryRoom != null) { client.Player.RemoveMoney(num); LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Room, client.Player.PlayerCharacter.ID, num, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", ""); GSPacketIn packet2 = client.Player.Out.SendMarryRoomInfo(client.Player, marryRoom); client.Player.Out.SendMarryRoomLogin(client.Player, true); marryRoom.SendToScenePlayer(packet2); CountBussiness.InsertSystemPayCount(client.Player.PlayerCharacter.ID, num, 0, 0, 0); } return(0); } client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0])); return(1); }