// to be called after every phase public Delta[] GetCleanUpDeltas(Damage.Type?phase) { List <Delta> deltas = new List <Delta>(); // clean units for (int l = 0; l < Lanes.Length; l++) { Lane lane = Lanes[l]; for (int side = 0; side < lane.Units.GetLength(0); side++) { for (int pos = 0; pos < lane.Units.GetLength(1); pos++) { Unit u = lane.Units[side, pos]; if (u != null && u.HealthPoints <= 0) { deltas.AddRange(u.OnDeathBeforeRemove(l, side, pos, this, phase)); deltas.AddRange(lane.GetDeathDeltas(side, pos, this)); deltas.AddRange(Players[side].Discard.GetDiscardDeltas(new Card[] { u.Card })); } } } } // clean towers -> player lives for (int l = 0; l < Lanes.Length; l++) { Lane lane = Lanes[l]; for (int i = 0; i < lane.Towers.Length; i++) { if (lane.Towers[i].HP <= 0) { deltas.AddRange(Players[i].LivesPool.GetSubtractDeltas(1)); deltas.AddRange(lane.Towers[i].GetReviveDeltas()); deltas.AddRange(Players[i].DeployPhasesPool.GetAddDeltas(1)); } } } return(deltas.ToArray()); }