Skip to content
Snippets Groups Projects
Commit d0f00d8d authored by Oscar-git97's avatar Oscar-git97
Browse files

ALl key elements added.

Missing:
- thourrogh testing
- bessere position des nbMines-Print
- schönere Visuals
parent 1fe34ef7
No related branches found
No related tags found
No related merge requests found
Showing
with 1737 additions and 1708 deletions
No preview for this file type
No preview for this file type
......@@ -13,6 +13,7 @@ org.eclipse.debug.ui.save_dirty_editors_before_launch=always
org.eclipse.debug.ui.user_view_bindings=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<viewBindings>\r\n <view id\="org.eclipse.jdt.debug.ui.DisplayView">\r\n <perspective id\="org.eclipse.debug.ui.DebugPerspective" userAction\="opened"/>\r\n </view>\r\n <view id\="org.eclipse.debug.ui.ExpressionView">\r\n <perspective id\="org.eclipse.debug.ui.DebugPerspective" userAction\="opened"/>\r\n </view>\r\n</viewBindings>\r\n
overriddenByCSS=,org.eclipse.debug.ui.MemoryHistoryKnownColor,org.eclipse.debug.ui.MemoryHistoryUnknownColor,org.eclipse.debug.ui.PREF_CHANGED_VALUE_BACKGROUND,org.eclipse.debug.ui.changedDebugElement,org.eclipse.debug.ui.consoleBackground,org.eclipse.debug.ui.errorColor,org.eclipse.debug.ui.inColor,org.eclipse.debug.ui.outColor,
pref_state_memento.org.eclipse.debug.ui.BreakpointView=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<VariablesViewMemento org.eclipse.debug.ui.SASH_DETAILS_PART\="315" org.eclipse.debug.ui.SASH_VIEW_PART\="684">\r\n<PRESENTATION_CONTEXT_PROPERTIES IMemento.internal.id\="org.eclipse.debug.ui.BreakpointView">\r\n<BOOLEAN BOOLEAN\="true" IMemento.internal.id\="org.eclipse.debug.ui.check"/>\r\n</PRESENTATION_CONTEXT_PROPERTIES>\r\n</VariablesViewMemento>
pref_state_memento.org.eclipse.debug.ui.VariableView=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<VariablesViewMemento org.eclipse.debug.ui.SASH_DETAILS_PART\="315" org.eclipse.debug.ui.SASH_VIEW_PART\="684">\r\n<COLUMN_SIZES IMemento.internal.id\="org.eclipse.debug.ui.VARIALBE_COLUMN_PRESENTATION.COL_VAR_VALUE" SIZE\="136"/>\r\n<COLUMN_SIZES IMemento.internal.id\="org.eclipse.debug.ui.VARIALBE_COLUMN_PRESENTATION.COL_VAR_NAME" SIZE\="133"/>\r\n<PRESENTATION_CONTEXT_PROPERTIES IMemento.internal.id\="org.eclipse.debug.ui.VariableView">\r\n<BOOLEAN BOOLEAN\="true" IMemento.internal.id\="PRESENTATION_SHOW_LOGICAL_STRUCTURES"/>\r\n</PRESENTATION_CONTEXT_PROPERTIES>\r\n</VariablesViewMemento>
pref_state_memento.org.eclipse.debug.ui.DebugVieworg.eclipse.debug.ui.DebugView=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<DebugViewMemento org.eclipse.debug.ui.BREADCRUMB_DROPDOWN_AUTO_EXPAND\="false"/>
pref_state_memento.org.eclipse.debug.ui.VariableView=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<VariablesViewMemento org.eclipse.debug.ui.SASH_DETAILS_PART\="315" org.eclipse.debug.ui.SASH_VIEW_PART\="684">\r\n<COLUMN_SIZES IMemento.internal.id\="org.eclipse.debug.ui.VARIALBE_COLUMN_PRESENTATION.COL_VAR_VALUE" SIZE\="136"/>\r\n<COLUMN_SIZES IMemento.internal.id\="org.eclipse.debug.ui.VARIALBE_COLUMN_PRESENTATION.COL_VAR_NAME" SIZE\="218"/>\r\n<PRESENTATION_CONTEXT_PROPERTIES IMemento.internal.id\="org.eclipse.debug.ui.VariableView">\r\n<BOOLEAN BOOLEAN\="true" IMemento.internal.id\="PRESENTATION_SHOW_LOGICAL_STRUCTURES"/>\r\n</PRESENTATION_CONTEXT_PROPERTIES>\r\n</VariablesViewMemento>
preferredDetailPanes=DefaultDetailPane,org.eclipse.jdt.debug.ui.JAVA_VARIABLE_DETAIL_PANE_VARIABLES\:org.eclipse.jdt.debug.ui.JAVA_VARIABLE_DETAIL_PANE_VARIABLES|org.eclipse.jdt.debug.ui.DETAIL_PANE_LINE_BREAKPOINT\:org.eclipse.jdt.debug.ui.DETAIL_PANE_LINE_BREAKPOINT|DefaultDetailPane\:DefaultDetailPane|
preferredTargets=default\:default|
No preview for this file type
No preview for this file type
......@@ -36,3 +36,8 @@
1731518920201 Rename package 'tp6.v2'
1731518936799 Rename package 'tp6.v3'
1731518944880 Rename package 'tp6.v33'
1731580564617 Rename field 'nbBlank'
1731587947676 Rename field 'neighbors'
1731588384721 Rename method 'countNeighbors'
1731588392288 Rename method 'addNeighbors'
1731591287742 Rename field 'nbNeighbors'
......@@ -11,7 +11,7 @@ public class Cell {
private int row;
private int column;
private boolean active;
private int nbNeighbors;
private int nbNeighboringBombes;
private boolean isFlagged;
private ArrayList<Cell> neighbors;
......@@ -24,7 +24,7 @@ public class Cell {
this.column = column;
this.active = true;
this.isFlagged = false;
this.nbNeighbors = 0;
this.nbNeighboringBombes = 0;
this.neighbors = new ArrayList<Cell>();
}
......@@ -41,7 +41,7 @@ public class Cell {
public void addNeighbor(Cell cell) {
neighbors.add(cell);
if (cell.isMine)
nbNeighbors++;
nbNeighboringBombes++;
}
public void setSelected(boolean isSelected) {
......@@ -54,10 +54,17 @@ public class Cell {
if (status && !this.isMine)
this.color = Color.DARK_GRAY;
}
public void reveal() {
this.isRevealed = true;
if(nbNeighboringBombes == 0) {
for(Cell neighbor : neighbors) {
if(!neighbor.isFlagged && !neighbor.isMine && !neighbor.isRevealed)
neighbor.reveal();
}
}
}
public boolean getIsRevealed() {
......@@ -69,11 +76,11 @@ public class Cell {
}
public void setNeighbors(int neighbors) {
this.nbNeighbors = neighbors;
this.nbNeighboringBombes = neighbors;
}
public int getNeighbors() {
return nbNeighbors;
return nbNeighboringBombes;
}
public boolean getIsSelected() {
......
......@@ -21,9 +21,11 @@ public class Minesweeper {
private ArrayList<ArrayList<Cell>> board;
public Minesweeper() {
this.nbColumns = 3;
this.nbLines = 3;
this.difficulte = 0.1;
this.nbColumns = 15;
this.nbLines = 15;
// this.nbColumns = 3;
// this.nbLines = 3;
this.difficulte = 0.2;
this.score = 0;
this.board = new ArrayList<ArrayList<Cell>>();
this.gameOver = false;
......@@ -52,7 +54,7 @@ public class Minesweeper {
for (Cell cell : row) {
addAllNeighbors(cell);
}
System.out.println("neighbors set");
}
private void addAllNeighbors(Cell cell) {
......@@ -160,6 +162,18 @@ public class Minesweeper {
return gameWin;
}
public void updateScore() {
int nbRevealedTmp = 0;
for (ArrayList<Cell> row : board)
for (Cell cell : row)
if(cell.isRevealed())
nbRevealedTmp++;
nbRevealed = nbRevealedTmp;
score = nbRevealed;
if(nbRevealed == nbBlanks)
gameWin = true;
}
public void flag(int line, int column) {
// TODO Auto-generated method stub
if (getCell(line, column).isFlagged())
......
......@@ -47,6 +47,8 @@ public class MinesweeperPanel extends JPanel implements MinesweeperPanelable {
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (!this.minesweeper.isOver())
this.minesweeper.updateScore();
this.nbColumns = this.minesweeper.getNbColumns();
this.nbRows = this.minesweeper.getNbLines();
......@@ -115,6 +117,7 @@ public class MinesweeperPanel extends JPanel implements MinesweeperPanelable {
g.drawString(score, xScore, (fontSize * 4) - getHeight() / 22);
}
@Deprecated
public void drawCell(Graphics g, int line, int column) {
g.setColor(Color.BLACK);
......@@ -211,5 +214,4 @@ public class MinesweeperPanel extends JPanel implements MinesweeperPanelable {
return false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment