public void TestClassList() { ClassList classList = new ClassList("races"); classList.AddClass(new Class("dwarf", new AttributeModifier(AttributeModifier.AttributeModifierOptions.SET, "use_hammer"), new AttributeModifier(AttributeModifier.AttributeModifierOptions.FORBID, "use_bow") )); classList.AddClass(new Class("elf", new AttributeModifier(AttributeModifier.AttributeModifierOptions.SET, "use_bow") )); Assert.IsTrue(classList.IsClassExisting("dwarf")); Assert.IsTrue(classList.IsClassExisting("elf")); Assert.IsFalse(classList.IsClassExisting("human")); Class dwarf = classList.GetClassByName("dwarf"); Class elf = classList.GetClassByName("elf"); Assert.IsTrue(dwarf.ContainsAttributeModifier("use_hammer")); Assert.IsTrue(dwarf.ContainsAttributeModifier("use_bow")); Assert.AreEqual(dwarf.GetAttributeModifier("use_bow").Option, AttributeModifier.AttributeModifierOptions.FORBID); }
public void TestAbilities() { ClassList races = new ClassList("races"); races.AddClass(new Class("dwarf", new AbilityModifier("STR", 2))); races.AddClass(new Class("elf", new AbilityModifier("STR", 3))); ClassList jobs = new ClassList("jobs"); jobs.AddClass(new Class("smith", new AbilityModifier("STR", 4))); jobs.AddClass(new Class("mage", new AbilityModifier("STR", -1))); SchemeFunction f = new SchemeFunction(); f.AddCommand(new CommandSetVariable("strength", "STR")); MapObject @object = new MapObject(); @object.Name = "some_object"; @object.Scheme = new Scheme("some_scheme"); @object.Variables.Add(new ObjectVariable(VariableTypes.Ability, "STR", 5)); //STR = 5 @object.Variables.Add(new ObjectVariable(VariableTypes.Number, "strength", 0)); Config config = new Config(); config.AddScheme(@object.Scheme); config.AddClassList(races); config.AddClassList(jobs); @object.Variables.Add(new ObjectVariable("races", "race", races.GetClassByName("dwarf"))); //dwarf: STR+2 @object.Variables.Add(new ObjectVariable("jobs", "job", jobs.GetClassByName("mage"))); //mage: STR-1 Game game = new Game(config); game._AddObject(@object); //Execute function on object f.Execute(@object, new Character(), game); Assert.AreEqual(6, @object.GetVariableByName("strength", config).Value); }
public void TestClasslistHandling() { ClassList races = new ClassList("races"); races.AddClass(new Class("dwarf")); races.AddClass(new Class("elf")); SchemeFunction f = new SchemeFunction(); f.AddCommand(new CommandOf("race", "actor", "_0")); f.AddCommand(new CommandEquals("_0", "dwarf", "isDwarf")); f.AddCommand(new CommandOf("race", "actor", "_0")); f.AddCommand(new CommandEquals("_0", "elf", "isElf")); MapObject @object = new MapObject(); @object.Name = "some_object"; @object.Scheme = new Scheme("some_scheme"); @object.Variables.Add(new ObjectVariable("logical", "isDwarf", false)); @object.Variables.Add(new ObjectVariable("logical", "isElf", false)); Config config = new Config(); config.AddScheme(@object.Scheme); config.AddClassList(races); Game game = new Game(config); game._AddObject(@object); Character actor = new Character(); actor.Scheme = new Scheme("character"); actor.Variables.Add(new ObjectVariable("races", "race", races.GetClassByName("dwarf"))); //Execute function on object f.Execute(@object, actor, game); Assert.AreEqual(@object.GetVariableByName("isDwarf", config).Value, true); Assert.AreEqual(@object.GetVariableByName("isElf", config).Value, false); }