예제 #1
0
 public void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Cuifen = Api.GetCharacter("Shadow Council", "Cuifen");
     Characters.Add(Api.GetCharacter("Shadow Council", "Leyr"));
     Characters.Add(Cuifen);
     Characters.Add(Api.GetCharacter("Shadow Council", "Anqwas"));
 }
예제 #2
0
 public static bool IsHealer(Character character)
 {
     foreach (CharacterTalent talents in character.Talents)
     {
         if (talents.Selected && talents.Spec.Role == "HEALING")
         {
             return true;
         }
     }
     return false;
 }
예제 #3
0
 public static CharacterTalent GetSelectedTalentSpec(Character character)
 {
     foreach (CharacterTalent talent in character.Talents)
     {
         if (talent.Selected)
         {
             return talent;
         }
     }
     return null;
 }
예제 #4
0
 public static string GetSelectedRole(Character character)
 {
     foreach (CharacterTalent talent in character.Talents)
     {
         if (talent.Selected)
         {
             return talent.Spec.Role;
         }
     }
     return null;
 }
        //TODO: cleanup 
        //probably better to override equality operators http://msdn.microsoft.com/en-us/library/ms173147.aspx
        public int CompareTo(Character other)
        {
            if (Name == other.Name
                && Realm == other.Realm
                && Class == other.Class
                && Race == other.Race
                && Gender == other.Gender)
            {
                return 0;
            }

            return -1;
        }
예제 #6
0
 public static bool NeedsInt(Character character)
 {
     switch (character.Class)
     {
         case CharacterClass.MAGE:
         case CharacterClass.PRIEST:
         case CharacterClass.WARLOCK:
             return true;
         case CharacterClass.DRUID:
             if (GetSelectedRole(character) == "HEALING" || GetSelectedTalentSpec(character).Spec.Name == "Balance") { return true; } else { return false; }
         case CharacterClass.MONK:
             if (GetSelectedRole(character) == "HEALING") { return true; } else { return false; }
         case CharacterClass.PALADIN:
             if (GetSelectedRole(character) == "HEALING") { return true; } else { return false; }
         case CharacterClass.SHAMAN:
             if (GetSelectedRole(character) == "HEALING" || GetSelectedTalentSpec(character).Spec.Name == "Elemental") { return true; } else { return false; }
         default:
             return false;
     }
 }
예제 #7
0
파일: Api.cs 프로젝트: berwyn/WoWSharp
 public static void StoreCharacter(Character character)
 {
     Characters.Add(character);
 }
