예제 #1
0
            public static Player ToPlayer(JsonPlayer jp)
            {
                List <Enchantment> buffs = new List <Enchantment>();

                if (jp.Buffs != null)
                {
                    foreach (JsonEnchantment je in jp.Buffs.Where(v => v != null))
                    {
                        Enchantment e = Enchantment.ToEnchantment(je);
                        if (e != null)
                        {
                            if (e.Attributes != null)
                            {
                                e.Attributes.SetValue(Attribute.CritChance, e.Attributes.GetValue(Attribute.CritChance) / 100);
                                e.Attributes.SetValue(Attribute.HitChance, e.Attributes.GetValue(Attribute.HitChance) / 100);
                                e.Attributes.SetValue(Attribute.AS, e.Attributes.GetValue(Attribute.AS) / 100);
                            }

                            buffs.Add(e);
                        }
                    }
                }

                return(new Player(null, Player.Classes.Warrior)
                {
                    // TODO race, classe etc.
                    Equipment = ToEquipment(jp.MH, jp.OH, jp.Ranged, jp.Equipment),
                    Buffs = buffs,
                    WindfuryTotem = jp.Buffs != null && jp.Buffs.Select(b => b.Name).Contains("Windfury Totem"),
                    Cooldowns = jp.Cooldowns.Where(v => v.Value == true).Select(c => c.Key).ToList()
                });
            }
예제 #2
0
            public static Player ToPlayer(JsonPlayer jp, bool tanking = false)
            {
                List <Enchantment> buffs = new List <Enchantment>();

                if (jp.Buffs != null)
                {
                    foreach (JsonEnchantment je in jp.Buffs.Where(v => v != null))
                    {
                        Enchantment e = Enchantment.ToEnchantment(je);
                        if (e != null)
                        {
                            if (e.Attributes != null)
                            {
                                e.Attributes.SetValue(Attribute.CritChance, e.Attributes.GetValue(Attribute.CritChance) / 100);
                                e.Attributes.SetValue(Attribute.HitChance, e.Attributes.GetValue(Attribute.HitChance) / 100);
                                e.Attributes.SetValue(Attribute.Haste, e.Attributes.GetValue(Attribute.Haste) / 100);
                                e.Attributes.SetValue(Attribute.SpellHitChance, e.Attributes.GetValue(Attribute.SpellHitChance) / 100);
                                e.Attributes.SetValue(Attribute.SpellCritChance, e.Attributes.GetValue(Attribute.SpellCritChance) / 100);
                            }

                            buffs.Add(e);
                        }
                    }
                }

                bool          windfurytotem = jp.Buffs != null && jp.Buffs.Any(b => b.Name.ToLower().Contains("windfury totem"));
                List <string> cooldowns     = jp.Cooldowns.Where(v => v.Value == true).Select(c => c.Key).ToList();

                switch (ToClass(jp.Class))
                {
                case Player.Classes.Druid:
                    return(new Druid(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Hunter:
                    return(new Hunter(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Paladin:
                    return(new Paladin(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Priest:
                    return(new Priest(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Rogue:
                    return(new Rogue(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Shaman:
                    return(new Shaman(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Warlock:
                    return(new Warlock(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                case Player.Classes.Warrior:
                    return(new Warrior(null, ToRace(jp.Race), 60, ToEquipment(jp.Weapons, jp.Equipment), null, buffs, tanking)
                    {
                        WindfuryTotem = windfurytotem,
                        Cooldowns = cooldowns
                    });

                default:
                    throw new NotImplementedException("This class isn't supported yet : " + ToClass(jp.Class));
                }
            }