/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2018-12-22
 * 时间: 16:21
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Text;
using Server.Config;

namespace Server.Data{
	/// <summary>
	/// 游戏信息
	/// </summary>
	public class GameInfo{
		
		/// <summary>
		/// gameid 服务器ServerId
		/// </summary>
		public int gameId;
		
		/// <summary>
		/// 是否开启朋友模式
		/// </summary>
		public int openFriend;
		
		/// <summary>
		/// 是否开启金币模式
		/// </summary>
		public int openGlod;
		
		/// <summary>
		/// 模块的id
		/// </summary>
		public int moduleId;
		
		/// <summary>
		/// 构造方法
		/// </summary>
		public GameInfo(){}

        public GameInfo(GameConfig gameConfig)
        {
            this.gameId = gameConfig.GameId;
            this.openFriend = gameConfig.OpenFriend;
            this.openGlod = gameConfig.OpenGold;
            this.moduleId = ServerConfigManager.Instance.NodeId;
        }

        /// <summary>
		/// 构造器
		/// </summary>
		/// <param name="gameid">游戏服务器id</param>
		/// <param name="openFriend">是否开启朋友模式</param>
		/// <param name="openGlod">是否开启金币模式</param>
		/// <param name="moudleId">模块id</param>
		public GameInfo(int gameid,int openFriend,int openGlod,int moudleId){
			this.gameId = gameid;
			this.openFriend = openFriend;
			this.openGlod = openGlod;
			this.moduleId = moudleId;
		}
		
		/// <summary>
		/// 游戏信息
		/// </summary>
		/// <returns></returns>
		public GameInfo Clone(){
			return this.MemberwiseClone() as GameInfo;
		}
		
		/// <summary>
		/// 
		/// </summary>
		/// <param name="obj"></param>
		/// <returns></returns>
		public override bool Equals(object obj)
		{
			GameInfo other = obj as GameInfo;
			if (other == null)
				return false;
			return this.gameId == other.gameId && this.moduleId == other.moduleId;
		}
		
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
		
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			StringBuilder sbr = new StringBuilder();
			sbr.Append(Environment.NewLine);
			sbr.Append("gameid:" + gameId);
			sbr.Append(Environment.NewLine);
			sbr.Append("openFriend:" + openFriend);
			sbr.Append(Environment.NewLine);
			sbr.Append("openGlod:" + openGlod);
			sbr.Append(Environment.NewLine);
			sbr.Append("moduleId:" + moduleId);
			return sbr.ToString();
		}

	}
}