public SodaScriptTrigger(SodaScriptTarget inTarget, SodaScriptCondition inCondition, SodaScriptComparison inComparison = SodaScriptComparison.EQUALS, string inCompareValue = "") { target = inTarget; condition = inCondition; comparison = inComparison; compareValue = inCompareValue; }
public void SetSecondaryCondition(SodaScriptCondition inCondition, SodaScriptComparison inComparison = SodaScriptComparison.EQUALS, string inCompareValue = "") { hasSecondaryCondition = true; secondaryCondition = inCondition; secondaryComparison = inComparison; secondaryCompareValue = inCompareValue; }
public SodaScriptTrigger AddTrigger(SodaScriptTarget inTarget, SodaScriptCondition inCondition, SodaScriptComparison inComparison = SodaScriptComparison.EQUALS, string inCompareValue = "") { SodaScriptTrigger t = new SodaScriptTrigger(inTarget, inCondition, inComparison, inCompareValue); triggers.Add(t); return(t); }
public static bool ConditionRequiresAComparison(SodaScriptCondition inCondition) { for (int i = 0; i < conditionsThatRequireAComparison.Length; i++) { if (conditionsThatRequireAComparison[i] == inCondition) { return(true); } } return(false); }
//COMPARISONS public static SodaScriptComparison[] GetAllowedComparisonsForCondition(SodaScriptCondition inCondition) { if (inCondition == SodaScriptCondition.STATUS) { return(justEqualsComparison); } else if (ConditionUsesPercentageCompareValues(inCondition)) { return(greaterOrLessThanComparison); } else { return(allComparisons); } }
//return true if this evals true for any target provided private void EvalCondition(SodaScriptCondition inCondition, SodaScriptComparison inComparison, string inCompareValue, List <CharacterData> inTargets) { CharacterData targ; EnemyCharacterData ecd; PlayerCharacterData pcd; culledTargets.Clear(); if (inCondition == SodaScriptCondition.WEAKEST) { culledTargets.Add(GetLowestHpPercentTarget(inTargets)); } else if (inCondition == SodaScriptCondition.TEAM_ALIVE) { targ = inTargets[0]; CharacterTeam team = targ.IsInFaction(Faction.PLAYER) ? adventure.playerTeam : adventure.enemyTeam; if (EvalNumericComparison(team.GetNumLivingMembers(), int.Parse(inCompareValue), inComparison)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.TEAM_HP) { targ = inTargets[0]; CharacterTeam team = targ.IsInFaction(Faction.PLAYER) ? adventure.playerTeam : adventure.enemyTeam; if (EvalNumericComparison(team.GetTeamHPPercent(), int.Parse(inCompareValue), inComparison)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.TEAM_NUM_BACK_TURNED) { targ = inTargets[0]; CharacterTeam team = targ.IsInFaction(Faction.PLAYER) ? adventure.playerTeam : adventure.enemyTeam; int numBackTurned = team.GetNumMembersWithBackTurnedTo(activeCharacter); if (EvalNumericComparison(numBackTurned, int.Parse(inCompareValue), inComparison)) { culledTargets.Add(targ); } } else { for (int i = 0; i < inTargets.Count; i++) { targ = inTargets[i]; if (inCondition == SodaScriptCondition.HP) { if (EvalNumericComparison(targ.GetHpPercent(), int.Parse(inCompareValue), inComparison)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.MP) { if (EvalNumericComparison(targ.GetMpPercent(), int.Parse(inCompareValue), inComparison)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.POSITION) { if (EvalNumericComparison(targ.originalOrderInTeam + 1, int.Parse(inCompareValue), inComparison)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.RANK) { bool foundRank = false; EnemyRank enemyRank = EnemyRank.NORM; EnemyRank parsedRank = (EnemyRank)Enum.Parse(typeof(EnemyRank), inCompareValue); if (targ is EnemyCharacterData) { foundRank = true; ecd = (EnemyCharacterData)targ; enemyRank = ecd.rank; } else if (targ.id == CharId.JANITOR) { foundRank = true; enemyRank = EnemyRank.BOSS; } if (foundRank) { if (EvalNumericComparison((int)enemyRank, (int)parsedRank, inComparison)) { culledTargets.Add(targ); } } } else if (inCondition == SodaScriptCondition.IS_ORE) { if (targ.isOre) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.ISNT_ORE) { if (!targ.isOre) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.IS_JANITOR) { if (targ.id == CharId.JANITOR) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.ISNT_JANITOR) { if (targ.id != CharId.JANITOR) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.BACK_IS_TURNED) { if (!targ.isOre && targ.BackIsTurnedTo(activeCharacter)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.BACK_ISNT_TURNED) { if (!targ.isOre && !targ.BackIsTurnedTo(activeCharacter)) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.HAS_ESSENCE) { if (targ.hasEssence) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.NO_ESSENCE) { if (!targ.hasEssence) { culledTargets.Add(targ); } } else if (inCondition == SodaScriptCondition.STATUS) { StatusEffectCategory parsedCategory = (StatusEffectCategory)Enum.Parse(typeof(StatusEffectCategory), inCompareValue); if (parsedCategory == StatusEffectCategory.POSITIVE) { bool hasPos = targ.HasPostiveStatusEffect(); if ((inComparison == SodaScriptComparison.EQUALS && hasPos) || (inComparison == SodaScriptComparison.NOT_EQUALS && !hasPos)) { culledTargets.Add(targ); } } else if (parsedCategory == StatusEffectCategory.NEGATIVE) { bool hasNeg = targ.HasNegativeStatusEffect(); if ((inComparison == SodaScriptComparison.EQUALS && hasNeg) || (inComparison == SodaScriptComparison.NOT_EQUALS && !hasNeg)) { culledTargets.Add(targ); } } else if (parsedCategory == StatusEffectCategory.NONE) { bool hasAny = targ.HasAnyStatusEffect(); if ((inComparison == SodaScriptComparison.EQUALS && !hasAny) || (inComparison == SodaScriptComparison.NOT_EQUALS && hasAny)) { culledTargets.Add(targ); } } } else { throw new Exception("Trigger condition " + inCondition + " is not supported as a condition"); } } //do a final list sort based on the condition? if (inCondition == SodaScriptCondition.HP) { if (inComparison == SodaScriptComparison.GREATER_THAN) { culledTargets = culledTargets.OrderByDescending(t => t.GetHpPercent()).ToList <CharacterData>(); } else if (inComparison == SodaScriptComparison.LESS_THAN) { culledTargets = culledTargets.OrderBy(t => t.GetHpPercent()).ToList <CharacterData>(); } } else if (inCondition == SodaScriptCondition.MP) { if (inComparison == SodaScriptComparison.GREATER_THAN) { culledTargets = culledTargets.OrderByDescending(t => t.GetMpPercent()).ToList <CharacterData>(); } else if (inComparison == SodaScriptComparison.LESS_THAN) { culledTargets = culledTargets.OrderBy(t => t.GetMpPercent()).ToList <CharacterData>(); } } } potentialTargets.Clear(); potentialTargets.AddRange(culledTargets); }
public static string GetDefaultCompareValueForCondition(SodaScriptCondition inCondition) { return(GetComparisonValuesForCondition(inCondition)[0]); }
public static bool IsAllowedComparisonValueForCondition(string inValue, SodaScriptCondition inCondition) { string[] allowedValues = GetComparisonValuesForCondition(inCondition); return(allowedValues.Contains(inValue)); }
//COMPARE VALUES public static string[] GetComparisonValuesForCondition(SodaScriptCondition inCondition) { return(comparisonValuesForCondition[inCondition]); }
public static SodaScriptComparison GetDefaultComparisonForCondition(SodaScriptCondition inCondition) { return(GetAllowedComparisonsForCondition(inCondition)[0]); }
public static bool IsAllowedComparisonForCondition(SodaScriptComparison inComparison, SodaScriptCondition inCondition) { SodaScriptComparison[] allowedComparisons = GetAllowedComparisonsForCondition(inCondition); return(allowedComparisons.Contains(inComparison)); }
public static bool ConditionUsesPercentageCompareValues(SodaScriptCondition inCondition) { return(inCondition == SodaScriptCondition.HP || inCondition == SodaScriptCondition.MP || inCondition == SodaScriptCondition.TEAM_HP); }
public static bool IsAllowedConditionForTarget(SodaScriptCondition inCondition, SodaScriptTarget inTarget) { SodaScriptCondition[] allowedConditions = GetAllowedConditionsForTarget(inTarget); return(allowedConditions.Contains(inCondition)); }