Exemple #1
0
        /// <summary>
        /// defines the people involved in the relationship
        /// </summary>        
        public void SetPeople(personality thisPerson, 
                              personality relationshipPerson)
        {
            atoms_incoming.Clear();
            AddToIncomingSet(relationshipPerson);

            atoms_outgoing.Clear();
            AddToOutgoingSet(thisPerson);
        }
Exemple #2
0
 public relationship(String type, 
                     personality thisPerson, 
                     personality relationshipPerson)
     : base(relationshipPerson, thisPerson, null)
 {
     initRelationship();
 }
Exemple #3
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public override void LoadFromXml(XmlNode xnod, int level)
        {
            LoadLinkFromXml(xnod, level);

            if (xnod.Name == "RelationshipType")
                SetRelationshipType(xnod.InnerText);

            if (xnod.Name == "PeopleRelationship")
            {
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    personality person = new personality();
                    person.LoadFromXml(xnod.ChildNodes[i], level);
                    if (i == 0)
                    {
                        atoms_incoming.Clear();
                        atoms_incoming.Add(person);
                    }
                    else
                    {
                        atoms_outgoing.Clear();
                        atoms_outgoing.Add(person);
                    }
                }
            }

            if (xnod.Name == "Started")
                SetStartedDate(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "Ended")
                SetEndedDate(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "Affect")
                affect = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Credibility")
                credibility = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "Familiarity")
                familiarity = truthvalue.FromString(xnod.InnerText);

            if (xnod.Name == "InterpersonalProperties")
            {
                property.Clear();
                String[] props = xnod.InnerText.Split(',');
                for (int i = 0; i < props.Length; i++)
                {
                    property.Add(Convert.ToInt32(props[i]));
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Exemple #4
0
 public void RemoveInterpersonalProperty(String Type, personality person, String interpersonalDescription)
 {
     int index = RelationshipExists(Type, person);
     if (index > -1)
     {
         relationship r = (relationship)relationships[index];
         r.RemoveInterpersonalProperty(interpersonalDescription);
     }
 }
Exemple #5
0
 /// <summary>
 /// remove a relationship
 /// </summary>
 /// <param name="Type"></param>
 /// <param name="person"></param>
 public void RemoveRelationship(String Type, personality person)
 {
     bool found = false;
     int i = 0;
     while ((i < relationships.Count) && (!found))
     {
         relationship r = (relationship)relationships[i];
         if ((r.GetRelationshipPerson() == person) && (Type == r.GetRelationshipType()))
         {
             relationships.Remove(r);
             found = true;
         }
         else
             i++;
     }
 }
Exemple #6
0
 /// <summary>
 /// add a relationship
 /// </summary>
 /// <param name="Type">the type of relationship, such as mother or father</param>
 /// <param name="person">person object</param>
 public void AddRelationship(String Type, personality person, DateTime started, DateTime ended, bool hasEnded, 
                             float affect, float credibility, float familiarity)
 {
     int index = RelationshipExists(Type, person);
     relationship r = null;
     if (index == -1)
     {
         r = new relationship(Type, person, this);
         relationships.Add(r);
     }
     else
     {
         r = (relationship)relationships[index];
     }
     r.SetStartedDate(started);
     r.SetEndedDate(ended);
     r.hasEnded = hasEnded;
     r.affect = new truthvalue(affect);
     r.credibility = new truthvalue(credibility);
     r.familiarity = new truthvalue(familiarity);
 }
Exemple #7
0
 /// <summary>
 /// does this relationship already exist?
 /// </summary>
 /// <param name="RelationshipType"></param>
 /// <param name="person"></param>
 /// <returns></returns>
 public int RelationshipExists(String RelationshipType, personality person)
 {
     bool found = false;
     int i = 0;
     while ((i < relationships.Count) && (!found))
     {
         relationship r = (relationship)relationships[i];
         if ((r.GetRelationshipPerson() == person) && (RelationshipType == r.GetRelationshipType()))
             found = true;
         else
             i++;
     }
     if (found)
         return (i);
     else
         return (-1);
 }
Exemple #8
0
 public possession AddPossession(String Name, String Type,
     DateTime AcquiredDate,
     DateTime RelinquishedDate,
     bool NotOwned,
     personality AcquiredFrom,
     String Affect, int value)
 {
     int index = possessionExists(Name);
     possession p = null;
     if (index == -1)
     {
         p = new possession();
         possessions.Add(p);
     }
     else
     {
         p = (possession)possessions[index];
     }
     p.BelongsTo = this;
     p.SetName(Name.ToLower().Trim());
     p.SetPossessionType(Type);
     p.SetAcquiredDate(AcquiredDate);
     p.SetRelinquishedDate(RelinquishedDate);
     p.notOwned = NotOwned;
     p.AcquiredFrom = AcquiredFrom;
     p.Value = value;
     return (p);
 }
Exemple #9
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public void LoadFromXml(XmlNode xnod, int level)
        {
            if (xnod.Name == "Type")
                Type = xnod.InnerText;

            if (xnod.Name == "Date")
                SetStartTime(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "Description")
                Description = xnod.InnerText;

            if (xnod.Name == "Locations")
            {
                locations.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    location locn = new location();
                    locn.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    locations.Add(locn);
                }
            }

            if (xnod.Name == "People")
            {
                people.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    personality p = new personality();
                    p.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    people.Add(p);
                }
            }

            if (xnod.Name == "Possessions")
            {
                possessions.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    possession p = new possession();
                    p.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    possessions.Add(p);
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public override void LoadFromXml(XmlNode xnod, int level)
        {
            LoadNodeFromXml(xnod, level);

            if (xnod.Name == "Geography")
            {
                locations.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    location locn = new location();
                    locn.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    locations.Add(locn);
                }
            }

            if (xnod.Name == "Population")
            {
                personalities.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    personality p = new personality();
                    p.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    personalities.Add(p);
                }
            }

            if (xnod.Name == "Events")
            {
                events.Clear();
                for (int i = 0; i < xnod.ChildNodes.Count; i++)
                {
                    societyevent ev = new societyevent();
                    ev.LoadFromXml((XmlNode)xnod.ChildNodes[i], level);
                    events.Add(ev);
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// create a new personality
        /// </summary>
        /// <param name="name"></param>
        public personality CreatePersonality(String name)
        {
            personality p = null;

            if (personalityExists(name) == -1)
            {
                p = new personality();
                p.SetName(name);
                String[] namestr = name.Split(' ');
                if (male_names.Contains(namestr[0].ToLower()))
                    p.isMale = true;
                else
                    p.isMale = false;
                p.SetDateOfBirth(new DateTime(1980, 1, 1));

                personalities.Add(p);
            }
            return (p);
        }
Exemple #12
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public override void LoadFromXml(XmlNode xnod, int level)
        {
            LoadNodeFromXml(xnod, level);

            if (xnod.Name == "BelongsTo")
            {
                BelongsTo = new personality();
                BelongsTo.LoadFromXml(xnod, level);
            }

            if (xnod.Name == "Name")
                Name = xnod.InnerText;

            if (xnod.Name == "PossessionType")
                SetPossessionType(xnod.InnerText);

            if (xnod.Name == "AcquiredDate")
                SetAcquiredDate(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "notOwned")
                notOwned = Convert.ToBoolean(xnod.InnerText);

            if (xnod.Name == "RelinquishedDate")
                SetRelinquishedDate(DateTime.Parse(xnod.InnerText));

            if (xnod.Name == "AcquiredFrom")
            {
                AcquiredFrom = new personality();
                AcquiredFrom.LoadFromXml(xnod, level);
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }