Пример #1
0
        private void UpdateStatsReceived(PlayerInfo playerInfo, SkillResult message, Entity entitySource, long time)
        {
            if (_hasReset.Contains(entitySource) && entitySource.IsBoss())
            {
                Console.WriteLine("Remove:" + entitySource.Name);
                DeleteEntity(entitySource);
                _hasReset.Remove(entitySource);
            }

            if (!IsValidAttack(message))
            {
                return;
            }

            //Not damage & if you are a healer, don't show heal / mana regen affecting you, as that will modify your crit rate and other stats.
            if ((message.IsHp && message.Amount > 0 || !message.IsHp) && !PlayerClassHelper.IsHeal(playerInfo.Class) &&
                (UserEntity.ForEntity(message.Source)["user"] != UserEntity.ForEntity(message.Target)["user"]))
            {
                UpdateSkillStats(message, new Entity(playerInfo.Player.User.Name), playerInfo, time);
                return;
            }

            if (message.Damage <= 0)
            {
                return;
            }

            var entity = entitySource;

            if (entitySource.IsBoss())
            {
                foreach (
                    var t in EntitiesStats.Where(t => t.Key.Name == entitySource.Name).OrderByDescending(t => t.Value.FirstHit))
                {
                    entity = t.Key;
                    break;
                }

                //Don't count damage taken if boss haven't taken any damage
                if (entity == null)
                {
                    return;
                }
            }

            playerInfo.Received.AddStats(time, entity, message.Damage);
            if (EntitiesStats.ContainsKey(entity))
            {
                return;
            }
            EntitiesStats.Add(entity, new EntityInfo());
        }
Пример #2
0
        public Dictionary <string, Item> GetItemDictionary()
        {
            Dictionary <string, Item> items   = new Dictionary <string, Item>();
            SqliteCommand             command = new SqliteCommand("SELECT * FROM items", this.Connection);
            SqliteDataReader          reader  = command.ExecuteReader();

            // Columns: item_id, item_name, localized_name, localized_desc, default_slot, slots, equip_regions, attributes
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Item item = new Item(Convert.ToInt32(reader["item_id"]), reader["item_name"].ToString());
                    item.LocalizedName        = reader["localized_name"].ToString();
                    item.LocalizedDescription = reader["localized_desc"].ToString();
                    item.DefaultSlot          = InventorySlotHelper.Cast(reader["default_slot"].ToString());
                    if (reader["slots"] != SQLHandler.Null)
                    {
                        MatchCollection matches = Regex.Matches(reader["slots"].ToString(), "\"([^\"]+)\":\"([^\"]+)\",");
                        foreach (Match slotPair in matches)
                        {
                            item.AddSlot(
                                PlayerClassHelper.Cast(slotPair.Groups[1].ToString()),
                                InventorySlotHelper.Cast(slotPair.Groups[2].ToString())
                                );
                        }
                    }
                    if (reader["equip_regions"] != SQLHandler.Null)
                    {
                        MatchCollection matches = Regex.Matches(reader["equip_regions"].ToString(), "\"([^\"]+)\",");
                        foreach (Match equipRegion in matches)
                        {
                            item.AddEquipRegion(equipRegion.Groups[1].ToString());
                        }
                    }
                    if (reader["attributes"] != SQLHandler.Null)
                    {
                        MatchCollection matches = Regex.Matches(reader["attributes"].ToString(), "\"([^\"]+)\":\"([^\"]+)\",");
                        foreach (Match attributePair in matches)
                        {
                            item.AddAttribute(
                                attributePair.Groups[1].ToString(),
                                attributePair.Groups[2].ToString()
                                );
                        }
                    }
                    items.Add(item.Name, item);
                }
            }
            reader.Close();
            return(items);
        }
        private static void ExportSkills()
        {
            var dc        = DCT.DataCenter;
            var dcObjects = dc.Root.ChildrenByName("StrSheet_UserSkill").SelectMany(x => x.ChildrenByName("String"));

            var skills = dcObjects
                         .Select(data => new
            {
                Id     = data.Attribute <int>("id"),
                Race   = data.Attribute <string>("race"),
                Gender = data.Attribute <string>("gender"),
                Class  = PlayerClassHelper.Parse(data.Attribute <string>("class")),
                Name   = data.Attribute <string>("name")
            })
                         .Where(x => !string.IsNullOrEmpty(x.Name))
                         .OrderBy(x => x.Class.ToString())
                         .ThenBy(x => x.Id);

            var lines = skills.Select(x => string.Join(" ", x.Id, x.Race, x.Gender, x.Class, x.Name));

            File.WriteAllLines(Utils.GetOutput("user_skills.txt"), lines);
        }
