public ObjectiveSuccessTrigger( ObjectiveSuccessLevel SuccessLevel, int Threshold, bool Invert, Objective Objective) { this.SuccessLevel = SuccessLevel; this.Threshold = Threshold; this.Invert = Invert; this.Objective = Objective; CanStopEarly = Objective.CanStopEarly(); }
public ObjectiveSuccessTrigger(ParseBlock Block) { var attributes = Block.BreakToAttributes <object>(typeof(Attribute)); SuccessLevel = (ObjectiveSuccessLevel)attributes[(int)Attribute.SUCCESS_LEVEL]; Threshold = (int)(attributes[(int)Attribute.THRESHOLD] ?? 1); Invert = (bool)(attributes[(int)Attribute.INVERT] ?? false); Objective = (Objective)attributes[(int)Attribute.OBJECTIVE]; CanStopEarly = Objective.CanStopEarly(); }
public ObjectiveSuccessLevel GetMatchResult(Army ForArmy, Match Match, bool MatchOver) { var cache = new Dictionary <Objective, int>(); ObjectiveSuccessLevel result = ObjectiveSuccessLevel.DEFEAT; foreach (ObjectiveSuccessTrigger t in Triggers) { if ((MatchOver || t.CanStopEarly) && t.IsSatisfied(ForArmy, Match, cache) && (int)t.SuccessLevel > (int)result) { result = t.SuccessLevel; } } return(result); }