Exemple #1
0
        public void property_update_succeeds()
        {
            var sut = new Royalty
            {
                Id            = 3425,
                TitleId       = 1789,
                RoyaltyAmount = 12,
                LowRange      = 5,
                HighRange     = 15,
                TitleCode     = "ABC123456",
                Title         = new Title {
                    Id = 1789, TitleCode = "ABC123456"
                }
            };

            using (new AssertionScope())
            {
                sut.Id.Should().Be(3425);
                sut.TitleId.Should().Be(1789);
                sut.RoyaltyAmount.Should().Be(12);
                sut.LowRange.Should().Be(5);
                sut.HighRange.Should().Be(15);
                sut.TitleCode.Should().Be("ABC123456");
                sut.Title.Should().NotBeNull();
                sut.Title.Id.Should().Be(1789);
            }
        }
Exemple #2
0
 public static void TriggerMassChangeLoyalty(Royalty newLord, Royalty previousLord)
 {
     if (onMassChangeLoyalty != null)
     {
         onMassChangeLoyalty(newLord, previousLord);
     }
 }
        public static void Example()
        {
            Console.WriteLine("**** 查询royalty 对象 ****");
            var listParams = new Dictionary <string, object> {
                { "payer_app", "app_LibTW1n1SOq9Pin1" },
                { "source_app", "app_LibTW1n1SOq9Pin1" },
                { "status", "created" },    //分润状态
                { "page", 1 },
                { "per_page", 1 }
            };

            Console.WriteLine(Royalty.List(listParams));


            Console.WriteLine("**** 查询royalty 列表 ****");
            Console.WriteLine(Royalty.Retrieve("421170321093600003"));
            Console.WriteLine();

            Console.WriteLine("**** 批量更新 royalty  ****");
            var updateParam = new Dictionary <string, object> {
                { "ids", new List <string> {
                      "170301124238000111",
                      "170301124238000211"
                  } },
                { "method", "manual" },
                { "description", "Your description" }
            };

            Console.WriteLine(Royalty.Update(updateParam));
            Console.WriteLine();
        }
Exemple #4
0
 public MarriedCouple(Royalty husband, Royalty wife)
 {
     this.husband              = husband;
     this.wife                 = wife;
     this.chanceForPregnancy   = 0.5f;
     this.weeksDueForPregnancy = 36;
     pregnancyActions         += WaitForBirth;
 }
