Skip to content

Commit

Permalink
Merge pull request #108 from StenAL/features
Browse files Browse the repository at this point in the history
Show time remaining for other players' turns in multiplayer and some other features
  • Loading branch information
PhilippvK authored May 25, 2024
2 parents 718b60f + f85615a commit dc2b5b3
Show file tree
Hide file tree
Showing 19 changed files with 390 additions and 418 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The Java Applet-based Minigolf Client was one of the most popular multiplayer ga

### Reimplementation
- Commented out any communication with original Playforia.net servers
- Use local Map store instead of database
- Use local map store instead of database
- Added ability to pass IP of server to client
- Ability to play on a single computer and hosting a game for up to 4 players in your home network
- Removed bad words and custom tracks
Expand All @@ -37,7 +37,7 @@ The Java Applet-based Minigolf Client was one of the most popular multiplayer ga
- Clone this repo: `git clone git@github.com:PhilippvK/playforia-minigolf.git`
- Install Java Development Kit 17 (https://adoptium.net/en-GB/temurin/releases/)
- Install Apache `maven` for building: https://maven.apache.org/install.html
- *Optional:* Install IntelliJ IDEA Java IDE (https://www.jetbrains.com/idea/download/) and import this reposiory as project
- *Optional:* Install IntelliJ IDEA Java IDE (https://www.jetbrains.com/idea/download/) and import this repository as project

### Building

Expand Down Expand Up @@ -67,11 +67,18 @@ We provide an experimental Dockerfile for easy hosting of the server application
Running the Editor is quite straightforward as it can be started like expected: `java -jar editor.jar`

### CLI options
Both client and server include CLI options for hostname (`-ip`), port (`-p`) settings. To learn about all the available setting you can include help with `-h` parameter.
Common CLI options for both the client and the server:
- `-ip` to set the hostname
- `-p` to set the port
- `-h` to learn about all the available options

To use custom tracks instead of the default set of bundled tracks, use the `--tracks-dir` option when starting the server and point it to where your tracks are located.
Server CLI options:
- `--tracks-dir` to use custom tracks instead of the default set of bundled tracks

If you want to enable debugging messages, add `--verbose` to the list of arguments.
Client CLI options:
- `--verbose` to enable debug logging
- `--norandom` to disable randomization for shots
- `--username` to set username from CLI and skip inputting it

## Compatibility

Expand Down Expand Up @@ -117,4 +124,4 @@ Tested:

Have fun.

If you miss the good old times before Playforia.net went down, Minigolf probably was one of your favourite games. I hope you will have some fun in the single player or with friends with this little crappy piece of oldschool software!
If you miss the good old times before Playforia.net went down, Minigolf probably was one of your favourite games. I hope you will have some fun in the single player or with friends with this little crappy piece of oldschool software!
19 changes: 12 additions & 7 deletions client/src/main/java/agolf/GameApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ protected int method32() {
return this.anInt3769;
}

public void setGameState(int var1) {// setGameState..maybe?
this.setGameState(var1, 0, 0);
public void setGameState(int state) {
this.setGameState(state, 0, 0);
}

protected void setGameState(int var1, int var2) {
this.setGameState(var1, var2, 0);
protected void setGameState(int state, int lobbyId) {
this.setGameState(state, lobbyId, 0);
}

protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
Expand All @@ -140,9 +140,14 @@ protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
//System.out.println(hasSession() + " " + gameContainer.synchronizedTrackTestMode.get());

if (Launcher.isUsingCustomServer()) {
TrackTestLoginPanel var4 = new TrackTestLoginPanel(this, super.appletWidth, super.appletHeight);
var4.setLocation(0, 0);
this.addToContent(var4);
String username = param.getUsername();
if (username == null) {
TrackTestLoginPanel loginPanel = new TrackTestLoginPanel(this, super.appletWidth, super.appletHeight);
loginPanel.setLocation(0, 0);
this.addToContent(loginPanel);
} else {
this.trackTestLogin(username, "");
}
} else if (this.hasSession()) {
super.param.noGuestAutoLogin();
this.gameContainer.connection.writeData("login\t" + super.param.getSession());
Expand Down
32 changes: 17 additions & 15 deletions client/src/main/java/agolf/TrackTestLoginPanel.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package agolf;

import com.aapeli.multiuser.UsernameValidator;

import java.awt.*;
import java.awt.event.*;
import java.util.regex.Pattern;

class TrackTestLoginPanel extends Panel implements ActionListener, KeyListener {

Expand All @@ -13,7 +14,6 @@ class TrackTestLoginPanel extends Panel implements ActionListener, KeyListener {
private TextField textFieldPassword;
private Button buttonOk;
private Label labelError;
private Pattern pattern;
private Label labelName;
private Label labelName2;
private Label labelPassword;
Expand All @@ -24,7 +24,6 @@ protected TrackTestLoginPanel(GameApplet gameApplet, int width, int height) {
this.width = width;
this.height = height;
this.setSize(width, height);
pattern = Pattern.compile("[^a-zA-Z0-9 ]");
this.create();
}

Expand All @@ -51,18 +50,6 @@ public void actionPerformed(ActionEvent evt) {
}

public void keyPressed(KeyEvent evt) {
if(evt.getKeyCode() == KeyEvent.VK_ENTER && buttonOk.isEnabled()) {
actionPerformed(null);
return;
}
boolean found = pattern.matcher(textFieldName.getText()).find() || textFieldName.getText().trim().equals("");
if(found) {
labelError.setVisible(true);
buttonOk.setEnabled(false);
} else {
labelError.setVisible(false);
buttonOk.setEnabled(true);
}
}

private void create() {
Expand All @@ -74,16 +61,19 @@ private void create() {
textFieldName.addKeyListener(this);
this.add(this.textFieldName);
textFieldName.requestFocus();

this.textFieldPassword = new TextField("");//("(password)");
this.textFieldPassword.setBounds(this.width / 2 - 75, this.height / 2 - 10, 150, 25);
this.textFieldPassword.setBackground(Color.white);
this.textFieldPassword.setForeground(Color.black);
textFieldPassword.setEchoChar('*');
//this.add(this.textFieldPassword); //Don't show this field

this.buttonOk = new Button("OK");
this.buttonOk.setBounds(this.width / 2 - 75, this.height / 2 + 50, 75, 25);
this.buttonOk.addActionListener(this);
this.add(this.buttonOk);

labelError = new Label("Only spaces, alphabetical and numerical characters are allowed");
labelError.setBounds(width / 2 - 75, height / 2 - 35, 400, 25);
labelError.setForeground(Color.red);
Expand All @@ -110,5 +100,17 @@ public void keyTyped(KeyEvent e) {
}

public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER && buttonOk.isEnabled()) {
actionPerformed(null);
return;
}
boolean validUsername = UsernameValidator.isValidUsername(textFieldName.getText());
if (validUsername) {
labelError.setVisible(false);
buttonOk.setEnabled(true);
} else {
labelError.setVisible(true);
buttonOk.setEnabled(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

class GameChatPanel extends Panel implements KeyListener, ActionListener {
class ChatPanel extends Panel implements KeyListener, ActionListener {

private static final int[] anIntArray330 = new int[]{3, 1, 4, 2};
private GameContainer gameContainer;
Expand All @@ -30,7 +30,7 @@ class GameChatPanel extends Panel implements KeyListener, ActionListener {
private boolean created;


protected GameChatPanel(GameContainer gameContainer, int width, int height, int gameExtra) {
protected ChatPanel(GameContainer gameContainer, int width, int height, int gameExtra) {
this.gameContainer = gameContainer;
this.width = width;
this.height = height;
Expand Down
8 changes: 4 additions & 4 deletions client/src/main/java/agolf/game/GameControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class GameControlPanel extends Panel implements ActionListener, ItemListener {

private GameContainer gameContainer;
private GamePlayerInfoPanel aGamePlayerInfoPanel__341;
private PlayerInfoPanel playerInfoPanel;
private int anInt342;
private int anInt343;
private int playerCount;
Expand All @@ -29,9 +29,9 @@ class GameControlPanel extends Panel implements ActionListener, ItemListener {
private boolean skipButtonVisible;


protected GameControlPanel(GameContainer var1, GamePlayerInfoPanel var2, int var3, int var4) {
protected GameControlPanel(GameContainer var1, PlayerInfoPanel var2, int var3, int var4) {
this.gameContainer = var1;
this.aGamePlayerInfoPanel__341 = var2;
this.playerInfoPanel = var2;
this.anInt342 = var3;
this.anInt343 = var4;
this.setSize(var3, var4);
Expand Down Expand Up @@ -68,7 +68,7 @@ public void actionPerformed(ActionEvent event) {
this.setVisible(false);
this.remove(this.buttonNewGame);
this.setVisible(true);
this.aGamePlayerInfoPanel__341.readyForNewGameLocal();
this.playerInfoPanel.readyForNewGameLocal();
this.gameContainer.gamePanel.requestNewGame();
} else if (source == this.buttonBack) {
this.buttonBack.removeActionListener(this);
Expand Down
Loading

0 comments on commit dc2b5b3

Please sign in to comment.