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); } } }
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)); } }
public ShipLocation(GridPoint startPoint, Direction direction, int shipLength) { var shipFields = BimaruValues.FieldValuesOfShip(direction, shipLength); Changes = new FieldsToChange <BimaruValue>(startPoint, direction, shipFields); }