public bool CanEncounter(Person person)
 {
     return (person.Age > 16
         || (person.HasFlag(IdentityFlags.OrphanFlag) && person.Age > 12))
         && !person.HasFlag(TravelFlags.SettledFlag)
         && person.Profession == null;
 }
        public bool Encounter(Person person)
        {
            person.Profession = null;
            person.Log("I got fired.");

            return true;
        }
 public bool CanEncounter(Person person)
 {
     return person.Age >= 8
            && person.HasFlag(IdentityFlags.TransgenderFlag)
            && !person.HasFlag(IdentityFlags.TransitionedFlag)
            && !person.HasFlag(IdentityFlags.TransitioningFlag);
 }
 public PersonalHistory(Person owner)
 {
     _owner = owner;
     Divorces = new List<Person>();
     Log = new List<string>();
     PastJobs = new List<Profession>();
     Schools = new List<string>();
 }
 /// <summary>
 /// Scoring an encounter takes various bits about a person and calculates a score
 /// that will be used to determine whether or not this person will do this event.
 /// (This is like a Target Number Modifier in more colloquial games like Dungeons and Dragons,
 /// or Shadowrun)
 /// This specific score provides situational-based modifiers.
 /// </summary>
 /// <param name="enactor">The enactor.</param>
 /// <returns></returns>
 public float ScoreEncounter(Person enactor)
 {
     return enactor.Personality.GetFacets()
         .Where(
             facet =>
                 enactor.Personality.GetDominantFacetType(facet) !=
                 enactor.Partner.Personality.GetDominantFacetType(facet))
         .Sum(facet => FacetInfluenceEnum.Minor.ToScore());
 }
        public Person CreatePerson(Person father, Person mother)
        {
            var child = _personBuilder.Build(father, mother);
            child.PopulationModule = this;
            child.Location = mother.Location;

            child = _personCache.Save(child);
            return child;
        }
        public bool Encounter(Person person)
        {
            var finalTerritory = _rootTerritory.GetLiveableTerritories().First(t => t != person.Location);

            person.AddFlag(TravelFlags.SettledFlag);
            finalTerritory.MovePerson(person);
            person.Log("I have settled permanently at {0}.", person.Location.Name);

            return true;
        }
        public void AddPerson(Person person)
        {
            _people.Add(person);
            ListBoxPeople.Items.Add(person);

            if (ListBoxPeople.Items.Count == 1)
            {
                ListBoxPeople.SelectedItem = person;
            }
        }
        public bool Encounter(Person person)
        {
            person.Gender = person.Gender == "Female"
                ? "Male"
                : "Female";
            person.FirstName = this._firstNameGenerator.Build(person).FirstName;
            person.Log(string.Format("Changed their name to {0} {1} and is now transistioning", person.FirstName,
                person.FamilyName));
            person.AddFlag(IdentityFlags.TransitioningFlag);

            return true;
        }
        public bool Encounter(Person person)
        {
            var month = _random.Next(3, 8);
            person.AddFlag(RomanticFlags.EngagedFlag);
            person.Partner.AddFlag(RomanticFlags.EngagedFlag);
            person.ClearFlag(RomanticFlags.DatingFlag);
            person.Partner.ClearFlag(RomanticFlags.DatingFlag);

            person.PopulationModule.SaveChanges(person.Partner);

            return true;
        }
        public float ScoreEncounter(Person enactor)
        {
            if (enactor.HasFlag(RomanticFlags.DatingFlag))
            {
                return FacetInfluenceEnum.Minor.ToScore()*-1;
            }

            if (enactor.HasFlag(RomanticFlags.EngagedFlag) || enactor.HasFlag(RomanticFlags.MarriedFlag))
            {
                return FacetInfluenceEnum.Major.ToScore()*-1;
            }

            return 0;
        }
 /// <summary>
 /// Simple gate-keeping check to determine if it is even physically possible for this event
 /// to be triggered.
 /// An example would be lighting a car on fire without a car. Without the car,
 /// you couldn't light the fire on said car.
 /// </summary>
 /// <param name="person">The person.</param>
 /// <returns>
 /// Whether or not this encounter can be encountered.
 /// </returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public bool CanEncounter(Person person)
 {
     // For purposes of this simulation, we assume if you're already in a relationship,
     // you won't be dating anyone else.
     //
     // We also assume that boys and girls are gross until about 14.
     //
     // (And that there's someone to date.)
     return person.Partner == null
            && !person.HasFlag(RomanticFlags.DatingFlag)
            && !person.HasFlag(RomanticFlags.EngagedFlag)
            && !person.HasFlag(RomanticFlags.MarriedFlag)
            && person.Age >= 14
            && person.Location.GetPeopleWhere(p => ValidPartner(person, p)).Any();
 }
        public bool Encounter(Person person)
        {
            var mate = person.Partner;
            person.Log("I had a divorce with {0}.", mate.Name);
            mate.Log("I had a divorce with {0}.", person.Name);
            person.ClearFlag(RomanticFlags.MarriedFlag);
            mate.ClearFlag(RomanticFlags.MarriedFlag);
            mate.History.Divorces.Add(person);
            person.History.Divorces.Add(mate);
            mate.Partner = null;
            person.Partner = null;

            person.PopulationModule.SaveChanges(mate);

            return true;
        }
        public void LoadPerson(Person person)
        {
            Clear();

            FirstNameLastNameBlock.Text = string.Format("{0}, {1}", person.FirstName, person.FamilyName);
            GenderBlock.Text = person.Gender;
            SexBlock.Text = person.Sex;
            AgeBlock.Text = person.Age.ToString();
            if (person.Partner != null
                && person.Partner.Id.HasValue)
            {
                var hyperlink = new Hyperlink();
                hyperlink.RequestNavigate += HyperlinkOnRequestNavigate;
                hyperlink.Inlines.Add(person.Partner.Name);
                hyperlink.NavigateUri = new Uri("person://" + person.Partner.Id.Value);
                SpouseBlock.Inlines.Add(hyperlink);
            }
            else
            {
                SpouseBlock.Text = "Single";
            }
            ProfessionBlock.Text = person.Profession != null
                ? string.Format("{0} at {1}", person.Profession.Title, person.Profession.Company)
                : "Unemployed";

            int index = 0;
            foreach (var child in person.Children)
            {
                var hyperlink = new Hyperlink();
                hyperlink.RequestNavigate += HyperlinkOnRequestNavigate;
                hyperlink.Inlines.Add(child.Name);
                ChildrenBlock.Inlines.Add(hyperlink);
                if (person.Children.Count > index + 1)
                {
                    ChildrenBlock.Inlines.Add(", ");
                }

                hyperlink.NavigateUri = new Uri("person://" + child.Id.Value);

                index++;
            }

            foreach (var flag in person.GetFlags())
            {
                FlagsBlock.Inlines.Add(flag.Name + Environment.NewLine);
            }
        }
 public Person Build(Person person)
 {
     string fname = "";
     if (person.Parents == null)
     {
         fname = _names
             .OrderBy(name => Guid.NewGuid())
             .First();
     }
     else
     {
         fname = person.Parents[0].FamilyName;
     }
     person.FamilyName = char.ToUpper(fname[0])
                         + fname.Substring(1).Trim('\r', '\n');
     return person;
 }
        public Person Build(Person person)
        {
            var fname = "";
            if (person.Gender == "Female")
                fname = _femaleNames
                    .OrderBy(name => Guid.NewGuid())
                    .First()
                    .ToLower();
            else
                fname = _maleNames
                    .OrderBy(name => Guid.NewGuid())
                    .First()
                    .ToLower();
            person.FirstName = char.ToUpper(fname[0])
                               + fname.Substring(1).Trim('\n','\r','\n');

            return person;
        }
        /// <summary>
        /// Scoring an encounter takes various bits about a person and calculates a score
        /// that will be used to determine whether or not this person will do this event.
        /// (This is like a Target Number Modifier in more colloquial games like Dungeons and Dragons,
        /// or Shadowrun)
        /// This specific score provides situational-based modifiers.
        /// </summary>
        /// <param name="enactor">The enactor.</param>
        /// <returns></returns>
        public float ScoreEncounter(Person enactor)
        {
            float score = 0;
            if (enactor.Partner != null)
            {
                score += FacetInfluenceEnum.Minor.ToScore();
            }

            if (enactor.HasFlag(RomanticFlags.DatingFlag))
            {
                score += FacetInfluenceEnum.Minor.ToScore();
            }
            else if (enactor.HasFlag(RomanticFlags.MarriedFlag))
            {
                score += FacetInfluenceEnum.Moderate.ToScore();
            }

            return score;
        }
        public bool Encounter(Person person)
        {
            var mate = person.Partner;

            // Mate them up!
            person.Log("I married {0}.", mate.Name);
            mate.Log("I married {0}. ", person.Name);
            person.AddFlag(RomanticFlags.MarriedFlag);
            mate.AddFlag(RomanticFlags.MarriedFlag);

            if (person.HasFlag(RomanticFlags.EngagedFlag))
            {
                person.ClearFlag(RomanticFlags.EngagedFlag);
                mate.ClearFlag(RomanticFlags.EngagedFlag);
            }

            person.PopulationModule.SaveChanges(mate);

            return true;
        }
        public bool Encounter(Person person)
        {
            var newTerritory = _availableTerritory.GetLiveableTerritories().First(t => t != person.Location);
            newTerritory.MovePerson(person);
            person.Log("I've moved to a new home at {0}", newTerritory.Name);

            if (person.Partner != null)
            {
                var mate = person.Partner;

                person.Log("I broke up with {0} to move.", mate.Name);
                mate.ClearFlags(FlagCategory.Romantic);
                person.ClearFlags(FlagCategory.Romantic);
                mate.Partner = null;
                person.Partner = null;
                person.PopulationModule.SaveChanges(mate);
            }

            return true;
        }
        public bool Encounter(Person person)
        {
            var potentialPartner =
                person.Location.GetPeopleWhere(p => ValidPartner(person, p))
                    .OrderBy(_ => Guid.NewGuid())
                    .FirstOrDefault();
            if (potentialPartner == null)
            {
                return false;
            }

            person.Log("I've started dating {0}!", potentialPartner.Name);
            potentialPartner.Log("I've started dating {0}!", person.Name);
            person.AddFlag(RomanticFlags.DatingFlag);
            potentialPartner.AddFlag(RomanticFlags.DatingFlag);

            person.Partner = potentialPartner;
            person.PopulationModule.SaveChanges(potentialPartner);

            return true;
        }
        public bool Encounter(Person person)
        {
            if ((Chance/(person.Children.Count*2)) < Universe.CurrentUniverse.RandomGenerator.NextDouble())
                return false;

            var mate = person.Partner;

            if (mate == null)
            {
                // We're having sex with a stranger!
                var stranger =
                    person.Location.GetPeopleWhere(p => p.Partner == null && !p.Equals(person)).FirstOrDefault();

                if (stranger == null)
                {
                    // No one to have sex with.
                    return false;
                }

                mate = stranger;
            }

            var child = person.PopulationModule.CreatePerson(person, mate);
            person.Children.Add(child);
            mate.Children.Add(child);
            child.Parents = new Person[2];
            child.Parents[0] = person;
            child.Parents[1] = mate;
            person.Log("I had a child with {0}.", mate.FirstName);
            mate.Log("I had a child with {0}", person.FirstName);

            if (Universe.CurrentUniverse.RandomGenerator.NextDouble() < 0.12)
            {
                person.Log("Passed away having a child.");
                person.DeathDate = Universe.CurrentUniverse.CurrentTime;
            }

            return true;
        }
        public Person Build(Person father = null, Person mother = null)
        {
            var person = new Person
            {
                Sex = _random.NextDouble() > 0.5
                    ? "Female"
                    : "Male",
                Fate = new Fate(_random.Next())
            };

            person.Gender = person.Sex;
            person.BirthDate = Universe.CurrentUniverse.CurrentTime;
            person = _firstNameGenerator.Build(person);

            if (father != null
                && mother != null)
            {
                person.FamilyName = mother.FamilyName;
            }
            else
            {
                person = _lastNameGenerator.Build(person);
            }

            // Transgender?
            if (0.063474382 > _random.NextDouble())
                person.AddFlag(IdentityFlags.TransgenderFlag);

            // Generate Personality
            person.Personality = Personality.CreateRandom(_random);

            // Generate Fate
            person.Fate.CalculateLifeline();

            return person;
        }
 public bool DoesMeetRequirements(Person person)
 {
     return true;
 }
 public void SaveChanges(Person person)
 {
     _personCache.Save(person);
 }
 public float ScoreEncounter(Person enactor)
 {
     return 0;
 }
 public bool CanEncounter(Person person)
 {
     return person.Age > 16
            && !person.HasFlag(TravelFlags.SettledFlag)
            && person.Profession == null;
 }
 public float ScoreEncounter(Person enactor)
 {
     throw new NotImplementedException();
 }
 public bool Encounter(Person person)
 {
     throw new NotImplementedException();
 }
 public bool CanEncounter(Person person)
 {
     return false;
 }
 public bool CanEncounter(Person person)
 {
     return person.Partner != null
            && person.Partner.HasFlag(RomanticFlags.DatingFlag)
            && person.HasFlag(RomanticFlags.DatingFlag);
 }