530 lines
30 KiB
Java
530 lines
30 KiB
Java
package at.reisinger;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
|
|
public class Battle {
|
|
|
|
private User player1, player2;
|
|
private int scorePlayer1, scorePlayer2, id;
|
|
private Cards deckPlayer1, deckPlayer2, deckPlayer1Init, deckPlayer2Init;
|
|
private Card spielfeldCardPlayer1, spielfeldCardPlayer2;
|
|
private ArrayList<String> log = new ArrayList<String>();
|
|
|
|
|
|
/**
|
|
* Erstellt ein neues Battle
|
|
* @param player1 Player 1 Obj
|
|
* @param player2 Player 2 Obj
|
|
* @param scorePlayer1 Score PLayer 1
|
|
* @param scorePlayer2 Score player 2
|
|
* @param deckPlayer1 Deck Player 1
|
|
* @param deckPlayer2 Deck Player 2
|
|
*/
|
|
public Battle(int id, User player1, User player2, int scorePlayer1, int scorePlayer2, Cards deckPlayer1, Cards deckPlayer2) {
|
|
this.id = id;
|
|
this.player1 = player1;
|
|
this.player2 = player2;
|
|
this.scorePlayer1 = scorePlayer1;
|
|
this.scorePlayer2 = scorePlayer2;
|
|
this.deckPlayer1 = deckPlayer1;
|
|
this.deckPlayer2 = deckPlayer2;
|
|
this.deckPlayer1Init = deckPlayer1;
|
|
this.deckPlayer2Init = deckPlayer2;
|
|
this.spielfeldCardPlayer1 = null;
|
|
this.spielfeldCardPlayer2 = null;
|
|
}
|
|
|
|
/**
|
|
* Erstellt ein neues Battle, im zustand offenes battle
|
|
* @param id
|
|
* @param player1
|
|
* @param deckPlayer1
|
|
*/
|
|
public Battle(int id, User player1, Cards deckPlayer1){
|
|
this.id = id;
|
|
this.player1 = player1;
|
|
this.deckPlayer1 = deckPlayer1;
|
|
this.scorePlayer1 = 100;
|
|
this.scorePlayer2 = 100;
|
|
this.deckPlayer2 = null;
|
|
this.deckPlayer1Init = deckPlayer1;
|
|
this.deckPlayer2Init = null;
|
|
this.spielfeldCardPlayer1 = null;
|
|
this.spielfeldCardPlayer2 = null;
|
|
}
|
|
|
|
/**
|
|
* Startet einen Kampf zw den beiden Playern
|
|
* @return true bei erfolg, sonst false
|
|
*/
|
|
public boolean doFight(){
|
|
System.out.println("DAS IS DAS BATTTTLLLLLLLEEEEEEEEEE FIIIIIGHT!");
|
|
System.out.println(player1.getName() + " |vs|" + player2.getName());
|
|
System.out.println(deckPlayer1.getCards().toString()+ " |vs| " + deckPlayer2.getCards().toString());
|
|
|
|
if(deckPlayer1.getCards().size() == 4 && deckPlayer2.getCards().size() == 4) {
|
|
//SHUFFLE DECK
|
|
ArrayList<Card> d1 = deckPlayer1.getCards();
|
|
ArrayList<Card> d2 = deckPlayer2.getCards();
|
|
Collections.shuffle(d1);
|
|
Collections.shuffle(d2);
|
|
deckPlayer1.setCards(d1);
|
|
deckPlayer1.setCards(d2);
|
|
|
|
//Runden
|
|
int maxroundcount = 100, counter = 0, counter2 = 0;
|
|
while(counter<maxroundcount) {
|
|
counter++;
|
|
counter2++;
|
|
if(counter2 < d1.size()-1 && counter2 < d2.size()-1){
|
|
counter2 = 0;
|
|
}
|
|
System.out.println("Runde: " + counter);
|
|
System.out.println("deck 1 size: " + d1.size() + " Deck 2 size: " + d2.size());
|
|
Card c1 = d1.get(counter2);
|
|
Card c2 = d2.get(counter2);
|
|
System.out.println("Card 1: " + c1.getElementTyp() + c1.getCardType() + "\nCard 2: " + c2.getElementTyp() + c2.getCardType());
|
|
if (d1.size() > 0 && d2.size() > 0 && counter<=maxroundcount) {
|
|
//GLEICHER TYP Monster
|
|
if (!c1.getCardType().name().toUpperCase().equals("SPELL") && !c2.getCardType().name().toUpperCase().equals("SPELL")) {
|
|
System.out.println("Same Monster");
|
|
//Check ob eine der beiden Carten ein Dragon ist
|
|
if ((c1.getCardType().name().toUpperCase().equals("DRANGON") && !c2.getCardType().name().toUpperCase().equals("DRANGON") || (!c1.getCardType().name().toUpperCase().equals("DRANGON") && c2.getCardType().name().toUpperCase().equals("DRANGON")))) {
|
|
//Eine der Karten is Dragon
|
|
System.out.println("Eine ist ein dragon");
|
|
Card dragon = null;
|
|
int dragonOwner = 0;
|
|
if (c1.getCardType().name().toUpperCase().equals("DRAGON")) {
|
|
dragon = c1;
|
|
dragonOwner = 1;
|
|
} else if (c2.getCardType().name().toUpperCase().equals("DRAGON")) {
|
|
dragon = c2;
|
|
dragonOwner = 2;
|
|
} else {
|
|
System.out.println("KEIN DRAGON GEFUNDEN");
|
|
return false;
|
|
}
|
|
if ((c1.getCardType().name().toUpperCase().equals("GOBLIN") && !c2.getCardType().name().toUpperCase().equals("GOBLIN") || (!c1.getCardType().name().toUpperCase().equals("GOBLIN") && c2.getCardType().name().toUpperCase().equals("GOBLIN")))) {
|
|
//Eine der Karten ist Goblin
|
|
System.out.println("Andere ist ein goblin");
|
|
Card goblin = null;
|
|
if (c1.getCardType().name().toUpperCase().equals("GOBLIN")) {
|
|
goblin = c1;
|
|
} else if (c2.getCardType().name().toUpperCase().equals("GOBLIN")) {
|
|
goblin = c2;
|
|
} else {
|
|
System.out.println("KEIN GOBLIN GEFUNDEN");
|
|
return false;
|
|
}
|
|
if (dragon.getDamage() > goblin.getDamage()) {
|
|
//Drache ist stärker
|
|
if (dragonOwner == 1) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
} else if (dragonOwner == 2) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer1 -= 5;
|
|
this.scorePlayer2 += 3;
|
|
}
|
|
log.add("Player " + dragonOwner + " gewinnt!\nDrache ist stärker! Drache: " + dragon.getDamage() + " vs Goblin: " + goblin.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else {
|
|
System.out.println("DRAW: Drache zu schwach um anzugreifen und GOBLIN zu feige.");
|
|
}
|
|
} else if ((c1.getCardType().name().toUpperCase().equals("ELF") && c1.getElementTyp().name().toUpperCase().equals("FIRE") && !c2.getCardType().name().toUpperCase().equals("ELF") || (!c1.getCardType().name().toUpperCase().equals("ELF") && c2.getElementTyp().name().toUpperCase().equals("FIRE") && c2.getCardType().name().toUpperCase().equals("ELF")))) {
|
|
//Eine der Karten ist der Fire Elf die andere Karte ist der drache
|
|
System.out.println("Andere ist ein elf");
|
|
Card fireelf = null;
|
|
if (dragonOwner == 1) {
|
|
fireelf = c2;
|
|
} else if (dragonOwner == 2) {
|
|
fireelf = c1;
|
|
}
|
|
|
|
if (fireelf.getDamage() > dragon.getDamage()) {
|
|
//Fireelf ist stärker
|
|
if (dragonOwner == 1) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
} else if (dragonOwner == 2) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer2 -= 5;
|
|
this.scorePlayer1 += 3;
|
|
}
|
|
log.add("Player " + dragonOwner + " gewinnt!\nWizzard ist stärker! Drache: " + dragon.getDamage() + " vs FireElves: " + fireelf.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
//Sonst nix tun, weil der drache den elf ned angreifen kann
|
|
} else {
|
|
if (c1.getDamage() > c2.getDamage()) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
log.add("Player 1 gewinnt!\n" + c1.getElementTyp() + c1.getCardType() + " ist stärker! " + c1.getElementTyp() + c1.getCardType() + ": " + c1.getDamage() + " vs " + c2.getElementTyp() + c2.getCardType() + ": " + c2.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else if (c1.getDamage() < c2.getDamage()) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
log.add("Player 2 gewinnt!\n" + c2.getElementTyp() + c2.getCardType() + " ist stärker! " + c2.getElementTyp() + c2.getCardType() + ": " + c2.getDamage() + " vs " + c1.getElementTyp() + c1.getCardType() + ": " + c1.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
}
|
|
|
|
//Checkt ob eine der beiden karten ein wizzard ist und der andere ein ork
|
|
} else if ((c1.getCardType().name().toUpperCase().equals("WIZZARD") && c2.getCardType().name().toUpperCase().equals("ORK") || (c2.getCardType().name().toUpperCase().equals("WIZZARD") && c1.getCardType().name().toUpperCase().equals("ORK")))) {
|
|
System.out.println("Eine wizzard Andere ist ein ork");
|
|
Card wizzard = null;
|
|
Card ork = null;
|
|
int wizzardOwner = 0;
|
|
if (c1.getCardType().name().toUpperCase().equals("WIZZARD")) {
|
|
wizzardOwner = 1;
|
|
wizzard = c1;
|
|
ork = c2;
|
|
} else if (c1.getCardType().name().toUpperCase().equals("WIZZARD")) {
|
|
wizzardOwner = 2;
|
|
wizzard = c2;
|
|
ork = c1;
|
|
}
|
|
if (wizzard.getDamage() > ork.getDamage()) {
|
|
if (wizzardOwner == 1) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
} else if (wizzardOwner == 2) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
}
|
|
|
|
log.add("Player " + wizzardOwner + " gewinnt!\nWizzard ist stärker! Wizzard: " + wizzard.getDamage() + " vs Ork: " + ork.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
//Sonst nix tun, weil der ork dem wizzard keinen schaden machen kann
|
|
} else {
|
|
//PURE MONSTER
|
|
if (c1.getDamage() > c2.getDamage()) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
log.add("Player 1 gewinnt!\n" + c1.getElementTyp() + c1.getCardType() + " ist stärker! " + c1.getElementTyp() + c1.getCardType() + ": " + c1.getDamage() + " vs " + c2.getElementTyp() + c2.getCardType() + ": " + c2.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else if (c1.getDamage() < c2.getDamage()) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
log.add("Player 2 gewinnt!\n" + c2.getElementTyp() + c2.getCardType() + " ist stärker! " + c2.getElementTyp() + c2.getCardType() + ": " + c2.getDamage() + " vs " + c1.getElementTyp() + c1.getCardType() + ": " + c1.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
//sonst nix weil bei gleichen damage --> draw
|
|
}
|
|
} else {//PURE SPELL & mixed
|
|
double damagePlayer1 = -1, damagePlayer2 = -1;
|
|
|
|
if (c1.getCardType().name().toUpperCase().equals("KNIGHT") || c2.getCardType().name().toUpperCase().equals("KNIGHT")) {
|
|
//Mixed mit "Spezialeffekt" KNIGHT
|
|
System.out.println("Spell und knight");
|
|
Card knight = null, other = null;
|
|
int knightOwner = 0;
|
|
if (c1.getCardType().name().toUpperCase().equals("KNIGHT")) {
|
|
knight = c1;
|
|
other = c2;
|
|
knightOwner = 1;
|
|
} else if (c2.getCardType().name().toUpperCase().equals("KNIGHT")) {
|
|
knight = c2;
|
|
other = c1;
|
|
knightOwner = 2;
|
|
}
|
|
double damageKnight = -1, damageOther = -1;
|
|
if (other.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//tot
|
|
damageKnight = 0;
|
|
damageOther = other.getDamage();
|
|
} else if (other.getElementTyp().name().toUpperCase().equals("FIRE") && knight.getElementTyp().name().equals("REGULAR")) {
|
|
//not effective
|
|
damageKnight = knight.getDamage() / 2;
|
|
//effective
|
|
damageOther = other.getDamage() * 2;
|
|
} else if (other.getElementTyp().name().toUpperCase().equals("FIRE") && knight.getElementTyp().name().equals("FIRE")) {
|
|
//no effect
|
|
damageKnight = knight.getDamage();
|
|
//no effect
|
|
damageOther = other.getDamage();
|
|
} else if (other.getElementTyp().name().toUpperCase().equals("FIRE") && knight.getElementTyp().name().equals("WATER")) {
|
|
//effective
|
|
damageKnight = knight.getDamage() * 2;
|
|
//not effective
|
|
damageOther = other.getDamage() / 2;
|
|
} else if (other.getElementTyp().name().toUpperCase().equals("REGULAR") && knight.getElementTyp().name().equals("REGULAR")) {
|
|
//no effect
|
|
damageKnight = knight.getDamage();
|
|
//no effect
|
|
damageOther = other.getDamage();
|
|
} else if (other.getElementTyp().name().toUpperCase().equals("REGULAR") && knight.getElementTyp().name().equals("FIRE")) {
|
|
//effective
|
|
damageKnight = knight.getDamage() * 2;
|
|
//not effective
|
|
damageOther = other.getDamage() / 2;
|
|
} else if (other.getElementTyp().name().toUpperCase().equals("REGULAR") && knight.getElementTyp().name().equals("WATER")) {
|
|
//not effective
|
|
damageKnight = knight.getDamage() / 2;
|
|
//effective
|
|
damageOther = other.getDamage() * 2;
|
|
}
|
|
if (damageKnight > damageOther) {
|
|
if (knightOwner == 1) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
log.add("Player 1 gewinnt!\n" + c1.getElementTyp() + c1.getCardType() + " ist stärker! " + c1.getElementTyp() + c1.getCardType() + ": " + damageKnight + " vs " + c2.getElementTyp() + c2.getCardType() + ": " + damageOther + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else if (knightOwner == 2) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
log.add("Player 2 gewinnt!\n" + c2.getElementTyp() + c2.getCardType() + " ist stärker! " + c2.getElementTyp() + c2.getCardType() + ": " + damageKnight + " vs " + c1.getElementTyp() + c1.getCardType() + ": " + damageOther + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
} else if (damageKnight < damageOther) {
|
|
if (knightOwner == 2) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
log.add("Player 1 gewinnt!\n" + c1.getElementTyp() + c1.getCardType() + " ist stärker! " + c1.getElementTyp() + c1.getCardType() + ": " + damageOther + " vs " + c2.getElementTyp() + c2.getCardType() + ": " + damageKnight + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else if (knightOwner == 1) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
log.add("Player 2 gewinnt!\n" + c2.getElementTyp() + c2.getCardType() + " ist stärker! " + c2.getElementTyp() + c2.getCardType() + ": " + damageOther + " vs " + c1.getElementTyp() + c1.getCardType() + ": " + damageKnight + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
}
|
|
} else if (c1.getCardType().name().toUpperCase().equals("KRAKEN") || c2.getCardType().name().toUpperCase().equals("KRAKEN")) {
|
|
//Mixed mit "Spezialeffekt" KRAKEN
|
|
if (c1.getCardType().name().toUpperCase().equals("KRAKEN")) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
log.add("Player 1 gewinnt!\n" + c1.getElementTyp() + c1.getCardType() + " ist stärker! " + c1.getElementTyp() + c1.getCardType() + ": " + c1.getDamage() + " vs " + c2.getElementTyp() + c2.getCardType() + ": 0\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else if (c2.getCardType().name().toUpperCase().equals("KRAKEN")) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
log.add("Player 2 gewinnt!\n" + c2.getElementTyp() + c2.getCardType() + " ist stärker! " + c2.getElementTyp() + c2.getCardType() + ": " + c2.getDamage() + " vs " + c1.getElementTyp() + c1.getCardType() + ": 0\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
} else {
|
|
////PURE SPELL & mixed mit elementen
|
|
System.out.println("Spell und mixed mit elementen");
|
|
//Player 1 Damage berechnen
|
|
if (c1.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
if (c2.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
//effective
|
|
damagePlayer1 = c1.getDamage() * 2;
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//not effective
|
|
damagePlayer1 = c1.getDamage() / 2;
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
//no effect
|
|
damagePlayer1 = c1.getDamage();
|
|
}
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
if (c2.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
//effective
|
|
damagePlayer1 = c1.getDamage() * 2;
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//no effect
|
|
damagePlayer1 = c1.getDamage();
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
//not effective
|
|
damagePlayer1 = c1.getDamage() / 2;
|
|
}
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
if (c2.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//effective
|
|
damagePlayer1 = c1.getDamage() * 2;
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
//not effective
|
|
damagePlayer1 = c1.getDamage() / 2;
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
//no effect
|
|
damagePlayer1 = c1.getDamage();
|
|
}
|
|
}
|
|
//P2 damage
|
|
if (c2.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
if (c1.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
//effective
|
|
damagePlayer2 = c2.getDamage() * 2;
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//not effective
|
|
damagePlayer2 = c2.getDamage() / 2;
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
//no effect
|
|
damagePlayer2 = c2.getDamage();
|
|
}
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
if (c1.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
//effective
|
|
damagePlayer2 = c2.getDamage() * 2;
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//no effect
|
|
damagePlayer2 = c2.getDamage();
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
//not effective
|
|
damagePlayer2 = c2.getDamage() / 2;
|
|
}
|
|
} else if (c2.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
if (c1.getElementTyp().name().toUpperCase().equals("WATER")) {
|
|
//effective
|
|
damagePlayer2 = c2.getDamage() * 2;
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("FIRE")) {
|
|
//not effective
|
|
damagePlayer2 = c2.getDamage() / 2;
|
|
} else if (c1.getElementTyp().name().toUpperCase().equals("REGULAR")) {
|
|
//no effect
|
|
damagePlayer2 = c2.getDamage();
|
|
}
|
|
}
|
|
|
|
if (damagePlayer1 > -1 && damagePlayer2 > -1) {
|
|
if (damagePlayer1 > damagePlayer2) {
|
|
d1.add(c2);
|
|
d2.remove(c2);
|
|
this.scorePlayer1 += 3;
|
|
this.scorePlayer2 -= 5;
|
|
log.add("Player 1 gewinnt!\n" + c1.getElementTyp() + c1.getCardType() + " ist stärker! " + c1.getElementTyp() + c1.getCardType() + ": " + damagePlayer1 + " vs " + c2.getElementTyp() + c2.getCardType() + ": " + damagePlayer2 + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
} else if (damagePlayer2 > damagePlayer1) {
|
|
d2.add(c1);
|
|
d1.remove(c1);
|
|
this.scorePlayer2 += 3;
|
|
this.scorePlayer1 -= 5;
|
|
log.add("Player 2 gewinnt!\n" + c2.getElementTyp() + c2.getCardType() + " ist stärker! " + c2.getElementTyp() + c2.getCardType() + ": " + damagePlayer2 + " vs " + c1.getElementTyp() + c1.getCardType() + ": " + damagePlayer1 + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: " + scorePlayer2);
|
|
}
|
|
} else {
|
|
System.out.println("Damage konnte nicht berechnet werden");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.deckPlayer1 = new Cards(d1);
|
|
this.deckPlayer2 = new Cards(d2);
|
|
}else{
|
|
System.out.println("Einer der Spieler hat zu wenige Karten im Deck");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Vergleicht 2 Card Typen von 2 Karten
|
|
* @param c1 Card 1
|
|
* @param c2 Card 2
|
|
* @return True wenn die CardType übereinstimmt, sonst false
|
|
*/
|
|
private boolean sameCardType(Card c1, Card c2){
|
|
if(c1.getCardType().name().equals(c2.getCardType().name())){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public ArrayList<String> getLog() {
|
|
return log;
|
|
}
|
|
|
|
|
|
public int getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(int id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public User getPlayer1() {
|
|
return player1;
|
|
}
|
|
|
|
public void setPlayer1(User player1) {
|
|
this.player1 = player1;
|
|
}
|
|
|
|
public User getPlayer2() {
|
|
return player2;
|
|
}
|
|
|
|
public void setPlayer2(User player2) {
|
|
this.player2 = player2;
|
|
}
|
|
|
|
public int getScorePlayer1() {
|
|
return scorePlayer1;
|
|
}
|
|
|
|
public void setScorePlayer1(int scorePlayer1) {
|
|
this.scorePlayer1 = scorePlayer1;
|
|
|
|
}
|
|
|
|
public int getScorePlayer2() {
|
|
return scorePlayer2;
|
|
}
|
|
|
|
public void setScorePlayer2(int scorePlayer2) {
|
|
this.scorePlayer2 = scorePlayer2;
|
|
}
|
|
|
|
public Cards getDeckPlayer1() {
|
|
return deckPlayer1;
|
|
}
|
|
|
|
public void setDeckPlayer1(Cards deckPlayer1) {
|
|
this.deckPlayer1 = deckPlayer1;
|
|
this.deckPlayer1Init = deckPlayer1;
|
|
}
|
|
|
|
public Cards getDeckPlayer2() {
|
|
return deckPlayer2;
|
|
}
|
|
|
|
public void setDeckPlayer2(Cards deckPlayer2) {
|
|
this.deckPlayer2 = deckPlayer2;
|
|
this.deckPlayer2Init = deckPlayer2;
|
|
}
|
|
|
|
public Card getSpielfeldCardPlayer1() {
|
|
return spielfeldCardPlayer1;
|
|
}
|
|
|
|
public void setSpielfeldCardPlayer1(Card spielfeldCardPlayer1) {
|
|
this.spielfeldCardPlayer1 = spielfeldCardPlayer1;
|
|
}
|
|
|
|
public Card getSpielfeldCardPlayer2() {
|
|
return spielfeldCardPlayer2;
|
|
}
|
|
|
|
public void setSpielfeldCardPlayer2(Card spielfeldCardPlayer2) {
|
|
this.spielfeldCardPlayer2 = spielfeldCardPlayer2;
|
|
}
|
|
|
|
public Cards getDeckPlayer1Init() {
|
|
return deckPlayer1Init;
|
|
}
|
|
|
|
public Cards getDeckPlayer2Init() {
|
|
return deckPlayer2Init;
|
|
}
|
|
}
|