Esempio n. 1
0
        private static void WritePerson(Person p, Faction f, int indent)
        {
            Lang lng = faction.Options.Lang;

            string s = "";

            if (p.Faction == f)
            {
                s = "* ";
            }
            else
            {
                s = "- ";
            }
            for (int i = 0; i < indent; i++)
            {
                s = "  " + s;
            }
            s += p.ToString(lng);

            if (p.Faction == f || !p.HideFaction)
            {
                s += ", " + p.Faction.ToString(lng);
            }

            if (p.IsDangerouslyInsane())
            {
                s += (lng == Lang.En ? ", insane" : ", безумен");
            }
            if (p.Chosen)
            {
                s += (lng == Lang.En ? ", chosen one" : ", избранный");
            }
            if (p.Patrolling)
            {
                s += (lng == Lang.En ? ", patrolling" : ", патрулирует");
            }
            if (p.Age <= Constants.ChildTurns)
            {
                s += (lng == Lang.En ? ", child" : ", ребёнок");
            }

            if (p.Faction == f)
            {
                if (p.Avoiding)
                {
                    s += (lng == Lang.En ? ", avoiding" : ", избегает боя");
                }
                if (p.Greedy)
                {
                    s += (lng == Lang.En ? ", greedy" : ", не делится");
                }
                if (p.Hide)
                {
                    s += (lng == Lang.En ? ", hiding" : ", скрывается");
                }
                else if (p.HideFaction)
                {
                    s += (lng == Lang.En ? ", hiding faction" : ", скрывает фракцию");
                }
            }

            if (p.Faction == faction)
            {
                s += ", " + p.Items.ToString(lng);
            }
            else
            {
                ItemList items = new ItemList();
                foreach (Item itm in p.Items)
                {
                    if (itm.Type.Weight > 0)
                    {
                        items.Add(itm);
                    }
                }
                s += ", " + items.ToString(lng);
            }

            if (p.Faction == f)
            {
                int weight = p.GetWeight();
                if (p.Man != null)
                {
                    weight -= p.Man.Weight;
                }

                s += (lng == Lang.En ? " Load: " : " Груз: ") +
                     weight.ToString() + ((lng == Lang.En) ? " kg." : " кг.");
                s += (lng == Lang.En ? " Skills: " : " Навыки: ") +
                     p.Skills.ToString(lng);

                if (p.Consume.Count > 0)
                {
                    s += (lng == Lang.En ? " Consuming: " : " Еда: ") +
                         p.Consume.ToString(lng);
                }
                if (p.Burn.Count > 0)
                {
                    s += (lng == Lang.En ? " Burning: " : " Топливо: ") +
                         p.Burn.ToString(lng);
                }
                if (p.Equipment.Count > 0)
                {
                    s += (lng == Lang.En ? " Equipment: " : " Снаряжение: ") +
                         p.Equipment.ToString(lng);
                }
                if (p.Spoils.Count > 0)
                {
                    s += (lng == Lang.En ? " Wanted spoils: " : " Желаемые трофеи: ") +
                         p.Spoils.ToString(lng);
                }

                s += (lng == Lang.En ? " Insanity: " : " Безумие: ") +
                     p.Insanity.ToString() + ".";

                int hire = p.GetHireAmount();
                if (hire == 1)
                {
                    s += (lng == Lang.En ? " Hire demand: day ration." : " Найм: дневной рацион.");
                }
                else if (hire > 1)
                {
                    s += String.Format((lng == Lang.En ? " Hire demand: {0} day rations." :
                                        " Найм: {0} рационов."), hire);
                }

                int rad_danger   = Math.Abs(p.RadiationDanger(true));
                int tempr_danger = p.TemperatureDanger(true);

                if (rad_danger > 0 || tempr_danger > 0)
                {
                    s += (lng == Lang.En ? " Danger:" : " Опасность:");
                    if (rad_danger > 0)
                    {
                        s += " " + rad_danger.ToString() + (lng == Lang.En ? " mR/h" : " мР/ч");
                    }
                    if (tempr_danger > 0)
                    {
                        if (rad_danger > 0)
                        {
                            s += ",";
                        }
                        s += " " + tempr_danger.ToString() + (lng == Lang.En ? "°C" : "°C");
                    }
                    s += ".";
                }
            }
            else if (!f.IsNPC)
            {
                // Show talents of other factions' persons if Chosen in region
                Person chosen = f.GetChosen();
                if (chosen != null && p.Region == chosen.Region)
                {
                    SkillTypeList talents = new SkillTypeList();
                    foreach (Skill sk in p.Skills)
                    {
                        if (sk.Type.BasedOn == null)
                        {
                            talents.Add(sk.Type);
                        }
                    }
                    s += (lng == Lang.En ? " Skills: " : " Навыки: ") +
                         talents.ToString(lng);
                }
            }

            if (p.TradeOrder != null)
            {
                Person receiver = null;
                if (p.TradeOrder.PersonNum != 0)
                {
                    receiver = p.Region.Persons.GetByNumber(p.TradeOrder.PersonNum);
                }
                if (p.TradeOrder.PersonNum == 0 || (receiver != null && receiver.Faction == f))
                {
                    if (lng == Lang.En)
                    {
                        s += " Trade: sells " + p.TradeOrder.SellWhat.ToString(p.TradeOrder.SellAmount, Lang.En) +
                             " for " + p.TradeOrder.BuyWhat.ToString(p.TradeOrder.BuyAmount, Lang.En);
                        if (receiver != null)
                        {
                            s += " to " + receiver.ToString(Lang.En);
                        }
                        s += ".";
                    }
                    else
                    {
                        s += " Бартер: предлагает: " + p.TradeOrder.SellWhat.ToString(p.TradeOrder.SellAmount, Lang.Ru) +
                             ", просит: " + p.TradeOrder.BuyWhat.ToString(p.TradeOrder.BuyAmount, Lang.Ru);
                        if (receiver != null)
                        {
                            s += ", покупатель:  " + receiver.ToString(Lang.Ru);
                        }
                        s += ".";
                    }
                }
            }

            if (p.Description != "")
            {
                if (lng == Lang.En)
                {
                    s = s.Substring(0, s.Length - 1) + "; " + MyStrings.Translit(p.Description);
                }
                else
                {
                    s = s.Substring(0, s.Length - 1) + "; " + p.Description;
                }
            }

            Write(s);
        }
