Skip to content

Commit

Permalink
MVC pattern where M is GameState, V is GUI and C is BattleshipEngine
Browse files Browse the repository at this point in the history
Now I need to decouple the GUI which is tightly linked to M
  • Loading branch information
Aleksandar authored and Aleksandar committed Dec 26, 2013
1 parent f9307b3 commit 19018ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Binary file modified battleships/bin/Battleships/BattleShipsEngine.class
Binary file not shown.
26 changes: 13 additions & 13 deletions battleships/src/Battleships/BattleShipsEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void startGame() {
}
private void determineIfShotSunkAShip(GUI gui, Agent smith) {
System.out.println("Player Home board \n" + gameState.playerHomeGrid.toString());
if(gameState.playerHomeGrid.isMineSunk()&& !gui.getPaintMineSunk())
if(gameState.playerHomeGrid.isMineSunk()&& !gui.paintMineSunk)
{
for (int i = 0; i < 10; i++) //change these to ROWS to use the default
{
Expand All @@ -145,43 +145,43 @@ private void determineIfShotSunkAShip(GUI gui, Agent smith) {
if(gameState.playerHomeGrid.getGridVal(i,j) == -6)
{
smith.setSunk(i,j);
gui.setPaintMineSunk();
gui.paintMineSunk = true;
}
}
}
}

if(gameState.playerHomeGrid.isDestSunk() && !gui.getPaintDestSunk())
if(gameState.playerHomeGrid.isDestSunk() && !gui.paintDestSunk)
{
for (int i = 0; i < 10; i++) //change these to ROWS to use the default
{
for (int j = 0; j < 10; j++)//change this to CoLumns for default
{
if(gui.data.gameState.playerHomeGrid.getGridVal(i,j) ==-1)
if(gameState.playerHomeGrid.getGridVal(i,j) == -1)
{
smith.setSunk(i,j);
gui.setPaintDestSunk();
gui.paintDestSunk = true;
}
}
}
}

if(gameState.playerHomeGrid.isSubSunk() && !gui.getPaintSubSunk())
if(gameState.playerHomeGrid.isSubSunk() && !gui.paintSubSunk)
{
for (int i = 0; i < 10; i++) //change these to ROWS to use the default
{
for (int j = 0; j < 10; j++)//change this to CoLumns for default
{
if(gui.data.gameState.playerHomeGrid.getGridVal(i,j) ==-5)
if(gameState.playerHomeGrid.getGridVal(i,j) == -5)
{
smith.setSunk(i,j);
gui.setPaintSubSunk();
gui.paintSubSunk = true;
}
}
}
}

if(gameState.playerHomeGrid.isBattleSunk() && !gui.getPaintBattleSunk())
if(gameState.playerHomeGrid.isBattleSunk() && !gui.paintBattleSunk)
{
for (int i = 0; i < 10; i++) //change these to ROWS to use the default
{
Expand All @@ -190,22 +190,22 @@ private void determineIfShotSunkAShip(GUI gui, Agent smith) {
if(gameState.playerHomeGrid.getGridVal(i,j) == -4)
{
smith.setSunk(i,j);
gui.setPaintBattleSunk();
gui.paintBattleSunk = true;
}
}
}
}

if(gameState.playerHomeGrid.isAirSunk() && !gui.getPaintAirSunk())
if(gameState.playerHomeGrid.isAirSunk() && !gui.paintAirSunk)
{
for (int i = 0; i < 10; i++) //change these to ROWS to use the default
{
for (int j = 0; j < 10; j++)//change this to CoLumns for default
{
if(gui.data.gameState.playerHomeGrid.getGridVal(i,j) ==-3)
if(gameState.playerHomeGrid.getGridVal(i,j) ==-3)
{
smith.setSunk(i,j);
gui.setPaintAirSunk();
gui.paintAirSunk = true;
}
}
}
Expand Down

0 comments on commit 19018ce

Please sign in to comment.