public void CharacteristicSetCtor_WithDoubleCharacteristics_CreatesValidCharacteristicSet() { // Arrange uint expectedAutoValue = 1; uint expectedBrawn = 2; // Act CharacteristicSet testSet = new CharacteristicSet(new List <Characteristic>() { new Characteristic(CharacteristicEnum.BRAWN, 2, null), new Characteristic(CharacteristicEnum.BRAWN, 3, null) }); // Assert foreach (Characteristic chara in testSet._characteristicList) { if (chara._associatedEnum != CharacteristicEnum.BRAWN) { Assert.AreEqual(expectedAutoValue, chara._value, chara._associatedEnum.ToString() + " haven't got the correct value (expected: " + expectedAutoValue + ", assigned: " + chara._value + ")"); } else { Assert.AreEqual(expectedBrawn, chara._value, chara._associatedEnum.ToString() + " haven't got the correct value (expected: " + expectedBrawn + ", assigned: " + chara._value + ")"); } } }
public static void Test03IdDoesNotFlow() { var j = new Job(EnvironmentMode.LegacyJitX64, RunMode.Long); // id will not flow, new Job Assert.False(j.HasValue(CharacteristicObject.IdCharacteristic)); Assert.False(j.Environment.HasValue(CharacteristicObject.IdCharacteristic)); Job.EnvironmentCharacteristic[j] = EnvironmentMode.LegacyJitX86.UnfreezeCopy(); // id will not flow Assert.False(j.HasValue(CharacteristicObject.IdCharacteristic)); Assert.False(j.Environment.HasValue(CharacteristicObject.IdCharacteristic)); var c = new CharacteristicSet(EnvironmentMode.LegacyJitX64, RunMode.Long); // id will not flow, new CharacteristicSet Assert.False(c.HasValue(CharacteristicObject.IdCharacteristic)); Job.EnvironmentCharacteristic[c] = EnvironmentMode.LegacyJitX86.UnfreezeCopy(); // id will not flow Assert.False(c.HasValue(CharacteristicObject.IdCharacteristic)); CharacteristicObject.IdCharacteristic[c] = "MyId"; // id set explicitly Assert.Equal("MyId", c.Id); j = new Job("MyId", EnvironmentMode.LegacyJitX64, RunMode.Long); // id set explicitly Assert.Equal("MyId", j.Id); Assert.Equal("MyId", j.Environment.Id); Job.EnvironmentCharacteristic[j] = EnvironmentMode.LegacyJitX86.UnfreezeCopy(); // id will not flow Assert.Equal("MyId", j.Id); Assert.Equal("MyId", j.Environment.Id); j = j.With(Jit.RyuJit); // custom id will flow Assert.Equal("MyId", j.Id); }
public void TrainCharacteristic_WithValidCharacteristic_IncreasesTheCharacteristicValueBy1() { // Arrange CharacteristicSet testSet = new CharacteristicSet(new List <Characteristic>() { new Characteristic(CharacteristicEnum.BRAWN, 2, null), new Characteristic(CharacteristicEnum.AGILITY, 2, null), new Characteristic(CharacteristicEnum.CUNNING, 2, null), new Characteristic(CharacteristicEnum.PRESENCE, 2, null), new Characteristic(CharacteristicEnum.WILLPOWER, 2, null), new Characteristic(CharacteristicEnum.INTELLECT, 2, null) }); uint expectedValue1 = 3; uint expectedValue2 = expectedValue1 + 1; // Act testSet.TrainCharacteristic(CharacteristicEnum.BRAWN); testSet.TrainCharacteristic(CharacteristicEnum.AGILITY); testSet.TrainCharacteristic(CharacteristicEnum.PRESENCE); testSet.TrainCharacteristic(CharacteristicEnum.INTELLECT); testSet.TrainCharacteristic(CharacteristicEnum.WILLPOWER); testSet.TrainCharacteristic(CharacteristicEnum.CUNNING); testSet.TrainCharacteristic(CharacteristicEnum.BRAWN); testSet.TrainCharacteristic(CharacteristicEnum.AGILITY); // Assert Assert.AreEqual(expectedValue2, testSet.Get(CharacteristicEnum.BRAWN)._value, "BRAWN is not the expected Value after training"); Assert.AreEqual(expectedValue2, testSet.Get(CharacteristicEnum.AGILITY)._value, "AGILITY is not the expected Value after training"); Assert.AreEqual(expectedValue1, testSet.Get(CharacteristicEnum.INTELLECT)._value, "INTELLECT is not the expected Value after training"); Assert.AreEqual(expectedValue1, testSet.Get(CharacteristicEnum.CUNNING)._value, "CUNNING is not the expected Value after training"); Assert.AreEqual(expectedValue1, testSet.Get(CharacteristicEnum.WILLPOWER)._value, "WILLPOWER is not the expected Value after training"); Assert.AreEqual(expectedValue1, testSet.Get(CharacteristicEnum.PRESENCE)._value, "PRESENCE is not the expected Value after training"); }
public void GetCharacteristic_WithEnum_GetsCharacteristic() { // Arrange uint expectedBrawn = 2; uint expectedAgility = 2; uint expectedIntellect = 2; uint expectedCunning = 2; uint expectedWillpower = 2; uint expectedPresence = 2; // Act CharacteristicSet testSet = new CharacteristicSet(new List <Characteristic>() { new Characteristic(CharacteristicEnum.BRAWN, expectedBrawn, null), new Characteristic(CharacteristicEnum.AGILITY, expectedAgility, null), new Characteristic(CharacteristicEnum.CUNNING, expectedCunning, null), new Characteristic(CharacteristicEnum.PRESENCE, expectedPresence, null), new Characteristic(CharacteristicEnum.WILLPOWER, expectedWillpower, null), new Characteristic(CharacteristicEnum.INTELLECT, expectedIntellect, null) }); // Assert Assert.AreEqual(expectedBrawn, testSet.Get(CharacteristicEnum.BRAWN)._value, "BRAWN is not the expected Value (Expected: " + expectedBrawn + ", is: " + testSet.Get(CharacteristicEnum.BRAWN)._value); Assert.AreEqual(expectedAgility, testSet.Get(CharacteristicEnum.AGILITY)._value, "AGILITY is not the expected Value (Expected: " + expectedAgility + ", is: " + testSet.Get(CharacteristicEnum.AGILITY)._value); Assert.AreEqual(expectedIntellect, testSet.Get(CharacteristicEnum.INTELLECT)._value, "INTELLECT is not the expected Value (Expected: " + expectedIntellect + ", is: " + testSet.Get(CharacteristicEnum.INTELLECT)._value); Assert.AreEqual(expectedCunning, testSet.Get(CharacteristicEnum.CUNNING)._value, "CUNNING is not the expected Value (Expected: " + expectedCunning + ", is: " + testSet.Get(CharacteristicEnum.CUNNING)._value); Assert.AreEqual(expectedWillpower, testSet.Get(CharacteristicEnum.WILLPOWER)._value, "WILLPOWER is not the expected Value (Expected: " + expectedWillpower + ", is: " + testSet.Get(CharacteristicEnum.WILLPOWER)._value); Assert.AreEqual(expectedPresence, testSet.Get(CharacteristicEnum.PRESENCE)._value, "PRESENCE is not the expected Value (Expected: " + expectedPresence + ", is: " + testSet.Get(CharacteristicEnum.PRESENCE)._value); }
public static void Test03IdDoesNotFlow() { var j = new Job(EnvMode.LegacyJitX64, RunMode.Long); // id will not flow, new Job False(j.HasValue(CharacteristicObject.IdCharacteristic)); False(j.Env.HasValue(CharacteristicObject.IdCharacteristic)); Job.EnvCharacteristic[j] = EnvMode.LegacyJitX86.UnfreezeCopy(); // id will not flow False(j.HasValue(CharacteristicObject.IdCharacteristic)); False(j.Env.HasValue(CharacteristicObject.IdCharacteristic)); var c = new CharacteristicSet(EnvMode.LegacyJitX64, RunMode.Long); // id will not flow, new CharacteristicSet False(c.HasValue(CharacteristicObject.IdCharacteristic)); Job.EnvCharacteristic[c] = EnvMode.LegacyJitX86.UnfreezeCopy(); // id will not flow False(c.HasValue(CharacteristicObject.IdCharacteristic)); CharacteristicObject.IdCharacteristic[c] = "MyId"; // id set explicitly Equal(c.Id, "MyId"); j = new Job("MyId", EnvMode.LegacyJitX64, RunMode.Long); // id set explicitly Equal(j.Id, "MyId"); Equal(j.Env.Id, "MyId"); Job.EnvCharacteristic[j] = EnvMode.LegacyJitX86.UnfreezeCopy(); // id will not flow Equal(j.Id, "MyId"); Equal(j.Env.Id, "MyId"); j = j.With(Jit.RyuJit); // id will not flow False(j.HasValue(CharacteristicObject.IdCharacteristic)); }
public void CharacteristicSetCtor_WithAllValidCharacteristics_CreatesValidCharacteristicSet() { // Arrange uint expectedValue = 2; // Act CharacteristicSet testSet = new CharacteristicSet(new List <Characteristic>() { new Characteristic(CharacteristicEnum.BRAWN, 2, null), new Characteristic(CharacteristicEnum.AGILITY, 2, null), new Characteristic(CharacteristicEnum.CUNNING, 2, null), new Characteristic(CharacteristicEnum.PRESENCE, 2, null), new Characteristic(CharacteristicEnum.WILLPOWER, 2, null), new Characteristic(CharacteristicEnum.INTELLECT, 2, null) }); // Assert foreach (Characteristic chara in testSet._characteristicList) { if (chara._associatedEnum != CharacteristicEnum.BRAWN) { Assert.AreEqual(expectedValue, chara._value, chara._associatedEnum.ToString() + " haven't got the correct value (expected: " + expectedValue + ", assigned: " + chara._value + ")"); } Assert.IsTrue(testSet._characteristicList.Count == 6, "The testSet has the wrong number of elements (Expected: 6, Added: " + testSet._characteristicList.Count + ")"); } }
public static void Test05ApplyCharacteristicSet() { var set1 = new CharacteristicSet(); var set2 = new CharacteristicSet(); set1 .Apply( new EnvMode { Platform = Platform.X64 }) .Apply( new Job { Run = { LaunchCount = 2 }, Env = { Platform = Platform.X86 } }); AssertProperties(set1, "LaunchCount=2, Platform=X86"); Equal(Job.EnvCharacteristic[set1].Platform, Platform.X86); Equal(set1.HasValue(Job.EnvCharacteristic), true); Equal(EnvMode.PlatformCharacteristic[set1], Platform.X86); set2.Apply(EnvMode.RyuJitX64).Apply(new GcMode { Concurrent = true }); Equal(Job.RunCharacteristic[set2], null); Equal(set2.HasValue(Job.RunCharacteristic), false); AssertProperties(set2, "Concurrent=True, Jit=RyuJit, Platform=X64"); var temp = set1.UnfreezeCopy(); set1.Apply(set2); set2.Apply(temp); AssertProperties(set1, "Concurrent=True, Jit=RyuJit, LaunchCount=2, Platform=X64"); AssertProperties(set2, "Concurrent=True, Jit=RyuJit, LaunchCount=2, Platform=X86"); var j = new Job(); AssertProperties(j, "Default"); j.Env.Gc.Apply(set1); AssertProperties(j, "Concurrent=True"); j.Run.Apply(set1); AssertProperties(j, "Concurrent=True, LaunchCount=2"); j.Env.Apply(set1); AssertProperties(j, "Jit=RyuJit, Platform=X64, Concurrent=True, LaunchCount=2"); j.Apply(set1); AssertProperties(j, "Jit=RyuJit, Platform=X64, Concurrent=True, LaunchCount=2"); }
public static InfrastructureMode Parse(CharacteristicSet set) { var mode = new InfrastructureMode(); mode.Toolchain = mode.Toolchain.Mutate(set); mode.Clock = mode.Clock.Mutate(set); mode.Engine = mode.Engine.Mutate(set); return(mode); }
// -------------------------------------------------------------------------------------------------------------------------------- // Helper Methods // -------------------------------------------------------------------------------------------------------------------------------- private int SumValues(CharacteristicSet testSet) { int sumValues = 0; foreach (Characteristic chara in testSet._characteristicList) { sumValues += (int)chara._value; } return(sumValues); }
public static GcMode Parse(CharacteristicSet set) { var mode = new GcMode(); mode.Server = mode.Server.Mutate(set); mode.Concurrent = mode.Concurrent.Mutate(set); mode.CpuGroups = mode.CpuGroups.Mutate(set); mode.Force = mode.Force.Mutate(set); mode.AllowVeryLargeObjects = mode.AllowVeryLargeObjects.Mutate(set); return(mode); }
public static EnvMode Parse(CharacteristicSet set) { var mode = new EnvMode(); mode.Platform = mode.Platform.Mutate(set); mode.Jit = mode.Jit.Mutate(set); mode.Runtime = mode.Runtime.Mutate(set); mode.Affinity = mode.Affinity.Mutate(set); mode.Gc = GcMode.Parse(set); return(mode); }
public static RunMode Parse(CharacteristicSet set) { var mode = new RunMode(); mode.RunStrategy = mode.RunStrategy.Mutate(set); mode.LaunchCount = mode.LaunchCount.Mutate(set); mode.WarmupCount = mode.WarmupCount.Mutate(set); mode.TargetCount = mode.TargetCount.Mutate(set); mode.IterationTime = mode.IterationTime.Mutate(set); mode.InvocationCount = mode.InvocationCount.Mutate(set); return(mode); }
public static AccuracyMode Parse(CharacteristicSet set) { var mode = new AccuracyMode(); mode.MaxStdErrRelative = mode.MaxStdErrRelative.Mutate(set); mode.MinIterationTime = mode.MinIterationTime.Mutate(set); mode.MinInvokeCount = mode.MinInvokeCount.Mutate(set); mode.EvaluateOverhead = mode.EvaluateOverhead.Mutate(set); mode.RemoveOutliers = mode.RemoveOutliers.Mutate(set); mode.AnaylyzeLaunchVariance = mode.AnaylyzeLaunchVariance.Mutate(set); return(mode); }
public static Job Parse(CharacteristicSet set, bool clearId = true) { var job = new Job(); if (!clearId) { job.Id = job.Id.Mutate(set); } job.Env = EnvMode.Parse(set); job.Run = RunMode.Parse(set); job.Infrastructure = InfrastructureMode.Parse(set); job.Accuracy = AccuracyMode.Parse(set); return(job); }
public void CharacteristicSetCtor_WithNull_CreatesCharacteristicSetWithAll1() { // Arrange uint expectedValue = 1; // Act CharacteristicSet testSet = new CharacteristicSet(); // Assert foreach (Characteristic chara in testSet._characteristicList) { Assert.AreEqual(expectedValue, chara._value, chara._associatedEnum.ToString() + " haven't got the correct value (expected: " + expectedValue + ", assigned: " + chara._value + ")"); } }
public void RandomCharacteristicSet_WithValue6_CreatesValidCharacteristicSet() { // Arrange int testValue = 6; int minValue = 6; int maxValue = 6; for (int i = 0; i < TEST_COUNT; ++i) { // Act CharacteristicSet testSet = CharacteristicFactory.RandomCharacteristicSet(testValue); // Assert Assert.IsTrue(SumValues(testSet) >= minValue && SumValues(testSet) <= maxValue, "An invalid sum of characteristics was created (" + SumValues(testSet) + ")"); } }
public void CharacteristicSetCtor_WithInvalidCharacteristics_CreatesValidCharacteristicSet() { // Arrange uint expectedAutoValue = 1; // Act CharacteristicSet testSet = new CharacteristicSet(new List <Characteristic>() { new Characteristic(CharacteristicEnum.BRAWN, 0, null), new Characteristic(CharacteristicEnum.CUNNING, 6, null) }); // Assert foreach (Characteristic chara in testSet._characteristicList) { Assert.AreEqual(expectedAutoValue, chara._value, chara._associatedEnum.ToString() + " haven't got the correct value (expected: " + expectedAutoValue + ", assigned: " + chara._value + ")"); } }
public void TrainCharacteristic_WithMaxedCharacteristic_DoesNotIncreasesTheCharacteristic() { // Arrange CharacteristicSet testSet = new CharacteristicSet(new List <Characteristic>() { new Characteristic(CharacteristicEnum.BRAWN, 5, null), new Characteristic(CharacteristicEnum.AGILITY, 2, null), new Characteristic(CharacteristicEnum.CUNNING, 2, null), new Characteristic(CharacteristicEnum.PRESENCE, 2, null), new Characteristic(CharacteristicEnum.WILLPOWER, 2, null), new Characteristic(CharacteristicEnum.INTELLECT, 2, null) }); uint expectedValue = 5; // Act testSet.TrainCharacteristic(CharacteristicEnum.BRAWN); // Assert Assert.AreEqual(expectedValue, testSet.Get(CharacteristicEnum.BRAWN)._value, "BRAWN is not the expected Value after training"); }
public static void Test06CharacteristicHacks() { var j = new Job(); Equal(j.Run.TargetCount, 0); RunMode.TargetCountCharacteristic[j] = 123; Equal(j.Run.TargetCount, 123); var old = j.Run; Job.RunCharacteristic[j] = new RunMode(); Equal(j.Run.TargetCount, 0); Job.RunCharacteristic[j] = old; old.TargetCount = 234; Equal(j.Run.TargetCount, 234); Equal(RunMode.TargetCountCharacteristic[j], 234); Characteristic a = Job.RunCharacteristic; // will not throw: a[j] = new RunMode(); Throws <ArgumentNullException>(() => a[j] = null); // nulls for job nodes are not allowed; Throws <ArgumentNullException>(() => a[j] = Characteristic.EmptyValue); Throws <ArgumentException>(() => a[j] = new EnvMode()); // not assignable; Throws <ArgumentException>(() => a[j] = new CharacteristicSet()); // not assignable; Throws <ArgumentException>(() => a[j] = 123); // not assignable; a = InfrastructureMode.ToolchainCharacteristic; // will not throw: a[j] = CsProjClassicNetToolchain.Net46; a[j] = null; a[j] = Characteristic.EmptyValue; Throws <ArgumentException>(() => a[j] = new EnvMode()); // not assignable; Throws <ArgumentException>(() => a[j] = new CharacteristicSet()); // not assignable; Throws <ArgumentException>(() => a[j] = 123); // not assignable; }
public static void Test06CharacteristicHacks() { var j = new Job(); Assert.Equal(0, j.Run.IterationCount); RunMode.IterationCountCharacteristic[j] = 123; Assert.Equal(123, j.Run.IterationCount); var old = j.Run; Job.RunCharacteristic[j] = new RunMode(); Assert.Equal(0, j.Run.IterationCount); Job.RunCharacteristic[j] = old; old.IterationCount = 234; Assert.Equal(234, j.Run.IterationCount); Assert.Equal(234, RunMode.IterationCountCharacteristic[j]); Characteristic a = Job.RunCharacteristic; // will not throw: a[j] = new RunMode(); Assert.Throws <ArgumentNullException>(() => a[j] = null); // nulls for job nodes are not allowed; Assert.Throws <ArgumentNullException>(() => a[j] = Characteristic.EmptyValue); Assert.Throws <ArgumentException>(() => a[j] = new EnvironmentMode()); // not assignable; Assert.Throws <ArgumentException>(() => a[j] = new CharacteristicSet()); // not assignable; Assert.Throws <ArgumentException>(() => a[j] = 123); // not assignable; a = InfrastructureMode.ToolchainCharacteristic; // will not throw: a[j] = CsProjClassicNetToolchain.Net46; a[j] = null; a[j] = Characteristic.EmptyValue; Assert.Throws <ArgumentException>(() => a[j] = new EnvironmentMode()); // not assignable; Assert.Throws <ArgumentException>(() => a[j] = new CharacteristicSet()); // not assignable; Assert.Throws <ArgumentException>(() => a[j] = 123); // not assignable; }
// -------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Creates a copy of the given character /// </summary> /// <param name="other">if null, a default character is created</param> public PAPICharacter(PAPICharacter other) : this() { if (other == null) { return; } _archetype = other._archetype; _species = new Species(other._species); _soak = new Value(other._soak); _health = new ThresholdValue(other._health); _defense = new Defense(other._defense); _characteristics = new CharacteristicSet(other._characteristics); _equipment = new Equipment(other._equipment); _inventory = new Inventory(other._inventory); _skillSet = new List <PAPISkill>(other._skillSet); _abilities = new List <Ability>(other._abilities); _career = new Career(other._career); _appearance = new CharacterAppearance(other._appearance); _gender = other._gender; _genderPreferences = new List <GenderEnum>(other._genderPreferences); WfLogger.Log(this, LogLevel.DETAILED, "Created new Character from another"); }
public UniqueRival(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences, int _relationshipToParty, List <CriticalInjury> _criticalInjuries, string _name, MotivationSet _motivationSet) : base(_archetype, _species, _soak, _health, _defense, _characteristics, _equipment, _inventory, _skillSet, _abilities, _career, _appearance, _gender, _genderPreferences, _relationshipToParty, _criticalInjuries) { this._name = (_name == null || _name == "") ? "NOT_VALID" : _name; this._motivationSet = (_motivationSet == null) ? new MotivationSet() : _motivationSet; WfLogger.Log(this, LogLevel.DETAILED, "Created new Unique Rival: " + this._name); }
public PlayerCharacter(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences, string _name, MotivationSet _motivationSet, List <CriticalInjury> _criticalInjuries, ThresholdValue _strain, List <SkillEnum> _careerSkills) : base(_archetype, _species, _soak, _health, _defense, _characteristics, _equipment, _inventory, _skillSet, _abilities, _career, _appearance, _gender, _genderPreferences) { this._name = (_name == null || _name == "") ? "NOT_VALID" : _name; this._motivationSet = (_motivationSet == null) ? new MotivationSet() : _motivationSet; this._criticalInjuries = (_criticalInjuries == null) ? new List <CriticalInjury>() : _criticalInjuries; this._strain = (_strain == null) ? SpeciesHandler.GetInitialStrain(this._species._enum) : _strain; this._careerSkills = (_careerSkills == null) ? new List <SkillEnum>() : _careerSkills; WfLogger.Log(this, LogLevel.DETAILED, "Created new PlayerCharacter " + this._name); }
public MinionGroup(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences, int _relationshipToParty, uint _groupSize) : base(_archetype, _species, _soak, _health, _defense, _characteristics, _equipment, _inventory, _skillSet, _abilities, _career, _appearance, _gender, _genderPreferences, _relationshipToParty) { this._groupSize = _groupSize; WfLogger.Log(this, LogLevel.DETAILED, "Created new Minion Group"); }
public Nemesis(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences, int _relationshipToParty, List <CriticalInjury> _criticalInjuries, string _name, MotivationSet _motivationSet, ThresholdValue _strain) : base(_archetype, _species, _soak, _health, _defense, _characteristics, _equipment, _inventory, _skillSet, _abilities, _career, _appearance, _gender, _genderPreferences, _relationshipToParty, _criticalInjuries, _name, _motivationSet) { this._strain = (_strain == null || _strain._threshold == 0) ? new ThresholdValue(SpeciesHandler.GetInitialStrain(this._species._enum)) : _strain; WfLogger.Log(this, LogLevel.DETAILED, "Created new Nemesis " + this._name); }
public JobMutator Add(CharacteristicSet set) { characteristicSet.Mutate(set); return(this); }
public NonPlayerCharacter(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences, int _relationshipToParty) : base(_archetype, _species, _soak, _health, _defense, _characteristics, _equipment, _inventory, _skillSet, _abilities, _career, _appearance, _gender, _genderPreferences) { _relationshipToParty = (_relationshipToParty < -100) ? -100 : _relationshipToParty; this._relationshipToParty = (_relationshipToParty > 100) ? 100 : _relationshipToParty; WfLogger.Log(this, LogLevel.DETAILED, "Created new NPC (Relationship to Party = " + this._relationshipToParty + ")"); }
public Rival(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences, int _relationshipToParty, List <CriticalInjury> _criticalInjuries) : base(_archetype, _species, _soak, _health, _defense, _characteristics, _equipment, _inventory, _skillSet, _abilities, _career, _appearance, _gender, _genderPreferences, _relationshipToParty) { this._criticalInjuries = (_criticalInjuries == null) ? new List <CriticalInjury>() : _criticalInjuries; WfLogger.Log(this, LogLevel.DETAILED, "Created new Rival"); }
public static void Test06CharacteristicHacks() { var j = new Job(); Equal(j.Run.TargetCount, 0); RunMode.TargetCountCharacteristic[j] = 123; Equal(j.Run.TargetCount, 123); var old = j.Run; Job.RunCharacteristic[j] = new RunMode(); Equal(j.Run.TargetCount, 0); Job.RunCharacteristic[j] = old; old.TargetCount = 234; Equal(j.Run.TargetCount, 234); Equal(RunMode.TargetCountCharacteristic[j], 234); Characteristic a = Job.RunCharacteristic; // will not throw: a[j] = new RunMode(); Throws<ArgumentNullException>(() => a[j] = null); // nulls for job nodes are not allowed; Throws<ArgumentNullException>(() => a[j] = Characteristic.EmptyValue); Throws<ArgumentException>(() => a[j] = new EnvMode()); // not assignable; Throws<ArgumentException>(() => a[j] = new CharacteristicSet()); // not assignable; Throws<ArgumentException>(() => a[j] = 123); // not assignable; a = InfrastructureMode.ToolchainCharacteristic; // will not throw: a[j] = ClassicToolchain.Instance; a[j] = null; a[j] = Characteristic.EmptyValue; Throws<ArgumentException>(() => a[j] = new EnvMode()); // not assignable; Throws<ArgumentException>(() => a[j] = new CharacteristicSet()); // not assignable; Throws<ArgumentException>(() => a[j] = 123); // not assignable; }
public static void Test03IdDoesNotFlow() { var j = new Job(EnvMode.LegacyJitX64, RunMode.Long); // id will not flow, new Job False(j.HasValue(JobMode.IdCharacteristic)); False(j.Env.HasValue(JobMode.IdCharacteristic)); Job.EnvCharacteristic[j] = EnvMode.LegacyJitX86.UnfreezeCopy(); // id will not flow False(j.HasValue(JobMode.IdCharacteristic)); False(j.Env.HasValue(JobMode.IdCharacteristic)); var c = new CharacteristicSet(EnvMode.LegacyJitX64, RunMode.Long); // id will not flow, new CharacteristicSet False(c.HasValue(JobMode.IdCharacteristic)); Job.EnvCharacteristic[c] = EnvMode.LegacyJitX86.UnfreezeCopy(); // id will not flow False(c.HasValue(JobMode.IdCharacteristic)); JobMode.IdCharacteristic[c] = "MyId"; // id set explicitly Equal(c.Id, "MyId"); j = new Job("MyId", EnvMode.LegacyJitX64, RunMode.Long); // id set explicitly Equal(j.Id, "MyId"); Equal(j.Env.Id, "MyId"); Job.EnvCharacteristic[j] = EnvMode.LegacyJitX86.UnfreezeCopy(); // id will not flow Equal(j.Id, "MyId"); Equal(j.Env.Id, "MyId"); j = j.With(Jit.RyuJit); // id will not flow False(j.HasValue(JobMode.IdCharacteristic)); }
public PAPICharacter(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics, Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance, GenderEnum _gender, List <GenderEnum> _genderPreferences) { this._archetype = (_archetype == null || _archetype == "") ? "Townspeople" : _archetype; this._species = (_species == null) ? SpeciesHandler.GetSpecies(SpeciesEnum.HUMAN) : _species; this._soak = (_soak == null) ? new Value(0, null) : _soak; this._characteristics = (_characteristics == null) ? new CharacteristicSet() : _characteristics; this._health = (_health == null) ? new ThresholdValue(SpeciesHandler.GetInitialHealth(this._species._enum)) : _health; this._defense = (_defense == null) ? new Defense(0, null, 0, null) : _defense; this._equipment = (_equipment == null) ? new Equipment(null, null, null, null) : _equipment; this._inventory = (_inventory == null) ? new Inventory(null, null) : _inventory; this._skillSet = (_skillSet == null) ? new List <PAPISkill>() : _skillSet; this._abilities = (_abilities == null) ? new List <Ability>() : _abilities; this._career = _career; this._appearance = (_appearance == null) ? new CharacterAppearance(SpeciesHandler.GetAverageAppearance(this._species._enum)) : _appearance; this._gender = _gender; this._genderPreferences = (_genderPreferences == null || _genderPreferences.Count == 0) ? new List <GenderEnum>() { GenderEnum.NONE } : _genderPreferences; WfLogger.Log(this, LogLevel.DETAILED, "Created new Character (" + this._species._enum + " " + this._archetype + ")"); }