Files
MVP1/Assets/Scripts/WorldMap/ReconReportText.cs
T
AlexanderandClaude Opus 5.5 61ba46947c Разведка М2: целенаправленная разведка поселений, замка и лагерей с отчётами II и III
Отряд идёт маршем, наблюдает 2/4 (поселение, лагерь) или 3/6 (замок) игровых часов, отчёт на конец наблюдения,
потом домой. Уровень II -- точные войска, герой, стены; III -- плюс защита и ресурсы ±15%. Один отчёт на операцию,
сохранение. Карта: кнопки «Разведка II/III», окно отчёта, «Отчёты», прогноз по отчёту вне обзора.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:21:54 +01:00

73 lines
3.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
using TMPro;
using UnityEngine;
// Отчёты разведки на экране (Разведка М2): текст отчёта и окно «Отчёты» с последними отчётами.
// Сами отчёты хранит модуль Разведки (IIntelligence.Reports) -- здесь только показ.
// Сведения -- на момент отчёта: сколько прошло с тех пор, видно в каждом отчёте.
public static class ReconReportText
{
static readonly string[] TroopNames = { "пехота", "лучники", "кавалерия", "осадные" };
static readonly Dictionary<string, string> ResourceNames = new Dictionary<string, string>
{
{ "Food", "еда" }, { "Wood", "дерево" }, { "Stone", "камень" }, { "Iron", "металл" }, { "Gold", "золото" }, { "Gems", "кристаллы" }
};
public static string Format(ReconReport r, long nowMs)
{
var lines = new List<string>
{
$"<b>{r.TargetName}</b> — разведка {(r.Level == 3 ? "III" : "II")}, {Ago(nowMs - r.TimeMs)} назад",
};
int total = 0;
var parts = new List<string>();
for (int i = 0; r.Units != null && i < r.Units.Length; i++)
{
total += r.Units[i];
if (r.Units[i] > 0) parts.Add($"{TroopNames[i % TroopNames.Length]} {r.Units[i]}");
}
lines.Add($"Гарнизон: {total}" + (parts.Count > 0 ? $" ({string.Join(", ", parts)})" : ""));
lines.Add((r.Fortified ? "Защитники за стенами" : "Стен нет, бой в поле") + (r.HasHero ? ", есть герой" : ", героя нет"));
if (r.Level >= 3)
{
if (!string.IsNullOrEmpty(r.Modifiers)) lines.Add("Защита: " + r.Modifiers);
var res = new List<string>();
for (int i = 0; r.ResourceNames != null && i < r.ResourceNames.Length; i++)
{
string name = ResourceNames.TryGetValue(r.ResourceNames[i], out var n) ? n : r.ResourceNames[i];
res.Add($"{name} ~{r.ResourceMin[i]}–{r.ResourceMax[i]}");
}
if (res.Count > 0) lines.Add("Ресурсы (оценка ±15%): " + string.Join(", ", res));
}
return string.Join("\n", lines);
}
static string Ago(long ms)
{
long min = System.Math.Max(0, ms) / 60_000;
if (min < 1) return "только что";
return min < 60 ? $"{min} мин" : $"{min / 60} ч {min % 60} мин";
}
// Окно «Отчёты»: последние отчёты, новые сверху
public static void OpenWindow()
{
var card = UIKit.Modal("ОТЧЁТЫ РАЗВЕДКИ", out GameObject root);
if (!GameServices.TryGet(out IIntelligence intel) || intel.Reports.Count == 0)
{
UIKit.Text(card, "Отчётов пока нет. Нажмите на город, лагерь или замок и отправьте «Разведку II» или «Разведку III».",
26, UIKit.Theme.TextDim, TextAlignmentOptions.Center);
}
else
{
long now = MarchManager.NowMs;
int shown = 0;
for (int i = intel.Reports.Count - 1; i >= 0 && shown < 5; i--, shown++)
UIKit.Text(card, Format(intel.Reports[i], now), 24, UIKit.Theme.Text, TextAlignmentOptions.Left);
if (intel.Reports.Count > 5)
UIKit.Text(card, $"И ещё {intel.Reports.Count - 5} более старых", 22, UIKit.Theme.TextDim, TextAlignmentOptions.Center);
}
UIKit.Button(card, "Закрыть", UIKit.Theme.Gray, () => Object.Destroy(root), -1, 80, 28);
}
}