Esempio n. 2
0
        private static XmlElement WritePerson(XmlElement parent, Person p)
        {
            XmlElement elPerson = doc.CreateElement("person");

            parent.AppendChild(elPerson);
            if (faction.Options.Lang == Lang.En)
            {
                elPerson.SetAttribute("name", MyStrings.Translit(p.Name));
                if (p.Description != "")
                {
                    elPerson.SetAttribute("description", MyStrings.Translit(p.Description));
                }
            }
            else
            {
                elPerson.SetAttribute("name", p.Name);
                if (p.Description != "")
                {
                    elPerson.SetAttribute("description", p.Description);
                }
            }
            elPerson.SetAttribute("n", p.Num.ToString());

            // Faction
            if (p.Faction == faction || !p.HideFaction)
            {
                ShowFaction(p.Faction);
                elPerson.SetAttribute("faction", p.Faction.Num.ToString());
            }

            // Flags
            if (p.IsDangerouslyInsane())
            {
                elPerson.SetAttribute("insane", "True");
            }
            if (p.Chosen)
            {
                elPerson.SetAttribute("chosen", "True");
            }
            if (p.Patrolling)
            {
                elPerson.SetAttribute("patrolling", "True");
            }
            if (p.Age <= Constants.ChildTurns)
            {
                elPerson.SetAttribute("child", "True");
            }

            if (p.Faction == faction)
            {
                if (p.Avoiding)
                {
                    elPerson.SetAttribute("avoiding", "True");
                }
                if (p.Greedy)
                {
                    elPerson.SetAttribute("greedy", "True");
                }
                if (p.Hide)
                {
                    elPerson.SetAttribute("hiding", "person");
                }
                else if (p.HideFaction)
                {
                    elPerson.SetAttribute("hiding", "faction");
                }
            }

            // Items
            foreach (Item itm in p.Items)
            {
                if (itm.Type.Weight == 0 && p.Faction != faction)
                {
                    continue;
                }
                AddItem(elPerson, itm, "item");
            }

            if (p.Faction == faction)
            {
                foreach (Skill sk in p.Skills)
                {
                    AddSkill(elPerson, sk, "skill");
                }

                elPerson.SetAttribute("insanity", p.Insanity.ToString());
                int hire = p.GetHireAmount();
                if (hire >= 1)
                {
                    elPerson.SetAttribute("hire-demand", hire.ToString());
                }

                foreach (ItemType it in p.Consume)
                {
                    AddItemType(elPerson, it, "consume");
                }
                foreach (ItemType it in p.Burn)
                {
                    AddItemType(elPerson, it, "burn");
                }
                foreach (ItemType it in p.Equipment)
                {
                    AddItemType(elPerson, it, "equipment");
                }
                foreach (ItemType it in p.Spoils)
                {
                    AddItemType(elPerson, it, "spoils");
                }
            }
            else if (!faction.IsNPC)
            {
                // Show talents of other factions' persons if Chosen in region
                Person chosen = faction.GetChosen();
                if (chosen != null && p.Region == chosen.Region)
                {
                    foreach (Skill sk in p.Skills)
                    {
                        if (sk.Type.BasedOn == null)
                        {
                            XmlElement el = doc.CreateElement("skill");
                            elPerson.AppendChild(el);
                            el.SetAttribute("id", sk.Type.Name);
                            ShowSkillType(sk.Type);
                        }
                    }
                }
            }

            // Trade order
            if (p.TradeOrder != null)
            {
                Person receiver = null;
                if (p.TradeOrder.PersonNum != 0)
                {
                    receiver = p.Region.Persons.GetByNumber(p.TradeOrder.PersonNum);
                }
                if (p.TradeOrder.PersonNum == 0 || (receiver != null && receiver.Faction == faction))
                {
                    XmlElement elTrade = doc.CreateElement("trade");
                    elPerson.AppendChild(elTrade);
                    AddItem(elTrade, new Item(p.TradeOrder.SellWhat, p.TradeOrder.SellAmount), "sell");
                    AddItem(elTrade, new Item(p.TradeOrder.BuyWhat, p.TradeOrder.BuyAmount), "buy");
                    if (receiver != null)
                    {
                        elTrade.SetAttribute("with", receiver.Num.ToString());
                    }
                }
            }

            // Orders
            if (p.Faction == faction)
            {
                string orders = "";
                foreach (string s in p.RepeatingLines)
                {
                    if (orders != "")
                    {
                        orders += "\\n";
                    }
                    orders += s.Replace("\\", "\\\\").Replace("<", "").Replace(">", "");
                }
                if (orders != "")
                {
                    XmlElement elOrders = doc.CreateElement("orders");
                    elOrders.InnerText = orders;
                    elPerson.AppendChild(elOrders);
                }
            }

            return(elPerson);
        }
