2023-10-05 23:32:29 +02:00
|
|
|
/*
|
|
|
|
============================================================
|
|
|
|
This is the "Spiel" file from Author: Philipp Kotte
|
|
|
|
written on: 05 / 10 / 2023 at: 23:25
|
|
|
|
============================================================
|
|
|
|
*/
|
|
|
|
package Facade;
|
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
import java.io.Serializable;
|
2023-10-10 12:38:27 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2023-10-11 11:06:39 +02:00
|
|
|
import Domain.Kartenstapel;
|
2023-10-10 12:38:27 +02:00
|
|
|
import Domain.Spieler;
|
2023-10-12 08:51:24 +02:00
|
|
|
import Domain.Stich;
|
2023-10-11 11:06:39 +02:00
|
|
|
import Domain.Block.Block;
|
2023-10-10 12:38:27 +02:00
|
|
|
import Domain.Enums.Geschlecht;
|
2023-10-12 08:51:24 +02:00
|
|
|
import Domain.Karten.Karte;
|
2023-10-10 12:38:27 +02:00
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
public class Spiel implements Serializable {
|
2023-10-05 23:32:29 +02:00
|
|
|
|
2023-10-11 11:04:46 +02:00
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// statische Konstanten
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// statische Attribute(zB. zähler)
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// Attribute jedes Objektes
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
2023-10-10 12:38:27 +02:00
|
|
|
private boolean istGestartet;
|
|
|
|
private boolean istBeendet;
|
|
|
|
private Spieler spielerAmZug;
|
|
|
|
private int runde;
|
2023-10-10 14:09:27 +02:00
|
|
|
private HashMap<Integer, Spieler> spieler = new HashMap<>();
|
|
|
|
private boolean[] id_check = { false, false, false, false, false, false };
|
2023-10-11 11:06:39 +02:00
|
|
|
private Kartenstapel kartenstapel;
|
|
|
|
private Block block;
|
2023-10-10 12:38:27 +02:00
|
|
|
|
2023-10-11 11:04:46 +02:00
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// Konstruktoren (default und spezifische)
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
2023-10-10 12:38:27 +02:00
|
|
|
public Spiel() {
|
|
|
|
this.istGestartet = false;
|
|
|
|
this.istBeendet = false;
|
|
|
|
this.spielerAmZug = null;
|
|
|
|
this.runde = 0;
|
|
|
|
};
|
2023-10-11 11:04:46 +02:00
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// statische Methoden
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// Getter und Setter
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
|
|
|
public void setSpielGestartet(boolean gestarted) {
|
|
|
|
this.istGestartet = gestarted;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSpielBeendet(boolean beendet) {
|
|
|
|
this.istBeendet = beendet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRunde(int runde) {
|
|
|
|
this.runde = runde;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSpielerAmZug(Spieler spieler) {
|
|
|
|
this.spielerAmZug = spieler;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// @Overrides
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2023-10-14 19:15:04 +02:00
|
|
|
String text = "\n";
|
|
|
|
String header = "Systemausgabe--------------------------------\n";
|
|
|
|
String footer = "---------------------------------------------\n";
|
|
|
|
text += header;
|
|
|
|
text += "Runde: " + getRunde() + "\n";
|
|
|
|
text += "Gestartet : " + (istSpielGestartet() ? "Ja " : "Nein ") + "\n";
|
|
|
|
text += "Beendet: " + (istSpielBeendet() ? "Ja" : "Nein") + "\n";
|
|
|
|
text += "Spieler am Zug: "
|
|
|
|
+ (this.spielerAmZug == null ? "Noch keine Spieler vorhanden" : this.spielerAmZug.getName()) + "\n";
|
|
|
|
if (this.spieler.size() == 0) {
|
|
|
|
text += "Noch keine Spieler vorhanden \n";
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < this.spieler.size(); i++) {
|
|
|
|
text += "Spieler " + (i + 1) + ": " + this.spieler.get(i + 1).getName() + " ("
|
|
|
|
+ this.spieler.get(i + 1).getGeschlecht() + ")" + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
text += footer;
|
|
|
|
return text;
|
2023-10-11 11:04:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// öffentliche Methodes
|
|
|
|
/*--------------------------------------------------------*/
|
2023-10-10 12:38:27 +02:00
|
|
|
|
|
|
|
public void addSpieler(String name, Geschlecht geschlecht) {
|
2023-10-10 14:09:27 +02:00
|
|
|
int id = 1;
|
|
|
|
while (id_check[id - 1]) {
|
|
|
|
id++;
|
|
|
|
}
|
2023-10-14 19:15:04 +02:00
|
|
|
id_check[id - 1] = true;
|
2023-10-10 14:09:27 +02:00
|
|
|
Spieler temp = new Spieler(id, name, geschlecht);
|
|
|
|
this.spieler.put(id, temp);
|
2023-10-14 19:15:04 +02:00
|
|
|
System.out.println(this.spieler.get(id));
|
2023-10-10 14:09:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void removeSpieler(int id_spieler) {
|
|
|
|
this.spieler.remove(id_spieler);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[] getAlleSpieler() {
|
2023-10-10 15:22:09 +02:00
|
|
|
String[] spieler_text = new String[this.spieler.size()];
|
2023-10-15 10:13:40 +02:00
|
|
|
for (int i = 0; i < this.spieler.size(); i++) {
|
|
|
|
spieler_text[i] = this.spieler.get(i + 1).toString();
|
2023-10-10 14:09:27 +02:00
|
|
|
}
|
2023-10-10 15:22:09 +02:00
|
|
|
return spieler_text;
|
2023-10-10 12:38:27 +02:00
|
|
|
}
|
|
|
|
|
2023-10-10 14:16:24 +02:00
|
|
|
public void starteSpiel() {
|
2023-10-12 08:51:24 +02:00
|
|
|
// sing genügend Spieler angelegt?
|
|
|
|
if (this.spieler.size() >= 3 && this.spieler.size() <= 6) {
|
|
|
|
this.istGestartet = true;
|
|
|
|
} else {
|
|
|
|
System.out.println("Es fehlen " + (3 - this.spieler.size()) + " spieler");
|
|
|
|
}
|
|
|
|
|
2023-10-10 14:16:24 +02:00
|
|
|
// Gameloop?
|
|
|
|
}
|
2023-10-10 14:09:27 +02:00
|
|
|
|
2023-10-10 15:30:47 +02:00
|
|
|
public String[] getSpielerAmZug() {
|
2023-10-11 11:15:39 +02:00
|
|
|
return new String[1];
|
2023-10-10 15:30:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean istSpielGestartet() {
|
|
|
|
return this.istGestartet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean istSpielBeendet() {
|
|
|
|
return this.istBeendet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[][] getBlock() {
|
|
|
|
return new String[0][0];
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getGewinner() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRunde() {
|
|
|
|
return this.runde;
|
|
|
|
}
|
|
|
|
|
2023-10-11 11:04:46 +02:00
|
|
|
public void mischen() {
|
2023-10-10 15:30:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void austeilen() {
|
|
|
|
|
2023-10-12 08:51:24 +02:00
|
|
|
// Spieler 1 bekommt karten
|
|
|
|
|
|
|
|
// Spieler 2 bekommt Karten
|
|
|
|
// ...
|
|
|
|
|
|
|
|
// letzer Spieler bekommt Karten
|
|
|
|
|
2023-10-10 15:30:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ausspielen(int idKarte) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void vorhersagen(int stiche) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-10-11 11:04:46 +02:00
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
// Hilfsmethoden (privat)
|
|
|
|
/*--------------------------------------------------------*/
|
|
|
|
|
2023-10-12 08:51:24 +02:00
|
|
|
private Stich[] erstelleStiche(int runde) {
|
|
|
|
return new Stich[runde];
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ermittleGewinner(Stich stich) {
|
|
|
|
stich.getKarten();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void spieler() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-10-10 14:16:24 +02:00
|
|
|
}
|