Exemple #5
0
    internal bool IsRoyaltyCloseRelative(Royalty otherRoyalty)
    {
        if (otherRoyalty.id == this.father.id || otherRoyalty.id == this.mother.id)
        {
            //royalty is father or mother
            return(true);
        }

        if (this.father.father != null && this.father.mother != null && this.mother.father != null && this.mother.mother != null)
        {
            if (otherRoyalty.id == this.father.father.id || otherRoyalty.id == this.father.mother.id ||
                otherRoyalty.id == this.mother.father.id || otherRoyalty.id == this.mother.mother.id)
            {
                //royalty is grand parent
                return(true);
            }
        }

        for (int i = 0; i < this.father.children.Count; i++)
        {
            if (otherRoyalty.id == this.father.children[i].id)
            {
                //royalty is sibling
                return(true);
            }
        }

        if (this.father.father != null)
        {
            for (int i = 0; i < this.father.father.children.Count; i++)
            {
                if (otherRoyalty.id == this.father.father.children [i].id)
                {
                    //royalty is uncle or aunt from fathers side
                    return(true);
                }
            }
        }

        if (this.mother.father != null)
        {
            for (int i = 0; i < this.mother.father.children.Count; i++)
            {
                if (otherRoyalty.id == this.mother.father.children [i].id)
                {
                    //royalty is uncle or aunt from mothers side
                    return(true);
                }
            }
        }

        return(false);
    }
    internal Royalty CreateSpouse(Royalty otherSpouse)
    {
        GENDER gender = GENDER.FEMALE;

        if (otherSpouse.gender == GENDER.FEMALE)
        {
            gender = GENDER.MALE;
        }
        Royalty spouse = new Royalty(otherSpouse.kingdom, UnityEngine.Random.Range(16, (otherSpouse.age + 1)), gender, otherSpouse.generation);

        Marry(otherSpouse, spouse);
        return(spouse);
    }
 internal bool SuccessionRoyaltiesHasLoyaltyTo(Royalty lord)
 {
     if (this.royaltyList.successionRoyalties.Count > 0)
     {
         for (int i = 0; i < this.royaltyList.successionRoyalties.Count; i++)
         {
             if (this.royaltyList.successionRoyalties[i].loyalLord.id == lord.id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #8
0
 internal void MassChangeLoyalty(Royalty newLoyalty, Royalty previousLoyalty)
 {
     if (previousLoyalty.id == this.loyalLord.id)
     {
         if (this.kingdom.id != newLoyalty.kingdom.id)
         {
             this.loyalLord = this.kingdom.assignedLord;
         }
         else
         {
             this.loyalLord = newLoyalty;
         }
     }
 }
Exemple #9
0
    public static void ChangeDescendantsRecursively(Royalty royalty, bool isDescendant)
    {
        royalty.isDirectDescendant = isDescendant;

        if (royalty.children.Count > 0)
        {
            for (int i = 0; i < royalty.children.Count; i++)
            {
                if (royalty.children[i] != null)
                {
                    ChangeDescendantsRecursively(royalty.children [i], isDescendant);
                }
            }
        }
    }
Exemple #10
0
 internal void ChangeLoyalty(Royalty newLoyalty)
 {
     if (newLoyalty == null)
     {
         this.loyalLord = this;
         Debug.Log(PoliticsPrototypeManager.Instance.month + "/" + PoliticsPrototypeManager.Instance.week + "/" + PoliticsPrototypeManager.Instance.year + ": " + this.name + " LOYALTY IS TO " + this.name);
     }
     else
     {
         this.loyalLord = newLoyalty;
         Debug.Log(PoliticsPrototypeManager.Instance.month + "/" + PoliticsPrototypeManager.Instance.week + "/" + PoliticsPrototypeManager.Instance.year + ": " + this.name + " LOYALTY IS TO " + newLoyalty.name);
     }
     this.previousConversionMonth = PoliticsPrototypeManager.Instance.month;
     this.previousConversionYear  = PoliticsPrototypeManager.Instance.year;
 }
Exemple #11
0
 public void RegisterRoyalty(Royalty royalty)
 {
     if (fullGenealogy.ContainsKey(royalty.generation))
     {
         List <Royalty> allRoyaltiesInGeneration = fullGenealogy [royalty.generation];
         allRoyaltiesInGeneration.Add(royalty);
     }
     else
     {
         fullGenealogy.Add(royalty.generation, new List <Royalty> ()
         {
             royalty
         });
     }
 }
Exemple #12
0
    internal void ChangeHatred()
    {
        List <Royalty> hatedRoyaltyPool = new List <Royalty> ();

        for (int i = 0; i < PoliticsPrototypeManager.Instance.kingdoms.Count; i++)
        {
            if (PoliticsPrototypeManager.Instance.kingdoms[i].kingdom.id != this.kingdom.id)
            {
                hatedRoyaltyPool.Add(PoliticsPrototypeManager.Instance.kingdoms [i].kingdom.assignedLord);
            }
        }
        if (hatedRoyaltyPool.Count > 0)
        {
            this.hatedLord = hatedRoyaltyPool [UnityEngine.Random.Range(0, hatedRoyaltyPool.Count)];
        }
    }
Exemple #13
0
 public void WaitForBirth()
 {
     if (wife.isDead)
     {
         Debug.Log("The baby died because the mother died");
         PoliticsPrototypeManager.Instance.turnEnded -= pregnancyActions;
     }
     weeksDueForPregnancy -= 1;
     if (weeksDueForPregnancy <= 0)
     {
         weeksDueForPregnancy = 36;
         Royalty baby = MarriageManager.Instance.MakeBaby(husband, wife);
         this.isPregnant = false;
         Debug.Log(PoliticsPrototypeManager.Instance.month + "/" + PoliticsPrototypeManager.Instance.week + "/" + PoliticsPrototypeManager.Instance.year + ": " + husband.name + " and " + wife.name + " had a baby, and named it :" + baby.name);
         PoliticsPrototypeManager.Instance.turnEnded -= pregnancyActions;
     }
 }
 public void SetRoyalty(Royalty royalty)
 {
     this.royalty = royalty;
     gameObject.GetComponentInChildren <UILabel>().text = royalty.name + " \n Location: " + royalty.kingdom.kingdomName;
     if (royalty.gender == GENDER.FEMALE)
     {
         gameObject.GetComponentInChildren <UI2DSprite> ().sprite2D = femaleSprite;
         gameObject.GetComponentInChildren <UI2DSprite> ().width    = 24;
         gameObject.GetComponentInChildren <UI2DSprite> ().height   = 37;
     }
     else
     {
         gameObject.GetComponentInChildren <UI2DSprite> ().sprite2D = maleSprite;
         gameObject.GetComponentInChildren <UI2DSprite> ().width    = 28;
         gameObject.GetComponentInChildren <UI2DSprite> ().height   = 28;
     }
 }
Exemple #15
0
    private void Assassinate(Royalty assassin, Royalty victim, KingdomTest targetKingdom)
    {
        victim.kingdom.royaltyList.allRoyalties.Remove(victim);
        victim.kingdom.royaltyList.successionRoyalties.Remove(victim);

        if (targetKingdom.assignedLord.id == victim.id)
        {
            if (victim.kingdom.royaltyList.successionRoyalties.Count <= 0)
            {
                victim.kingdom.AssignNewLord(null);
            }
            else
            {
                victim.kingdom.AssignNewLord(victim.kingdom.royaltyList.successionRoyalties [0]);
            }
        }

        Debug.Log(PoliticsPrototypeManager.Instance.month + "/" + PoliticsPrototypeManager.Instance.week + "/" + PoliticsPrototypeManager.Instance.year + ": " + assassin.name + " of " + assassin.kingdom.kingdomName + " ASSASSINATED " + victim.name + " of " + victim.kingdom.kingdomName);
    }
Exemple #16
0
    public Royalty(KingdomTest kingdom, int age, GENDER gender, int generation)
    {
        this.id         = GetID() + 1;
        this.name       = RandomNameGenerator.GenerateRandomName() + " " + this.id;
        this.age        = age;
        this.gender     = gender;
        this.generation = generation;
        this.kingdom    = kingdom;
        this.trait      = GetTrait();
//		this.trait = new TRAIT[]{TRAIT.VICIOUS, TRAIT.NONE};
        this.loyalLord          = null;
        this.hatedLord          = null;
        this.father             = null;
        this.mother             = null;
        this.spouse             = null;
        this.children           = new List <Royalty> ();
        this.royaltyChances     = new RoyaltyChances();
        this.birthMonth         = (MONTH)PoliticsPrototypeManager.Instance.month;
        this.birthWeek          = PoliticsPrototypeManager.Instance.week;
        this.birthYear          = PoliticsPrototypeManager.Instance.year;
        this.isIndependent      = false;
        this.isMarried          = false;
        this.isDirectDescendant = false;
        this.isDead             = false;
        this.kingdom.royaltyList.allRoyalties.Add(this);
        if (this.kingdom.assignedLord == null)
        {
            this.loyalLord = this;
        }
        else
        {
            this.loyalLord = this.kingdom.assignedLord;
        }

        PoliticsPrototypeManager.Instance.RegisterRoyalty(this);
        SetLastID(this.id);

        RoyaltyEventDelegate.onIncreaseIllnessAndAccidentChance += IncreaseIllnessAndAccidentChance;
        RoyaltyEventDelegate.onChangeIsDirectDescendant         += ChangeIsDirectDescendant;
        RoyaltyEventDelegate.onMassChangeLoyalty    += MassChangeLoyalty;
        PoliticsPrototypeManager.Instance.turnEnded += TurnActions;
    }
Exemple #17
0
        public static string WhoWon(List <WinnerModels> Royal,
                                    List <WinnerModels> ToK, List <WinnerModels> Straight,
                                    List <WinnerModels> Flush, List <WinnerModels> Pair,
                                    HighestCard highestcard, Royalty royalty)
        {
            string result;

            if (Royal.Count > 0)
            {
                Winner(ref Royal, ref royalty, ref highestcard, "Royal Flush", out result);
                return(result);
            }

            if (ToK.Count > 0)
            {
                Winner(ref ToK, ref royalty, ref highestcard, "Three of a Kind", out result);
                return(result);
            }

            if (Straight.Count > 0)
            {
                Winner(ref Straight, ref royalty, ref highestcard, "Straight", out result);
                return(result);
            }

            if (Flush.Count > 0)
            {
                Winner(ref Flush, ref royalty, ref highestcard, "Flush", out result);
                return(result);
            }

            if (Pair.Count > 0)
            {
                Winner(ref Pair, ref royalty, ref highestcard, "Pair", out result);
                return(result);
            }

            return($"Player: {highestcard.playerId} has won with the highest card {highestcard.Total}");
        }
Exemple #18
0
        private bool BloodLine(string royal, ref Royalty royalty)
        {
            string highest = royalty.HighestRoyal;

            if (royal == "A" && (highest == "K" || highest == "Q" || highest == "J" || highest == "Commoner"))
            {
                return(true);
            }
            if (royal == "K" && (highest == "Q" || highest == "J" || highest == "Commoner"))
            {
                return(true);
            }
            if (royal == "Q" && (highest == "J" || highest == "Commoner"))
            {
                return(true);
            }
            if (royal == "J" && highest == "Commoner")
            {
                return(true);
            }

            return(false);
        }
    internal void Marry(Royalty husband, Royalty wife)
    {
        Debug.Log(PoliticsPrototypeManager.Instance.month + "/" + PoliticsPrototypeManager.Instance.week + "/" + PoliticsPrototypeManager.Instance.year + ": " + husband.name + " got married to " + wife.name);
        husband.spouse        = wife;
        wife.spouse           = husband;
        husband.isMarried     = true;
        wife.isMarried        = true;
        husband.isIndependent = true;
        wife.isIndependent    = true;

        if (wife.kingdom.assignedLord.id == wife.id)
        {
            //if wife is currently queen of a kingdom, the husband will recieve the kingdom
            wife.kingdom.AssimilateKingdom(husband.kingdom);
        }

        //the wife will transfer to the court of the husband
        wife.kingdom = husband.kingdom;
//		wife.loyalLord = husband.kingdom.assignedLord;
//		husband.kingdom.royaltyList.allRoyalties.Add(wife);
//		wife.kingdom.royaltyList.allRoyalties.Remove(wife);

        husband.kingdom.marriedCouples.Add(new MarriedCouple(husband, wife));
    }
    internal Royalty MakeBaby(Royalty father, Royalty mother, int age = 0, bool isLord = false)
    {
        GENDER gender = (GENDER)(UnityEngine.Random.Range(0, System.Enum.GetNames(typeof(GENDER)).Length));

//		int age = 0;
        if (isLord)
        {
            int randomGender = UnityEngine.Random.Range(0, 100);
            if (randomGender < 20)
            {
                gender = GENDER.FEMALE;
            }
            else
            {
                gender = GENDER.MALE;
            }

//			age = UnityEngine.Random.Range (16, 36);
        }
        Royalty child = new Royalty(father.kingdom, age, gender, father.generation + 1);

        if (father.isDirectDescendant || mother.isDirectDescendant)
        {
            child.isDirectDescendant = true;
        }
        father.AddChild(child);
        mother.AddChild(child);
        child.AddParents(father, mother);
        if (child.isDirectDescendant)
        {
            child.kingdom.UpdateLordSuccession();
        }
//		father.kingdom.royaltyList.allRoyalties.Add (child);

        return(child);
    }
Exemple #21
0
        public static void Winner(ref List <WinnerModels> list, ref Royalty royalty,
                                  ref HighestCard highestCard, string type, out string result)
        {
            string winners      = "";
            string highestRoyal = royalty.HighestRoyal;

            foreach (WinnerModels player in list)
            {
                winners = $"{winners} {player.playerId}";
            }

            if (list.Count > 1 && highestRoyal == "Commoner")
            {
                result = $"It's a tie! Players: {winners} had a {type}! Player {highestCard.playerId} won with the highest hand {highestCard.Total}";
                return;
            }
            if (list.Count > 1 && highestRoyal != "Commoner")
            {
                result = $"It's a tie! Players: {winners} had a {type}! Player {royalty.playerId} won with the highest Royal {RoyalInterpreter(royalty.HighestRoyal)}";
                return;
            }

            result = $"Player: {winners} won with a {type}!";
        }
Exemple #22
0
        public void CheckList(List <Player> players)
        {
            List <WinnerModels> RoyalList    = new List <WinnerModels>();
            List <WinnerModels> ToKList      = new List <WinnerModels>();
            List <WinnerModels> StraightList = new List <WinnerModels>();
            List <WinnerModels> FlushList    = new List <WinnerModels>();
            List <WinnerModels> PairList     = new List <WinnerModels>();
            HighestCard         highestcard  = new HighestCard {
                Total = 0, playerId = -1
            };
            Royalty royalty = new Royalty {
                HighestRoyal = "Commoner", playerId = -1
            };

            foreach (Player aPlayer in players)
            {
                bool isToK      = ToK(aPlayer);
                bool isStraight = Straight(aPlayer);
                bool isFlush    = Flush(aPlayer);
                bool isPair     = Pair(aPlayer);

                int    pHighCard = HighCard(aPlayer);
                string pRoyal    = CheckRoyalty(aPlayer);

                //Append player info if it reaches one of the conditionals
                if (isToK)
                {
                    ToKList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isStraight && isFlush)
                {
                    RoyalList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isStraight)
                {
                    StraightList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isFlush)
                {
                    FlushList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isPair)
                {
                    PairList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (pHighCard > highestcard.Total)
                {
                    highestcard = new HighestCard {
                        playerId = aPlayer.Id, Total = pHighCard
                    };
                }
                if (BloodLine(pRoyal, ref royalty))
                {
                    royalty = new Royalty {
                        HighestRoyal = pRoyal, playerId = aPlayer.Id
                    };
                }

                //Display the players' hands
                Console.WriteLine("{0}: {1}{2}, {3}{4}, {5}{6}",
                                  aPlayer.Id,
                                  aPlayer.Card1.Rank, aPlayer.Card1.Suit,
                                  aPlayer.Card2.Rank, aPlayer.Card2.Suit,
                                  aPlayer.Card3.Rank, aPlayer.Card3.Suit);
            }

            //Display the winner(s)
            Console.WriteLine("\n {0} \n\nPress Enter to continue",
                              WhoWon(RoyalList, ToKList,
                                     StraightList, FlushList,
                                     PairList, highestcard,
                                     royalty));

            Console.ReadLine();
        }
    void CheckForMarriage()
    {
        List <Royalty> elligibleBachelors     = GetElligibleBachelorsForMarriage();
        List <Royalty> elligibleBachelorettes = GetElligibleBachelorettesForMarriage();

        for (int i = 0; i < elligibleBachelors.Count; i++)
        {
            Royalty currentBachelor    = elligibleBachelors[i];
            Royalty mostElligibleBride = null;
            List <BRIDE_CRITERIA> mostElligibleBridesPoints = new List <BRIDE_CRITERIA>();
            //find bride
            for (int j = 0; j < elligibleBachelorettes.Count; j++)
            {
                if (currentBachelor.IsRoyaltyCloseRelative(elligibleBachelorettes [j]))
                {
                    //currentBachelorette is a close relative, DO NOT MARRY
                    continue;
                }
                Royalty currentBachelorette = elligibleBachelorettes[j];
                if (mostElligibleBride == null)
                {
                    mostElligibleBride = currentBachelorette;

                    if (currentBachelorette.loyalLord.id == currentBachelor.loyalLord.id)
                    {
                        mostElligibleBridesPoints.Add(BRIDE_CRITERIA.IS_LOYAL_TO_SAME_LORD);
                    }

                    if (currentBachelorette.kingdom.cities.Count > currentBachelor.kingdom.cities.Count)
                    {
                        mostElligibleBridesPoints.Add(BRIDE_CRITERIA.HAS_MORE_CITIES);
                    }

                    if (currentBachelorette.kingdom.lord.id != currentBachelor.hatedLord.id)
                    {
                        mostElligibleBridesPoints.Add(BRIDE_CRITERIA.IS_NOT_FROM_HATED_KINGDOM);
                    }
                }
                else
                {
                    List <BRIDE_CRITERIA> currentBacheloretteCriteria = new List <BRIDE_CRITERIA>();
                    if (currentBachelorette.loyalLord.id == currentBachelor.loyalLord.id)
                    {
                        currentBacheloretteCriteria.Add(BRIDE_CRITERIA.IS_LOYAL_TO_SAME_LORD);
                    }

                    if (currentBachelorette.kingdom.cities.Count > currentBachelor.kingdom.cities.Count)
                    {
                        currentBacheloretteCriteria.Add(BRIDE_CRITERIA.HAS_MORE_CITIES);
                    }

                    if (currentBachelorette.kingdom.lord.id != currentBachelor.hatedLord.id)
                    {
                        currentBacheloretteCriteria.Add(BRIDE_CRITERIA.IS_NOT_FROM_HATED_KINGDOM);
                    }

                    if (currentBacheloretteCriteria.Count > mostElligibleBridesPoints.Count)
                    {
                        mostElligibleBride = currentBachelorette;
                        mostElligibleBridesPoints.Clear();
                        mostElligibleBridesPoints.AddRange(currentBacheloretteCriteria);
                    }
                }

                if (mostElligibleBridesPoints.Count >= 3)
                {
                    //best possible bride already found
                    break;
                }
            }

            if (mostElligibleBride != null)
            {
                Marry(currentBachelor, mostElligibleBride);
                elligibleBachelorettes = GetElligibleBachelorettesForMarriage();
            }
            else
            {
                Debug.Log("Could not find bride for :" + currentBachelor.name);
            }
        }
    }
 internal void AddRoyaltyToKingdom(Royalty royalty)
 {
     this.royaltyList.allRoyalties.Add(royalty);
     royalty.kingdom   = this;
     royalty.loyalLord = this.assignedLord;
 }
    internal void CreateInitialRoyalties()
    {
        this.royaltyList.allRoyalties.Clear();
        this.royaltyList.successionRoyalties.Clear();
        GENDER gender       = GENDER.MALE;
        int    randomGender = UnityEngine.Random.Range(0, 100);

        if (randomGender < 20)
        {
            gender = GENDER.FEMALE;
        }
        this.assignedLord = new Royalty(this, UnityEngine.Random.Range(16, 36), gender, 2);
        Royalty father = new Royalty(this, UnityEngine.Random.Range(60, 81), GENDER.MALE, 1);
        Royalty mother = new Royalty(this, UnityEngine.Random.Range(60, 81), GENDER.FEMALE, 1);

        this.assignedLord.isDirectDescendant = true;

        father.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), PoliticsPrototypeManager.Instance.year - father.age);
        mother.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), PoliticsPrototypeManager.Instance.year - mother.age);
        this.assignedLord.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - this.assignedLord.age));

        father.AddChild(this.assignedLord);
        mother.AddChild(this.assignedLord);
        this.assignedLord.AddParents(father, mother);
        MarriageManager.Instance.Marry(father, mother);

