/
romashov.z
/
PPAGame
Обзор
Документация
Войти
/
romashov.z
/
PPAGame
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Units/LiteUnit.cs
65 строк
2 KB
Zakhar Romashov
Добавили логику с бафами
29 апр 2026, 13:06
29 апр 2026, 13:06
7623dfb
Код
Авторство
О чём код?
using System; namespace ArmyBattleGame { class LiteUnit : BaseUnit, ICanBeHealed, ICanBeCloned, ISpecialAbility { public static readonly double BaseCost = 80 + 40 * 2 + 20 * 0.5; public LiteUnit() { SetHealth(80); Damage = 40; Shield = 20; Cost = BaseCost; } public IUnit Clone() { var clone = new LiteUnit(); clone.Health = Health; return clone; } public void UseSpecial(BattleContext ctx, UnitPosition attackerPos) { if (!IsAlive) return; if (!SquireTargeting.TryGetAdjacentHeavy(ctx.OwnArmy, attackerPos, out var heavyPos, out var heavy)) { ctx.Logger.LogSquireNoHeavy(this, attackerPos.Row); return; } if (Random.Shared.NextDouble() >= SquireTargeting.ApplyBuffChance) { ctx.Logger.LogSquireBuffMiss(this, heavy); return; } SquireBuffKind? kind = SquireTargeting.PickRandomMissingBuff(heavy); if (kind == null) { ctx.Logger.LogSquireBuffsSaturated(this, heavy); return; } if (heavy is HeavyUnit hu) { var wrapped = new BuffedHeavyUnit(hu, kind.Value); ctx.OwnArmy.SetAt(heavyPos.Row, heavyPos.Col, wrapped); ctx.Logger.LogSquireBuffApplied(this, wrapped, kind.Value); } else if (heavy is BuffedHeavyUnit bh) { if (!bh.TryAddBuff(kind.Value)) { ctx.Logger.LogSquireBuffsSaturated(this, bh); return; } ctx.Logger.LogSquireBuffApplied(this, bh, kind.Value); } } } }