private static string FieldsFromEnum1(CharacterFields flagsEnum)
        {
            int flagsValue = Convert.ToInt32(flagsEnum);

            var values = Enum.GetValues(flagsEnum.GetType()).Cast <int>().Where(x => (flagsValue & x) == x)
                         .Except(new[] { 0x0, 0x7FFF, 0x7FFFFFFF }).Select(x => Enum.GetName(flagsEnum.GetType(), x).ToString()).ToArray();

            return(string.Join(",", values).ToLowerInvariant());
        }
Ejemplo n.º 2
0
        public Character GetCharacter(string name, string realm, CharacterFields fields = CharacterFields.None)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException("name");
            if (string.IsNullOrWhiteSpace(realm))
                throw new ArgumentNullException("realm");

            return this.Get<Character>(string.Format("character/{0}/{1}", realm, name), fields: fields);
        }
Ejemplo n.º 3
0
        public Character GetCharacterProfile(string realm, string character, CharacterFields field)
        {
            string fieldInput = field.ToString();

            Request request = new Request(User_Agent);

            request.Get($"{Api_Url}wow/character/{realm}/{character}?fields={fieldInput}&locale={Locale}&apikey={Api_Key}");
            return(new Character(JObject.Parse(request.Response)));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///   Get character profile information asynchronously
 /// </summary>
 /// <param name="realm"> realm name </param>
 /// <param name="characterName"> character name </param>
 /// <param name="fieldsToRetrieve"> the profile fields to retrieve </param>
 /// <returns> The status of the async operation </returns>
 public Task<Character> GetCharacterAsync(string realm, string characterName, CharacterFields fieldsToRetrieve)
 {
     string[] fields =
         EnumHelper<CharacterFields>.GetNames().Where(
             name =>
             name != "All" &&
             (fieldsToRetrieve & (CharacterFields)Enum.Parse(typeof(CharacterFields), name, true)) != 0).Select
             (name => char.ToLowerInvariant(name[0]) + name.Substring(1)).ToArray();
     string queryString = fields.Length == 0 ? "" : "?fields=" + string.Join(",", fields);
     return _client.GetAsync<Character>("wow/character/" + GetRealmSlug(realm) + "/" + Uri.EscapeUriString(characterName) + queryString);
 }
Ejemplo n.º 5
0
 public void SkillNotUsable(CharacterFields tp_field)
 {
     for (int i = 0; i < 4; i++)
     {
         try {
             foreach (Transform trans in tp_field.Columns[(appliedSkill.ActivateRow[i]) - 1].ToArray())
             {
                 tp_list.Add(trans);
             }
         } catch {
         }
     }
 }
Ejemplo n.º 6
0
        public CharacterResponse GetCharacter(string CharacterApiId, CharacterFields CharacterFields = CharacterFields.ALL)
        {
            string _RequestResourceUrl = ApiResources.Character.Resource + "/" + CharacterApiId;

            Parameter _FieldsParam = null;

            if (CharacterFields != CharacterFields.ALL)
            {
                _FieldsParam = RestHelper.BuildParameter(ApiResources.Character.Parameters.FieldList, EnumHelper.CleanEnumAndReturnAsLowercaseString(CharacterFields), ParameterType.QueryString);
            }

            return(GetResource <CharacterResponse>(_RequestResourceUrl, _FieldsParam));
        }
Ejemplo n.º 7
0
 public void StaticTargetApply(CharacterFields tp_field)
 {
     int[] tp_targets = appliedSkill.StaticTarget;
     try{
         for (int i = 0; i < tp_targets.Length; i++)
         {
             if (tp_targets[i] == 1)
             {
                 tp_list.Add(tp_field.AllPositions [i]);
             }
         }
     }catch {
     }
 }
Ejemplo n.º 8
0
    void Awake()
    {
        k_CharacterFields = this;

        Rows    = new List <Transform> [4];
        Columns = new List <Transform> [4];

        Position = new List <Transform> ();
        Row1     = new List <Transform> ();
        Row2     = new List <Transform> ();
        Row3     = new List <Transform> ();
        Row4     = new List <Transform> ();
        Column1  = new List <Transform> ();
        Column2  = new List <Transform> ();
        Column3  = new List <Transform> ();
        Column4  = new List <Transform> ();

        AllPositions = new List <Transform> ();

        for (int i = 0; i < 16; i++)
        {
            this.Position.Add(transform.GetChild(i));
        }

        if (gameObject.transform.name == "LeftBattleGround")
        {
            for (int i = 0; i < 4; i++)
            {
                Column1.Add(Position [3 + 4 * i]);
                Column2.Add(Position [2 + 4 * i]);
                Column3.Add(Position [1 + 4 * i]);
                Column4.Add(Position [0 + 4 * i]);
            }
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                Column1.Add(Position [0 + 4 * i]);
                Column2.Add(Position [1 + 4 * i]);
                Column3.Add(Position [2 + 4 * i]);
                Column4.Add(Position [3 + 4 * i]);
            }
        }
        Row1 = Position.GetRange(0, 4);
        Row2 = Position.GetRange(4, 4);
        Row3 = Position.GetRange(8, 4);
        Row4 = Position.GetRange(12, 4);
    }