//		if (this.id == 1) {
//			Royalty spouse = MarriageManager.Instance.CreateSpouse (this.assignedLord);
//			spouse.AssignBirthday ((MONTH)(UnityEngine.Random.Range (1, System.Enum.GetNames (typeof(MONTH)).Length)), UnityEngine.Random.Range (1, 5), (PoliticsPrototypeManager.Instance.year - spouse.age));
//
//			Royalty lordChild = MarriageManager.Instance.MakeBaby (this.assignedLord, spouse, 16, false);
//			lordChild.AssignBirthday ((MONTH)(UnityEngine.Random.Range (1, System.Enum.GetNames (typeof(MONTH)).Length)), UnityEngine.Random.Range (1, 5), (PoliticsPrototypeManager.Instance.year - spouse.age));
//			lordChild.gender = GENDER.MALE;
//
//
//			Royalty sibling = MarriageManager.Instance.MakeBaby (father, mother, 30, false);
//			sibling.AssignBirthday ((MONTH)(UnityEngine.Random.Range (1, System.Enum.GetNames (typeof(MONTH)).Length)), UnityEngine.Random.Range (1, 5), (PoliticsPrototypeManager.Instance.year - sibling.age));
//			sibling.gender = GENDER.FEMALE;
//
//			Royalty sibling1 = MarriageManager.Instance.MakeBaby (father, mother, 30, false);
//			sibling1.AssignBirthday ((MONTH)(UnityEngine.Random.Range (1, System.Enum.GetNames (typeof(MONTH)).Length)), UnityEngine.Random.Range (1, 5), (PoliticsPrototypeManager.Instance.year - sibling.age));
//			sibling1.gender = GENDER.MALE;
//
//			Royalty spouse1 = MarriageManager.Instance.CreateSpouse (sibling1);
//			spouse1.AssignBirthday ((MONTH)(UnityEngine.Random.Range (1, System.Enum.GetNames (typeof(MONTH)).Length)), UnityEngine.Random.Range (1, 5), (PoliticsPrototypeManager.Instance.year - spouse.age));
//
//			Royalty siblingChild1 = MarriageManager.Instance.MakeBaby (sibling1, spouse1, 16, false);
//			siblingChild1.AssignBirthday ((MONTH)(UnityEngine.Random.Range (1, System.Enum.GetNames (typeof(MONTH)).Length)), UnityEngine.Random.Range (1, 5), (PoliticsPrototypeManager.Instance.year - sibling.age));
//			siblingChild1.gender = GENDER.FEMALE;
//		}

        int siblingsChance = UnityEngine.Random.Range(0, 100);

        if (siblingsChance < 50)
        {
            Royalty sibling  = MarriageManager.Instance.MakeBaby(father, mother, UnityEngine.Random.Range(0, this.assignedLord.age), false);
            Royalty sibling2 = MarriageManager.Instance.MakeBaby(father, mother, UnityEngine.Random.Range(0, this.assignedLord.age), false);

            sibling.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - sibling.age));
            sibling2.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - sibling2.age));
        }
        else if (siblingsChance >= 50 && siblingsChance < 75)
        {
            Royalty sibling = MarriageManager.Instance.MakeBaby(father, mother, UnityEngine.Random.Range(0, this.assignedLord.age), false);
            sibling.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - sibling.age));
        }

        int spouseChance = UnityEngine.Random.Range(0, 100);

        if (spouseChance < 80)
        {
            Royalty spouse = MarriageManager.Instance.CreateSpouse(this.assignedLord);
            spouse.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - spouse.age));

            int childChance = UnityEngine.Random.Range(0, 100);
            if (childChance < 50)
            {
                if (this.assignedLord.spouse.age == 16)
                {
                    //NO CHILD
                }
                else if (this.assignedLord.spouse.age == 17)
                {
                    Royalty child1 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 0, false);
                    child1.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child1.age));
                }
                else if (this.assignedLord.spouse.age == 18)
                {
                    Royalty child1 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 0, false);
                    Royalty child2 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 1, false);

                    child1.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child1.age));
                    child2.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child2.age));
                }
                else
                {
                    Royalty child1 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 0, false);
                    Royalty child2 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 1, false);
                    Royalty child3 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 2, false);

                    child1.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child1.age));
                    child2.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child2.age));
                    child3.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child3.age));
                }
            }
            else if (childChance >= 50 && childChance < 70)
            {
                if (this.assignedLord.spouse.age == 16)
                {
                    //NO CHILD
                }
                else if (this.assignedLord.spouse.age == 17)
                {
                    Royalty child1 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 0, false);
                    child1.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child1.age));
                }
                else
                {
                    Royalty child1 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 0, false);
                    Royalty child2 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 1, false);

                    child1.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child1.age));
                    child2.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child2.age));
                }
            }
            else if (childChance >= 70 && childChance < 90)
            {
                if (this.assignedLord.spouse.age == 16)
                {
                    //NO CHILD
                }
                else
                {
                    Royalty child1 = MarriageManager.Instance.MakeBaby(this.assignedLord, this.assignedLord.spouse, 0, false);
                    child1.AssignBirthday((MONTH)(UnityEngine.Random.Range(1, System.Enum.GetNames(typeof(MONTH)).Length)), UnityEngine.Random.Range(1, 5), (PoliticsPrototypeManager.Instance.year - child1.age));
                }
            }
        }
        this.royaltyList.allRoyalties = this.royaltyList.allRoyalties.Distinct().ToList();
        UpdateLordSuccession();
    }
