123 lines
3.0 KiB
Java
123 lines
3.0 KiB
Java
/*
|
|
============================================================
|
|
This is the "Kartenstapel" file from Author: Philipp Kotte
|
|
written on: 05 / 10 / 2023 at: 23:42
|
|
============================================================
|
|
*/
|
|
package Domain;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
import Domain.Enums.Kartenfarbe;
|
|
import Domain.Karten.*;
|
|
|
|
public class Kartenstapel {
|
|
|
|
/*------------------------------------------*/
|
|
// statische Konstanten
|
|
/*------------------------------------------*/
|
|
|
|
/*------------------------------------------*/
|
|
// statische Attribute(zB. zähler)
|
|
/*------------------------------------------*/
|
|
|
|
/*------------------------------------------*/
|
|
// Attribute jedes Objektes
|
|
/*------------------------------------------*/
|
|
private boolean[][] belegung = {
|
|
{ false, false, false, false, false, false, false, false, false, false, false, false, false, false, false },
|
|
{ false, false, false, false, false, false, false, false, false, false, false, false, false, false, false },
|
|
{ false, false, false, false, false, false, false, false, false, false, false, false, false, false, false },
|
|
{ false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }
|
|
};
|
|
|
|
private Karte[] kartenStapel = new Karte[60];
|
|
|
|
/*------------------------------------------*/
|
|
// Konstruktoren (default und spezifische)
|
|
/*------------------------------------------*/
|
|
|
|
public Kartenstapel() {
|
|
mischen();
|
|
|
|
}
|
|
|
|
/*------------------------------------------*/
|
|
// statische Methoden
|
|
/*------------------------------------------*/
|
|
|
|
/*------------------------------------------*/
|
|
// Getter und Setter
|
|
/*------------------------------------------*/
|
|
|
|
/**
|
|
* Ausgabe des ersten Elements des Stapels.
|
|
*
|
|
* @return erstes Element
|
|
*/
|
|
public Karte getObersteKarte() {
|
|
return kartenStapel[0];
|
|
}
|
|
|
|
/**
|
|
* Ausgabe der Stapelgroesse.
|
|
*
|
|
* @return laenge des Kartenstapels-Arrays
|
|
*/
|
|
public int getAnzahlKarten() {
|
|
return kartenStapel.length;
|
|
}
|
|
|
|
/*------------------------------------------*/
|
|
// @Overrides
|
|
/*------------------------------------------*/
|
|
|
|
/*------------------------------------------*/
|
|
// öffentliche Methoden
|
|
/*------------------------------------------*/
|
|
|
|
public void mischen() {
|
|
|
|
}
|
|
|
|
/*------------------------------------------*/
|
|
// Hilfsmethoden (privat)
|
|
/*------------------------------------------*/
|
|
|
|
private void Kartenverteilung() {
|
|
|
|
Random r = new Random();
|
|
List<Karte> karten = new ArrayList<>();
|
|
while (karten.size() < 60) {
|
|
int high = 4;
|
|
int low = 1;
|
|
int ultra_high = 15;
|
|
int x = r.nextInt(high - low) + low;
|
|
int y = r.nextInt(ultra_high - low) + low;
|
|
if (!belegung[x - 1][y - 1]) {
|
|
if (y == 1) {
|
|
karten.add(new Narrenkarte(x * y));
|
|
} else if (y == 15) {
|
|
karten.add(new Magierkarte(x * y));
|
|
} else {
|
|
if (x == 1) {
|
|
karten.add(new Zahlenkarte(Kartenfarbe.ZWERG, y));
|
|
} else if (x == 2) {
|
|
|
|
} else if (x == 3) {
|
|
|
|
} else if (x == 4) {
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
}
|