Пример #4
0
        private static void ExportSkills()
        {
            var dc        = DCT.DataCenter;
            var dcObjects = dc.Root.ChildrenByName("StrSheet_UserSkill").SelectMany(x => x.ChildrenByName("String"));

            var skills = dcObjects
                         .Select(data => new
            {
                id     = NullCommon(data.Attribute <int>("id")),
                race   = NullCommon(data.Attribute <string>("race")),
                gender = NullCommon(data.Attribute <string>("gender")),
                @class = NullCommon(PlayerClassHelper.Parse(data.Attribute <string>("class"))),
                name   = NullCommon(data.Attribute <string>("name"))
            })
                         .Where(x => !string.IsNullOrEmpty(x.name))
                         .OrderBy(x => x.@class)
                         .ThenBy(x => x.id);

            var lines = skills.Select(o => JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            File.WriteAllLines(Utils.GetOutput("user_skills.json"), lines);
        }
Пример #5
0
 public RaceGenderClass(string race, string gender, string @class)
 {
     Race   = (Race)Enum.Parse(typeof(Race), race, true);
     Gender = (Gender)Enum.Parse(typeof(Gender), gender);
     Class  = PlayerClassHelper.Parse(@class);
 }
Пример #6
0
        private void BuildItems()
        {
            List <VDFNode> tfItems = this.ItemsGame.Head.GetValueFromKey("items");

            foreach (VDFNode entry in tfItems)
            {
                string itemName = entry.GetValueFromKey("name");
                int    itemID   = itemName == "default" ? -1 : int.Parse(entry.Key);            // The only item without a valid int ID is "default"
                Item   item     = new Item(itemID, itemName);

                // Import Prefabs
                if (entry.KeyExists("prefab"))
                {
                    string   prefabValue = entry.GetValueFromKey("prefab");
                    string[] inheritList = prefabValue.Split(' ');
                    foreach (string prefabName in inheritList)
                    {
                        item.ImportPrefab(this.PrefabsTable, prefabName);
                    }
                }

                // Localization
                if (entry.KeyExists("item_name"))
                {
                    item.LocalizedName = entry.GetValueFromKey("item_name");
                }
                if (entry.KeyExists("item_description"))
                {
                    item.LocalizedDescription = entry.GetValueFromKey("item_description");
                }

                // Attributes
                if (entry.KeyExists("attributes"))                   // Standard attributes
                {
                    List <VDFNode> attributesList = entry.GetValueFromKey("attributes");
                    foreach (VDFNode attributeNode in attributesList)
                    {
                        item.AddAttribute(attributeNode.Key, attributeNode.GetValueFromKey("value"));
                    }
                }
                if (entry.KeyExists("static_attrs"))                   // Static attributes
                {
                    List <VDFNode> staticAttributesList = entry.GetValueFromKey("static_attrs");
                    foreach (VDFNode attributeNode in staticAttributesList)
                    {
                        item.AddAttribute(attributeNode.Key, attributeNode.Value);
                    }
                }

                // Slots
                if (entry.KeyExists("item_slot") && ((string)entry.GetValueFromKey("item_slot")).Length > 0)                   // Default slot definition
                {
                    InventorySlot inventorySlot = InventorySlotHelper.Cast(entry.GetValueFromKey("item_slot"));

                    item.DefaultSlot = inventorySlot;
                }
                if (entry.KeyExists("used_by_classes"))                   // Direct slot definition
                {
                    List <VDFNode> classesList = entry.GetValueFromKey("used_by_classes");
                    foreach (VDFNode classNode in classesList)
                    {
                        PlayerClass   classType = PlayerClassHelper.Cast(classNode.Key);
                        InventorySlot inventorySlot;
                        if (classNode.Value == "1")
                        {
                            inventorySlot = InventorySlot.DEFAULT;
                        }
                        else
                        {
                            inventorySlot = InventorySlotHelper.Cast(classNode.Value);
                        }
                        item.AddSlot(classType, inventorySlot);
                    }
                }

                // Equip region
                if (entry.KeyExists("equip_region"))
                {
                    if (entry.GetNode("equip_region").Value is string)                       // Single region
                    {
                        item.AddEquipRegion(entry.GetValueFromKey("equip_region"));
                    }
                    else if (entry.GetNode("equip_region").Value is List <VDFNode> )                     // Ambiguous multiple region (Valve error?)
                    {
                        List <VDFNode> regions = entry.GetValueFromKey("equip_region");
                        foreach (VDFNode equipRegion in regions)
                        {
                            if (equipRegion.Value == "1")
                            {
                                item.AddEquipRegion(equipRegion.Key);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("item equip_region type not found");
                    }
                }
                if (entry.KeyExists("equip_regions"))                   // Multiple region
                {
                    List <VDFNode> regions = entry.GetValueFromKey("equip_regions");
                    foreach (VDFNode equipRegion in regions)
                    {
                        if (equipRegion.Value == "1")
                        {
                            item.AddEquipRegion(equipRegion.Key);
                        }
                    }
                }

                // Add to table
                ItemsSet.Add(item);
            }
        }
Пример #7
0
        private void BuildPrefabs()
        {
            List <VDFNode> tfPrefabs = this.ItemsGame.Head.GetValueFromKey("prefabs");

            foreach (VDFNode entry in tfPrefabs)
            {
                Prefab prefab = new Prefab(entry.Key);

                // Accummulate Prefabs (just store for later, don't do anything with them yet)
                if (entry.KeyExists("prefab"))
                {
                    string   prefabValue = entry.GetValueFromKey("prefab");
                    string[] inheritList = prefabValue.Split(' ');
                    foreach (string prefabName in inheritList)
                    {
                        prefab.AddPrefab(prefabName);
                    }
                }

                // Localization
                if (entry.KeyExists("item_name"))
                {
                    prefab.LocalizedName = entry.GetValueFromKey("item_name");
                }
                if (entry.KeyExists("item_description"))
                {
                    prefab.LocalizedDescription = entry.GetValueFromKey("item_description");
                }

                // Attributes
                if (entry.KeyExists("attributes"))                   // Standard attributes
                {
                    List <VDFNode> attributesList = entry.GetValueFromKey("attributes");
                    foreach (VDFNode attributeNode in attributesList)
                    {
                        prefab.AddAttribute(attributeNode.Key, attributeNode.GetValueFromKey("value"));
                    }
                }
                if (entry.KeyExists("static_attrs"))                   // Static attributes
                {
                    List <VDFNode> staticAttributesList = entry.GetValueFromKey("static_attrs");
                    foreach (VDFNode attributeNode in staticAttributesList)
                    {
                        prefab.AddAttribute(attributeNode.Key, attributeNode.Value);
                    }
                }

                // Slots
                if (entry.KeyExists("item_slot"))                   // Default slot definition
                {
                    InventorySlot inventorySlot = InventorySlotHelper.Cast(entry.GetValueFromKey("item_slot"));
                    prefab.DefaultSlot = inventorySlot;
                }
                if (entry.KeyExists("used_by_classes"))                   // Direct slot definition
                {
                    List <VDFNode> classesList = entry.GetValueFromKey("used_by_classes");
                    foreach (VDFNode classNode in classesList)
                    {
                        PlayerClass   classType = PlayerClassHelper.Cast(classNode.Key);
                        InventorySlot inventorySlot;
                        if (classNode.Value == "1")
                        {
                            inventorySlot = InventorySlot.DEFAULT;
                        }
                        else
                        {
                            inventorySlot = InventorySlotHelper.Cast(classNode.Value);
                        }
                        prefab.AddSlot(classType, inventorySlot);
                    }
                }

                // Equip region
                if (entry.KeyExists("equip_region"))
                {
                    if (entry.GetNode("equip_region").Value is string)                       // Single region
                    {
                        prefab.AddEquipRegion(entry.GetValueFromKey("equip_region"));
                    }
                    else if (entry.GetNode("equip_region").Value is List <VDFNode> )                     // Ambiguous multiple region (Valve error?)
                    {
                        List <VDFNode> regions = entry.GetValueFromKey("equip_region");
                        foreach (VDFNode equipRegion in regions)
                        {
                            if (equipRegion.Value == "1")
                            {
                                prefab.AddEquipRegion(equipRegion.Key);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("prefab equip_region type not found");
                    }
                }
                if (entry.KeyExists("equip_regions"))                   // Multiple region
                {
                    List <VDFNode> regions = entry.GetValueFromKey("equip_regions");
                    foreach (VDFNode equipRegion in regions)
                    {
                        if (equipRegion.Value == "1")
                        {
                            prefab.AddEquipRegion(equipRegion.Key);
                        }
                    }
                }

                // Add to table
                PrefabsTable.Add(prefab.Name, prefab);
            }
        }