public void TestInvalidBoardHeight() { BoardDimensions dimensions = new BoardDimensions(TestDataCreator.TestBoardWidth, TestDataCreator.TestBoardHeight); dimensions.Height = null; dimensions.VerifyDimensions(); }
public void TestHasValidBoardDimension() { BoardDimensions dimensions = new BoardDimensions(TestDataCreator.TestBoardWidth, TestDataCreator.TestBoardHeight); dimensions.Width = TestDataCreator.IncorrectBoardWidth; dimensions.Height = TestDataCreator.IncorrectBoardHeight; Assert.IsFalse(dimensions.HasValidDimensions); }
public SolutionLoader(string fileName, BoardDimensions dimensions) { Guard.IsTrue(dimensions.Width * dimensions.Height * dimensions.BlockWidth * dimensions.BlockHeight != 0, "All Board dimensions must be greater than zero"); //Do not check if the file exists and has a valid format until the board is loaded (lazy approach) _fileName = fileName; _dimensions = dimensions; }
public void TestSetDimensions() { BoardDimensions dimensions = new BoardDimensions(TestDataCreator.TestBoardWidth, TestDataCreator.TestBoardHeight); Assert.AreEqual(TestDataCreator.TestBoardWidth, dimensions.Width); Assert.AreEqual(TestDataCreator.TestBoardHeight, dimensions.Height); dimensions.Width = TestDataCreator.OtherTestBoardWidth; dimensions.Height = TestDataCreator.OtherTestBoardHeight; Assert.AreEqual(TestDataCreator.OtherTestBoardWidth, dimensions.Width); Assert.AreEqual(TestDataCreator.OtherTestBoardHeight, dimensions.Height); Assert.IsTrue(dimensions.HasValidDimensions); }
public GameBoard(int width, int height, int goalAreaHeight) { Width = width; Height = height; GoalAreaHeight = goalAreaHeight; BoardDim = new BoardDimensions(Width, Height, GoalAreaHeight); Board = new Field[width, height]; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { Board[i, j] = new Field(); if (j < GoalAreaHeight || j >= (Height - GoalAreaHeight)) { Board[i, j].Type = FieldType.GoalArea; } } } }
public void SetValue(String variable, String value) { if (variable.ToLower().Trim().Equals("numtracks")) { NumTracks = Int32.Parse(value); } else if (variable.ToLower().Trim().Equals("numdrawntracks")) { NumDrawnTracks = Int32.Parse(value); } else if (variable.ToLower().Trim().Equals("rpenabletype")) { RPEnableType = (RockPowerEnableTypes)Enum.Parse(typeof(RockPowerEnableTypes), value.Trim().ToUpper()); } else if (variable.ToLower().Trim().Equals("dimensions")) { Dimensions = (BoardDimensions)Enum.Parse(typeof(BoardDimensions), value.Trim().ToUpper()); } else if (variable.ToLower().Trim().Equals("codename")) { CodeName = value; } else if (variable.ToLower().Trim().Equals("fullname")) { FullName = value; } else if (variable.ToLower().Trim().Equals("containsheldnotes")) { ContainsHeldNotes = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("canwhammy")) { CanWhammy = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("canhopo")) { CanHOPO = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("hassolos")) { HasSolos = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("pitchshifts")) { PitchShifts = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("containstext")) { ContainsText = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("typesofphrase")) { TypesOfPhrases = (PhraseType)Enum.Parse(Type.GetType("PhraseType"), value.Trim().ToUpper()); } else if (variable.ToLower().Trim().Equals("needsstrum")) { NeedsStrum = Boolean.Parse(value); } else if (variable.ToLower().Trim().Equals("maxmultiplier")) { MaxMultiplier = Int32.Parse(value); } else if (variable.ToLower().Trim().Equals("overmultiplier")) { OverMultiplier = value; } else if (variable.ToLower().Trim().Equals("bumpnotes")) { BumpNotes = 0; value = value.Trim(); while (value.Length > 0) { if (value.IndexOf(',') < 0) { BumpNotes |= (((ulong)1) << Int32.Parse(value.Trim())); break; } else { BumpNotes |= (((ulong)1) << Int32.Parse(value.Substring(0, value.IndexOf(',')).Trim())); value = value.Substring(value.IndexOf(',') + 1).Trim(); } } } else if (variable.ToLower().Trim().Equals("colors")) { value = value.Trim(); int index = 0;; while (value.Length > 0) { if (value.IndexOf(',') < 0) { break; } colorIndices[index] = Int32.Parse(value.Substring(0, value.IndexOf(',')).Trim()); value = value.Substring(value.IndexOf(',') + 1).Trim(); index++; } } else if (variable.ToLower().Trim().Equals("diffsame")) { DiffSame = Boolean.Parse(value); } else { throw new InvalidOperationException("Invalid Instrument Variable Name: " + variable); } }
private void InitBoardDimensions() { this.Dimensions = new BoardDimensions(TestBoardWidth, TestBoardHeight); Assert.AreEqual(Dimensions.Width, TestBoardWidth); Assert.AreEqual(Dimensions.Height, TestBoardHeight); }
public void TestVerification() { BoardDimensions dimensions = new BoardDimensions(TestDataCreator.IncorrectBoardWidth, TestDataCreator.IncorrectBoardHeight); dimensions.VerifyDimensions(); }
public static int ToCellAt(int x, int y, BoardDimensions boardDimensions) { Contract.Requires(boardDimensions != null); return((y * boardDimensions.Width) + x); }
public static int ToCellAt(CellCoordinates cellCoordinates, BoardDimensions boardDimensions) { return(ToCellAt(cellCoordinates.X, cellCoordinates.Y, boardDimensions)); }
public static CellCoordinates FromCellAt(int cellAt, BoardDimensions boardDimensions) { Contract.Requires(boardDimensions != null); return(new CellCoordinates(cellAt % boardDimensions.Width, cellAt / boardDimensions.Width)); }
public static bool IsInside(int cellAt, BoardDimensions boardDimensions) { Contract.Requires(boardDimensions != null); return(IsInside(cellAt, boardDimensions.Width * boardDimensions.Height)); }
public static bool IsInside(int x, int y, BoardDimensions boardDimensions) { Contract.Requires(boardDimensions != null); return(x >= 0 && x < boardDimensions.Width && y >= 0 && y < boardDimensions.Height); }
public static bool IsInside(CellCoordinates cellCoordinates, BoardDimensions boardDimensions) { return(IsInside(cellCoordinates.X, cellCoordinates.Y, boardDimensions)); }