using System;
using System.Collections.Generic;
using System.Text;

namespace JuSNS.AppClient
{
    /// <summary>
    /// 朋友类
    /// </summary>
    public class Friend
    {
        /// <summary>
        /// 取得某用户的朋友用户ID
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        static public int[] Get(int UserID)
        {
            AppRequest req = new AppRequest("Friend", "Get", UserID.ToString());
            string str = req.Result;
            string[] arrStr = str.Split(',');
            int i = 0;
            int[] rInt = new int[1];
            foreach (string s in arrStr)
            {
                i++;
                Array.Resize<int>(ref rInt, i);
                int.TryParse(s, out rInt[i - 1]);
            }
            return rInt;
        }
        /// <summary>
        /// 取得当前用户的好友
        /// </summary>
        /// <returns></returns>
        static public int[] Get()
        {
            return Get(User.UserID);
        }
        /// <summary>
        /// 判断是否为朋友
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="FriendID">朋友ID</param>
        /// <returns></returns>
        static public bool IsFriends(int UserID,int FriendID)
        {
            AppRequest req = new AppRequest("Friend", "AreFriends", UserID.ToString() + "," + FriendID);
            string str = req.Result;
            int n = 0;
            int.TryParse(str, out n);
            if (n == 1)
            {
                return false;
            }
            return false;
        }
        static public bool IsFriends(int FriendID)
        {
            return IsFriends(User.UserID);
        }
        /// <summary>
        /// 取得本应用程序的好友
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <returns></returns>
        static public int[] GetAppUsers(int UserID)
        {
            AppRequest req = new AppRequest("Friend", "GetAppUsers", UserID.ToString());
            string str = req.Result;
            string[] arrStr = str.Split(',');
            int i = 0;
            int[] rInt = new int[1];
            foreach (string s in arrStr)
            {
                i++;
                Array.Resize<int>(ref rInt, i);
                int.TryParse(s, out rInt[i - 1]);
            }
            return rInt;
        }
        /// <summary>
        /// 取得当前用户本应用程序的好友
        /// </summary>
        /// <returns></returns>
        static public int[] GetAppUsers()
        {
            return GetAppUsers(User.UserID);
        }
    }
}
