Skip to content

Commit

Permalink
v1.6
Browse files Browse the repository at this point in the history
Added a table which contains all the past rounds and fixed some bug about restoring a saved match
  • Loading branch information
acerbisgianluca committed Dec 7, 2017
1 parent dad67eb commit fc1c4df
Show file tree
Hide file tree
Showing 44 changed files with 363 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Wed, 06 Dec 2017 19:00:25 +0100
#Thu, 07 Dec 2017 16:20:52 +0100


D\:\\Project\\Java\ Project\\Memory=
Binary file modified build/classes/Memory/Deck.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$1.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$10.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$11.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$12.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$13.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$14.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$15.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$16.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$17.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$18.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$19.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$2.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$20.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$21.class
Binary file not shown.
Binary file added build/classes/Memory/Game$22.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$3.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$4.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$5.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$6.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$7.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$8.class
Binary file not shown.
Binary file modified build/classes/Memory/Game$9.class
Binary file not shown.
Binary file modified build/classes/Memory/Game.class
Binary file not shown.
Binary file modified build/classes/Memory/GameManager.class
Binary file not shown.
Binary file added build/classes/Memory/Points$1.class
Binary file not shown.
Binary file added build/classes/Memory/Points.class
Binary file not shown.
Binary file modified build/classes/Memory/Start$1.class
Binary file not shown.
Binary file modified build/classes/Memory/Start$2.class
Binary file not shown.
Binary file modified build/classes/Memory/Start$3.class
Binary file not shown.
Binary file modified build/classes/Memory/Start$4.class
Binary file not shown.
Binary file modified build/classes/Memory/Start.class
Binary file not shown.
Binary file modified dist/Memory.jar
Binary file not shown.
Binary file modified dist/Memory.zip
Binary file not shown.
1 change: 1 addition & 0 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/D:/Project/Java%20Project/Memory/src/Memory/Points.java</file>
<file>file:/D:/Project/Java%20Project/Memory/src/Memory/Card.java</file>
<file>file:/D:/Project/Java%20Project/Memory/src/Memory/Start.java</file>
<file>file:/D:/Project/Java%20Project/Memory/src/Memory/Deck.java</file>
Expand Down
5 changes: 4 additions & 1 deletion src/Memory/Deck.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public void mix (){
deck[pos2].setPos(temp);
}

//enable card
for(i = 0; i < this.N; i++)
deck[i].setEnabled(true);