예제 #8
0
        private int HistoryCreateNewSet(Character characterDetails, int id)
        {
            int changeEvents = 0;
            Dictionary<String, dynamic> data = new Dictionary<String, dynamic>();

            string serializedCharacter = SerializeObject(characterDetails); // new character data in serialized form
            object lastSerialized = HistoryGetLastCharacterData(id);        // character data for the last entry in serialized form

            // basic data for this entry
            data.Add("character_id", id);
            data.Add("date", DateTime.Now);

            if (lastSerialized != null) // data for this character already exists
            {
                // the last character
                Character oldCharacter = (Character)UnserializeObject(lastSerialized.ToString(), typeof(Character));

                if (oldCharacter.LastModified == characterDetails.LastModified) // current character is the same as the last one. don't insert into db
                {
                    data.Add("serializedCharacter", "");
                    data.Add("duplicate_last", 1);

                    this.Text = this.Text + " - No new data";
                }
                else // new character data, insert.
                {
                    data.Add("serializedCharacter", serializedCharacter.Replace("'", "''"));
                    data.Add("duplicate_last", 0);

                    this.Text = this.Text + " - Comparing";

                    // detect changes in: items, enchants
                    CharacterEquipment oldEquipment = oldCharacter.Items;
                    PropertyInfo[] properties = oldEquipment.GetType().GetProperties();

                    foreach (PropertyInfo property in properties)
                    {
                        if (property.GetValue(oldEquipment, null) != null && property.GetValue(oldEquipment, null).GetType() == typeof(CharacterItem))
                        {
                            CharacterItem oldItem = (CharacterItem)property.GetValue(oldEquipment, null);
                            CharacterItem correspondingNewItem = (CharacterItem)characterDetails.Items.GetType().GetProperty(property.Name).GetValue(characterDetails.Items, null);
                            if (oldItem.Id != correspondingNewItem.Id)
                            {
                                // item changed
                                insertChangelogEvent(id, "Item slot '" + property.Name + "' changed");
                                changeEvents++;
                            }
                            else
                            {
                                // item did not change
                                if (oldItem.TooltipParams.Enchant != correspondingNewItem.TooltipParams.Enchant)
                                {
                                    // enchant changed
                                    insertChangelogEvent(id, "Enchantment for item slot '" + property.Name + "' changed");
                                    changeEvents++;
                                }

                                if (oldItem.TooltipParams.Reforge != correspondingNewItem.TooltipParams.Reforge)
                                {
                                    // reforge changed
                                    insertChangelogEvent(id, "Reforge for item slot '" + property.Name + "' changed");
                                    changeEvents++;
                                }

                                if (oldItem.TooltipParams.Gem0 != correspondingNewItem.TooltipParams.Gem0)
                                {
                                    // gem 0 changed
                                    insertChangelogEvent(id, "Gem 0 for item slot '" + property.Name + "' changed");
                                    changeEvents++;
                                }

                                if (oldItem.TooltipParams.Gem1 != correspondingNewItem.TooltipParams.Gem1)
                                {
                                    // gem 1 changed
                                    insertChangelogEvent(id, "Gem 1 for item slot '" + property.Name + "' changed");
                                    changeEvents++;
                                }

                                if (oldItem.TooltipParams.Gem2 != correspondingNewItem.TooltipParams.Gem2)
                                {
                                    // gem 2 changed
                                    insertChangelogEvent(id, "Gem 2 for item slot '" + property.Name + "' changed");
                                    changeEvents++;
                                }
                            } // end: if (item changed)
                        } // end: if (property is item)
                    } // end: foreach (items)

                    for (int i = 0; i < oldCharacter.Talents.Count(); i++)
                    {
                        // glyph changes: major
                        for (int a = 0; a < oldCharacter.Talents.ToArray()[i].Glyphs.Major.Count(); a++)
                        {
                            if (oldCharacter.Talents.ToArray()[i].Glyphs.Major.ToArray()[a].Name != characterDetails.Talents.ToArray()[i].Glyphs.Major.ToArray()[a].Name) {
                                insertChangelogEvent(id, "Major glyph #" + a.ToString() + " for the talent set #" + i.ToString() + " changed");
                                changeEvents++;
                            }
                        }

                        if (oldCharacter.Talents.ToArray()[i].Glyphs.Major.Count() != characterDetails.Talents.ToArray()[i].Glyphs.Major.Count())
                        {
                            insertChangelogEvent(id, "The number of glyphs for the talent set #" + i.ToString() + " changed");
                            changeEvents++;
                        }

                        // glyph changes: minor
                        for (int b = 0; b < oldCharacter.Talents.ToArray()[i].Glyphs.Major.Count(); b++)
                        {
                            if (oldCharacter.Talents.ToArray()[i].Glyphs.Major.ToArray()[b].Name != characterDetails.Talents.ToArray()[i].Glyphs.Major.ToArray()[b].Name)
                            {
                                insertChangelogEvent(id, "Minor glyph #" + b.ToString() + " for the talent set #" + i.ToString() + " changed");
                                changeEvents++;
                            }
                        }

                        if (oldCharacter.Talents.ToArray()[i].Glyphs.Minor.Count() != characterDetails.Talents.ToArray()[i].Glyphs.Minor.Count())
                        {
                            insertChangelogEvent(id, "The number of glyphs for the talent set #" + i.ToString() + " changed");
                            changeEvents++;
                        }

                        // talent changes
                        if (oldCharacter.Talents.ToArray()[i].Talents.Count() != characterDetails.Talents.ToArray()[i].Talents.Count())
                        {
                            insertChangelogEvent(id, "The number of talents for the talent set #" + i.ToString() + " changed");
                            changeEvents++;
                        }

                        for (int c = 0; c < oldCharacter.Talents.ToArray()[i].Talents.Count(); c++)
                        {
                            if (oldCharacter.Talents.ToArray()[i].Talents.ToArray()[c].Column != characterDetails.Talents.ToArray()[i].Talents.ToArray()[c].Column)
                            {
                                insertChangelogEvent(id, "The number of talents for the talent set #" + i.ToString() + " changed");
                                changeEvents++;
                            }
                        }
                    }
                    // spec count changes!!!!!!
                    if (oldCharacter.Talents.Count() != characterDetails.Talents.Count())
                    {
                        insertChangelogEvent(id, "The number of talents specs changed");
                        changeEvents++;
                    }

                } // end: if (new character)
            } // end: if (old character data present)
            else
            {
                // first entry, insert.
                data.Add("serializedCharacter", serializedCharacter.Replace("'", "''"));
                data.Add("duplicate_last", 0);
                this.Text = this.Text + " - Inserting";
            }

            sqliteDatabase.Insert("characterHistory", data);
            return changeEvents;
        }
예제 #9
0
 public bool ProfessionHasEnchanting(Character character)
 {
     foreach (CharacterProfession profession in character.Professions.Primary)
     {
         return (profession.Name == "Enchanting");
     }
     return false;
 }