Skip to content

Commit 4489f4f

Browse files
committed
added release notes
1 parent aca2c03 commit 4489f4f

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }}
3333
path: ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-${{ env.VERSION }}.jar
3434

35+
- name: Extract Changelog for Current Release
36+
id: extract_changelog
37+
run: |
38+
content=$(awk "/\[${{ env.VERSION }}\]/,0" CHANGELOG.md)
39+
echo "RELEASE_NOTES=$content" >> $GITHUB_ENV
40+
3541
- name: Create GitHub Release
3642
id: create_release
3743
uses: actions/create-release@v1
@@ -40,6 +46,7 @@ jobs:
4046
with:
4147
tag_name: ${{ github.ref }}
4248
release_name: Release ${{ github.ref }}
49+
body: ${{ env.RELEASE_NOTES }}
4350

4451
- name: Attach JAR to Release
4552
uses: actions/upload-release-asset@v1

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## [v1.1.0] - 2023-09-03
4+
### Added
5+
- added reset button to reset the game
6+
7+
## [v1.0.0] - 2023-09-03
8+
### Added
9+
- Initial release.

src/Connect4.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void runGame() {
4040
columnButtons = new JButton[COLUMNS];
4141

4242
createDropButtons();
43+
addResetButton();
4344

4445
// set each tile as an unclickable button with a white background to just add circles on top
4546
for (int row = 0; row < ROWS; row++) {
@@ -80,17 +81,39 @@ public void actionPerformed(ActionEvent e) {
8081
if (checkWin(WHITE)) {
8182
JOptionPane.showMessageDialog(Connect4.this, "WHITE wins!");
8283
gameOver = true;
84+
8385
} else if (checkWin(BLACK)) {
8486
JOptionPane.showMessageDialog(Connect4.this, "BLACK wins!");
8587
gameOver = true;
88+
8689
} else if (checkDraw()) {
8790
JOptionPane.showMessageDialog(Connect4.this, "Draw!");
8891
gameOver = true;
92+
8993
}
9094
}
9195
}
9296
}
9397

98+
private void addResetButton() {
99+
JPanel resetPanel = new JPanel();
100+
JButton resetButton = new JButton("Reset");
101+
resetButton.addActionListener(new ActionListener() {
102+
public void actionPerformed(ActionEvent e) {
103+
// Reset the game
104+
105+
isWhiteTurn = true;
106+
gameOver = false;
107+
runGame();
108+
}
109+
});
110+
resetPanel.add(resetButton);
111+
add(resetPanel, BorderLayout.SOUTH);
112+
pack();
113+
setVisible(true);
114+
}
115+
116+
94117
public void setGridIcon() {
95118
Component[] components = boardPanel.getComponents();
96119
int index = COLUMNS; // start at the bottom left of the board by reducing the indexes of drop buttons
@@ -134,7 +157,11 @@ public void makeUserMove(int column) {
134157
}
135158
}
136159
}
137-
switchTurn();
160+
161+
// switch turns
162+
if(moveMade){
163+
switchTurn();
164+
}
138165
}
139166

140167
// Switch turns

0 commit comments

Comments
 (0)