Exemple #1
0
        protected override void ReadEntry(JObject entry)
        {
            entry.AssertNotMissing("name", "raceId");

            var data = new ActorData();

            data.Name       = entry.ReadString("name");
            data.RaceId     = entry.ReadInt("raceId");
            data.Height     = entry.ReadFloat("height", 1);
            data.Weight     = entry.ReadFloat("weight", 1);
            data.Upper      = entry.ReadFloat("upper", 1);
            data.Lower      = entry.ReadFloat("lower", 1);
            data.FaceItemId = entry.ReadInt("face");
            data.SkinColor  = entry.ReadInt("skinColor");
            data.EyeType    = entry.ReadInt("eyeType");
            data.EyeColor   = entry.ReadInt("eyeColor");
            data.MouthType  = entry.ReadInt("mouthType");
            data.HairItemId = entry.ReadInt("hair");
            data.HairColor  = entry.ReadUInt("hairColor");

            data.HasColors = entry.ContainsAnyKeys("color1", "color2", "color3");
            if (data.HasColors)
            {
                data.Color1 = entry.ReadUInt("color1");
                data.Color2 = entry.ReadUInt("color2");
                data.Color3 = entry.ReadUInt("color3");
            }

            if (entry.ContainsKey("items"))
            {
                foreach (JObject itemEntry in entry["items"])
                {
                    itemEntry.AssertNotMissing("itemId", "pocket");

                    var itemData = new ActorItemData();

                    itemData.ItemId    = itemEntry.ReadInt("itemId");
                    itemData.Pocket    = (Pocket)itemEntry.ReadInt("pocket");
                    itemData.HasColors = itemEntry.ContainsAnyKeys("color1", "color2", "color3");
                    if (itemData.HasColors)
                    {
                        itemData.Color1 = itemEntry.ReadUInt("color1");
                        itemData.Color2 = itemEntry.ReadUInt("color2");
                        itemData.Color3 = itemEntry.ReadUInt("color3");
                    }

                    data.Items.Add(itemData);
                }
            }

            this.Entries[data.Name] = data;
        }
Exemple #2
0
        protected override void ReadEntry(JObject entry)
        {
            entry.AssertNotMissing("name", "raceId");

            var data = new ActorData();

            data.Name       = entry.ReadString("name");
            data.RaceId     = entry.ReadInt("raceId");
            data.Height     = entry.ReadFloat("height", 1);
            data.Weight     = entry.ReadFloat("weight", 1);
            data.Upper      = entry.ReadFloat("upper", 1);
            data.Lower      = entry.ReadFloat("lower", 1);
            data.FaceItemId = entry.ReadInt("face");
            data.SkinColor  = entry.ReadInt("skinColor");
            data.EyeType    = entry.ReadInt("eyeType");
            data.EyeColor   = entry.ReadInt("eyeColor");
            data.MouthType  = entry.ReadInt("mouthType");
            data.HairItemId = entry.ReadInt("hair");
            data.HairColor  = entry.ReadUInt("hairColor");

            data.HasColors = entry.ContainsAnyKeys("color1", "color2", "color3");
            if (data.HasColors)
            {
                data.Color1 = entry.ReadUInt("color1");
                data.Color2 = entry.ReadUInt("color2");
                data.Color3 = entry.ReadUInt("color3");
            }

            data.Title   = entry.ReadInt("title");
            data.Age     = Math.Max(1, entry.ReadInt("age"));
            data.Level   = Math.Max(1, entry.ReadInt("level"));
            data.AP      = entry.ReadInt("ap");
            data.Life    = Math.Max(1, entry.ReadFloat("life"));
            data.Mana    = Math.Max(1, entry.ReadFloat("mana"));
            data.Stamina = Math.Max(1, entry.ReadFloat("stamina"));
            data.Str     = Math.Max(1, entry.ReadFloat("str"));
            data.Int     = Math.Max(1, entry.ReadFloat("int"));
            data.Dex     = Math.Max(1, entry.ReadFloat("dex"));
            data.Will    = Math.Max(1, entry.ReadFloat("will"));
            data.Luck    = Math.Max(1, entry.ReadFloat("luck"));

            if (entry.ContainsKey("items"))
            {
                foreach (JObject itemEntry in entry["items"])
                {
                    itemEntry.AssertNotMissing("itemId", "pocket");

                    var itemData = new ActorItemData();

                    itemData.ItemId    = itemEntry.ReadInt("itemId");
                    itemData.Pocket    = (Pocket)itemEntry.ReadInt("pocket");
                    itemData.Amount    = itemEntry.ReadInt("amount");
                    itemData.HasColors = itemEntry.ContainsAnyKeys("color1", "color2", "color3");
                    if (itemData.HasColors)
                    {
                        itemData.Color1 = itemEntry.ReadUInt("color1");
                        itemData.Color2 = itemEntry.ReadUInt("color2");
                        itemData.Color3 = itemEntry.ReadUInt("color3");
                    }
                    itemData.State = itemEntry.ReadInt("state");

                    data.Items.Add(itemData);
                }
            }

            if (entry.ContainsKey("skills"))
            {
                foreach (JObject skillEntry in entry["skills"])
                {
                    skillEntry.AssertNotMissing("skillId", "rank");

                    var skillData = new ActorSkillData();

                    skillData.SkillId = (SkillId)skillEntry.ReadInt("skillId");

                    var rank = skillEntry.ReadString("rank");
                    skillData.Rank = (SkillRank)(rank == "N" ? 0 : 16 - Convert.ToInt32(rank, 16));

                    data.Skills.Add(skillData);
                }
            }

            this.Entries[data.Name] = data;
        }