Exemplo n.º 1
0
        public void TestSetOffGridFieldValuesToNotWater()
        {
            var grid = new BimaruGrid(3, 4);

            foreach (var p in GetSomeOffGridPoints(grid))
            {
                foreach (var v in BimaruValues.AllBimaruValues().Where(v => v != BimaruValue.WATER))
                {
                    Assert.ThrowsException <InvalidFieldValueChange>(() => grid[p] = v);
                }
            }
        }
Exemplo n.º 2
0
        public IEnumerable <FieldsToChange <BimaruValue> > GetChangeTrials(IGame game)
        {
            var notFullyDetPoint = GetNotFullyDeterminedPoint(game);

            if (notFullyDetPoint == null)
            {
                yield break;
            }

            var value = game.Grid[notFullyDetPoint.Value];

            bool isDeterminedAndCompatible(BimaruValue newValue) =>
            newValue.IsFullyDetermined() &&
            value.IsCompatibleChangeTo(newValue);

            foreach (BimaruValue newValue in BimaruValues.AllBimaruValues().Where(isDeterminedAndCompatible))
            {
                yield return(new FieldsToChange <BimaruValue>(notFullyDetPoint.Value, newValue));
            }
        }
Exemplo n.º 3
0
        public ShipLocation(GridPoint startPoint, Direction direction, int shipLength)
        {
            var shipFields = BimaruValues.FieldValuesOfShip(direction, shipLength);

            Changes = new FieldsToChange <BimaruValue>(startPoint, direction, shipFields);
        }