|
|
|
@@ -1,4 +1,5 @@
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
public class Raumschiff {
|
|
|
|
|
private int photonentorpedoAnzahl;
|
|
|
|
@@ -15,15 +16,14 @@ public class Raumschiff {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Raumschiff(int photonentorpedoAnzahl, int energieversorgungInProzent, int schildeInProzent, int huelleInProzent, int lebenserhaltungssystemeInProzent, int androidenAnzahl, String schiffsname, ArrayList<Ladung> ladungsverzeichnis) {
|
|
|
|
|
this.photonentorpedoAnzahl = photonentorpedoAnzahl;
|
|
|
|
|
this.energieversorgungInProzent = energieversorgungInProzent;
|
|
|
|
|
this.schildeInProzent = schildeInProzent;
|
|
|
|
|
this.huelleInProzent = huelleInProzent;
|
|
|
|
|
this.lebenserhaltungssystemeInProzent = lebenserhaltungssystemeInProzent;
|
|
|
|
|
this.androidenAnzahl = androidenAnzahl;
|
|
|
|
|
this.schiffsname = schiffsname;
|
|
|
|
|
this.ladungsverzeichnis = ladungsverzeichnis;
|
|
|
|
|
public Raumschiff(int photonentorpedoAnzahl, int energieversorgungInProzent, int schildeInProzent, int huelleInProzent, int lebenserhaltungssystemeInProzent, int androidenAnzahl, String schiffsname) {
|
|
|
|
|
this.setPhotonentorpedoAnzahl(photonentorpedoAnzahl);
|
|
|
|
|
this.setEnergieversorgungInProzent(energieversorgungInProzent);
|
|
|
|
|
this.setSchildeInProzent(schildeInProzent);
|
|
|
|
|
this.setHuelleInProzent(huelleInProzent);
|
|
|
|
|
this.setLebenserhaltungssystemeInProzent(lebenserhaltungssystemeInProzent);
|
|
|
|
|
this.setAndroidenAnzahl(androidenAnzahl);
|
|
|
|
|
this.setSchiffsname(schiffsname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getPhotonentorpedoAnzahl() {
|
|
|
|
@@ -87,30 +87,146 @@ public class Raumschiff {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void photonentorpedoSchiessen(Raumschiff r) {
|
|
|
|
|
//TODO
|
|
|
|
|
if (this.getPhotonentorpedoAnzahl() == 0) {
|
|
|
|
|
nachrichtAnAlle("-=*Click*=-");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.setPhotonentorpedoAnzahl(this.getPhotonentorpedoAnzahl()-1);
|
|
|
|
|
nachrichtAnAlle("Photonentorpedo abgeschossen");
|
|
|
|
|
treffer(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void phaserkanoneSchiessen(Raumschiff r) {
|
|
|
|
|
//TODO
|
|
|
|
|
if (this.getEnergieversorgungInProzent() < 50) {
|
|
|
|
|
nachrichtAnAlle("-=*Click*=-");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.setEnergieversorgungInProzent(this.getEnergieversorgungInProzent()-50);
|
|
|
|
|
nachrichtAnAlle("Phaserkanone abgeschossen");
|
|
|
|
|
treffer(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treffer(Raumschiff r) {
|
|
|
|
|
//TODO
|
|
|
|
|
System.out.println(r.getSchiffsname() + "wurde getroffen!");
|
|
|
|
|
|
|
|
|
|
//wenn Schilde vollständig zerstört
|
|
|
|
|
if (r.getSchildeInProzent() < 1) {
|
|
|
|
|
|
|
|
|
|
if (r.getHuelleInProzent() < 1) {
|
|
|
|
|
r.setLebenserhaltungssystemeInProzent(0);
|
|
|
|
|
nachrichtAnAlle("Lebenserhaltungssysteme von Raumschiff " + r.schiffsname + "vernichtet");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//Hülle um 50 Prozent abbauen
|
|
|
|
|
r.setHuelleInProzent(r.getHuelleInProzent() - 50);
|
|
|
|
|
//Energieversorgung um 50 Prozent abbauen
|
|
|
|
|
r.setEnergieversorgungInProzent(r.getEnergieversorgungInProzent() - 50);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//Schilde um 50 Prozent schwächen
|
|
|
|
|
r.setSchildeInProzent(r.getSchildeInProzent()-50);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void nachrichtAnAlle(String message) {
|
|
|
|
|
//TODO
|
|
|
|
|
broadcastKommunikator.add(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ArrayList<String> eintraegeLogbuchZurueckgeben() {
|
|
|
|
|
//TODO
|
|
|
|
|
return null;
|
|
|
|
|
return broadcastKommunikator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void photonentorpedosLaden(int anzahlTorpedos) {
|
|
|
|
|
//TODO
|
|
|
|
|
if (this.ladungPhotonentorpedosAnzahl() == 0) {
|
|
|
|
|
System.out.println("Keine Photonentorpedos gefunden!");
|
|
|
|
|
nachrichtAnAlle("=*Click*=-");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void reparaturDurchfuehren(boolean schutzschilde, boolean energieversorgung, boolean schiffshuell)
|
|
|
|
|
else {
|
|
|
|
|
//wenn Photonentorpedos mehr als in Ladung verfügbar, alle verfügbaren laden
|
|
|
|
|
if (anzahlTorpedos > this.ladungPhotonentorpedosAnzahl())
|
|
|
|
|
anzahlTorpedos = this.ladungPhotonentorpedosAnzahl();
|
|
|
|
|
|
|
|
|
|
System.out.println(anzahlTorpedos + "Photonentorpedo(s) eingesetzt");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void reparaturDurchfuehren(boolean schutzschilde, boolean energieversorgung, boolean schiffshuelle, int anzahlDroiden) {
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
int zufallszahl = random.nextInt(100);
|
|
|
|
|
int anzahlTrue = 0;
|
|
|
|
|
|
|
|
|
|
if (schutzschilde) {
|
|
|
|
|
anzahlTrue += 1;
|
|
|
|
|
}
|
|
|
|
|
else if (energieversorgung) {
|
|
|
|
|
anzahlTrue += 1;
|
|
|
|
|
}
|
|
|
|
|
else if (schiffshuelle) {
|
|
|
|
|
anzahlTrue += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int reparaturErg = (zufallszahl * anzahlDroiden) / anzahlTrue;
|
|
|
|
|
|
|
|
|
|
if (schutzschilde) {
|
|
|
|
|
this.setSchildeInProzent(this.getSchildeInProzent() + reparaturErg);
|
|
|
|
|
}
|
|
|
|
|
else if (energieversorgung) {
|
|
|
|
|
this.setEnergieversorgungInProzent(this.getEnergieversorgungInProzent() + reparaturErg);
|
|
|
|
|
}
|
|
|
|
|
else if (schiffshuelle) {
|
|
|
|
|
this.setHuelleInProzent(this.getHuelleInProzent() + reparaturErg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void zustandRaumschiff() {
|
|
|
|
|
System.out.println("Schiffsname: " + this.schiffsname);
|
|
|
|
|
System.out.println("photonentorpedoAnzahl: " + this.photonentorpedoAnzahl);
|
|
|
|
|
System.out.println("energieversorgungInProzent: " + this.energieversorgungInProzent);
|
|
|
|
|
System.out.println("schildeInProzent: " + this.schildeInProzent);
|
|
|
|
|
System.out.println("huelleInProzent: " + this.huelleInProzent);
|
|
|
|
|
System.out.println("lebenserhaltungssystemeInProzent: " + this.lebenserhaltungssystemeInProzent);
|
|
|
|
|
System.out.println("androidenAnzahl: " + this.androidenAnzahl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ladungsverzeichnisAusgeben() {
|
|
|
|
|
System.out.println("Ladungen des Raumschiffs " + this.schiffsname);
|
|
|
|
|
System.out.println("============================================");
|
|
|
|
|
for (Ladung ladung:this.ladungsverzeichnis) {
|
|
|
|
|
System.out.println("Ladungsbezeichnung: " + ladung.getBezeichnung());
|
|
|
|
|
System.out.println("Menge: " + ladung.getMenge());
|
|
|
|
|
System.out.println("============================================");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ladungsverzeichnisAufraeumen() {
|
|
|
|
|
ladungsverzeichnis.removeIf(ladung -> ladung.getMenge() == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int ladungPhotonentorpedosAnzahl() {
|
|
|
|
|
int anzahl = 0;
|
|
|
|
|
for (Ladung ladung:this.ladungsverzeichnis) {
|
|
|
|
|
if (ladung.getBezeichnung().equalsIgnoreCase("photonentorpedos")) anzahl += ladung.getMenge();
|
|
|
|
|
}
|
|
|
|
|
return anzahl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ladungPhotonentorpedoVermindern(int anzahl) {
|
|
|
|
|
int tempToRemove;
|
|
|
|
|
for (Ladung ladung:this.ladungsverzeichnis) {
|
|
|
|
|
if (ladung.getBezeichnung().equalsIgnoreCase("photonentorpedos") && anzahl > 0) {
|
|
|
|
|
if (ladung.getMenge() < anzahl) {
|
|
|
|
|
tempToRemove = ladung.getMenge();
|
|
|
|
|
anzahl -= tempToRemove;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tempToRemove = ladung.getMenge();
|
|
|
|
|
}
|
|
|
|
|
ladung.setMenge(ladung.getMenge()-tempToRemove);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|