Exemple #1
0
        public Pet GetPetById(int id)
        {
            HttpResponseMessage response = this.HttpGetWithAuth($"{this.locale.host}data/wow/pet/{id}?namespace=static-{this.locale.region}&locale={this.locale.code}&access_token={this.accessToken}");
            JObject             data     = JObject.Parse(response.Content.ReadAsStringAsync().Result);
            Pet pet = new Pet();

            pet.id          = Convert.ToInt32(data["id"]);
            pet.name        = data["name"].ToString();
            pet.description = data["description"].ToString();

            PetType type = new PetType();

            type.id   = Convert.ToInt32(data["battle_pet_type"]["id"]);
            type.type = data["battle_pet_type"]["type"].ToString();
            type.name = data["battle_pet_type"]["name"].ToString();
            pet.type  = type;

            pet.isCapturable   = (bool)data["is_capturable"];
            pet.isTradable     = (bool)data["is_tradable"];
            pet.isBattlePet    = (bool)data["is_battlepet"];
            pet.isAllianceOnly = (bool)data["is_alliance_only"];
            pet.isHordeOnly    = (bool)data["is_horde_only"];

            if (data["abilities"] != null)
            {
                foreach (JObject _ability in data["abilities"].Children())
                {
                    PetAbility ability = this.GetPetAbilityById(Convert.ToInt32(_ability["ability"]["id"]));
                    ability.slot          = Convert.ToInt32(_ability["slot"]);
                    ability.requiredLevel = Convert.ToInt32(_ability["required_level"]);
                    pet.abilities.Add(ability);
                }
            }

            if (data["source"] != null)
            {
                PetSource source = new PetSource();
                source.name = data["source"]["name"].ToString();
                source.type = data["source"]["type"].ToString();
                pet.source  = source;
            }

            pet.icon = data["icon"].ToString();

            Creature creature = this.GetCreatureById(Convert.ToInt32(data["creature"]["id"]));

            pet.creature = creature;

            pet.isRandomCreatureDisplay = (bool)data["is_random_creature_display"];

            pet.media        = new PetMedia();
            pet.media.petId  = pet.id;
            pet.media.assets = this.GetPetMediaAssetsByPetId(pet.id);

            return(pet);
        }
Exemple #2
0
        public PetAbility GetPetAbilityById(int id)
        {
            HttpResponseMessage response = this.HttpGetWithAuth($"{this.locale.host}data/wow/pet-ability/{id}?namespace=static-{this.locale.region}&locale={this.locale.code}&access_token={this.accessToken}");
            JObject             data     = JObject.Parse(response.Content.ReadAsStringAsync().Result);
            PetAbility          ability  = new PetAbility();

            ability.id   = Convert.ToInt32(data["id"]);
            ability.name = data["name"].ToString();

            PetType type = new PetType();

            type.id      = Convert.ToInt32(data["battle_pet_type"]["id"]);
            type.type    = data["battle_pet_type"]["type"].ToString();
            type.name    = data["battle_pet_type"]["name"].ToString();
            ability.type = type;

            ability.rounds = Convert.ToInt32(data["rounds"]);

            ability.media        = new PetAbilityMedia();
            ability.media.id     = Convert.ToInt32(data["media"]["id"]);
            ability.media.assets = this.GetPetAbilityMediaAssetsByPetAbilityId(ability.id);

            return(ability);
        }