private void AddRuleBreaks(int illegalPlayerId, Lineup.Group group) { for (int i = 0; i < group.Positions.Count; i++) { var pos = group.Positions[i]; if (illegalPlayerId == pos.Player.Member.Id) { _ruleBreaks.Add(new RuleBreak((group.Type, i), 0, "Player can not play twice in same position type!")); } if (Lineup.PositionType.Double.HasFlag(group.Type) && illegalPlayerId == pos.OtherPlayer.Member.Id) { _ruleBreaks.Add(new RuleBreak((group.Type, i), 1, "Player can not play twice in same position type!")); } } }
//Check if any position under a certain position is not empty. //If so, add rulebreak. private bool CheckBelowPositions(Lineup.Group group, int i) { bool wasSuccessful = true; for (int j = i; j < group.Positions.Count; j++) { if (!CheckPositionNull(group.Positions[j], group.Type)) { wasSuccessful = false; _ruleBreaks.Add(new RuleBreak((group.Type, j), 0, "Position can not be placed below an empty position!")); if (Lineup.PositionType.Double.HasFlag(group.Type)) { _ruleBreaks.Add(new RuleBreak((group.Type, j), 1, "Position can not be placed below an empty position!")); } } } return(wasSuccessful); }