Exemple #26
0
    internal void AttemptToMarry()
    {
        if (this.gender == GENDER.FEMALE)
        {
            Debug.Log("Cannot trigger marriage on women");
            return;
        }

        if (this.isMarried)
        {
            Debug.Log("Royalty is already married!");
            return;
        }

        if (this.age < 16)
        {
            Debug.Log("Royalties below age 16 can't be married!");
            return;
        }
        List <Royalty> elligibleBachelorettes = MarriageManager.Instance.GetElligibleBachelorettesForMarriage();

        Royalty currentBachelor    = this;
        Royalty mostElligibleBride = null;
        List <BRIDE_CRITERIA> mostElligibleBridesPoints = new List <BRIDE_CRITERIA>();

        //find bride
        for (int j = 0; j < elligibleBachelorettes.Count; j++)
        {
            Royalty currentBachelorette = elligibleBachelorettes[j];
            if (IsRoyaltyCloseRelative(currentBachelorette))
            {
                continue;
            }
            if (mostElligibleBride == null)
            {
                mostElligibleBride = currentBachelorette;

                if (currentBachelorette.kingdom.id == currentBachelor.loyalLord.kingdom.id)
                {
                    mostElligibleBridesPoints.Add(BRIDE_CRITERIA.IS_LOYAL_TO_SAME_LORD);
                }

                if (currentBachelorette.kingdom.cities.Count > currentBachelor.kingdom.cities.Count)
                {
                    mostElligibleBridesPoints.Add(BRIDE_CRITERIA.HAS_MORE_CITIES);
                }

                if (currentBachelor.hatedLord == null || currentBachelorette.kingdom.id != currentBachelor.hatedLord.kingdom.id)
                {
                    mostElligibleBridesPoints.Add(BRIDE_CRITERIA.IS_NOT_FROM_HATED_KINGDOM);
                }
            }
            else
            {
                List <BRIDE_CRITERIA> currentBacheloretteCriteria = new List <BRIDE_CRITERIA>();
                if (currentBachelorette.loyalLord.id == currentBachelor.loyalLord.id)
                {
                    currentBacheloretteCriteria.Add(BRIDE_CRITERIA.IS_LOYAL_TO_SAME_LORD);
                }

                if (currentBachelorette.kingdom.cities.Count > currentBachelor.kingdom.cities.Count)
                {
                    currentBacheloretteCriteria.Add(BRIDE_CRITERIA.HAS_MORE_CITIES);
                }

                if (currentBachelor.hatedLord == null || currentBachelorette.kingdom.lord.id != currentBachelor.hatedLord.id)
                {
                    currentBacheloretteCriteria.Add(BRIDE_CRITERIA.IS_NOT_FROM_HATED_KINGDOM);
                }

                if (currentBacheloretteCriteria.Count > mostElligibleBridesPoints.Count)
                {
                    mostElligibleBride = currentBachelorette;
                    mostElligibleBridesPoints.Clear();
                    mostElligibleBridesPoints.AddRange(currentBacheloretteCriteria);
                }
            }

            if (mostElligibleBridesPoints.Count >= 3)
            {
                //best possible bride already found
                break;
            }
        }

        if (mostElligibleBride != null)
        {
            MarriageManager.Instance.Marry(currentBachelor, mostElligibleBride);
        }
        else
        {
            Debug.Log("Could not find bride for :" + currentBachelor.name);
        }
    }