//DEBUG
System.out.println("Nuovo campo:");
for(i = 0; i < this.N; i++){
Expand All @@ -81,5 +85,4 @@ public Card findCard (int pos) {

return null;
}

}
10 changes: 9 additions & 1 deletion src/Memory/Game.form
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
<Property name="text" type="java.lang.String" value="Opzioni"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuPoints">
<Properties>
<Property name="text" type="java.lang.String" value="Mostra punteggi"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuPointsActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuReset">
<Properties>
<Property name="text" type="java.lang.String" value="Ricomincia"/>
Expand Down Expand Up @@ -57,7 +65,7 @@
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="menuBar"/>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
Expand Down
42 changes: 30 additions & 12 deletions src/Memory/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class Game extends javax.swing.JFrame {

private GameManager gm;

Timer timer;

/**
* Creates new form Game
* @param gm
Expand Down Expand Up @@ -116,6 +114,7 @@ private void initComponents() {
progressBar = new javax.swing.JProgressBar();
menuBar = new javax.swing.JMenuBar();
menuElement = new javax.swing.JMenu();
menuPoints = new javax.swing.JMenuItem();
menuReset = new javax.swing.JMenuItem();
menuRestart = new javax.swing.JMenuItem();
menuSave = new javax.swing.JMenuItem();
Expand Down Expand Up @@ -321,6 +320,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

menuElement.setText("Opzioni");

menuPoints.setText("Mostra punteggi");
menuPoints.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuPointsActionPerformed(evt);
}
});
menuElement.add(menuPoints);

menuReset.setText("Ricomincia");
menuReset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Expand Down Expand Up @@ -375,6 +382,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void btnCard1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCard1ActionPerformed
Expand Down Expand Up @@ -464,6 +472,11 @@ private void menuSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
saveMatch();
}//GEN-LAST:event_menuSaveActionPerformed

private void menuPointsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuPointsActionPerformed
Points p = new Points(gm);
p.setVisible(true);
}//GEN-LAST:event_menuPointsActionPerformed

public void pressButton(JButton button, int pos) {
if(gm.getFirst()) {
gm.setCard1(gm.getDeck().findCard(pos));
Expand Down Expand Up @@ -508,7 +521,7 @@ public void hideCards () {
}

public void turn () {
timer = new Timer();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run(){
Expand All @@ -523,15 +536,15 @@ public void run(){

timer.cancel();

gm.setUnLock(true);
gm.setFirst(true);

timer = null;
gm.setUnLock(true);
}
}, 3000);
}

public void update () {
gm.updatePoints();

progressBar.setValue(gm.getPlayer1Score() + gm.getPlayer2Score());
progressBar.setString(progressBar.getValue() + "/8");

Expand All @@ -541,14 +554,18 @@ public void update () {
gm.setPlayer1Round(gm.getPlayer1Round() + 1);
lblPlayer1Round.setText("Round vinti da " + gm.getPlayer1Name() + ": " + gm.getPlayer1Round() + "/" + gm.getRound2win());
if(gm.getPlayer1Round() == gm.getRound2win())
JOptionPane.showMessageDialog(rootPane, gm.getPlayer1Name() + " ha vinto!", "WINNER WINNER CHICKEN DINNER", 1, winner);
JOptionPane.showMessageDialog(rootPane, gm.getPlayer1Name() + " ha vinto!", "WINNER WINNER CHICKEN DINNER", JOptionPane.INFORMATION_MESSAGE, winner);
else
JOptionPane.showMessageDialog(rootPane, gm.getPlayer1Name() + " ha vinto il " + (gm.getPlayer1Round() + gm.getPlayer2Round()) + "° round!", "WINNER WINNER CHICKEN DINNER", JOptionPane.INFORMATION_MESSAGE, winner);
}
else {
lblPlayer2.setText("Punteggio di " + gm.getPlayer2Name() + ": " + gm.getPlayer2Score());
gm.setPlayer2Round(gm.getPlayer2Round() + 1);
lblPlayer2Round.setText("Round vinti da " + gm.getPlayer2Name() +": " + gm.getPlayer2Round() + "/" + gm.getRound2win());
if(gm.getPlayer2Round() == gm.getRound2win())
JOptionPane.showMessageDialog(rootPane, gm.getPlayer2Name() + " ha vinto!", "WINNER WINNER CHICKEN DINNER", 1, winner);
JOptionPane.showMessageDialog(rootPane, gm.getPlayer2Name() + " ha vinto!", "WINNER WINNER CHICKEN DINNER", JOptionPane.INFORMATION_MESSAGE, winner);
else
JOptionPane.showMessageDialog(rootPane, gm.getPlayer2Name() + " ha vinto il " + (gm.getPlayer1Round() + gm.getPlayer2Round()) + "° round!", "WINNER WINNER CHICKEN DINNER", JOptionPane.INFORMATION_MESSAGE, winner);
}

reset();
Expand Down Expand Up @@ -591,7 +608,7 @@ public void reset() {
System.exit(0);
}

JOptionPane.showMessageDialog(rootPane, "Il campo è stato rigenerato!", "AVVISO", 1);
JOptionPane.showMessageDialog(rootPane, "Il campo è stato rigenerato!", "AVVISO", JOptionPane.INFORMATION_MESSAGE);

progressBar.setValue(0);

Expand All @@ -606,7 +623,7 @@ public void reset() {
public void saveMatch() {
GameManager savedGM = new GameManager(gm);

if(timer != null)
if(!savedGM.getUnLock())
savedGM.setPlayer1(!savedGM.getPlayer1());

savedGM.setFirst(true);
Expand All @@ -619,9 +636,9 @@ public void saveMatch() {
stream.writeObject(savedGM);
stream.close();

JOptionPane.showMessageDialog(rootPane, "La partita è stata salvata!", "PARTITA SALVATA", 1);
JOptionPane.showMessageDialog(rootPane, "La partita è stata salvata!", "PARTITA SALVATA", JOptionPane.INFORMATION_MESSAGE);
} catch (IOException ex) {
Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(rootPane, "C'è stato un errore durante il salvataggio della partita, riprova!", "PARTITA NON SALVATA", JOptionPane.ERROR_MESSAGE);
}
}

Expand Down Expand Up @@ -667,6 +684,7 @@ public int exit() {
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenu menuElement;
private javax.swing.JMenuItem menuExit;
private javax.swing.JMenuItem menuPoints;
private javax.swing.JMenuItem menuReset;
private javax.swing.JMenuItem menuRestart;
private javax.swing.JMenuItem menuSave;
Expand Down
20 changes: 15 additions & 5 deletions src/Memory/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GameManager implements Serializable{
private final int round2win;
private int player1Round;
private int player2Round;
private int[][] points;

public GameManager(String player1Name, String player2Name, int round) {
this.first = true;
Expand All @@ -46,6 +47,7 @@ public GameManager(String player1Name, String player2Name, int round) {
this.round2win = (round / 2) + 1;
this.player1Round = 0;
this.player2Round = 0;
this.points = new int[round][2];

deck = new Deck (N_CARDS);
}
Expand All @@ -62,13 +64,23 @@ public GameManager(GameManager gm) {
this.player2Score = gm.getPlayer2Score();
this.round2win = gm.getRound2win();
this.player1Round = gm.getPlayer1Round();
this.player2Round = gm.getPlayer2Score();
this.player2Round = gm.getPlayer2Round();
this.points = gm.getPoints();

deck = gm.getDeck();
}

public void updatePoints() {
int round = player1Round + player2Round;

points[round][0] = player1Score;
points[round][1] = player2Score;
}

public int[][] getPoints() {
return points;
}


public int getN_CARDS() {
return N_CARDS;
}
Expand Down Expand Up @@ -159,7 +171,5 @@ public void setPlayer1Round(int player1Round) {

public void setPlayer2Round(int player2Round) {
this.player2Round = player2Round;
}


}
}
124 changes: 124 additions & 0 deletions src/Memory/Points.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="Memory: Overwatch Edition"/>
<Property name="type" type="java.awt.Window$Type" editor="org.netbeans.modules.form.editors.EnumEditor">
<Value id="POPUP"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-56,0,0,1,-90"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="false"/>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="12" y="12" width="-1" height="-1"/>
</Constraint>
</Constraints>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="105" max="-2" attributes="0"/>
<Component id="lblTitle" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="375" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lblTitle" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="124" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblTitle">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="18" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Storico dei punteggi"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="3" rowCount="0">
<Column editable="false" title="Round" type="java.lang.Integer"/>
<Column editable="false" title="Giocatore 1" type="java.lang.String"/>
<Column editable="false" title="Giocatore 2" type="java.lang.String"/>
</Table>
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0">
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false">
<Title/>
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false">
<Title/>
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false">
<Title/>
<Editor/>
<Renderer/>
</Column>
</TableColumnModel>
</Property>
<Property name="rowSelectionAllowed" type="boolean" value="false"/>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="false" resizingAllowed="true"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>
Loading

0 comments on commit fc1c4df

Please sign in to comment.