Ejemplo n.º 1
0
        //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>();
        }
Ejemplo n.º 2
0
 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 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, "", "", "");
                    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;

        }
Ejemplo n.º 4
0
 public GSPacketIn SendContinuation(GamePlayer player, MarryRoomInfo info)
 {
     GSPacketIn pkg = new GSPacketIn((byte)ePackageType.MARRY_CMD, player.PlayerCharacter.ID);
     pkg.WriteByte((byte)MarryCmdType.CONTINUATION);
     pkg.WriteInt(info.AvailTime);
     SendTCP(pkg);
     return pkg;
 }
Ejemplo n.º 5
0
        public GSPacketIn SendMarryRoomInfoToPlayer(GamePlayer player, bool state, MarryRoomInfo info)
        {
            GSPacketIn pkg = new GSPacketIn((byte)ePackageType.MARRY_ROOM_STATE, player.PlayerCharacter.ID);
            pkg.WriteBoolean(state);
            if (state)
            {
                pkg.WriteInt(info.ID);
                pkg.WriteString(info.Name);
                pkg.WriteInt(info.MapIndex);
                pkg.WriteInt(info.AvailTime);
                //pkg.WriteInt(info.Count);
                //pkg.WriteInt(room.Player.PlayerCharacter.ID);
                //pkg.WriteInt(room.Groom.PlayerCharacter.ID);
                //pkg.WriteInt(room.Bride.PlayerCharacter.ID);
                pkg.WriteInt(info.PlayerID);
                pkg.WriteInt(info.GroomID);
                pkg.WriteInt(info.BrideID);

                pkg.WriteDateTime(info.BeginTime);
                //pkg.WriteBoolean(info.IsHymeneal);
                pkg.WriteBoolean(info.IsGunsaluteUsed);
            }
            SendTCP(pkg);
            return pkg;
        }
Ejemplo n.º 6
0
 public bool UpdateMarryRoomInfo(MarryRoomInfo info)
 {
     bool flag = false;
     try
     {
         SqlParameter[] SqlParameters = new SqlParameter[9]
     {
       new SqlParameter("@ID", (object) info.ID),
       new SqlParameter("@AvailTime", (object) info.AvailTime),
       new SqlParameter("@BreakTime", (object) info.BreakTime),
       new SqlParameter("@roomIntroduction", (object) info.RoomIntroduction),
       new SqlParameter("@isHymeneal", (object) (int) (info.IsHymeneal ? 1 : 0)),
       new SqlParameter("@Name", (object) info.Name),
       new SqlParameter("@Pwd", (object) info.Pwd),
       new SqlParameter("@IsGunsaluteUsed", (object) (int) (info.IsGunsaluteUsed ? 1 : 0)),
       new SqlParameter("@Result", SqlDbType.Int)
     };
         SqlParameters[8].Direction = ParameterDirection.ReturnValue;
         this.db.RunProcedure("SP_Update_Marry_Room_Info", SqlParameters);
         flag = (int)SqlParameters[8].Value == 0;
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"UpdateMarryRoomInfo", ex);
     }
     return flag;
 }
Ejemplo n.º 7
0
 public bool InsertMarryRoomInfo(MarryRoomInfo info)
 {
     bool flag = false;
     try
     {
         SqlParameter[] SqlParameters = new SqlParameter[20];
         SqlParameters[0] = new SqlParameter("@ID", (object)info.ID);
         SqlParameters[0].Direction = ParameterDirection.InputOutput;
         SqlParameters[1] = new SqlParameter("@Name", (object)info.Name);
         SqlParameters[2] = new SqlParameter("@PlayerID", (object)info.PlayerID);
         SqlParameters[3] = new SqlParameter("@PlayerName", (object)info.PlayerName);
         SqlParameters[4] = new SqlParameter("@GroomID", (object)info.GroomID);
         SqlParameters[5] = new SqlParameter("@GroomName", (object)info.GroomName);
         SqlParameters[6] = new SqlParameter("@BrideID", (object)info.BrideID);
         SqlParameters[7] = new SqlParameter("@BrideName", (object)info.BrideName);
         SqlParameters[8] = new SqlParameter("@Pwd", (object)info.Pwd);
         SqlParameters[9] = new SqlParameter("@AvailTime", (object)info.AvailTime);
         SqlParameters[10] = new SqlParameter("@MaxCount", (object)info.MaxCount);
         SqlParameters[11] = new SqlParameter("@GuestInvite", (object)(int)(info.GuestInvite ? 1 : 0));
         SqlParameters[12] = new SqlParameter("@MapIndex", (object)info.MapIndex);
         SqlParameters[13] = new SqlParameter("@BeginTime", (object)info.BeginTime);
         SqlParameters[14] = new SqlParameter("@BreakTime", (object)info.BreakTime);
         SqlParameters[15] = new SqlParameter("@RoomIntroduction", (object)info.RoomIntroduction);
         SqlParameters[16] = new SqlParameter("@ServerID", (object)info.ServerID);
         SqlParameters[17] = new SqlParameter("@IsHymeneal", (object)(int)(info.IsHymeneal ? 1 : 0));
         SqlParameters[18] = new SqlParameter("@IsGunsaluteUsed", (object)(int)(info.IsGunsaluteUsed ? 1 : 0));
         SqlParameters[19] = new SqlParameter("@Result", SqlDbType.Int);
         SqlParameters[19].Direction = ParameterDirection.ReturnValue;
         this.db.RunProcedure("SP_Insert_Marry_Room_Info", SqlParameters);
         flag = (int)SqlParameters[19].Value == 0;
         if (flag)
             info.ID = (int)SqlParameters[0].Value;
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"InsertMarryRoomInfo", ex);
     }
     return flag;
 }
