Made fight fightable

This commit is contained in:
jonathan
2025-09-30 16:23:05 +02:00
parent f27dd199b8
commit 0e315396c9
42 changed files with 889 additions and 251 deletions
+18 -13
View File
@@ -5,41 +5,46 @@ namespace Babushka.scripts.CSharp.Common.Fight;
public static class FightUtils
{
public static int GetEnteredAmount(this FightWorld.EnemyGroup self)
public static int GetEnteredAmount(this FightWorld.FighterGroup self)
{
return self.enemies.Count(e => e.IsAlive() && e.entered);
}
public static bool TryGetFirstUnenteredFighter(this FightWorld.EnemyGroup self, out FightWorld.Fighter fighter)
public static IEnumerable<FightWorld.Fighter> GetUptoUnenteredFighters(
this FightWorld.FighterGroup self,
int maxFighters)
{
foreach (var f in self.enemies.Where(e=>!e.entered && e.IsAlive()))
{
fighter = f;
return true;
}
if (maxFighters <= self.enemies.Count)
return self.enemies
.Where(e => !e.entered && e.IsAlive());
fighter = null!;
return false;
return self.enemies
.Where(e => !e.entered && e.IsAlive())
.Take(maxFighters);
}
public static bool IsAlive(this FightWorld.Fighter self)
{
return self.GetHealth() >= 0;
}
public static bool IsDead(this FightWorld.Fighter self)
{
return !self.IsAlive();
}
public static int GetHealth(this FightWorld.Fighter self)
{
return self.health ?? self.maxHealth;
}
public static bool AreAllDead(this FightWorld.EnemyGroup self)
public static void AddHealth(this FightWorld.Fighter self, int addHealth)
{
self.health = self.GetHealth() + addHealth;
}
public static bool AreAllDead(this FightWorld.FighterGroup self)
{
return self.enemies.All(e => e.IsDead());
}
}