Example #1
0
 /// <summary>
 /// Searches through the entire more to see if there are any moves left. If so, 
 /// returns true and the location of the move. 
 /// </summary>
 /// <param name="rowHint">The row of the token that can be switched to make a move. </param>
 /// <param name="colHint">The column of the token that can be switched to make a move. </param>
 /// <returns>True if a move is possible, false otherwise. </returns>
 public virtual bool areMovesLeft(IBasicPokemonToken[,] pokemonGrid, out int rowHint, out int colHint)
 {
     PokemonGrid = pokemonGrid;
     NewPokemonGrid = pokemonGrid;
     bool isMove = false;
     for (int row = 0; row < gridSize; row++)
     {
         for (int col = 0; col < gridSize - 1; col++)
         {
             isMove = testForMove(row, col);
             if (isMove)
             {
                 rowHint = row;
                 colHint = col;
                 return true;
             }
             GridOperations.invertGrid(_pokemonGrid);
             GridOperations.invertGrid(_newPokemonGrid);
             isMove = testForMove(row, col);
             GridOperations.invertGrid(_pokemonGrid);
             GridOperations.invertGrid(_newPokemonGrid);
             if (isMove)
             {
                 rowHint = col;
                 colHint = row;
                 return true;
             }
         }
     }
     rowHint = -1;
     colHint = -1;
     return false;
 }
 public void InvertGrid_NoError_GridInverted()
 {
     IBasicPokemonToken[,] pokemonToInvert = new IBasicPokemonToken[3, 3];
     pokemonToInvert[0, 0] = new BulbasaurToken();
     pokemonToInvert[0, 1] = new BulbasaurToken();
     pokemonToInvert[0, 2] = new BulbasaurToken();
     pokemonToInvert[1, 0] = new CharmanderToken();
     pokemonToInvert[1, 1] = new CharmanderToken();
     pokemonToInvert[1, 2] = new CharmanderToken();
     pokemonToInvert[2, 0] = new BulbasaurToken();
     pokemonToInvert[2, 1] = new BulbasaurToken();
     pokemonToInvert[2, 2] = new BulbasaurToken();
     IBasicPokemonToken[,] invertedPokemon = new IBasicPokemonToken[3, 3];
     invertedPokemon[0, 0] = new BulbasaurToken();
     invertedPokemon[0, 1] = new CharmanderToken();
     invertedPokemon[0, 2] = new BulbasaurToken();
     invertedPokemon[1, 0] = new BulbasaurToken();
     invertedPokemon[1, 1] = new CharmanderToken();
     invertedPokemon[1, 2] = new BulbasaurToken();
     invertedPokemon[2, 0] = new BulbasaurToken();
     invertedPokemon[2, 1] = new CharmanderToken();
     invertedPokemon[2, 2] = new BulbasaurToken();
     GridOperations.invertGrid(pokemonToInvert);
     Assert.AreEqual(pokemonToInvert, invertedPokemon);
 }
Example #3
0
 /// <summary>
 /// Copies a 2-d array of IBasicPokemonTokens to another 2-d array. 
 /// </summary>
 /// <param name="gridToCopy">The 2-d array from which to copy. </param>
 /// <param name="gridDestination">The 2-d array to copy to. </param>
 public static void copyGrid(IBasicPokemonToken[,] gridToCopy, IBasicPokemonToken[,] gridDestination)
 {
     int rowLength = gridToCopy.GetLength(0);
     int colLength = gridToCopy.GetLength(1);
     if (rowLength != gridDestination.GetLength(0) || colLength != gridDestination.GetLength(1))
     {
         throw new ArithmeticException("Dimensions of grid did not match dimensions of destination grid");
     }
     else
     {
         for (int row = 0; row < rowLength; row++)
         {
             for (int col = 0; col < colLength; col++)
             {
                 gridDestination[row, col] = gridToCopy[row, col];
             }
         }
     }
 }