Ejemplo n.º 9
0
        public static string BuildQueryString(this CharacterFields fields)
        {
            switch (fields)
            {
            case CharacterFields.All:
                return("&fields=achievements,appearance,feed,guild,hunter pets,items,mounts,pets,pet slots,professions,progression,pvp,quests,reputation,statistics,stats,talents,titles,audit");

            case CharacterFields.None:
                return(string.Empty);

            default:
                var flags = fields.ToString().ToLower();
                return($"&fields={flags}");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">The Characters name</param>
        /// <param name="characterOptions">What characteroptions should be set (enum)</param>
        /// <param name="realm"></param>
        /// <returns>CharacterRoot object</returns>
        public CharacterRoot GetCharacter(string name, CharacterOptions characterOptions, string realm)
        {
            var character = new CharacterRoot();

            var url = string.Format(@"{0}/wow/character/{1}/{2}?locale={3}{4}&apikey={5}",
                                    _Host,
                                    realm,
                                    name,
                                    _Locale,
                                    CharacterFields.BuildOptionalFields(characterOptions),
                                    _APIKey);

            character = json.GetDataFromURL <CharacterRoot>(url);

            return(character);
        }
        public static string BuildQueryString(this CharacterFields fields)
        {
            // The Blizzard API only accepts lowercase fields.
            string flags = fields.ToString().ToLower();

            if (flags == "all")
            {
                return("&fields=achievements,appearance,feed,guild,hunter pets,items,mounts,pets,pet slots," +
                       "professions,progression,pvp,quests,reputation,statistics,stats,talents,titles,audit");
            }
            if (flags == "none")
            {
                return(string.Empty);
            }

            return($"&fields={flags}");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets data about a character.
        /// </summary>
        /// <param name="name">The Characters name.</param>
        /// <param name="characterOptions">What characteroptions should be set (enum).</param>
        /// <param name="realm">The realm this character exists on.</param>
        /// <returns>CharacterRoot object</returns>
        public async Task <CharacterRoot> GetCharacterAsync(string name, CharacterOptions characterOptions, string realm)
        {
            var character = new CharacterRoot();

            var url =
                string.Format(
                    @"{0}/wow/character/{1}/{2}?locale={3}{4}&apikey={5}",
                    _Host,
                    realm,
                    name,
                    _Locale,
                    CharacterFields.BuildOptionalFields(characterOptions),
                    _APIKey);

            character = await this.jsonUtility.GetDataFromURLAsync <CharacterRoot>(url);

            return(character);
        }
Ejemplo n.º 13
0
    public void PositionalTargetApply(CharacterFields tp_field, int tp_rowPos)
    {
        int[]      tp_targets = appliedSkill.PositionalTarget;
        List <int> tp_listed  = new List <int> (tp_targets);

        switch (tp_rowPos)
        {
        case 0:
            tp_listed.RemoveRange(0, 12);
            break;

        case 1:
            tp_listed.RemoveRange(0, 8);
            tp_listed.RemoveRange(16, 4);
            break;

        case 2:
            tp_listed.RemoveRange(0, 4);
            tp_listed.RemoveRange(16, 8);
            break;

        case 3:
            tp_listed.RemoveRange(16, 12);
            break;
        }

        List <Transform> tp_fields = new List <Transform> ();

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                tp_fields.Add(tp_field.Rows [i] [j]);
            }
        }

        for (int i = 0; i < 16; i++)
        {
            if (tp_listed [i] == 1)
            {
                tp_list.Add(tp_fields [i]);
            }
        }
    }
Ejemplo n.º 14
0
 void Start()
 {
     //StartCoroutine (GetTargetFields ());
     LeftBattlePanel  = GameManager.k_Manager.k_LeftBattlePanel.GetComponent <CharacterFields> ();
     RightBattlePanel = GameManager.k_Manager.k_RightBattlePanel.GetComponent <CharacterFields> ();
 }
Ejemplo n.º 15
0
 public static IEnumerable <string> GetFieldsAsStrings(this CharacterFields fields)
 {
     return(GetFieldsAsStrings <CharacterFields>((int)fields));
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Gets data about a character.
        /// </summary>
        /// <param name="name">The Characters name.</param>
        /// <param name="characterOptions">What characteroptions should be set (enum).</param>
        /// <param name="realm">The realm this character exists on.</param>
        /// <returns>CharacterRoot object</returns>
        public async Task <CharacterRoot> GetCharacterAsync(string name, CharacterOptions characterOptions, string realm)
        {
            var url = $"{Host}/wow/character/{realm}/{name}?locale={Locale}{CharacterFields.BuildOptionalFields(characterOptions)}&apikey={APIKey}";

            return(await this._jsonUtility.GetDataFromURLAsync <CharacterRoot>(url));
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     The Character Profile API is the primary way to access character information. This API can be used to
        ///     fetch a single character at a time through an HTTP GET request to a URL describing the character
        ///     profile resource. By default, these requests return a basic dataset, and each request can return zero
        ///     or more additional fields. To access this API, craft a resource URL pointing to the desired character
        ///     for which to retrieve information.
        /// </summary>
        /// <param name="realm">
        ///     The character's realm.
        ///     Can be provided as the proper realm name or the normalized realm name.
        /// </param>
        /// <param name="characterName">The name of the character to retrieve.</param>
        /// <param name="fields">
        ///     The dataset to retrieve for the character. Each field value is explained in more detail in the
        ///     following requests. If no fields are specified the API will only return basic data about the character.
        ///     <seealso cref="CharacterFields" />
        /// </param>
        /// <returns>
        ///     The specified character profile and additional data.
        /// </returns>
        /// >
        public async Task <RequestResult <Character> > GetCharacterAsync(string realm, string characterName, CharacterFields fields = CharacterFields.None)
        {
            var queryStringFields = fields.BuildQueryString();

            return(await Get <Character>($"{Host}/wow/character/{realm}/{characterName}?&locale={Locale}{queryStringFields}"));
        }
Ejemplo n.º 18
0
 public void SetField(CharacterFields field, float value)
 {
     SetField((ushort)field, value);
 }
Ejemplo n.º 19
0
 public float GetFieldFloat(CharacterFields field)
 {
     return(GetFieldFloat((ushort)field));
 }
Ejemplo n.º 20
0
 public int GetFieldSigned(CharacterFields field)
 {
     return(GetFieldSigned((ushort)field));
 }
Ejemplo n.º 21
0
        /// <summary>
        ///   Get character profile information asynchronously
        /// </summary>
        /// <param name="realm"> realm name </param>
        /// <param name="characterName"> character name </param>
        /// <param name="fieldsToRetrieve"> the profile fields to retrieve </param>
        /// <param name="callback"> Async callback </param>
        /// <param name="asyncState"> The user defined state </param>
        /// <returns> The status of the async operation </returns>
        public Task <Character> GetCharacterAsync(string realm, string characterName, CharacterFields fieldsToRetrieve)
        {
            string[] fields =
                EnumHelper <CharacterFields> .GetNames().Where(
                    name =>
                    name != "All" &&
                    (fieldsToRetrieve & (CharacterFields)Enum.Parse(typeof(CharacterFields), name, true)) != 0).Select
                    (name => char.ToLowerInvariant(name[0]) + name.Substring(1)).ToArray();

            string queryString = fields.Length == 0 ? "" : "?fields=" + string.Join(",", fields);

            return
                (GetAsync <Character>(
                     "/api/wow/character/" + GetRealmSlug(realm) + "/" + Uri.EscapeUriString(characterName) + queryString,
                     null));
        }
Ejemplo n.º 22
0
        public async Task <Character> GetCharacterAsync(string realm, string characterName, CharacterOptions characterOptions = CharacterOptions.None)
        {
            string query = $"/wow/character/{realm}/{characterName}";

            return(await reader.GetAsync <Character>(query, CharacterFields.BuildOptionalFields(characterOptions)));
        }
		/// <summary>
		/// Gets the character information for the specified realm and character name.
		/// </summary>
		/// <param name="realmName">The name of the realm.</param>
		/// <param name="characterName">The name of the character.</param>
		/// <param name="fields">Specifies the information to retrieve for this character.</param>
		/// <param name="action">The action to execute once the response was received.</param>
		public void GetCharacterAsync(string realmName, string characterName, CharacterFields fields, Action<Character> action)
		{
			try
			{
				var fieldsQueryString = BuildCharacterFieldsQueryString(fields);
				var apiMethod = new Uri(BattleNetBaseUri, String.Format(BattleNetSettings.BattleNet_Api_Character, realmName, characterName, fieldsQueryString)).ToString();
				CallApiMethodAsync(apiMethod, jsonResult =>
				{
					try
					{
						var character = JsonConvert.DeserializeObject<Character>(jsonResult);
						if (character != null)
						{
							character.Region = Region;
						}

						action(character);
					}
					catch (Exception ex)
					{
						action(null);
					}
				});
			}
			catch (Exception ex)
			{
				action(null);
			}
		}
		/// <summary>
		/// Builds the character fields query string from the specified fields object.
		/// </summary>
		/// <param name="fields">The character fields object to build the query string from.</param>
		/// <returns>
		/// The character fields query string from the specified fields object.
		/// </returns>
		internal string BuildCharacterFieldsQueryString(CharacterFields fields)
		{
			var fieldQueryString = fields.GetValues().Cast<CharacterFields>().Where(value => value != CharacterFields.All && (fields & value) == value).Aggregate(String.Empty, (current, value) => String.Format("{0}{1}{2}", current, !String.IsNullOrEmpty(current) ? "," : String.Empty, EnumHelper.GetApiUrlFieldName(value)));
			return !String.IsNullOrEmpty(fieldQueryString) ? String.Format("?fields={0}", fieldQueryString) : String.Empty;
		}