public static string ToCustomString(this EthicsScale me) { switch (me) { case EthicsScale.Murder: return("would not hesitate to [Murder]"); case EthicsScale.Beat: return("would not hesitate to [Beat]"); case EthicsScale.Exploit: return("would not hesitate to [Exploit]"); case EthicsScale.Coexist: return("would reasonably [Coexist] with"); case EthicsScale.Cooperate: return("would reliably [Cooperate] with"); case EthicsScale.Befriend: return("would be a loyal [Friend] to"); case EthicsScale.Confide: default: return("would be a trusted [Confidant] for"); } }
protected Relationship MirrorTrustFromOther(Character self, Character other, Random rng) { EthicsScale initialTrust; var otherTrust = other.GetTrustTowards(self); bool coinflip = rng.Next(0, 2) == 0; if (self.BaseSuspicion < other.BaseSuspicion) { initialTrust = coinflip ? otherTrust.HigherLevel() : otherTrust; } else if (self.BaseSuspicion > other.BaseSuspicion) { initialTrust = coinflip ? otherTrust.LowerLevel() : otherTrust; } else { initialTrust = otherTrust; } EthicsScale intialEthics = GetProbableEthics(self.BaseMorality, initialTrust, rng); var r = new Relationship(self.Id, other.Id, initialTrust, intialEthics); return(r); }
public const int SCALE_FOR_GAPS_BETWEEN_TRUST_LEVELS = 100;//Dictates how many events it takes to change trust levels public Relationship(int givenSelfId, int givenOtherId, EthicsScale initialTrust, EthicsScale initialEthics) { this.selfId = givenSelfId; this.otherId = givenOtherId; this.trust = initialTrust; this.ethics = initialEthics; }
protected Relationship NewRandomTrustRelation(Character self, Character other, Random rng) { EthicsScale initialTrust; if (rng == null) { rng = new Random(); } var diceRoll = rng.Next(16); switch (diceRoll) { case 0: initialTrust = EthicsScale.Confide; break; case 1: case 2: initialTrust = EthicsScale.Befriend; break; case 3: case 4: case 5: initialTrust = EthicsScale.Cooperate; break; case 6: case 7: case 8: case 9: initialTrust = EthicsScale.Coexist; break; case 10: case 11: case 12: initialTrust = EthicsScale.Exploit; break; case 13: case 14: initialTrust = EthicsScale.Beat; break; default: initialTrust = EthicsScale.Murder; break; } EthicsScale intialEthics = GetProbableEthics(self.BaseMorality, initialTrust, rng); var r = new Relationship(self.Id, other.Id, initialTrust, intialEthics); return(r); }
public void TestInitialize() { EthicsScale givenMin = EthicsScale.Coexist; Role theRole = new Role("r"); minMutualTrust = new Mocks.Mock_Prereq_MutualTrust_Min(givenMin, theRole); Assert.AreEqual(minMutualTrust.BenchmarkTrust, givenMin); Assert.IsNotNull(minMutualTrust.Role); }
public void TestInitialize() { EthicsScale givenMax = EthicsScale.Exploit; Role role1 = new Role("r1"); Role role2 = new Role("r2"); maxEthics = new Mocks.Mock_Prereq_DirectionalEthics_Max(givenMax, role1, role2); Assert.AreEqual(maxEthics.BenchmarkEthics_AtoB, givenMax); Assert.IsNotNull(maxEthics.RoleAlpha); Assert.IsNotNull(maxEthics.RoleBeta); }
public List <string> LoadNames_OfGivenTrust(SocietySnapshot society, EthicsScale givenTrust) { var theRelations = MyBase.AllRelations.Where(r => r.Trust == givenTrust); var theNames = new List <string>(); foreach (Relationship r in theRelations) { theNames.Add(society.AllCharacters.First(c => c.Id == r.OtherId).Name); } return(theNames); }
protected EthicsScale GetProbableEthics(Morality theMorality, EthicsScale theTrust, Random rng) { EthicsScale theEthics; bool coinflip = rng.Next(0, 2) == 0; if (theMorality == Morality.Forgive) { theEthics = coinflip ? theTrust.HigherLevel() : theTrust; } else if (theMorality == Morality.Exploit) { theEthics = coinflip ? theTrust.LowerLevel() : theTrust; } else //Reciprocate { theEthics = theTrust; } return(theEthics); }
protected string DescribeDurability(EthicsScale trustOrEthics, int durability) { if (durability == 0) { return(string.Empty); } int?threshold = durability > 0 ? GapToNextLevel(trustOrEthics, true) : GapToNextLevel(trustOrEthics, false); if (threshold == null) { return(string.Empty); } var percentDurability = System.Math.Abs((100 * durability) / threshold.Value); var nextLevel = durability > 0 ? trustOrEthics.HigherLevel() : trustOrEthics.LowerLevel(); var summary = string.Format("{0}% of the way to [{1}]", percentDurability, nextLevel.ToString()); return(summary); }
//#TODO - change private methods to be protected, and add Mock class to be unit tested private void UpdateLevelFromDurability(ref EthicsScale level, ref int durability) { bool movingUpwards = durability > 0; int? threshold = GapToNextLevel(level, movingUpwards); if (threshold == null) //already at max/min level { return; } if (movingUpwards && durability >= threshold) { level = level.HigherLevel(); durability -= threshold.Value; UpdateLevelFromDurability(ref level, ref durability); } else if (!movingUpwards && durability <= threshold) { level = level.LowerLevel(); durability -= threshold.Value; UpdateLevelFromDurability(ref level, ref durability); } }
public static EthicsScale LowerLevel(this EthicsScale me) { EthicsScale lower; switch (me) { case EthicsScale.Murder: lower = me; break; case EthicsScale.Beat: lower = EthicsScale.Murder; break; case EthicsScale.Exploit: lower = EthicsScale.Beat; break; case EthicsScale.Coexist: lower = EthicsScale.Exploit; break; case EthicsScale.Cooperate: lower = EthicsScale.Coexist; break; case EthicsScale.Befriend: lower = EthicsScale.Cooperate; break; default: lower = EthicsScale.Befriend; break; } return(lower); }
public static EthicsScale HigherLevel(this EthicsScale me) { EthicsScale higher; switch (me) { case EthicsScale.Murder: higher = EthicsScale.Beat; break; case EthicsScale.Beat: higher = EthicsScale.Exploit; break; case EthicsScale.Exploit: higher = EthicsScale.Coexist; break; case EthicsScale.Coexist: higher = EthicsScale.Cooperate; break; case EthicsScale.Cooperate: higher = EthicsScale.Befriend; break; case EthicsScale.Befriend: higher = EthicsScale.Confide; break; default: higher = me; break; } return(higher); }
private int?GapToNextLevel(EthicsScale currentLevel, bool movingUpwards) { int next = 0; if (movingUpwards) { next = (int)currentLevel.HigherLevel(); } else { next = (int)currentLevel.LowerLevel(); } int current = (int)currentLevel; if (next == current) //already at max/min level { return(null); } int gap = (next - current) * SCALE_FOR_GAPS_BETWEEN_TRUST_LEVELS; return(gap); }
public Mock_Prereq_MutualTrust_Min(EthicsScale benchmark, Role whichRole) : base(benchmark, whichRole) { }
public DirectionalEthics(EthicsScale ethics_AtoB, Role roleA, Role roleB) : base(roleA, roleB) { benchmarkEthics_AtoB = ethics_AtoB; }
protected override bool PassesBenchmark(EthicsScale value) { return(value <= this.benchmarkTrust_AtoB); }
/// <param name="maximum_AtoB">Inclusive maximum trust value</param> public DirectionalTrust_Max(EthicsScale maximum_AtoB, Role roleA, Role roleB) : base(maximum_AtoB, roleA, roleB) { }
/// <param name="minimum_AtoB">Inclusive minimum trust value</param> public DirectionalTrust_Min(EthicsScale minimum_AtoB, Role roleA, Role roleB) : base(minimum_AtoB, roleA, roleB) { }
protected abstract bool PassesBenchmark(EthicsScale theValue);
/// <param name="maximum">Inclusive maximum ethics value</param> public MutualEthics_Max(EthicsScale maximum, Role whichRole) : base(maximum, whichRole) { }
public MutualEthics(EthicsScale benchmark, Role whichRole) : base(whichRole) { benchmarkEthics = benchmark; }
/// <param name="minimum">Inclusive minimum ethics value</param> public MutualEthics_Min(EthicsScale minimum, Role whichRole) : base(minimum, whichRole) { }
public MutualTrust(EthicsScale benchmark, Role whichRole) : base(whichRole) { benchmarkTrust = benchmark; }
public Mock_Prereq_DirectionalEthics_Max(EthicsScale maximum_AtoB, Role roleA, Role roleB) : base(maximum_AtoB, roleA, roleB) { }
public DirectionalTrust(EthicsScale trust_AtoB, Role roleA, Role roleB) : base(roleA, roleB) { benchmarkTrust_AtoB = trust_AtoB; }
public bool PublicPassesBenchmark(EthicsScale value) { return(this.PassesBenchmark(value)); }
protected override bool PassesBenchmark(EthicsScale value) { return(value >= this.benchmarkEthics); }