Esempio n. 3
0
        private static void WritePerson(Person p, Faction f, int indent)
        {
            Lang lng = faction.Options.Lang;

            string s = "";

            if (p.Faction == f)
            {
                s = "* ";
            }
            else
            {
                s = "- ";
            }
            for (int i = 0; i < indent; i++)
            {
                s = "  " + s;
            }
            s += p.ToString(lng);

            if (p.Faction == f || !p.HideFaction)
            {
                s += ", " + p.Faction.ToString(lng);

                //if (!p.Faction.Description.Equals(""))
                //	s += ", " + p.Faction.Description.ToString();
            }

            if (p.Insanity >= Constants.DangerousInsanity)
            {
                s += (lng == Lang.En ? ", insane" : ", безумен");
            }
            if (p.Chosen)
            {
                s += (lng == Lang.En ? ", chosen one" : ", избранный");
            }
            if (p.Patrolling)
            {
                s += (lng == Lang.En ? ", patrolling" : ", патрулирует");
            }
            if (p.Age <= Constants.ChildTurns)
            {
                s += (lng == Lang.En ? ", child" : ", ребёнок");
            }

            if (p.Faction == f)
            {
                if (p.Avoiding)
                {
                    s += (lng == Lang.En ? ", avoiding" : ", избегает боя");
                }
                if (p.Hide)
                {
                    s += (lng == Lang.En ? ", hiding" : ", скрывается");
                }
                else if (p.HideFaction)
                {
                    s += (lng == Lang.En ? ", hiding faction" : ", скрывает фракцию");
                }
            }

            if (p.Faction == faction)
            {
                s += ", " + p.Items.ToString(lng);
            }
            else
            {
                ItemArrayList items = new ItemArrayList();
                foreach (Item itm in p.Items)
                {
                    if (itm.Type.Weight > 0)
                    {
                        items.Add(itm);
                    }
                }
                s += ", " + items.ToString(lng);
            }

            if (p.Faction == f)
            {
                int weight = p.GetWeight();
                if (p.Man != null)
                {
                    weight -= p.Man.Weight;
                }

                s += (lng == Lang.En ? " Load: " : " Груз: ") +
                     weight.ToString() + ((lng == Lang.En) ? " kg." : " кг.");
                s += (lng == Lang.En ? " Skills: " : " Навыки: ") +
                     p.Skills.ToString(lng);

                if (p.Consume.Count > 0)
                {
                    s += (lng == Lang.En ? " Consuming: " : " Еда: ") +
                         p.Consume.ToString(lng);
                }
                if (p.Burn.Count > 0)
                {
                    s += (lng == Lang.En ? " Burning: " : " Топливо: ") +
                         p.Burn.ToString(lng);
                }
                if (p.Equipment.Count > 0)
                {
                    s += (lng == Lang.En ? " Equipment: " : " Снаряжение: ") +
                         p.Equipment.ToString(lng);
                }

                s += (lng == Lang.En ? " Insanity: " : " Безумие: ") +
                     p.Insanity.ToString() + ".";

                int hire = p.GetHireAmount();
                if (hire == 1)
                {
                    s += (lng == Lang.En ? " Hire demand: day ration." : " Найм: дневной рацион.");
                }
                else if (hire > 1)
                {
                    s += String.Format((lng == Lang.En ? " Hire demand: {0} day rations." :
                                        " Найм: {0} рационов."), hire);
                }

                int rad_danger   = Math.Abs(p.RadiationDanger(true));
                int tempr_danger = p.TemperatureDanger(true);

                if (rad_danger > 0 || tempr_danger > 0)
                {
                    s += (lng == Lang.En ? " Danger:" : " Опасность:");
                    if (rad_danger > 0)
                    {
                        s += " " + rad_danger.ToString() + (lng == Lang.En ? " mR/h" : " мР/ч");
                    }
                    if (tempr_danger > 0)
                    {
                        if (rad_danger > 0)
                        {
                            s += ",";
                        }
                        s += " " + tempr_danger.ToString() + (lng == Lang.En ? "°C" : "°C");
                    }
                    s += ".";
                }

                if (!p.Description.Equals(""))
                {
                    s += " " + p.Description.ToString() + ".";
                }
            }

            if (p.TradeOrder != null)
            {
                Person receiver = null;
                if (p.TradeOrder.PersonNum != 0)
                {
                    receiver = p.Region.Persons.GetByNumber(p.TradeOrder.PersonNum);
                }
                if (p.TradeOrder.PersonNum == 0 || (receiver != null && receiver.Faction == f))
                {
                    s += " Trade: sells " + p.TradeOrder.SellWhat.ToString(p.TradeOrder.SellAmount, Lang.En) +
                         " for " + p.TradeOrder.BuyWhat.ToString(p.TradeOrder.BuyAmount, Lang.En);
                    if (receiver != null)
                    {
                        s += " to " + receiver.ToString(Lang.En);
                    }
                    s += ".";
                }
            }

            Write(s);
        }