♻️ Implemented FightersFormation to keep track of the fight entered state of the fighters
This commit is contained in:
@@ -6,22 +6,14 @@ namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public static class FightUtils
|
||||
{
|
||||
public static int GetEnteredAmount(this FightWorld.FighterGroup self)
|
||||
public static IEnumerable<FightWorld.Fighter> WhereIsAlive(this IEnumerable<FightWorld.Fighter> self)
|
||||
{
|
||||
return self.enemies.Count(e => e.IsAlive() && e.entered);
|
||||
return self.Where(e => e.IsAlive());
|
||||
}
|
||||
|
||||
public static IEnumerable<FightWorld.Fighter> GetUptoUnenteredFighters(
|
||||
this FightWorld.FighterGroup self,
|
||||
int maxFighters)
|
||||
|
||||
public static IEnumerable<FightWorld.Fighter> WhereIsNotInFormation(this IEnumerable<FightWorld.Fighter> self, FighterFormation formation)
|
||||
{
|
||||
if (maxFighters <= self.enemies.Count)
|
||||
return self.enemies
|
||||
.Where(e => !e.entered && e.IsAlive());
|
||||
|
||||
return self.enemies
|
||||
.Where(e => !e.entered && e.IsAlive())
|
||||
.Take(maxFighters);
|
||||
return self.Where(e => !e.IsInFormation(formation));
|
||||
}
|
||||
|
||||
public static bool IsAlive(this FightWorld.Fighter self)
|
||||
@@ -43,9 +35,14 @@ public static class FightUtils
|
||||
{
|
||||
self.health = self.GetHealth() + addHealth;
|
||||
}
|
||||
|
||||
public static bool IsInFormation(this FightWorld.Fighter self, FighterFormation formation)
|
||||
{
|
||||
return formation.ContainsFighter(self);
|
||||
}
|
||||
|
||||
public static bool AreAllDead(this FightWorld.FighterGroup self)
|
||||
{
|
||||
return self.enemies.All(e => e.IsDead());
|
||||
return self.fighters.All(e => e.IsDead());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user