public static void ResolveTriggers(TriggerTypes triggerType, Action callBack = null) { if (callBack != null) { Console.Write(triggerType.ToString(), LogTypes.Triggers, true, "yellow"); } else { Console.Write(triggerType + " is resolved again", LogTypes.Triggers, false, "yellow"); } if (triggerType == TriggerTypes.OnDamageIsDealt && callBack != null) { DamageNumbers.UpdateSavedHP(); } StackLevel currentLevel = GetCurrentLevel(); if (currentLevel == null || currentLevel.IsActive) { CreateNewLevelOfStack(triggerType, callBack); currentLevel = GetCurrentLevel(); } if (!currentLevel.IsActive) { SetStackLevelCallBack(callBack); List <Trigger> currentTriggersList = currentLevel.GetTriggersByPlayer(Phases.PlayerWithInitiative); Players.PlayerNo currentPlayer = (currentTriggersList.Count > 0) ? Phases.PlayerWithInitiative : Roster.AnotherPlayer(Phases.PlayerWithInitiative); currentTriggersList = currentLevel.GetTriggersByPlayer(currentPlayer); if (currentTriggersList.Count != 0) { currentLevel.IsActive = true; if ((currentTriggersList.Count == 1) || (IsAllSkippable(currentTriggersList))) { FireTrigger(currentTriggersList[0]); } else { RunDecisionSubPhase(); } } else { if (triggerType == TriggerTypes.OnDamageIsDealt) { DamageNumbers.ShowChangedHP(); } DoCallBack(); } } }
public static void ResolveTriggers(TriggerTypes triggerType, Action callBack = null) { if (DebugManager.DebugTriggers) { Debug.Log("Triggers are resolved: " + triggerType); } if (triggerType == TriggerTypes.OnDamageIsDealt && callBack != null) { DamageNumbers.UpdateSavedHP(); } StackLevel currentLevel = GetCurrentLevel(); if (currentLevel == null || currentLevel.IsActive) { CreateNewLevelOfStack(callBack); currentLevel = GetCurrentLevel(); } if (!currentLevel.IsActive) { SetStackLevelCallBack(callBack); List <Trigger> currentTriggersList = currentLevel.GetTriggersByPlayer(Phases.PlayerWithInitiative); Players.PlayerNo currentPlayer = (currentTriggersList.Count > 0) ? Phases.PlayerWithInitiative : Roster.AnotherPlayer(Phases.PlayerWithInitiative); currentTriggersList = currentLevel.GetTriggersByPlayer(currentPlayer); if (currentTriggersList.Count != 0) { currentLevel.IsActive = true; if ((currentTriggersList.Count == 1) || (IsAllSkippable(currentTriggersList))) { FireTrigger(currentTriggersList[0]); } else { RunDecisionSubPhase(); } } else { if (triggerType == TriggerTypes.OnDamageIsDealt) { DamageNumbers.ShowChangedHP(); } DoCallBack(); } } }