/
romashov.z
/
PPAGame
Обзор
Документация
Войти
/
romashov.z
/
PPAGame
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
gameUI-clean
PPAGameUI/GuiBattleLogger.cs
61 строка
3 KB
Artemiy Ivanov
PPAGame + PPAGameUI Avalonia UI
02 июн 2026, 13:42
02 июн 2026, 13:42
c122c02
Код
Авторство
О чём код?
using System; using ArmyBattleGame; namespace PPAGameUI; public enum LogMode { Full, DeathsOnly, None } public class GuiBattleLogger : IBattleLogger { private readonly LogMode _mode; public event Action<string>? Logged; public GuiBattleLogger(LogMode mode = LogMode.Full) => _mode = mode; private void Log(string msg) => Logged?.Invoke(msg); public void LogAttack(IUnit attacker, IUnit target, double damage) { if (_mode == LogMode.Full) Log($"⚔️ {attacker.DisplayName} → {target.DisplayName} −{damage:F0} HP"); } public void LogDeath(IUnit unit) { if (_mode != LogMode.None) Log($"💀 {unit.DisplayName} погиб"); } public void LogArrowShot(IUnit archer, int archerPos, IUnit target, int targetPos, double damage) { if (_mode == LogMode.Full) Log($"🏹 {archer.DisplayName} [р{archerPos + 1}] → {target.DisplayName} [р{targetPos + 1}] −{damage:F0} HP"); } public void LogOutOfRange(IUnit archer, int archerPos, int range) { if (_mode == LogMode.Full) Log($"🏹 {archer.DisplayName} вне досягаемости (R={range})"); } public void LogHeal(IUnit healer, int healerPos, IUnit target, int targetPos, double amount) { if (_mode == LogMode.Full) Log($"💚 {healer.DisplayName} [р{healerPos + 1}] → {target.DisplayName} [р{targetPos + 1}] +{amount:F0} HP"); } public void LogHealTargetAlreadyFull(IUnit healer, int healerPos, IUnit target, int targetPos) { if (_mode == LogMode.Full) Log($"💚 {healer.DisplayName} — {target.DisplayName} уже с полным HP"); } public void LogNoHealTarget(IUnit healer, int healerPos) { if (_mode == LogMode.Full) Log($"💚 {healer.DisplayName} — некого лечить"); } public void LogClone(IUnit wizard, int wizardPos, IUnit source, int sourcePos, IUnit clone) { if (_mode == LogMode.Full) Log($"🔮 {wizard.DisplayName} клонирует {source.DisplayName} → +{clone.GetType().Name}"); } public void LogCloneFailed(IUnit wizard, int wizardPos, IUnit source, int sourcePos) { if (_mode == LogMode.Full) Log($"🔮 {wizard.DisplayName} — клонирование {source.DisplayName} не удалось"); } public void LogCloneNone(IUnit wizard, int wizardPos) { if (_mode == LogMode.Full) Log($"🔮 {wizard.DisplayName} — некого клонировать"); } public void LogSquireNoHeavy(IUnit squire, int squireRow) { if (_mode == LogMode.Full) Log($"🗡️ {squire.DisplayName} — нет соседнего тяжёлого"); } public void LogSquireBuffMiss(IUnit squire, IUnit heavy) { if (_mode == LogMode.Full) Log($"🗡️ {squire.DisplayName} → {heavy.DisplayName}: оснащение не удалось"); } public void LogSquireBuffsSaturated(IUnit squire, IUnit heavy) { if (_mode == LogMode.Full) Log($"🗡️ {squire.DisplayName} — {heavy.DisplayName} уже полностью оснащён"); } public void LogSquireBuffApplied(IUnit squire, IUnit heavy, SquireBuffKind kind) { if (_mode == LogMode.Full) Log($"🗡️ {squire.DisplayName} оснащает {heavy.DisplayName}: +{kind}"); } public void LogBuffStripped(IUnit heavy, SquireBuffKind kind) { if (_mode == LogMode.Full) Log($" ↘ {heavy.DisplayName} потерял {kind}"); } }