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 (object obj in BattleReport) { if (obj.GetType() == typeof(string)) { Write((string)obj); } else { Write(((ILocalized)obj).ToString(lng)); } } Write(""); } } } // Events Write("Events during turn:|События этого хода:"); foreach (Event obj in f.Events) { Write(obj.ToString(lng)); } Write(""); // The Greatest if (Faction.TheGreatest != null && Faction.TheGreatest.GetChosen() != null) { Write(String.Format("Rumors are, {0} is the strongest leader in Wasteland.|" + "Люди говорят, что самый сильный вождь Пустошей - {1}.", Faction.TheGreatest.GetChosen().ToString(Lang.En) + ", " + Faction.TheGreatest.ToString(Lang.En), Faction.TheGreatest.GetChosen().ToString(Lang.Ru) + ", " + Faction.TheGreatest.ToString(Lang.Ru))); 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.Installed.Count > 0) { s += ", " + b.Installed.ToString(lng); } else { s += "."; } ItemList needs = b.GetNeeds(); if (needs.Count > 0) { s += (lng == Lang.En ? " Needs: " : " Нужно: ") + needs.ToString(lng); } if (b.Description != "") { if (lng == Lang.En) { s = s.Substring(0, s.Length - 1) + "; " + MyStrings.Translit(b.Description); } else { s = s.Substring(0, s.Length - 1) + "; " + b.Description; } } 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) { if (f.Options.Template == TemplateType.Long) { string line = (lng == Lang.En ? MyStrings.Translit(p.Name) : p.Name); foreach (SkillType talent in p.GetTalents()) { line += ", " + (lng == Lang.En ? talent.FullNameEn : talent.FullNameRu); } line += "."; if (p.Leader != null) { line += (lng == Lang.En ? " Leader: " : " Бригадир: ") + (lng == Lang.En ? MyStrings.Translit(p.Leader.Name) : p.Leader.Name) + "."; } while (true) { int j = 70; while (line.Length > j && line[j] != ' ') { j--; } if (line.Length > j) { tw.WriteLine(";" + line.Substring(0, j)); line = line.Substring(j + 1); } else { tw.WriteLine(";" + line); break; } } } 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, false); /* * TextWriter tw1 = new StreamWriter("report.xml", false, System.Text.Encoding.GetEncoding(1251)); * tw1.Write(XmlReport.Generate(faction)); * tw1.Close(); */ } tw.Close(); f.AllShown(); }
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(); }