Compare commits
No commits in common. "main" and "ole" have entirely different histories.
3
makefile
3
makefile
|
@ -29,9 +29,6 @@ test-jar: jar
|
||||||
# $(JR) -cp "$(OUT_DIR)/:$(LIB_DIR)/*" $(MAIN_CLASS)
|
# $(JR) -cp "$(OUT_DIR)/:$(LIB_DIR)/*" $(MAIN_CLASS)
|
||||||
$(JR) -jar $(OUT_DIR)/$(JAR_NAME)
|
$(JR) -jar $(OUT_DIR)/$(JAR_NAME)
|
||||||
|
|
||||||
docs:
|
|
||||||
javadoc -cp "$(LIB_DIR)/*" -d "docs" $(SRC_DIR)/*.java
|
|
||||||
|
|
||||||
test: classfiles
|
test: classfiles
|
||||||
$(JR) -cp "$(OUT_DIR)$(SEPERATOR)$(LIB_DIR)/*" $(MAIN_CLASS)
|
$(JR) -cp "$(OUT_DIR)$(SEPERATOR)$(LIB_DIR)/*" $(MAIN_CLASS)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
|
/**
|
||||||
|
* Die Klasse AiPlayer ist die Basis für alle Ki Spieler und jede Spezifische Ki erweitert diese Klasse.
|
||||||
|
* @author Florian und Florian
|
||||||
|
* */
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Klasse AiPlayer ist die Basis für alle Ki Spieler und jede Spezifische Ki erweitert diese Klasse.
|
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
|
||||||
* */
|
|
||||||
public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +18,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor
|
* Konstruktor
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
|
||||||
*/
|
*/
|
||||||
public AiPlayer() {
|
public AiPlayer() {
|
||||||
this.setName("AI Player");
|
this.setName("AI Player");
|
||||||
|
@ -26,7 +27,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
/**
|
/**
|
||||||
* Gibt einen zufälligen Punkt im Spielfeld zurück.
|
* Gibt einen zufälligen Punkt im Spielfeld zurück.
|
||||||
* @return Ein zufälliger Punkt
|
* @return Ein zufälliger Punkt
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
|
||||||
*/
|
*/
|
||||||
public Point RandomPoint() {
|
public Point RandomPoint() {
|
||||||
Random random = new Random(); // Pseudo Random für zufallszahlen
|
Random random = new Random(); // Pseudo Random für zufallszahlen
|
||||||
|
@ -38,7 +38,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
/**
|
/**
|
||||||
* Initialisiert das Board.
|
* Initialisiert das Board.
|
||||||
* @param size größe des Boards
|
* @param size größe des Boards
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createBoard(int size) {
|
public void createBoard(int size) {
|
||||||
|
@ -49,7 +48,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ki Methode zum zufälligen Setzten der Schiffe
|
* Ki Methode zum zufälligen Setzten der Schiffe
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
|
||||||
*/
|
*/
|
||||||
public void aiSetShips() {
|
public void aiSetShips() {
|
||||||
for(int i = 0; i < super.board.getShips().size(); i++) { // Interiert durch alle Shiffe
|
for(int i = 0; i < super.board.getShips().size(); i++) { // Interiert durch alle Shiffe
|
||||||
|
@ -60,7 +58,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Ki Methode zum zufälligen Schießen auf das gegnerische Board.
|
* Ki Methode zum zufälligen Schießen auf das gegnerische Board.
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
|
||||||
*/
|
*/
|
||||||
public void aiShoot() {
|
public void aiShoot() {
|
||||||
if (!this.myTurn) return;
|
if (!this.myTurn) return;
|
||||||
|
@ -68,12 +65,7 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Nachdem receiveShoot beim gegner den schuss verarbeitet hat,
|
|
||||||
* wird diese Methode mit der antwort aufgerufen.
|
|
||||||
* @param hitResponse the hitresponse
|
|
||||||
* @author Florian Alexy und Florian Hantzschel und Luca Conte
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void receiveHit(HitResponse hitResponse) {
|
public synchronized void receiveHit(HitResponse hitResponse) {
|
||||||
// Eltern-Klasse LocalPlayer updatet myTurn
|
// Eltern-Klasse LocalPlayer updatet myTurn
|
||||||
|
@ -87,11 +79,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Erhält einen schuss vom gegner und verarbeitet ihn.
|
|
||||||
* @param point the location to be shot
|
|
||||||
* @author Florian Alexy und Florian Hantzschel und Luca Conte
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void receiveShoot(Point point) {
|
public synchronized void receiveShoot(Point point) {
|
||||||
super.receiveShoot(point);
|
super.receiveShoot(point);
|
||||||
|
@ -105,7 +92,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
/**
|
/**
|
||||||
* Wird aufgerufen, wenn in determineCoinToss festgestellt wurde das die Ki anfängt.
|
* Wird aufgerufen, wenn in determineCoinToss festgestellt wurde das die Ki anfängt.
|
||||||
* Erster Schuss wird gestartet.
|
* Erster Schuss wird gestartet.
|
||||||
* @author Florian Alexy und Florian Hantzschel und Luca Conte
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void beginTurn() {
|
public void beginTurn() {
|
||||||
|
@ -116,7 +102,7 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes past threads and tries firing a shot.
|
* Closes past threads and tries firing a shot.
|
||||||
* @author Luca Conte, Florian Alexy und Florian Hantzschel
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
Iterator<Thread> i = this.shootThreads.iterator();
|
Iterator<Thread> i = this.shootThreads.iterator();
|
||||||
|
@ -155,7 +141,6 @@ public abstract class AiPlayer extends LocalPlayer implements Runnable {
|
||||||
while(i.hasNext()) {
|
while(i.hasNext()) {
|
||||||
Thread thread = i.next();
|
Thread thread = i.next();
|
||||||
try {
|
try {
|
||||||
thread.interrupt();
|
|
||||||
thread.join();
|
thread.join();
|
||||||
i.remove();
|
i.remove();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.net.Socket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an Interface to communicate using a socket asynchronously
|
* Provides an Interface to communicate using a socket asynchronously
|
||||||
* @author Luca Conte, Peer Ole Wachtel
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
public class AsyncSocket {
|
public class AsyncSocket {
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/**
|
/**
|
||||||
* defines a message listener for AsyncSockets
|
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
public interface AsyncSocketListener {
|
public interface AsyncSocketListener {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Klasse ist das Board von eimem spieler und enthält alle logischen operationen.
|
* Diese Klasse ist das Board von eimem spieler und enthält alle logischen operationen.
|
||||||
* Sprich ist das Backend Board.
|
* Sprich ist das Backend Board.
|
||||||
*
|
*
|
||||||
* @author Peer Ole Wachtel, Florian Alexy und Florian Hantzschel
|
* @author Peer Ole Wachtel, Florian Alexy und Florian Hantzschel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Board {
|
public class Board {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,7 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nimmt einen punkt entgegen und Gibt einen HitResponse zurück.
|
* Nimmt einen punkt entgegen und Gibt einen Hitrespons zurück.
|
||||||
* @param point auf den geschossen wurde
|
* @param point auf den geschossen wurde
|
||||||
* @return
|
* @return
|
||||||
* @author Peer Ole Wachtel
|
* @author Peer Ole Wachtel
|
||||||
|
@ -103,9 +104,7 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a list of all the Ships on the board
|
|
||||||
* @return a list of all the Ships on the board
|
* @return a list of all the Ships on the board
|
||||||
* @author Peer Ole Wachtel
|
|
||||||
*/
|
*/
|
||||||
public List<Ship> getShips() {
|
public List<Ship> getShips() {
|
||||||
return ships;
|
return ships;
|
||||||
|
@ -118,7 +117,7 @@ public class Board {
|
||||||
* to all adjacened hit responses with type HIT using `propagateSunk`.
|
* to all adjacened hit responses with type HIT using `propagateSunk`.
|
||||||
* @param hitResponse the HitResponse to be added
|
* @param hitResponse the HitResponse to be added
|
||||||
* @return true when the hit response was added, otherwise false
|
* @return true when the hit response was added, otherwise false
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
*
|
||||||
*/
|
*/
|
||||||
public synchronized boolean addHits(HitResponse hitResponse) {
|
public synchronized boolean addHits(HitResponse hitResponse) {
|
||||||
if (this.getHitResponseOnPoint(hitResponse.getPoint()) == null){
|
if (this.getHitResponseOnPoint(hitResponse.getPoint()) == null){
|
||||||
|
@ -150,9 +149,7 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the size of the board
|
|
||||||
* @return the size of the board
|
* @return the size of the board
|
||||||
* @author Florian Alexy, Florian Hantzschel
|
|
||||||
*/
|
*/
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return this.size;
|
return this.size;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class BoardDisplay extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor des Board Displays
|
* Konstruktor der startLocalGame.
|
||||||
* @param gridSize Die Größe des Spielfelds
|
* @param gridSize Die Größe des Spielfelds
|
||||||
* @param player Der Spieler
|
* @param player Der Spieler
|
||||||
* @author Lucas Bronson
|
* @author Lucas Bronson
|
||||||
|
@ -174,7 +174,6 @@ public class BoardDisplay extends JPanel {
|
||||||
if(currentShip != null) {
|
if(currentShip != null) {
|
||||||
test = currentShip.getVirtualOccupiedPoints(mousePosition, horizontal);
|
test = currentShip.getVirtualOccupiedPoints(mousePosition, horizontal);
|
||||||
}
|
}
|
||||||
if (player == null || player.getBoard() == null) return;
|
|
||||||
for(int i = 0; i < gridSize; i++) {
|
for(int i = 0; i < gridSize; i++) {
|
||||||
for(int j = 0; j < gridSize; j++) {
|
for(int j = 0; j < gridSize; j++) {
|
||||||
if(fields[i][j] == null) {
|
if(fields[i][j] == null) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class GameBoard extends JPanel {
|
||||||
ImageIcon gameBoardX = new ImageIcon("graphics/gameboardx.png");
|
ImageIcon gameBoardX = new ImageIcon("graphics/gameboardx.png");
|
||||||
|
|
||||||
// kontextText Text-Strings
|
// kontextText Text-Strings
|
||||||
String kT1 = "Bitte Schiffe setzten - Rechtsclick zum drehen";
|
String kT1 = "Bitte Schiffe setzten";
|
||||||
String kT2 = "Warte auf Gegner";
|
String kT2 = "Warte auf Gegner";
|
||||||
String kT3 = "Du fängst an";
|
String kT3 = "Du fängst an";
|
||||||
String kT4 = "Dein Gegner fängt an";
|
String kT4 = "Dein Gegner fängt an";
|
||||||
|
@ -155,7 +155,7 @@ public class GameBoard extends JPanel {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
kontextText.setText(kT2);
|
kontextText.setText(kT2);
|
||||||
p1.ready();
|
p1.ready();
|
||||||
if(p1.isReady()) {
|
if(true) {
|
||||||
remove(readyButton);
|
remove(readyButton);
|
||||||
remove(resetButton);
|
remove(resetButton);
|
||||||
remove(rightButtonsPanel);
|
remove(rightButtonsPanel);
|
||||||
|
@ -225,11 +225,6 @@ public class GameBoard extends JPanel {
|
||||||
public Player getP1() {
|
public Player getP1() {
|
||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Getter für Player2
|
|
||||||
* @return Player 2
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public Player getP2() {
|
public Player getP2() {
|
||||||
return p2;
|
return p2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ public class GameController {
|
||||||
private static MainFrame mainFrame;
|
private static MainFrame mainFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the current MainFrame
|
|
||||||
* @return the current MainFrame
|
* @return the current MainFrame
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +21,6 @@ public class GameController {
|
||||||
return GameController.mainFrame;
|
return GameController.mainFrame;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* sets the current MainFrame
|
|
||||||
* @param mainFrame the current MainFrame
|
* @param mainFrame the current MainFrame
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
|
@ -126,7 +124,7 @@ public class GameController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds the largest common version in two lists of version strings
|
* finds the largest common version in two lists of version strings
|
||||||
* @return null if no common versions are found otherwise returns the most recent version present in both lists
|
* @return null if no common versions are found
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
public static String findMostRecentVersion(List<String> versions1, List<String> versions2) {
|
public static String findMostRecentVersion(List<String> versions1, List<String> versions2) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Hauptklasse über die der MainFrame gestartet wird
|
* Hauptklasse über die der MainFrame gestartet wird
|
||||||
* @author Lucas Bronson, Peer Ole Wachtel, Joshua Kuklok
|
* @author Lucas Bronson, Ole Wachtel, Joshua Kuklok
|
||||||
*/
|
*/
|
||||||
public class HalloSchiffeVersenken {
|
public class HalloSchiffeVersenken {
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ public class HalloSchiffeVersenken {
|
||||||
* Erstellt und setzt den Mainframe
|
* Erstellt und setzt den Mainframe
|
||||||
* @param args Argumente an Main durch Konsole etc.
|
* @param args Argumente an Main durch Konsole etc.
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @author Peer Ole Wachtel
|
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
MainFrame mf = new MainFrame();
|
MainFrame mf = new MainFrame();
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* Eine Antwort auf einen Schuss
|
|
||||||
* enthält einen Punkt, auf den geschossen wurde, sowie einen typen,
|
|
||||||
* der angibt, ob es sich bei dem Schuss um einen Treffer handelt
|
|
||||||
* @author Peer Ole Wachtel
|
|
||||||
*/
|
|
||||||
public class HitResponse {
|
public class HitResponse {
|
||||||
/**
|
/**
|
||||||
* Speichert den typ der HitResponse.
|
* Speichert den typ der HitResponse.
|
||||||
|
@ -42,20 +37,10 @@ public class HitResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the type of the HitResponse
|
|
||||||
* @return the type of the HitResponse
|
|
||||||
* @author Florian Hantzschel
|
|
||||||
*/
|
|
||||||
public HitResponseType getHitResponse() {
|
public HitResponseType getHitResponse() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the point of the HitResponse
|
|
||||||
* @return the point of the HitResponse
|
|
||||||
* @author Florian Hantzschel
|
|
||||||
*/
|
|
||||||
public Point getPoint() {
|
public Point getPoint() {
|
||||||
return this.point;
|
return this.point;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* Repräsentiert einen menschlichen Spieler
|
|
||||||
* @author Luca Conte, Florian Hantzschel
|
|
||||||
*/
|
|
||||||
public class HumanPlayer extends LocalPlayer {
|
public class HumanPlayer extends LocalPlayer {
|
||||||
/**
|
/**
|
||||||
* shoots a shot onto the provided point on the enemy board
|
* shoots a shot onto the provided point on the enemy board
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
|
||||||
* repräsentiert einen Player, der Lokal an dem Gerät spielt,
|
|
||||||
* auf dem dieses Programm läuft
|
|
||||||
* @author Luca Conte, Peer Ole Wachtel, Florian Hantzschel
|
|
||||||
*/
|
|
||||||
public class LocalPlayer extends Player {
|
public class LocalPlayer extends Player {
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +77,6 @@ public class LocalPlayer extends Player {
|
||||||
/**
|
/**
|
||||||
* sends shot to enemy player.
|
* sends shot to enemy player.
|
||||||
* should ONLY be called on HumanPlayer
|
* should ONLY be called on HumanPlayer
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void shoot(Point point){
|
public void shoot(Point point){
|
||||||
|
|
|
@ -6,7 +6,6 @@ import javax.swing.*;
|
||||||
/**
|
/**
|
||||||
* Klasse für Erstellung von looseScreen Objekten
|
* Klasse für Erstellung von looseScreen Objekten
|
||||||
* Dient zur Anzeige das ein Spiel verloren wurde
|
* Dient zur Anzeige das ein Spiel verloren wurde
|
||||||
* @author Joshua Kuklok, Luca Bronson
|
|
||||||
*/
|
*/
|
||||||
public class LoseScreen extends JPanel {
|
public class LoseScreen extends JPanel {
|
||||||
JLabel loseLabel = new JLabel("Du hast Verloren");
|
JLabel loseLabel = new JLabel("Du hast Verloren");
|
||||||
|
|
|
@ -126,10 +126,10 @@ public class MainFrame extends JFrame {
|
||||||
* Spezifische ShowPanel für WinScreen Klasse
|
* Spezifische ShowPanel für WinScreen Klasse
|
||||||
* @param panelName Name des anzuzeigenden Panels
|
* @param panelName Name des anzuzeigenden Panels
|
||||||
* @param player Player von dem die funktion aufgerufen worden ist
|
* @param player Player von dem die funktion aufgerufen worden ist
|
||||||
* @author Lucas Bronson, Peer Ole Wachtel, Luca Conte
|
* @author Lucas Bronson, Peer Ole Wachtel
|
||||||
*/
|
*/
|
||||||
public void showPanelWin(String panelName, Player player){
|
public void showPanelWin(String panelName, Player player){
|
||||||
if(gameBoard == null || player != gameBoard.getP1()){
|
if(player != gameBoard.getP1()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ public class MainFrame extends JFrame {
|
||||||
* Spezifische ShowPanel für LooseScreen Klasse
|
* Spezifische ShowPanel für LooseScreen Klasse
|
||||||
* @param panelName Name des anzuzeigenden Panels
|
* @param panelName Name des anzuzeigenden Panels
|
||||||
* @param player Player von dem die funktion aufgerufen worden ist
|
* @param player Player von dem die funktion aufgerufen worden ist
|
||||||
* @author Lucas Bronson, Peer Ole Wachtel, Luca Conte
|
* @author Lucas Bronson, Peer Ole Wachtel
|
||||||
*/
|
*/
|
||||||
public void showPanelLose(String panelName, Player player){
|
public void showPanelLose(String panelName, Player player){
|
||||||
if(gameBoard == null || player != gameBoard.getP1()){
|
if(player != gameBoard.getP1()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ public class MainFrame extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aktualisiert das Spielfeld
|
* Aktualisiert das Spielfeld (kontextText)
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
public void refreshGameBoard() {
|
public void refreshGameBoard() {
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
/**
|
|
||||||
* Abstrakte Repräsentation eines Spielers, der an einem anderen gerät spielt
|
|
||||||
* und durch eine Online Verbindung mit dieser Instanz kommuniziert
|
|
||||||
* @author Luca Conte, Peer Ole Wachtel
|
|
||||||
*/
|
|
||||||
public abstract class OnlinePlayer extends Player implements AsyncSocketListener {
|
public abstract class OnlinePlayer extends Player implements AsyncSocketListener {
|
||||||
protected AsyncSocket socket;
|
protected AsyncSocket socket;
|
||||||
protected int wantedBoardSize;
|
protected int wantedBoardSize;
|
||||||
|
@ -14,33 +9,19 @@ public abstract class OnlinePlayer extends Player implements AsyncSocketListener
|
||||||
* @param size the size of the board the enemy player wants to play with
|
* @param size the size of the board the enemy player wants to play with
|
||||||
* the actual board size will be determined once the semester of the online partner is known
|
* the actual board size will be determined once the semester of the online partner is known
|
||||||
* @param socket an AsyncSocket to communicate with the enemy through
|
* @param socket an AsyncSocket to communicate with the enemy through
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
|
||||||
*/
|
*/
|
||||||
public OnlinePlayer(Integer size, AsyncSocket socket) {
|
public OnlinePlayer(Integer size, AsyncSocket socket) {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.wantedBoardSize = size;
|
this.wantedBoardSize = size;
|
||||||
this.myCoin = null;
|
this.myCoin = null;
|
||||||
socket.setHandler(this);
|
socket.setHandler(this);
|
||||||
|
//TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* sends the IAM Package for introduction
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public abstract void sendIAM();
|
public abstract void sendIAM();
|
||||||
|
|
||||||
/**
|
|
||||||
* receives a message from the AsyncSocket
|
|
||||||
* satisfies AsyncSocketListener interface
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public abstract void receive(String message);
|
public abstract void receive(String message);
|
||||||
|
|
||||||
/**
|
|
||||||
* receives the coin toss result from the enemy
|
|
||||||
* @param coin the result of the coin toss
|
|
||||||
* @author Peer Ole Wachtel
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void receiveCoin(boolean coin);
|
public abstract void receiveCoin(boolean coin);
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eine Implementierung des Kommunikationsprotokoll nach Version 1.1.0 des Netzwerkstandards
|
|
||||||
* https://github.com/lgc-4/ProgProjekt-Netzwerkstandard
|
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
|
||||||
*/
|
|
||||||
public class OnlinePlayer_1_1_0 extends OnlinePlayer {
|
public class OnlinePlayer_1_1_0 extends OnlinePlayer {
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstellt einen Online Player
|
|
||||||
* @param size die maximale Größe des Spielfelds
|
|
||||||
* @param socket der Socket zur Kommunikation mit dem Online Partner
|
|
||||||
*/
|
|
||||||
public OnlinePlayer_1_1_0(Integer size, AsyncSocket socket) {
|
public OnlinePlayer_1_1_0(Integer size, AsyncSocket socket) {
|
||||||
super(size, socket);
|
super(size, socket);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +107,7 @@ public class OnlinePlayer_1_1_0 extends OnlinePlayer {
|
||||||
* receives a shot from the enemy and sends it to the online partner
|
* receives a shot from the enemy and sends it to the online partner
|
||||||
* if it is not the enemies turn, this method does nothing.
|
* if it is not the enemies turn, this method does nothing.
|
||||||
* @param point the point to be shot
|
* @param point the point to be shot
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
* @author Peer Ole Wachtel
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void receiveShoot(Point point){
|
public synchronized void receiveShoot(Point point){
|
||||||
|
@ -130,7 +118,7 @@ public class OnlinePlayer_1_1_0 extends OnlinePlayer {
|
||||||
/**
|
/**
|
||||||
* receives a hitresponse from the enemy player and sends it to the online partner
|
* receives a hitresponse from the enemy player and sends it to the online partner
|
||||||
* @param hitResponse the hitresponse to be sent
|
* @param hitResponse the hitresponse to be sent
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
* @author Peer Ole Wachtel
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void receiveHit(HitResponse hitResponse) {
|
public synchronized void receiveHit(HitResponse hitResponse) {
|
||||||
|
@ -164,22 +152,12 @@ public class OnlinePlayer_1_1_0 extends OnlinePlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* für Online Player nicht zu implementieren
|
|
||||||
* nur für HumanPlayer relevant
|
|
||||||
* @author Luca Conte, Peer Ole Wachtel
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void shoot(Point point) {
|
public synchronized void shoot(Point point) {
|
||||||
// SHOULD NEVER BE CALLED ON ONLINE PLAYER. ONLY ON HUMAN PLAYER
|
// SHOULD NEVER BE CALLED ON ONLINE PLAYER. ONLY ON HUMAN PLAYER
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* empfängt Withdraw vom Gegner und leitet es an den Online Partner weiter
|
|
||||||
* beendet das Spiel
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveWithdraw() {
|
public void receiveWithdraw() {
|
||||||
this.socket.send(new SocketPackage("WITHDRAW"));
|
this.socket.send(new SocketPackage("WITHDRAW"));
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* abstrakte repräsentation eines Spielers
|
|
||||||
* @author Peer Ole Wachtel, Luca Conte, Lucas Bronson
|
|
||||||
*/
|
|
||||||
public abstract class Player {
|
public abstract class Player {
|
||||||
protected boolean myTurn;
|
protected boolean myTurn;
|
||||||
protected boolean isServer;
|
protected boolean isServer;
|
||||||
|
@ -16,10 +12,6 @@ public abstract class Player {
|
||||||
|
|
||||||
protected boolean hasReceivedCoin;
|
protected boolean hasReceivedCoin;
|
||||||
|
|
||||||
/**
|
|
||||||
* Konstruktor
|
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
|
||||||
*/
|
|
||||||
public Player() {
|
public Player() {
|
||||||
this.setName("Player");
|
this.setName("Player");
|
||||||
this.hasReceivedCoin = false;
|
this.hasReceivedCoin = false;
|
||||||
|
@ -37,25 +29,10 @@ public abstract class Player {
|
||||||
this.board = new Board(size);
|
this.board = new Board(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* receives a shot onto a point from the enemy
|
|
||||||
* @param point the location to be shot
|
|
||||||
* @author Luca Conte, Peer Ole Wachtel
|
|
||||||
*/
|
|
||||||
public abstract void receiveShoot(Point point);
|
public abstract void receiveShoot(Point point);
|
||||||
|
|
||||||
/**
|
|
||||||
* receives a hit response from the enemy as a response to a receiveShoot call
|
|
||||||
* @param hitResponse the hitresponse
|
|
||||||
* @author Peer Ole Wachtel
|
|
||||||
*/
|
|
||||||
public abstract void receiveHit(HitResponse hitResponse);
|
public abstract void receiveHit(HitResponse hitResponse);
|
||||||
|
|
||||||
/**
|
|
||||||
* sends shot to enemy player.
|
|
||||||
* should ONLY be called on HumanPlayer
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public abstract void shoot(Point point);
|
public abstract void shoot(Point point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +60,6 @@ public abstract class Player {
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the name of this player
|
* returns the name of this player
|
||||||
* @return the name of this player
|
* @return the name of this player
|
||||||
|
@ -150,7 +126,6 @@ public abstract class Player {
|
||||||
/**
|
/**
|
||||||
* returns whether this player is ready and has sent their coin to the enemy player
|
* returns whether this player is ready and has sent their coin to the enemy player
|
||||||
* @return the player's ready state
|
* @return the player's ready state
|
||||||
* @author Lucas Bronson
|
|
||||||
*/
|
*/
|
||||||
public boolean isReady() {
|
public boolean isReady() {
|
||||||
return this.sentCoin;
|
return this.sentCoin;
|
||||||
|
@ -162,6 +137,7 @@ public abstract class Player {
|
||||||
* and players
|
* and players
|
||||||
*
|
*
|
||||||
* This method should be called at the end of a game
|
* This method should be called at the end of a game
|
||||||
|
* This method should be called at the end of a game
|
||||||
*
|
*
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
|
@ -172,39 +148,18 @@ public abstract class Player {
|
||||||
this.enemy = null;
|
this.enemy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the player wins
|
|
||||||
* ends the game
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public void win() {
|
public void win() {
|
||||||
GameController.getMainFrame().showPanelWin("", this);
|
GameController.getMainFrame().showPanelWin("", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the player loses
|
|
||||||
* ends the game
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public void lose() {
|
public void lose() {
|
||||||
GameController.getMainFrame().showPanelLose("", this);
|
GameController.getMainFrame().showPanelLose("", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the player loses by withdrawal
|
|
||||||
* ends the game
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public void withdraw() {
|
public void withdraw() {
|
||||||
this.enemy.receiveWithdraw();
|
this.enemy.receiveWithdraw();
|
||||||
this.lose();
|
this.lose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the enemy player withdraws
|
|
||||||
* ends the game
|
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
|
||||||
public void receiveWithdraw(){
|
public void receiveWithdraw(){
|
||||||
this.win();
|
this.win();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* repräsentation der Koordinaten eines Feldes auf dem Spielfeld
|
|
||||||
* @author Peer Ole Wachtel, Luca Conte
|
|
||||||
*/
|
|
||||||
public class Point {
|
public class Point {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
|
|
|
@ -5,10 +5,6 @@ import java.util.List;
|
||||||
|
|
||||||
record ShipData (int size, String name){}
|
record ShipData (int size, String name){}
|
||||||
|
|
||||||
/**
|
|
||||||
* repräsentation eines Schiffes auf dem Spielfeld
|
|
||||||
* @author Peer Ole Wachtel, Lucas Bronson, Florian Hanzschel
|
|
||||||
*/
|
|
||||||
public class Ship {
|
public class Ship {
|
||||||
static List<List<ShipData>> semeterList =
|
static List<List<ShipData>> semeterList =
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
|
@ -193,7 +189,7 @@ public class Ship {
|
||||||
/**
|
/**
|
||||||
* returns the position of this ship
|
* returns the position of this ship
|
||||||
* @return the position of this ship
|
* @return the position of this ship
|
||||||
* @author Peer Ole Wachtel
|
* @author Peer Ole Wachte
|
||||||
*/
|
*/
|
||||||
public Point getPosition() {
|
public Point getPosition() {
|
||||||
return position;
|
return position;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
/**
|
/**
|
||||||
* beschreibt ein Package das durch einen AsyncSocket gesendet werden kann nach Netzwerkstandard
|
|
||||||
* https://github.com/lgc-4/ProgProjekt-Netzwerkstandard
|
|
||||||
* @author Luca Conte
|
* @author Luca Conte
|
||||||
*/
|
*/
|
||||||
public class SocketPackage {
|
public class SocketPackage {
|
||||||
|
@ -90,7 +88,6 @@ public class SocketPackage {
|
||||||
* parses the package into a string according to https://github.com/lgc-4/ProgProjekt-Netzwerkstandard
|
* parses the package into a string according to https://github.com/lgc-4/ProgProjekt-Netzwerkstandard
|
||||||
* the package name and data are joined using a space " " `0x20`
|
* the package name and data are joined using a space " " `0x20`
|
||||||
* @return the package in string format
|
* @return the package in string format
|
||||||
* @author Luca Conte
|
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (this.data == null || this.data.length() == 0) {
|
if (this.data == null || this.data.length() == 0) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import java.util.ArrayList;
|
|
||||||
// import java.util.Random; wird nicht mehr verwendet
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Klasse implementiert den Harten Ki Spieler.
|
* Diese Klasse implementiert den Harten Ki Spieler.
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
* @author Florian Alexy und Florian Hantzschel
|
||||||
* */
|
* */
|
||||||
|
import java.util.ArrayList;
|
||||||
|
// import java.util.Random; wird nicht mehr verwendet
|
||||||
|
|
||||||
public class SpecificAiPlayerHard extends AiPlayer{
|
public class SpecificAiPlayerHard extends AiPlayer{
|
||||||
|
|
||||||
private int gridSize;
|
private int gridSize;
|
||||||
|
@ -21,8 +21,7 @@ public class SpecificAiPlayerHard extends AiPlayer{
|
||||||
VERTIKAL
|
VERTIKAL
|
||||||
}
|
}
|
||||||
private Orientierung orientierung;
|
private Orientierung orientierung;
|
||||||
// Speichert den ersten Treffer zur Bestimmung der Orientierung
|
private Point firstHit; // Speichert den ersten Treffer zur Bestimmung der Orientierung
|
||||||
private Point firstHit;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Klasse implementiert den Medium Ki Spieler.
|
* Diese Klasse implementiert den Medium Ki Spieler.
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
* @author Florian Alexy und Florian Hantzschel
|
||||||
* */
|
* */
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SpecificAiPlayerMedium extends AiPlayer{
|
public class SpecificAiPlayerMedium extends AiPlayer{
|
||||||
/**
|
/**
|
||||||
* Liste an Punkten die beschossen werden sollen. (Mögliche weitere Segmente vom schiff)
|
* Liste an Punkten die beschossen werden sollen. (Mögliche weitere Segmente vom schiff)
|
||||||
|
@ -48,7 +48,7 @@ public class SpecificAiPlayerMedium extends AiPlayer{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Die Methode bestimmt welche Position als nächstes beschossen werden soll.
|
* Die Methode bestimmt welche Position als nächstes beschossen werden soll.
|
||||||
* @return der Punkt auf den als nächtest geschossen werden soll
|
* @return
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
* @author Florian Alexy und Florian Hantzschel
|
||||||
*/
|
*/
|
||||||
public Point ComputeNextShot() {
|
public Point ComputeNextShot() {
|
||||||
|
@ -72,7 +72,7 @@ public class SpecificAiPlayerMedium extends AiPlayer{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Methode erweitert die hitsQueue um die umliegenden Punkte die Schiffe seien könnten.
|
* Diese Methode erweitert die hitsQueue um die umliegenden Punkte die Schiffe seien könnten.
|
||||||
* @param point der Punkt dessen nachbarn zur hitQueue hinzugefügt werden sollen
|
* @param point
|
||||||
* @author Florian Alexy und Florian Hantzschel
|
* @author Florian Alexy und Florian Hantzschel
|
||||||
*/
|
*/
|
||||||
private void addAdjacentPoints(Point point) {
|
private void addAdjacentPoints(Point point) {
|
||||||
|
|
|
@ -225,13 +225,10 @@ public class startLocalGame extends JPanel {
|
||||||
private void toggleLeftPlayerIconLeft() {
|
private void toggleLeftPlayerIconLeft() {
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
leftPlayerIcon.setIcon(aiPlayerHardIcon);
|
leftPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
leftPlayerIcon.setIcon(humanPlayerIcon);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
leftPlayerIcon.setIcon(aiPlayerNormalIcon);
|
leftPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
}
|
}
|
||||||
|
@ -244,13 +241,10 @@ public class startLocalGame extends JPanel {
|
||||||
private void toggleLeftPlayerIconRight() {
|
private void toggleLeftPlayerIconRight() {
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
leftPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
leftPlayerIcon.setIcon(aiPlayerNormalIcon);
|
leftPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
leftPlayerIcon.setIcon(aiPlayerHardIcon);
|
leftPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
leftPlayerIcon.setIcon(humanPlayerIcon);
|
leftPlayerIcon.setIcon(humanPlayerIcon);
|
||||||
}
|
}
|
||||||
|
@ -263,10 +257,8 @@ public class startLocalGame extends JPanel {
|
||||||
private void toggleRightPlayerIconLeft() {
|
private void toggleRightPlayerIconLeft() {
|
||||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||||
rightPlayerIcon.setIcon(aiPlayerHardIcon);
|
rightPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
|
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
||||||
rightPlayerIcon.setIcon(aiPlayerEasyIcon);
|
rightPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
|
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
}
|
}
|
||||||
|
@ -279,10 +271,8 @@ public class startLocalGame extends JPanel {
|
||||||
private void toggleRightPlayerIconRight() {
|
private void toggleRightPlayerIconRight() {
|
||||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon) {
|
||||||
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
rightPlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
|
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon){
|
||||||
rightPlayerIcon.setIcon(aiPlayerHardIcon);
|
rightPlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
|
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
rightPlayerIcon.setIcon(aiPlayerEasyIcon);
|
rightPlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
}
|
}
|
||||||
|
@ -296,13 +286,10 @@ public class startLocalGame extends JPanel {
|
||||||
// Für Linken Spieler
|
// Für Linken Spieler
|
||||||
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
if (leftPlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
leftPlayerTextField.setText(leftPlayerNickname);
|
leftPlayerTextField.setText(leftPlayerNickname);
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (leftPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
leftPlayerTextField.setText("Einfach");
|
leftPlayerTextField.setText("Einfach");
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (leftPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
leftPlayerTextField.setText("Mittel");
|
leftPlayerTextField.setText("Mittel");
|
||||||
|
|
||||||
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (leftPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
leftPlayerTextField.setText("Schwer");
|
leftPlayerTextField.setText("Schwer");
|
||||||
}
|
}
|
||||||
|
@ -310,10 +297,8 @@ public class startLocalGame extends JPanel {
|
||||||
// Für Rechten Spieler
|
// Für Rechten Spieler
|
||||||
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
if (rightPlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
rightPlayerTextField.setText("Einfach");
|
rightPlayerTextField.setText("Einfach");
|
||||||
|
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (rightPlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
rightPlayerTextField.setText("Mittel");
|
rightPlayerTextField.setText("Mittel");
|
||||||
|
|
||||||
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (rightPlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
rightPlayerTextField.setText("Schwer");
|
rightPlayerTextField.setText("Schwer");
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,13 +192,10 @@ public class startMultiplayerGame extends JPanel {
|
||||||
private void togglePlayerIconLeft() {
|
private void togglePlayerIconLeft() {
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
PlayerIcon.setIcon(aiPlayerHardIcon);
|
PlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
PlayerIcon.setIcon(humanPlayerIcon);
|
PlayerIcon.setIcon(humanPlayerIcon);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
PlayerIcon.setIcon(aiPlayerEasyIcon);
|
PlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
PlayerIcon.setIcon(aiPlayerNormalIcon);
|
PlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
}
|
}
|
||||||
|
@ -211,13 +208,10 @@ public class startMultiplayerGame extends JPanel {
|
||||||
private void togglePlayerIconRight() {
|
private void togglePlayerIconRight() {
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
PlayerIcon.setIcon(aiPlayerEasyIcon);
|
PlayerIcon.setIcon(aiPlayerEasyIcon);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
PlayerIcon.setIcon(aiPlayerNormalIcon);
|
PlayerIcon.setIcon(aiPlayerNormalIcon);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
PlayerIcon.setIcon(aiPlayerHardIcon);
|
PlayerIcon.setIcon(aiPlayerHardIcon);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
PlayerIcon.setIcon(humanPlayerIcon);
|
PlayerIcon.setIcon(humanPlayerIcon);
|
||||||
}
|
}
|
||||||
|
@ -230,13 +224,10 @@ public class startMultiplayerGame extends JPanel {
|
||||||
private void updateTextFields() {
|
private void updateTextFields() {
|
||||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||||
PlayerTextField.setText(PlayerNickname);
|
PlayerTextField.setText(PlayerNickname);
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
} else if (PlayerIcon.getIcon() == aiPlayerEasyIcon){
|
||||||
PlayerTextField.setText("Einfach");
|
PlayerTextField.setText("Einfach");
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
} else if (PlayerIcon.getIcon() == aiPlayerNormalIcon) {
|
||||||
PlayerTextField.setText("Mittel");
|
PlayerTextField.setText("Mittel");
|
||||||
|
|
||||||
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
} else if (PlayerIcon.getIcon() == aiPlayerHardIcon) {
|
||||||
PlayerTextField.setText("Schwer");
|
PlayerTextField.setText("Schwer");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue