Skip to content

Commit c97018b

Browse files
committed
Merge branch 'master' into release
2 parents 041f803 + 6b15210 commit c97018b

13 files changed

Lines changed: 224 additions & 32 deletions

File tree

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Upload Release Assets
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-and-upload:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
17+
- name: Set up JDK 25
18+
uses: actions/setup-java@v5
19+
with:
20+
java-version: '25'
21+
distribution: 'temurin'
22+
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v5
25+
26+
- name: Build JAR with Gradle
27+
run: ./gradlew build
28+
29+
- name: Build Debian package
30+
run: ./package-deb.sh
31+
32+
- name: Build ZIP archive
33+
run: ./package.sh
34+
35+
- name: Upload release assets
36+
uses: softprops/action-gh-release@v2
37+
with:
38+
files: |
39+
./app/build/libs/app.jar
40+
./numberguessinggame.deb
41+
./archive.zip

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ gradle-app.setting
2323
# Ignore Gradle build output directory
2424
build
2525

26-
archive.zip
26+
archive.zip
27+
numberguessinggame.deb

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,36 @@
22

33
A simple number guessing game where you try to guess a randomly generated number. The game will tell you if your guess is too high or too low until you find the correct number.
44

5-
## Running the Game
5+
## Installation & Running
6+
7+
### Installation via Debian Package (Linux)
8+
9+
For Debian/Ubuntu and derivatives (recommended for terminal usage):
10+
11+
1. Download the `.deb` package from the [latest release](https://github.com/Project516/NumberGuessingGame/releases)
12+
2. Install it:
13+
```bash
14+
sudo apt update # Update packages
15+
sudo apt install ./numberguessinggame.deb # From directory the deb package is in
16+
sudo apt install -f # Install dependencies if needed
17+
```
18+
3. Run from anywhere in your terminal:
19+
```bash
20+
numberguessinggame
21+
```
22+
23+
To uninstall:
24+
```bash
25+
sudo apt remove numberguessinggame
26+
```
627

7-
### Requirements
28+
### Manual Installation
29+
30+
#### Requirements
831

932
- Java 8 or higher (may require Java 17+ in future versions)
1033

11-
### How to Run
34+
#### How to Run
1235

1336
**On Windows:**
1437
Run `run.bat`
@@ -55,12 +78,21 @@ gradle build
5578
gradle test
5679
```
5780

58-
### Creating Release Archive
81+
### Creating Release Archives
82+
83+
#### Zip Archive
5984

6085
**On Windows:**
61-
Run `.\gradlew build` and `package.bat` from the project root.
86+
Run `.\gradlew build` and `.\package.bat` from the project root.
6287

6388
**On Linux/Mac:**
6489
Run `./package.sh` from the project root.
6590

66-
This will create `archive.zip` containing the application, run scripts, and README. The archive can be released to GitHub Releases.
91+
This will create `archive.zip` containing the application, run scripts, README, and LICENSE. The archive can be released to GitHub Releases.
92+
93+
#### Debian Package
94+
95+
**On Linux:**
96+
Run `./package-deb.sh` from the project root.
97+
98+
This will create `numberguessinggame.deb` which can be installed via `apt`/`dpkg` on Debian-based systems. The package can be released to GitHub Releases for easy distribution.

app/src/main/java/io/github/project516/NumberGuessingGame/DebugInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class DebugInfo {
66
ReadVersionFile vFile = new ReadVersionFile();
77

88
void launchDebug() {
9-
System.out.println("===== DEBUG INFO =====\n\n");
9+
System.out.println("\n===== DEBUG INFO =====\n\n");
1010
System.out.println("Java version: " + sysInfo.version());
1111
System.out.println("Vendor: " + sysInfo.vendor());
1212
System.out.println("JDK name: " + sysInfo.name());
@@ -15,6 +15,6 @@ void launchDebug() {
1515
}
1616

1717
void gameCrash() {
18-
System.out.println("\n\n=====Program Crashed!=====\n\n");
18+
System.out.println("\n\n===Program Crashed!===\n\n");
1919
}
2020
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.project516.NumberGuessingGame;
2+
3+
import java.awt.*;
4+
import javax.swing.*;
5+
6+
// TODO
7+
8+
public class GUI {
9+
void createWindow() {
10+
JFrame jframe = new JFrame("Number Guessing Game");
11+
JLabel jlabel = new JLabel("Number Guessing Game", SwingConstants.CENTER);
12+
// JButton jbutton = new JButton("Start game!");
13+
14+
jframe.getContentPane().add(jlabel, BorderLayout.CENTER);
15+
16+
jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Exit on close
17+
jframe.setSize(300, 300);
18+
19+
jframe.setVisible(true); // Set visible
20+
}
21+
22+
public static void main(String[] args) { // Test GUI
23+
GUI GUI = new GUI();
24+
GUI.createWindow();
25+
}
26+
}

app/src/main/java/io/github/project516/NumberGuessingGame/GameInfo.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,16 @@ void about() {
55
System.out.println("This is a Number Guessing Game!");
66
System.out.println("Guess a number between 1 and 100!\n");
77
}
8+
9+
String author() {
10+
return "project516";
11+
}
12+
13+
String projectURL() {
14+
return "https://github.com/project516/numberguessinggame";
15+
}
16+
17+
String onlineJavadoc() {
18+
return "https://project516.github.io/NumberGuessingGame";
19+
}
820
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.github.project516.NumberGuessingGame;
2+
3+
public class GameLogic {
4+
// TODO port game logic from Main to GameLogic
5+
void game() {
6+
7+
RandomNumber ranNumber = new RandomNumber();
8+
int number = ranNumber.number(100);
9+
int numOfGuesses = 0;
10+
ScannerHelper scan = new ScannerHelper();
11+
CheckGuess check = new CheckGuess();
12+
13+
while (true) {
14+
15+
System.out.print("Guess a number: ");
16+
int guess = scan.userGuess();
17+
check.check(guess);
18+
if (guess > number) {
19+
System.out.println("You guessed to much!");
20+
} else if (guess < number) {
21+
System.out.println("You guessed to little!");
22+
} else {
23+
numOfGuesses++;
24+
System.out.println("Took you " + numOfGuesses + " guesses!");
25+
scan.close();
26+
break;
27+
}
28+
numOfGuesses++;
29+
}
30+
}
31+
}

app/src/main/java/io/github/project516/NumberGuessingGame/Main.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,17 @@ public class Main {
44

55
public static void main(String[] args) {
66

7-
int numOfGuesses = 0;
8-
97
ScannerHelper scan = new ScannerHelper();
10-
RandomNumber ranNumber = new RandomNumber();
11-
CheckGuess check = new CheckGuess();
128
DebugInfo debugInfo = new DebugInfo();
139
GameInfo gameInfo = new GameInfo();
10+
GameLogic logic = new GameLogic();
1411

1512
debugInfo.launchDebug();
1613

1714
try {
18-
int number = ranNumber.number(100);
19-
gameInfo.about();
2015

21-
while (true) {
22-
23-
System.out.print("Guess a number: ");
24-
int guess = scan.userGuess();
25-
check.check(guess);
26-
if (guess > number) {
27-
System.out.println("You guessed to much!");
28-
} else if (guess < number) {
29-
System.out.println("You guessed to little!");
30-
} else {
31-
numOfGuesses++;
32-
break;
33-
}
34-
numOfGuesses++;
35-
}
36-
37-
System.out.println("Took you " + numOfGuesses + " guesses!");
16+
gameInfo.about();
17+
logic.game();
3818

3919
} catch (Exception e) {
4020

debian-package/DEBIAN/control

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: numberguessinggame
2+
Version: 1.0.0
3+
Section: games
4+
Priority: optional
5+
Architecture: all
6+
Depends: default-jre | java8-runtime
7+
Maintainer: project516 <project516.progress139@slmail.me>
8+
Description: A simple number guessing game
9+
A simple number guessing game where you try to guess a randomly
10+
generated number. The game will tell you if your guess is too high
11+
or too low until you find the correct number.

debian-package/DEBIAN/postinst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Make the game executable
5+
chmod +x /usr/games/numberguessinggame
6+
7+
exit 0

0 commit comments

Comments
 (0)