Exemplo n.º 1
0
        /// <summary>
        /// 查找玩家
        /// </summary>
        /// <param name="playerId">玩家Id</param>
        /// <returns></returns>
        public Player FindPlayer(int playerId)
        {
            using (var reader = MySqlDatabaseHelper.ExecuteReader(CommandType.Text,
                                                                  "SELECT * FROM Players WHERE Id=@charId", new MySqlParameter("@charId", playerId)))
            {
                if (reader.Read())
                {
                    return(new Player(
                               reader.GetInt32("Id"),
                               reader.GetString("Name"),
                               (PlayerGender)reader.GetInt32("Gender"),
                               reader.GetUInt32("Level"),
                               reader.GetUInt32("PhysicalStrength"),
                               reader.GetUInt32("Endurance"),
                               reader.GetUInt32("CE")
                               ));
                }

                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加载玩家好友数据
        /// </summary>
        /// <param name="playerId">玩家Id</param>
        /// <returns></returns>
        public List <PlayerFriendModel> GetFriendIdList(int playerId)
        {
            using (var reader = MySqlDatabaseHelper.ExecuteReader(CommandType.Text,
                                                                  "SELECT * FROM Players WHERE Id IN (SELECT FriendCharacterId FROM friends WHERE CharacterId = @charId)",
                                                                  new MySqlParameter("@charId", playerId)))
            {
                var friendIdList = new List <PlayerFriendModel>();

                while (reader.Read())
                {
                    friendIdList.Add(new PlayerFriendModel
                    {
                        FriendId     = reader.GetInt32("Id"),
                        FriendName   = reader.GetString("Name"),
                        FriendGender = reader.GetBoolean("Gender"),
                        FriendCe     = reader.GetUInt32("CE")
                    });
                }

                return(friendIdList);
            }
        }