Exemple #27
0
 internal void AddParents(Royalty father, Royalty mother)
 {
     this.father = father;
     this.mother = mother;
 }
Exemple #28
0
 internal void AddChild(Royalty child)
 {
     this.children.Add(child);
 }
    public void ShowRoyaltyInfo(Royalty royalty)
    {
        lblCurrentLordInfo.text  = "";
        lblCurrentLordInfo.text += "Age: " + royalty.age.ToString() + "\t Gender: " + royalty.gender.ToString() + "\t Dead: " + royalty.isDead + "\n" +
                                   "Illness Chance: " + royalty.royaltyChances.illnessChance.ToString() + "\t Accident Chance: " + royalty.royaltyChances.accidentChance.ToString() + "\n";
        lblCurrentLordInfo.text += "Birthweek (WW/MM/YYYY): " + royalty.birthWeek.ToString() + "/" + royalty.birthMonth.ToString() + "/" + royalty.birthYear.ToString() + "\n";
        if (royalty.loyalLord != null)
        {
            lblCurrentLordInfo.text += "Loyal to: " + royalty.loyalLord.name + "\t";
        }
        if (royalty.hatedLord != null)
        {
            lblCurrentLordInfo.text += "Hates lord: " + royalty.hatedLord.name;
        }
        lblCurrentLordInfo.text += "\n Traits: ";
        for (int i = 0; i < royalty.trait.Length; i++)
        {
            lblCurrentLordInfo.text += royalty.trait[i].ToString() + ", ";
        }

        currentlySelectedRoyalty = royalty;
        HideKingdomInfo();
        List <RoyaltyListItem> objectsToDestroy = royaltyInfoWindowGO.GetComponentsInChildren <RoyaltyListItem>(true).ToList();

        for (int i = 0; i < objectsToDestroy.Count; i++)
        {
            Destroy(objectsToDestroy [i].gameObject);
        }

        GameObject currentRoyaltyGO = Instantiate(royaltyPrefab, currentRoyaltyParent) as GameObject;

        currentRoyaltyGO.transform.localPosition = Vector3.zero;
        currentRoyaltyGO.transform.localScale    = Vector3.one;
        currentRoyaltyGO.GetComponent <RoyaltyListItem>().SetRoyalty(royalty);

        if (royalty.spouse != null)
        {
            currentRoyaltyGO = Instantiate(royaltyPrefab, partnerParent) as GameObject;
            currentRoyaltyGO.transform.localPosition = Vector3.zero;
            currentRoyaltyGO.transform.localScale    = Vector3.one;
            currentRoyaltyGO.GetComponent <RoyaltyListItem> ().SetRoyalty(royalty.spouse);
        }

        if (royalty.father != null)
        {
            currentRoyaltyGO = Instantiate(royaltyPrefab, fatherParent) as GameObject;
            currentRoyaltyGO.transform.localPosition = Vector3.zero;
            currentRoyaltyGO.transform.localScale    = Vector3.one;
            currentRoyaltyGO.GetComponent <RoyaltyListItem> ().SetRoyalty(royalty.father);
        }

        if (royalty.mother != null)
        {
            currentRoyaltyGO = Instantiate(royaltyPrefab, motherParent) as GameObject;
            currentRoyaltyGO.transform.localPosition = Vector3.zero;
            currentRoyaltyGO.transform.localScale    = Vector3.one;
            currentRoyaltyGO.GetComponent <RoyaltyListItem> ().SetRoyalty(royalty.mother);
        }

        if (royalty.father != null)
        {
            for (int i = 0; i < royalty.father.children.Count; i++)
            {
                Royalty currentChild = royalty.father.children [i];
                if (currentChild.id == royalty.id)
                {
                    continue;
                }
                currentRoyaltyGO = Instantiate(royaltyPrefab, siblingsGrid.transform) as GameObject;
                currentRoyaltyGO.transform.localPosition = Vector3.zero;
                currentRoyaltyGO.transform.localScale    = Vector3.one;
                currentRoyaltyGO.GetComponent <RoyaltyListItem> ().SetRoyalty(currentChild);
            }
        }

        for (int i = 0; i < royalty.children.Count; i++)
        {
            currentRoyaltyGO = Instantiate(royaltyPrefab, childrenGrid.transform) as GameObject;
            currentRoyaltyGO.transform.localPosition = Vector3.zero;
            currentRoyaltyGO.transform.localScale    = Vector3.one;
            currentRoyaltyGO.GetComponent <RoyaltyListItem>().SetRoyalty(royalty.children[i]);
        }
        siblingsGrid.enabled = true;
        childrenGrid.enabled = true;

        if (currentlySelectedKingdom.assignedLord.id == royalty.id && royalty.trait.Contains(TRAIT.VICIOUS))
        {
            assassinationBtn.isEnabled = true;
            conversionBtn.isEnabled    = true;
        }
        else
        {
            assassinationBtn.isEnabled = false;
            conversionBtn.isEnabled    = false;
        }

//		if (royalty.gender == GENDER.MALE && !royalty.isMarried && royalty.age >= 16) {
//			marriageBtn.isEnabled = true;
//		} else {
//			marriageBtn.isEnabled = false;
//		}

        royaltyInfoWindowGO.SetActive(true);
    }
