Ejemplo n.º 1
0
 public string   getCharacterAction(WoWCharacterModel character)
 {
     if (index == 0)
     {
         return("New character: " + character.name + "!");
     }
     if (index == 1)
     {
         return("My character " + character.name + " died " + character.deaths + " times!");
     }
     if (index == 2)
     {
         return("My character " + character.name + " facepalmed " + character.facepalmed + " times!");
     }
     if (index == 3)
     {
         return("My character " + character.name + " level up! Now level " + character.level + "!");
     }
     if (index == 4)
     {
         return("My character " + character.name + " has accomplished new quests. Total:" + character.questsDone + "!");
     }
     if (index == 5)
     {
         return("My character " + character.name + " went fishing! He now has caught " + character.fishCaught + " fish!");
     }
     return("");
 }
Ejemplo n.º 2
0
 public void     updateCharacter(int stat, WoWCharacterModel character, AreaDbContext DB)
 {
     if (index == 1)
     {
         character.deaths = stat;
     }
     if (index == 2)
     {
         character.facepalmed = stat;
     }
     if (index == 3)
     {
         character.level = stat;
     }
     if (index == 4)
     {
         character.questsDone = stat;
     }
     if (index == 5)
     {
         character.fishCaught = stat;
     }
     DB.wowcharactermodels.Update(character);
     DB.SaveChanges();
 }
Ejemplo n.º 3
0
 public bool alreadyExists(List <WoWCharacterModel> existing_characters, WoWCharacterModel character)
 {
     foreach (var existing_character in existing_characters)
     {
         if (existing_character.realm == character.realm && existing_character.name == character.name)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
        public bool   checkAndUpdateCharacter(WoWCharacterModel charact, AreaDbContext DB)
        {
            int stat = getNewCharacterStat(charact.realm, charact.name);

            if (stat > getCurrentCharacterStat(charact))
            {
                Console.WriteLine(charact.name + " stat: " + stat + " current_stat : " + getCurrentCharacterStat(charact));
                updateCharacter(stat, charact, DB);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        public WoWCharacterModel getAllInfos(string realm, string name)
        {
            WoWCharacterModel character = new WoWCharacterModel();

            character.deaths     = 0;
            character.facepalmed = 0;
            character.level      = 0;
            character.questsDone = 0;
            character.fishCaught = 0;
            try {
                var client = new WebClient();
                client.UseDefaultCredentials = true;
                client.QueryString.Add("apikey", "ak8a3kw6ksu5y89t8bx5ct8f4kp5uzv5");
                client.QueryString.Add("fields", "statistics");
                client.QueryString.Add("locale", "en_GB");
                string  result = client.DownloadString("https://eu.api.battle.net/wow/character/" + realm + "/" + name);
                dynamic obj    = JsonConvert.DeserializeObject(result);
                var     value  = obj["statistics"]["subCategories"];
                character.level = obj["level"];
                foreach (var subcategory in value)
                {
                    if (subcategory["name"].ToString() == "Skills")
                    {
                        character.fishCaught = (subcategory["subCategories"][0]["statistics"][7]["quantity"]);
                    }
                    if (subcategory["name"].ToString() == "Quests")
                    {
                        character.questsDone = (subcategory["statistics"][0]["quantity"]);
                    }
                    if (subcategory["name"].ToString() == "Social")
                    {
                        character.facepalmed = (subcategory["statistics"][1]["quantity"]);
                    }
                    if (subcategory["name"].ToString() == "Deaths")
                    {
                        character.deaths = (subcategory["statistics"][0]["quantity"]);
                    }
                }
            }
            catch
            {
                return(character);
            }
            return(character);
        }
Ejemplo n.º 6
0
 public int   getCurrentCharacterStat(WoWCharacterModel character)
 {
     if (index == 1)
     {
         return(character.deaths);
     }
     if (index == 2)
     {
         return(character.facepalmed);
     }
     if (index == 3)
     {
         return(character.level);
     }
     if (index == 4)
     {
         return(character.questsDone);
     }
     if (index == 5)
     {
         return(character.fishCaught);
     }
     return(character.level);
 }
Ejemplo n.º 7
0
        public int   getFishCaught(string realm, string name)
        {
            WoWCharacterModel character = getAllInfos(realm, name);

            return(character.fishCaught);
        }
Ejemplo n.º 8
0
        public int   getQuestsDone(string realm, string name)
        {
            WoWCharacterModel character = getAllInfos(realm, name);

            return(character.questsDone);
        }
Ejemplo n.º 9
0
        public int   getFacepalmed(string realm, string name)
        {
            WoWCharacterModel character = getAllInfos(realm, name);

            return(character.facepalmed);
        }
Ejemplo n.º 10
0
        public int   getDeaths(string realm, string name)
        {
            WoWCharacterModel character = getAllInfos(realm, name);

            return(character.deaths);
        }