public static Item Deserialize(dynamic data) { var item = new Item { WearLoc = ( WearLocation )Enum.Parse(typeof(WearLocation), ( string )data.WearLoc), Cost = data.Cost ?? 0, }; if (data.Flags != null) { item.Flags = ( ItemFlags )Enum.Parse(typeof(ItemFlags), ( string )data.Flags); } if (data.Stack != null) { item.Stack = Stack.Deserialize(data.Stack); } if (data.Stats != null) { item.Stats = AspectFactory.Stats().Deserialize(data.Stats); } if (data.Weapon != null) { item.Weapon = AspectFactory.Weapon().Deserialize(data.Weapon); } EntitySerializer.Deserialize(data, item); return(item); }
public void Deserialize() { var data = JsonConvert.DeserializeObject( "{ 'hp': 200, " + "'attack': 15, 'armor': 14," + "'mattack': 30, 'marmor': 31," + "'accuracy': 21, 'evasion': 17, 'critchance': 3 ," + "'strength': 25, 'dexterety': 26, 'constitution': 27, 'intellect': 28, 'wisdom': 29 }"); var stats = AspectFactory.Stats(); stats.Deserialize(data); Assert.AreEqual(200, stats.Health); Assert.AreEqual(15, stats.Attack); Assert.AreEqual(14, stats.Armor); Assert.AreEqual(30, stats.MagicAttack); Assert.AreEqual(31, stats.MagicArmor); Assert.AreEqual(21, stats.Accuracy); Assert.AreEqual(17, stats.Evasion); Assert.AreEqual(3, stats.CriticalHitChance); Assert.AreEqual(25, stats.Strength); Assert.AreEqual(26, stats.Dexterety); Assert.AreEqual(27, stats.Constitution); Assert.AreEqual(28, stats.Intellect); Assert.AreEqual(29, stats.Wisdom); }
public void DeserializeTest() { var complex = AspectFactory.Complex(); complex.stats = AspectFactory.Stats(); var data = JsonConvert.DeserializeObject("{ 'stats': {} }"); complex.Deserialize(data); Assert.IsNotNull(complex.stats); }
static ClassFactory() { var stats = AspectFactory.Stats(); stats.Strength = 20; stats.Dexterety = 20; stats.Constitution = 20; stats.Intellect = 20; stats.Wisdom = 20; _warrior = new Class("warrior", stats); }
public void SerializeTest() { var complex = AspectFactory.Complex(); complex.stats = AspectFactory.Stats(); complex.health = AspectFactory.Health(); var data = complex.Serialize(); Assert.IsNotNull(data["stats"]); Assert.IsNotNull(data["health"]); }
public void DefenderAttackIgnored() { var stats = AspectFactory.Stats(); stats.Attack = 100; var ev = Event.Create("ch_is_attacking_this", EventReturnMethod.None, new EventArg("ch", null), new EventArg("ch1", null), new EventArg("attack", AspectFactory.Attack())); stats.ReceiveEvent(ev); Assert.AreEqual(60, ev["attack"].CalculateDamage(60)); }
public void EventIsForwardedToAutoAttack() { Event testEvent = null; var mockAutoAttack = new Mock <AutoAttackAbility>(); mockAutoAttack.Setup(autoattack => autoattack.ReceiveEvent(It.IsAny <Event>())) .Callback <Event>(e => { testEvent = e; }); var spec = new Class("test_spec", AspectFactory.Stats()) { AutoAttack = mockAutoAttack.Object }; spec.ReceiveEvent(Event.Create("test_event")); mockAutoAttack.VerifyAll(); Assert.AreEqual("test_event", testEvent.Name); }
public static dynamic CreateTestStats() { var stats = AspectFactory.Stats(); stats.Health = 100; stats.Attack = 10; stats.Armor = 11; stats.MagicAttack = 30; stats.MagicArmor = 31; stats.Accuracy = 20; stats.Evasion = 16; stats.CriticalHitChance = 3; stats.Strength = 25; stats.Dexterety = 26; stats.Constitution = 27; stats.Intellect = 28; stats.Wisdom = 29; return(stats); }
public void Stats() { Assert.IsNotNull(AspectFactory.Stats()); }