Example #4
0
 /// <summary>
 /// Inverts a square 2-dimensional array of IBasicPokemonTokens. 
 /// </summary>
 /// <param name="gridToInvert">The 2-d array to invert. </param>
 public static void invertGrid(IBasicPokemonToken[,] gridToInvert)
 {
     int rowLength = gridToInvert.GetLength(0);
     int colLength = gridToInvert.GetLength(1);
     if (rowLength != colLength)
     {
         throw new ArithmeticException("Grid is not square.");
     }
     else
     {
         IBasicPokemonToken[,] invertedGrid = new IBasicPokemonToken[rowLength, colLength];
         for (int row = 0; row < rowLength; row++)
         {
             for (int col = 0; col < colLength; col++)
             {
                 invertedGrid[row, col] = gridToInvert[col, row];
             }
         }
         copyGrid(invertedGrid, gridToInvert);
     }
 }
Example #5
0
 public MakingPlayEventArgs(IBasicPokemonToken[,] pokemonGrid)
 {
     PokemonGrid = pokemonGrid;
 }
Example #6
0
 private IBasicPokemonToken[,] generateStableGrid()
 {
     int tokenToAdd = 0;
     IBasicPokemonToken[,] pokemonGrid = new IBasicPokemonToken[PokemonBoard.gridSize, PokemonBoard.gridSize];
     for (int row = 0; row < PokemonBoard.gridSize; row++)
     {
         for (int col = 0; col < PokemonBoard.gridSize; col++)
         {
             pokemonGrid[row, col] = (PokemonToken)Activator.CreateInstance(PokemonBoard.TokenList[tokenToAdd++ % 6 + 1]);
         }
     }
     return pokemonGrid;
 }
 public static ImageBrush getImageBrush(IBasicPokemonToken pokemon)
 {
     return _pictureDictionary[pokemon.GetType()];
 }
Example #8
0
 /// <summary>
 /// Checks to see if a PokemonToken is in the same evolution chain as another PokemonToken
 /// </summary>
 public bool isSameSpecies(IBasicPokemonToken pokemonToken)
 {
     return this.Species() == pokemonToken.Species();
 }
Example #9
0
 /// <summary>
 /// Begins a play. 
 /// </summary>
 /// <param name="row1">The row of the first location on the grid. </param>
 /// <param name="col1">The column of the first location on the grid. </param>
 /// <param name="row2">The row of the second location on the grid. </param>
 /// <param name="col2">The column of the second location on the grid. </param>
 /// <returns>True if a play was made, false otherwise. </returns>
 public virtual void tryPlay(IBasicPokemonToken[,] pokemonGrid, int row1, int col1, int row2, int col2)
 {
     if (GridOperations.arePiecesAdjacent(row1, col1, row2, col2))
     {
         PokemonGrid = pokemonGrid;
         NewPokemonGrid = pokemonGrid;
         makePlay(row1, col1, row2, col2);
         updateBoard();
         OnEndingPlay();
     }
 }
Example #10
0
 /// <summary>
 /// Searches through the entire board and marks any tokens in the same evolution chain
 /// as the given IBasicPokemonToken as null. 
 /// </summary>
 /// <param name="pokemon">The pokemon for which all tokens of the same species will be marked null. </param>
 public virtual void markAllTokensOfSameTypeAsNull(IBasicPokemonToken pokemon)
 {
     int numTokensMarkedNull = 0;
     for (int row = 0; row < gridSize; row++)
     {
         for (int col = 0; col < gridSize; col++)
         {
             if (_pokemonGrid[row, col].isSameSpecies(pokemon))
             {
                 numTokensMarkedNull++;
                 updateToken(row, col);
             }
         }
     }
      OnPointsAdded((int)Math.Pow(numTokensMarkedNull, 2) * 10);
 }
 public void InvertGrid_GridNotSquare_ThrowArithmeticException()
 {
     IBasicPokemonToken[,] pokemonToInvert = new IBasicPokemonToken[3, 4];
     GridOperations.invertGrid(pokemonToInvert);
 }
 public void CopyGrid_GridRowsMismatched_ThrowArithmeticException()
 {
     IBasicPokemonToken[,] firstGrid = new IBasicPokemonToken[3, 3];
     IBasicPokemonToken[,] secondGrid = new IBasicPokemonToken[4, 3];
     GridOperations.copyGrid(firstGrid, secondGrid);
 }