Exemple #30
0
    internal void Conversion()
    {
        KingdomTest targetKingdom = this.kingdom.relationshipKingdoms [UnityEngine.Random.Range(0, this.kingdom.relationshipKingdoms.Count)].kingdom;
        Royalty     targetRoyalty = null;
        int         targetChance  = UnityEngine.Random.Range(0, 100);

        if (targetKingdom.royaltyList.successionRoyalties.Count > 3)
        {
            if (targetChance < 20)
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [0];
            }
            else if (targetChance >= 21 && targetChance < 50)
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [1];
            }
            else if (targetChance >= 51 && targetChance < 90)
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [2];
            }
            else
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [UnityEngine.Random.Range(3, targetKingdom.royaltyList.successionRoyalties.Count)];
            }
        }
        else if (targetKingdom.royaltyList.successionRoyalties.Count > 2)
        {
            if (targetChance < 24)
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [0];
            }
            else if (targetChance >= 24 && targetChance < 57)
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [1];
            }
            else
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [2];
            }
        }
        else if (targetKingdom.royaltyList.successionRoyalties.Count > 1)
        {
            if (targetChance < 49)
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [0];
            }
            else
            {
                targetRoyalty = targetKingdom.royaltyList.successionRoyalties [1];
            }
        }
        else if (targetKingdom.royaltyList.successionRoyalties.Count > 0)
        {
            targetRoyalty = targetKingdom.royaltyList.successionRoyalties [0];
        }


        if (targetRoyalty != null)
        {
            Debug.Log("Attempting to convert " + targetRoyalty.name);
            if (!targetRoyalty.trait.Contains(TRAIT.LOYAL))
            {
                if (targetRoyalty.hatedLord == null || targetRoyalty.hatedLord.id != this.id)
                {
                    if (targetRoyalty.previousConversionMonth == 0)
                    {
                        if (targetRoyalty.trait.Contains(TRAIT.TRAITOR))
                        {
                            int conversionChance = UnityEngine.Random.Range(0, 100);
                            if (conversionChance < 80)
                            {
                                targetRoyalty.ChangeLoyalty(this);
                            }
                        }
                        else
                        {
                            int conversionChance = UnityEngine.Random.Range(0, 100);
                            if (conversionChance < 30)
                            {
                                targetRoyalty.ChangeLoyalty(this);
                            }
                        }
                    }
                    else
                    {
                        int monthDifference = PoliticsPrototypeManager.Instance.month - targetRoyalty.previousConversionMonth;
                        int yearDifference  = PoliticsPrototypeManager.Instance.year - targetRoyalty.previousConversionYear;
                        int difference      = monthDifference + (yearDifference * 12);

                        if (difference >= 3)
                        {
                            if (targetRoyalty.trait.Contains(TRAIT.TRAITOR))
                            {
                                int conversionChance = UnityEngine.Random.Range(0, 100);
                                if (conversionChance < 80)
                                {
                                    targetRoyalty.ChangeLoyalty(this);
                                }
                            }
                            else
                            {
                                int conversionChance = UnityEngine.Random.Range(0, 100);
                                if (conversionChance < 30)
                                {
                                    targetRoyalty.ChangeLoyalty(this);
                                }
                            }
                        }
                    }
                }
            }
        }
        else
        {
            Debug.LogWarning("No Conversion Target!");
        }
    }