ole #7

Merged
lgc merged 23 commits from ole into main 2024-11-26 14:01:01 +00:00
10 changed files with 187 additions and 5 deletions
Showing only changes of commit 579ce9831d - Show all commits

7
src/AiPlayer.java Normal file
View File

@ -0,0 +1,7 @@
public abstract class AiPlayer {
public void setBoardSize(int s) {
// raum für schmerzen
}
}

View File

@ -1,2 +1,43 @@
import java.util.List;
public class Board { public class Board {
/*
- hits : List<HitResponse>
- ships : List<Ship>
- size : int
- display : BoardDisplay
*/
/*
* + hit(HitResponse)
* + click(Point) : void
*/
List<HitResponse> hits;
List<Ship> ships;
int size;
public Board() {
// MISS,SHIP, HIT
// MISS bedeutet nichts auf der Position vorhanden
// SHIP bedeutet ungetroffenes Schiff auf der Position vorhanden
// HIT bedeutet getroffenes Schiff auf der Position vorhanden
}
public void setSize(int s) {
this.size = s;
}
public void initBoard() {
for (int i=0;size>i;i++) {
for (int j=0;size>j;j++) {
HitResponse missPos = new HitResponse();
missPos.setHitResponse(HitResponseType.MISS);
missPos.setPoint(i,j);
hits.add(missPos);
}
}
}
} }

31
src/GameController.java Normal file
View File

@ -0,0 +1,31 @@
public class GameController {
public void startOnlineGame() {
// fuck you Luca and Ole von Florian und nicht von Florian
}
public void startLocalGame(HumanPlayer player, AiPlayer enemy, int size) {
//Player initialisieren Board
player.setBoardSize(size);
enemy.setBoardSize(size);
// Schiffe setzen
// für player durch UI
/*
* Todo
* enemy.setships();
*/
boolean condition = true;
while(condition) {
//Gameloop bis Sieger
//WIP
break;
}
}
}

View File

@ -1,10 +1,16 @@
public class HalloSchiffeVersenken { public class HalloSchiffeVersenken {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
int default_size = 14;
HumanPlayer player = new HumanPlayer();
AiPlayer enemy = new SpecificAiPlayer1(); // auswählen hehe. mal gucken und viel spaßßß
GameController game_controller = new GameController();
game_controller.startLocalGame(player, enemy, default_size); // default_size oder auswählen, viel spaß
/*
System.out.println("HelloSchiffeVersenekn"); System.out.println("HelloSchiffeVersenekn");
System.out.println("sound"); System.out.println("sound");
SoundHandler.playSound("hit"); SoundHandler.playSound("hit");
@ -13,7 +19,7 @@ public class HalloSchiffeVersenken {
SoundHandler.setSoundOn(false); SoundHandler.setSoundOn(false);
System.out.println("sound off"); System.out.println("sound off");
SoundHandler.playSound("hit"); SoundHandler.playSound("hit");
*/
} }
} }

View File

@ -3,4 +3,18 @@ import java.awt.*;
public class HitResponse { public class HitResponse {
private HitResponseType type; private HitResponseType type;
private Point point; private Point point;
public HitResponseType getHitResponse() {
return this.type;
}
public void setHitResponse(HitResponseType a) {
this.type = a;
}
public Point getPoint() {
return this.point;
}
public void setPoint(int x, int y) {
this.point = new Point(x,y);
}
} }

View File

@ -1,3 +1,3 @@
public enum HitResponseType { public enum HitResponseType {
MISS, HIT, SUNK, VICTORY MISS, SHIP, HIT, SUNK, VICTORY
} }

34
src/HumanPlayer.java Normal file
View File

@ -0,0 +1,34 @@
public class HumanPlayer extends LocalPlayer {
/*
- myTurn : bool
- isServer : bool
- waitingForResponse : bool
- enemy : Player
- name : String
- board : Board
+ receiveShoot(Point) : void
+ receiveHit(HitResponse) : void
+ click(Point) : void
+ beginTurn() : void
*/
private boolean myTurn;
private boolean isServer;
private boolean waitingForResponse;
private Player enemy;
private String name;
private Board board;
public HumanPlayer() {
Board board = new Board();
this.board = board;
}
public void setBoardSize(int s) {
this.board.setSize(s);
this.board.initBoard();
}
}

4
src/LocalPlayer.java Normal file
View File

@ -0,0 +1,4 @@
public class LocalPlayer extends Player {
}

24
src/Ship.java Normal file
View File

@ -0,0 +1,24 @@
import java.awt.Point;
public class Ship {
/*
- size : int
- horizontal : bool
- position : Point
- name : String
- button : ShipButton
+ setPosition(Point) : void
*/
int size;
boolean horizontal;
Point position;
String name;
public void setPosition(Point pos) {
// raum für gedanken und die Methode
}
}

View File

@ -0,0 +1,21 @@
public class SpecificAiPlayer1 extends AiPlayer{
private boolean myTurn;
private boolean isServer;
private boolean waitingForResponse;
private Player enemy;
private String name;
private Board board;
public SpecificAiPlayer1() {
Board board = new Board();
this.board = board;
}
public void setBoardSize(int s) {
this.board.setSize(s);
this.board.initBoard();
}
}