Beispiel #1
0
        public float draw()
        {
            int   min    = (int)(_min * 10);
            int   max    = (int)(_max * 10);
            int   picked = _pickStrategy.drawBetween(min, max);
            float result = (float)picked / 10f;

            return(result);
        }
Beispiel #2
0
        public Cell drawBetweenWithExclusion(Cell min, Cell max, params Cell[] excluded)
        {
            if (min.hasNegativeIndexes() && max.hasNegativeIndexes())
            {
                return(min);
            }
            if (min.hasNegativeIndexes())
            {
                min = min.toNearestPositiveCell();
            }
            if (max.hasNegativeIndexes())
            {
                max = max.toNearestPositiveCell();
            }

            HashSet <Cell> uniqueExclusion = new HashSet <Cell>();

            foreach (Cell each in excluded)
            {
                Cell toAdd = each;
                if (each.hasNegativeIndexes())
                {
                    toAdd = toAdd.toNearestPositiveCell();
                }
                uniqueExclusion.Add(toAdd);
            }

            List <Cell> cleanedExclusions = new List <Cell>(uniqueExclusion);
            //cleanedExclusions.Remove(min);
            //cleanedExclusions.Remove(max);

            int distance = min.distance(max) - cleanedExclusions.Count;

            if (distance <= 0)
            {
                return(min);
            }

            int selectedCellPosition = _strategy.drawBetween(0, distance - 1);

            Cell[]      cells  = min.cells(max);
            List <Cell> asList = new List <Cell>(cells);

            foreach (Cell each in cleanedExclusions)
            {
                asList.Remove(each);
            }
            return(asList[selectedCellPosition]);
        }
Beispiel #3
0
 public int draw()
 {
     return(_pickStrategy.drawBetween(_min, _max));
 }