/
romashov.z
/
PPAGame
Обзор
Документация
Войти
/
romashov.z
/
PPAGame
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
UI/ConsoleBattleLogger.cs
132 строки
5 KB
Zakhar Romashov
Добавили логику с бафами
29 апр 2026, 13:06
29 апр 2026, 13:06
7623dfb
Код
Авторство
О чём код?
namespace ArmyBattleGame { class ConsoleBattleLogger : IBattleLogger { private static string N(IUnit u) => u.DisplayName; public void LogAttack(IUnit attacker, IUnit target, double damage) { ConsoleHelper.Write( $"{N(attacker)} атакует {N(target)} и наносит ", ConsoleColor.Gray ); ConsoleHelper.Write($"{damage:F1}", ConsoleColor.Red); ConsoleHelper.WriteLine(" урона", ConsoleColor.Gray); } public void LogDeath(IUnit unit) { ConsoleHelper.WriteLine($"{N(unit)} погиб!", ConsoleColor.DarkRed); } public void LogArrowShot(IUnit archer, int archerPos, IUnit target, int targetPos, double damage) { ConsoleHelper.Write( $"{N(archer)} (поз {archerPos}) стреляет по {N(target)} (поз {targetPos}) и наносит ", ConsoleColor.Gray ); ConsoleHelper.Write($"{damage:F1}", ConsoleColor.Red); ConsoleHelper.WriteLine(" урона", ConsoleColor.Gray); } public void LogOutOfRange(IUnit archer, int archerPos, int range) { ConsoleHelper.WriteLine( $"{N(archer)} (поз {archerPos}) не может достать — Range={range}", ConsoleColor.Gray ); } public void LogHeal(IUnit healer, int healerPos, IUnit target, int targetPos, double amount) { ConsoleHelper.Write( $"{N(healer)} (поз {healerPos}) лечит {N(target)} (поз {targetPos}) на ", ConsoleColor.Gray ); ConsoleHelper.Write($"{amount:F1}", ConsoleColor.Green); ConsoleHelper.WriteLine(" HP", ConsoleColor.Gray); } public void LogHealTargetAlreadyFull(IUnit healer, int healerPos, IUnit target, int targetPos) { ConsoleHelper.WriteLine( $"{N(healer)} (поз {healerPos}) — {N(target)} (поз {targetPos}) уже с полным HP, лечение не требуется", ConsoleColor.Gray ); } public void LogNoHealTarget(IUnit healer, int healerPos) { ConsoleHelper.WriteLine( $"{N(healer)} (поз {healerPos}) — некого лечить в радиусе", ConsoleColor.Gray ); } public void LogClone(IUnit wizard, int wizardPos, IUnit source, int sourcePos, IUnit clone) { ConsoleHelper.Write( $"{N(wizard)} (поз {wizardPos}) клонирует {N(source)} (поз {sourcePos}) → ", ConsoleColor.Gray ); ConsoleHelper.WriteLine($"создан {clone.GetType().Name}!", ConsoleColor.Magenta); } public void LogCloneFailed(IUnit wizard, int wizardPos, IUnit source, int sourcePos) { ConsoleHelper.WriteLine( $"{N(wizard)} (поз {wizardPos}) попытался клонировать {N(source)} (поз {sourcePos}) — неудача", ConsoleColor.DarkGray ); } public void LogCloneNone(IUnit wizard, int wizardPos) { ConsoleHelper.WriteLine( $"{N(wizard)} (поз {wizardPos}) — некого клонировать в радиусе", ConsoleColor.Gray ); } public void LogSquireNoHeavy(IUnit squire, int squireRow) { ConsoleHelper.WriteLine( $"{N(squire)} (поз {squireRow}) — нет соседнего тяжёлого в колонке", ConsoleColor.DarkGray ); } public void LogSquireBuffMiss(IUnit squire, IUnit heavy) { ConsoleHelper.WriteLine( $"{N(squire)} не удалось оснастить {N(heavy)} (неудача)", ConsoleColor.DarkGray ); } public void LogSquireBuffsSaturated(IUnit squire, IUnit heavy) { ConsoleHelper.WriteLine( $"{N(squire)} — у {N(heavy)} уже все виды снаряжения", ConsoleColor.DarkGray ); } public void LogSquireBuffApplied(IUnit squire, IUnit heavy, SquireBuffKind kind) { ConsoleHelper.Write( $"{N(squire)} снабжает {N(heavy)}: ", ConsoleColor.Gray ); ConsoleHelper.WriteLine(kind.ToString(), ConsoleColor.Magenta); } public void LogBuffStripped(IUnit heavy, SquireBuffKind kind) { ConsoleHelper.WriteLine( $" с {N(heavy)} сорвано: {kind}", ConsoleColor.DarkYellow ); } } }