示例#1
0
 public int opinionExists(String Type, societyevent ev)
 {
     int index = 0;
     bool found = false;
     while ((index < opinions.Count) && (!found))
     {
         opinion op = (opinion)opinions[index];
         if ((op.GetOpinionType() == Type) && (op.Event == ev))
             found = true;
         else
             index++;
     }
     if (found)
         return (index);
     else
         return (-1);
 }
示例#2
0
 public void RemoveOpinion(String Type, societyevent ev)
 {
     int index = 0;
     bool found = false;
     while ((index < opinions.Count) && (!found))
     {
         opinion op = (opinion)opinions[index];
         if ((op.GetOpinionType() == Type) && (op.Event == ev))
         {
             found = true;
             opinions.Remove(op);
         }
         else
             index++;
     }
 }
示例#3
0
 public opinion AddOpinion(String Type, societyevent Event, String Reason)
 {
     int index = opinionExists(Type, Event);
     opinion op = null;
     if (index == -1)
     {
         op = new opinion();
         opinions.Add(op);
     }
     else
     {
         op = (opinion)opinions[index];
     }
     op.SetOpinionType(Type);
     op.Event = Event;
     op.Reason = Reason;
     return (op);
 }
示例#4
0
        public String Type; // the type of event

        #endregion Fields

        #region Methods

        public void Add(societyevent sub_event)
        {
            if (!subevents.Contains(sub_event))
                subevents.Add(sub_event);
        }
示例#5
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 == "OpinionType")
                SetOpinionType(xnod.InnerText);

            if (xnod.Name == "OpinionEvent")
            {
                Event = new societyevent();
                Event.LoadFromXml(xnod, level + 1);
            }

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

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

            // 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;
                }
            }
        }
示例#6
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;
                }
            }
        }
示例#7
0
        /// <summary>
        /// create a new event
        /// </summary>
        public societyevent CreateEvent(String Type, DateTime Date, String Description,
            String LocationName, String LocationCountry,
            String LocationName2, String LocationCountry2,
            String people)
        {
            societyevent e = null;

            int index = eventExists(Type, Date);
            if (index == -1)
            {
                e = new societyevent();
                events.Add(e);
            }
            else e = (societyevent)events[index];

            index = LocationExists(LocationName, LocationCountry);
            if (index == -1)
            {
                e.locations.Add(AddLocation(LocationName, LocationCountry, ""));
            }
            else
            {
                e.locations.Add((location)locations[index]);
            }

            if ((LocationName2 != "") || (LocationCountry2 != ""))
            {
                index = LocationExists(LocationName2, LocationCountry2);
                if (index == -1)
                {
                    e.locations.Add(AddLocation(LocationName2, LocationCountry2, ""));
                }
                else
                {
                    e.locations.Add((location)locations[index]);
                }
            }

            if (people != "")
            {
                String[] person = people.Split(',');
                for (int i = 0; i < person.Length; i++)
                {
                    person[i] = person[i].Trim();
                    index = personalityExists(person[i]);
                    if (index > -1)
                        if (!e.people.Contains((personality)personalities[index]))
                            e.people.Add((personality)personalities[index]);
                }
            }

            e.Type = Type;
            e.SetStartTime(Date);
            e.Description = Description;
            return (e);
        }