Ejemplo n.º 8
0
        public static MarryRoom CreateMarryRoom(GamePlayer player, MarryRoomInfo info)
        {
            if(!player.PlayerCharacter.IsMarried)
            {
                return null;
            }

            MarryRoom room = null;
            DateTime beginTime = DateTime.Now;

            info.PlayerID = player.PlayerCharacter.ID;
            info.PlayerName = player.PlayerCharacter.NickName;
            if (player.PlayerCharacter.Sex == true)
            {
                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 = beginTime;
            info.BreakTime = beginTime;

            using (PlayerBussiness db = new PlayerBussiness())
            {
                if (db.InsertMarryRoomInfo(info))
                {
                    room = new MarryRoom(info, _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 (room != null)
            {

                _locker.AcquireWriterLock();
                try
                {
                    _Rooms.Add(room.Info.ID, room);
                }
                finally
                {
                    _locker.ReleaseWriterLock();
                }

                if (room.AddPlayer(player))
                {
                    room.BeginTimer(60 * 1000 * 60 * room.Info.AvailTime);
                    return room;
                }
            }

            return null;
        }
Ejemplo n.º 9
0
 public GSPacketIn SendContinuation(Game.Server.GameObjects.GamePlayer player, SqlDataProvider.Data.MarryRoomInfo info)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
 public GSPacketIn SendMarryRoomInfoToPlayer(Game.Server.GameObjects.GamePlayer player, bool state, SqlDataProvider.Data.MarryRoomInfo info)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        public MarryRoomInfo GetMarryRoomInfoSingle(int id)
        {
            SqlDataReader reader = null;
            try
            {
                SqlParameter[] para = new SqlParameter[1];
                para[0] = new SqlParameter("@ID", id);

                db.GetReader(ref reader, "SP_Get_Marry_Room_Info_Single", para);
                while (reader.Read())
                {
                    MarryRoomInfo info = new MarryRoomInfo();
                    info.ID = (int)reader["ID"];
                    info.Name = reader["Name"].ToString();
                    info.PlayerID = (int)reader["PlayerID"];
                    info.PlayerName = reader["PlayerName"].ToString();
                    info.GroomID = (int)reader["GroomID"];
                    info.GroomName = reader["GroomName"].ToString();
                    info.BrideID = (int)reader["BrideID"];
                    info.BrideName = reader["BrideName"].ToString();
                    info.Pwd = reader["Pwd"].ToString();
                    info.AvailTime = (int)reader["AvailTime"];
                    info.MaxCount = (int)reader["MaxCount"];
                    info.GuestInvite = (bool)reader["GuestInvite"];
                    info.MapIndex = (int)reader["MapIndex"];
                    info.BeginTime = (DateTime)reader["BeginTime"];
                    info.BreakTime = (DateTime)reader["BreakTime"];
                    info.RoomIntroduction = reader["RoomIntroduction"].ToString();
                    info.ServerID = (int)reader["ServerID"];
                    info.IsHymeneal = (bool)reader["IsHymeneal"];
                    info.IsGunsaluteUsed = (bool)reader["IsGunsaluteUsed"];
                    return info;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("GetMarryRoomInfo", e);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }

            return null;
        }
Ejemplo n.º 13
0
        public MarryRoomInfo[] GetMarryRoomInfo()
        {
            SqlDataReader reader = null;
            List<MarryRoomInfo> infos = new List<MarryRoomInfo>();
            try
            {
                db.GetReader(ref reader, "SP_Get_Marry_Room_Info");
                while (reader.Read())
                {
                    MarryRoomInfo info = new MarryRoomInfo();
                    info.ID = (int)reader["ID"];
                    info.Name = reader["Name"].ToString();
                    info.PlayerID = (int)reader["PlayerID"];
                    info.PlayerName = reader["PlayerName"].ToString();
                    info.GroomID = (int)reader["GroomID"];
                    info.GroomName = reader["GroomName"].ToString();
                    info.BrideID = (int)reader["BrideID"];
                    info.BrideName = reader["BrideName"].ToString();
                    info.Pwd = reader["Pwd"].ToString();
                    info.AvailTime = (int)reader["AvailTime"];
                    info.MaxCount = (int)reader["MaxCount"];
                    info.GuestInvite = (bool)reader["GuestInvite"];
                    info.MapIndex = (int)reader["MapIndex"];
                    info.BeginTime = (DateTime)reader["BeginTime"];
                    info.BreakTime = (DateTime)reader["BreakTime"];
                    info.RoomIntroduction = reader["RoomIntroduction"].ToString();
                    info.ServerID = (int)reader["ServerID"];
                    info.IsHymeneal = (bool)reader["IsHymeneal"];
                    info.IsGunsaluteUsed = (bool)reader["IsGunsaluteUsed"];
                    infos.Add(info);
                }

                return infos.ToArray();
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("GetMarryRoomInfo", e);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }

            return null;
        }
Ejemplo n.º 14
0
        public bool UpdateMarryRoomInfo(MarryRoomInfo info)
        {
            bool result = false;
            try
            {
                SqlParameter[] para = new SqlParameter[9];
                para[0] = new SqlParameter("@ID", info.ID);
                para[1] = new SqlParameter("@AvailTime", info.AvailTime);
                para[2] = new SqlParameter("@BreakTime", info.BreakTime);
                para[3] = new SqlParameter("@roomIntroduction", info.RoomIntroduction);
                para[4] = new SqlParameter("@isHymeneal", info.IsHymeneal);
                para[5] = new SqlParameter("@Name", info.Name);
                para[6] = new SqlParameter("@Pwd", info.Pwd);
                para[7] = new SqlParameter("@IsGunsaluteUsed", info.IsGunsaluteUsed);
                para[8] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
                para[8].Direction = ParameterDirection.ReturnValue;
                db.RunProcedure("SP_Update_Marry_Room_Info", para);
                result = (int)para[8].Value == 0;

            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("UpdateMarryRoomInfo", e);
            }

            return result;
        }
Ejemplo n.º 15
0
        public bool InsertMarryRoomInfo(MarryRoomInfo info)
        {
            bool result = false;
            try
            {
                SqlParameter[] para = new SqlParameter[20];
                para[0] = new SqlParameter("@ID", info.ID);
                para[0].Direction = ParameterDirection.InputOutput;
                para[1] = new SqlParameter("@Name", info.Name);
                para[2] = new SqlParameter("@PlayerID", info.PlayerID);
                para[3] = new SqlParameter("@PlayerName", info.PlayerName);
                para[4] = new SqlParameter("@GroomID", info.GroomID);
                para[5] = new SqlParameter("@GroomName", info.GroomName);
                para[6] = new SqlParameter("@BrideID", info.BrideID);
                para[7] = new SqlParameter("@BrideName", info.BrideName);
                para[8] = new SqlParameter("@Pwd", info.Pwd);
                para[9] = new SqlParameter("@AvailTime", info.AvailTime);
                para[10] = new SqlParameter("@MaxCount", info.MaxCount);
                para[11] = new SqlParameter("@GuestInvite", info.GuestInvite);
                para[12] = new SqlParameter("@MapIndex", info.MapIndex);
                para[13] = new SqlParameter("@BeginTime", info.BeginTime);
                para[14] = new SqlParameter("@BreakTime", info.BreakTime);
                para[15] = new SqlParameter("@RoomIntroduction", info.RoomIntroduction);
                para[16] = new SqlParameter("@ServerID", info.ServerID);
                para[17] = new SqlParameter("@IsHymeneal", info.IsHymeneal);
                para[18] = new SqlParameter("@IsGunsaluteUsed", info.IsGunsaluteUsed);
                para[19] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
                para[19].Direction = ParameterDirection.ReturnValue;
                db.RunProcedure("SP_Insert_Marry_Room_Info", para);

                result = (int)para[19].Value == 0;
                if (result)
                {
                    info.ID = (int)para[0].Value;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("InsertMarryRoomInfo", e);
            }
            return result;
        }