Ejemplo 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.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);
        }
Ejemplo n.º 2
0
        private static void GenerateFaction(string filename)
        {
            Faction f = faction;

            tw = new StreamWriter(filename, false, System.Text.Encoding.GetEncoding(1251));

            // Header
            Write("To: " + f.Email);
            Write("Subject: [Wasteland] Report for turn " + Map.Turn.ToString());
            Write("Content-Disposition: attachment");
            Write("");
            Write("Wasteland Report For:|Отчёт фракции:");
            Write(f.ToString(lng));
            Write(String.Format("Turn {0}, {1}|Ход {0}, {2}",
                                Map.Turn, Month.Current.NameEn, Month.Current.NameRu));
            Write("");

            if (f.Options.TextReport)
            {
                // Engine
                Write("Wasteland Engine Version: " + MainClass.EngineVersion +
                      "|Версия сервера Wasteland: " + MainClass.EngineVersion);
                Write("");

                if (!faction.IsNPC)
                {
                    // Skill reports
                    if (f.SkillsToShow.Count > 0)
                    {
                        Write("Skill reports:|Описания навыков:");
                        Write("");
                        foreach (SkillType st in f.SkillsToShow)
                        {
                            WriteSkillReport(st);
                        }
                    }

                    // Item reports
                    if (f.ItemsToShow.Count > 0)
                    {
                        Write("Item reports:|Описания вещей:");
                        Write("");
                        foreach (ItemType it in f.ItemsToShow)
                        {
                            WriteItemReport(it);
                        }
                    }

                    // Object reports
                    if (f.BuildingsToShow.Count > 0)
                    {
                        Write("Object reports:|Описания объектов:");
                        Write("");
                        foreach (BuildingType bt in f.BuildingsToShow)
                        {
                            WriteBuildingReport(bt);
                        }
                    }

                    // Battles
                    foreach (Region r in Map.Regions)
                    {
                        if (r.BattleReports.Count == 0 || (!RegionIsVisible(r, f) &&
                                                           !f.BattleRegions.Contains(r)))
                        {
                            continue;
                        }

                        Write("Battle reports:|Отчёты о сражениях:");
                        Write("");
                        foreach (ArrayList BattleReport in r.BattleReports)
                        {
                            foreach (string s in BattleReport)
                            {
                                Write(s);
                            }
                            Write("");
                        }
                    }
                }

                // Events
                Write("Events during turn:|События этого хода:");
                foreach (string s in f.Events)
                {
                    Write(s);
                }
                Write("");

                // Attitudes
                Write(String.Format("Declared Attitudes (default {0}):|Отношения (по умолчанию {0}):",
                                    f.DefaultAttitude.ToString()));
                for (Attitude a = Attitude.Hostile; a <= Attitude.Ally; a++)
                {
                    Write(a + " : " + AttitudeListString(f, a));
                }
                Write("");

                // Regions
                foreach (Region r in Map.Regions)
                {
                    if (!faction.IsNPC && !RegionIsVisible(r, f))
                    {
                        continue;
                    }

                    // Print region
                    Write("");
                    Write(r.ToString(lng));
                    Write("------------------------------------------------------------");

                    // Weather and resources shown is for next turn
                    Map.Turn++;
                    Write(String.Format("  Weather forecast: {0}, {1}°C, {2} mR/h.|" +
                                        "  Прогноз погоды: {3}, {1}°C, {2} мР/ч.",
                                        r.Weather.ToString(Lang.En), r.Temperature,
                                        r.Radiation, r.Weather.ToString(Lang.Ru)));
                    Write((lng == Lang.En ? "  Resources: " : "  Ресурсы: ") +
                          r.TurnResources.ToString(lng));
                    Map.Turn--;

                    Write((lng == Lang.En ? "  Junk: " : "  Мусор: ") +
                          r.Junk.ToString(lng));

                    Write("");

                    // Exits
                    Write("Exits:|Выходы:");
                    for (Direction i = Direction.North; i <= Direction.Northwest; i++)
                    {
                        Region exit = r.RegionInDir((Direction)i);
                        if (exit != null)
                        {
                            if (lng == Lang.Ru)
                            {
                                Write("  " + Map.DirectionFullNamesRu[(int)i - 1] + " : " + exit.ToString(lng));
                            }
                            else
                            {
                                Write("  " + i.ToString() + " : " + exit.ToString(lng));
                            }
                        }
                    }
                    Write("");

                    // Persons
                    WritePersons(r, null, f);
                    Write("");

                    // Buildings and persons inside
                    foreach (Building b in r.Buildings)
                    {
                        string s = "+ " + b.ToString(lng) + " : " + b.Type.ToString(lng);
                        if (!b.Description.Equals(""))
                        {
                            s += "; " + b.Description.ToString() + ".";
                        }
                        else
                        {
                            s += ".";
                        }
                        s += " Installed: ";
                        if (b.Installed.Count > 0)
                        {
                            s += b.Installed.ToString(lng);
                        }
                        else
                        {
                            s += "Nothing.";
                        }
                        ItemArrayList needs = b.GetNeeds();
                        if (needs.Count > 0)
                        {
                            s += (lng == Lang.En ? " Needs: " : " Нужно: ") + needs.ToString(lng);
                        }

                        Write(s);
                        WritePersons(r, b, f);
                        Write("");
                    }
                }

                if (faction.IsNPC)
                {
                    return;
                }

                // Orders template
                Write("");
                Write("Orders Template:|Шаблон приказов:");
                Write("");
                Write(String.Format("#orders {0} \"{1}\"", f.Num, f.Password));
                Write("");

                foreach (Person p in f.Persons)
                {
                    Write(String.Format("person {0}", p.Num));
                    foreach (string s in p.RepeatingLines)
                    {
                        Write(s);
                    }
                    Write("");
                }

                Write("#end");
                Write("");
            }

            if (faction.Options.XmlReport)
            {
                Write("");
                Write("XML version (for client applications):|XML-версия (для программ-клиентов):");
                Write("");
                Write(XmlReport.Generate(faction), false);

                /*
                 * TextWriter tw1 = new StreamWriter("report.xml", false, System.Text.Encoding.GetEncoding(1251));
                 * tw1.Write(XmlReport.Generate(faction));
                 * tw1.Close();
                 */
            }

            tw.Close();
            f.AllShown();
        }