コード例 #1
0
        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");
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        //#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);
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public Mock_Prereq_MutualTrust_Min(EthicsScale benchmark, Role whichRole) : base(benchmark, whichRole)
 {
 }
コード例 #15
0
 public DirectionalEthics(EthicsScale ethics_AtoB, Role roleA, Role roleB) : base(roleA, roleB)
 {
     benchmarkEthics_AtoB = ethics_AtoB;
 }
コード例 #16
0
 protected override bool PassesBenchmark(EthicsScale value)
 {
     return(value <= this.benchmarkTrust_AtoB);
 }
コード例 #17
0
 /// <param name="maximum_AtoB">Inclusive maximum trust value</param>
 public DirectionalTrust_Max(EthicsScale maximum_AtoB, Role roleA, Role roleB) : base(maximum_AtoB, roleA, roleB)
 {
 }
コード例 #18
0
 /// <param name="minimum_AtoB">Inclusive minimum trust value</param>
 public DirectionalTrust_Min(EthicsScale minimum_AtoB, Role roleA, Role roleB) : base(minimum_AtoB, roleA, roleB)
 {
 }
コード例 #19
0
 protected abstract bool PassesBenchmark(EthicsScale theValue);
コード例 #20
0
 /// <param name="maximum">Inclusive maximum ethics value</param>
 public MutualEthics_Max(EthicsScale maximum, Role whichRole) : base(maximum, whichRole)
 {
 }
コード例 #21
0
 public MutualEthics(EthicsScale benchmark, Role whichRole) : base(whichRole)
 {
     benchmarkEthics = benchmark;
 }
コード例 #22
0
 /// <param name="minimum">Inclusive minimum ethics value</param>
 public MutualEthics_Min(EthicsScale minimum, Role whichRole) : base(minimum, whichRole)
 {
 }
コード例 #23
0
 public MutualTrust(EthicsScale benchmark, Role whichRole) : base(whichRole)
 {
     benchmarkTrust = benchmark;
 }
コード例 #24
0
 public Mock_Prereq_DirectionalEthics_Max(EthicsScale maximum_AtoB, Role roleA, Role roleB) : base(maximum_AtoB, roleA, roleB)
 {
 }
コード例 #25
0
 public DirectionalTrust(EthicsScale trust_AtoB, Role roleA, Role roleB) : base(roleA, roleB)
 {
     benchmarkTrust_AtoB = trust_AtoB;
 }
コード例 #26
0
 public bool PublicPassesBenchmark(EthicsScale value)
 {
     return(this.PassesBenchmark(value));
 }
コード例 #27
0
 protected override bool PassesBenchmark(EthicsScale value)
 {
     return(value >= this.benchmarkEthics);
 }