private List <Field> GetAllDoubles() { var list = _dBoard.GetFieldsByType(FieldEnum.Double).ToList(); list.Add(_dBoard.GetDoubleBull()); return(list); }
private Field GetFieldToCheckNumber(int leftScore, int leftDarts) { var doubleBull = this.dartBoard.GetDoubleBull(); if (leftScore == 50 && leftDarts == 1) { return(doubleBull); } var prioList = new List <List <Field> > { new List <Field>(), new List <Field>(), new List <Field>(), new List <Field>() }; var typeList = new List <FieldEnum> { FieldEnum.SingleOut, FieldEnum.SingleBull, FieldEnum.Double, FieldEnum.Triple }; foreach (var type in typeList) { var selectedFields = dartBoard.GetFieldsByType(type).ToList(); if (type == FieldEnum.Triple) { selectedFields.Add(doubleBull); } foreach (var field in selectedFields) { var doubleField = GetDoubleField(leftScore - field.Value); if (doubleField == null) { if (leftDarts == 2 && leftScore - field.Value == 50) { prioList[GetPrio(doubleBull)].Add(field); } continue; } prioList[GetPrio(doubleField)].Add(field); } foreach (var list in prioList) { if (list.Count > 0) { return(list.First(x => list.Max(y => y.Value) == x.Value)); } } } return(playerHand.Score19 ? dartBoard.GetTripleField(57) : dartBoard.GetTripleField(60)); }