Battle Bugfixes

This commit is contained in:
Georg Reisinger 2020-12-31 04:26:32 +01:00
parent 13bec601db
commit 93cbd8aae2
2 changed files with 322 additions and 322 deletions

View File

@ -73,338 +73,346 @@ public class Battle {
deckPlayer1.setCards(d2); deckPlayer1.setCards(d2);
//Runden //Runden
int maxroundcount = 100; int maxroundcount = 100, counter = 0, counter2 = 0;
for(int i = 0; d1.size()>i && d2.size()>i && i<maxroundcount; i++) { while(counter<maxroundcount) {
System.out.println("Runde: " + i); counter++;
Card c1 = d1.get(i); counter2++;
Card c2 = d2.get(i); if(counter2 < d1.size()-1 && counter2 < d2.size()-1){
System.out.println("Card 1: " + c1.getElementTyp()+c1.getCardType() + "\nCard 2: "+c2.getElementTyp()+c2.getCardType()); counter2 = 0;
//GLEICHER TYP Monster }
if (!c1.getCardType().name().toUpperCase().equals("SPELL") && !c2.getCardType().name().toUpperCase().equals("SPELL")) { System.out.println("Runde: " + counter);
System.out.println("Same Monster"); System.out.println("deck 1 size: " + d1.size() + " Deck 2 size: " + d2.size());
//Check ob eine der beiden Carten ein Dragon ist Card c1 = d1.get(counter2);
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")))) { Card c2 = d2.get(counter2);
//Eine der Karten is Dragon System.out.println("Card 1: " + c1.getElementTyp() + c1.getCardType() + "\nCard 2: " + c2.getElementTyp() + c2.getCardType());
System.out.println("Eine ist ein dragon"); if (d1.size() > 0 && d2.size() > 0 && counter<=maxroundcount) {
Card dragon = null; //GLEICHER TYP Monster
int dragonOwner = 0; if (!c1.getCardType().name().toUpperCase().equals("SPELL") && !c2.getCardType().name().toUpperCase().equals("SPELL")) {
if (c1.getCardType().name().toUpperCase().equals("DRAGON")) { System.out.println("Same Monster");
dragon = c1; //Check ob eine der beiden Carten ein Dragon ist
dragonOwner = 1; 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")))) {
} else if (c2.getCardType().name().toUpperCase().equals("DRAGON")) { //Eine der Karten is Dragon
dragon = c2; System.out.println("Eine ist ein dragon");
dragonOwner = 2; Card dragon = null;
} else { int dragonOwner = 0;
System.out.println("KEIN DRAGON GEFUNDEN"); if (c1.getCardType().name().toUpperCase().equals("DRAGON")) {
return false; dragon = c1;
} dragonOwner = 1;
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")))) { } else if (c2.getCardType().name().toUpperCase().equals("DRAGON")) {
//Eine der Karten ist Goblin dragon = c2;
System.out.println("Andere ist ein goblin"); dragonOwner = 2;
Card goblin = null;
if (c1.getCardType().name().toUpperCase().equals("GOBLIN")) {
goblin = c1;
} else if (c2.getCardType().name().toUpperCase().equals("GOBLIN")) {
goblin = c2;
} else { } else {
System.out.println("KEIN GOBLIN GEFUNDEN"); System.out.println("KEIN DRAGON GEFUNDEN");
return false; return false;
} }
if (dragon.getDamage() > goblin.getDamage()) { 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")))) {
//Drache ist stärker //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) { 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); d1.add(c2);
d2.remove(c2); d2.remove(c2);
this.scorePlayer1 += 3; this.scorePlayer1 += 3;
this.scorePlayer2 -= 5; this.scorePlayer2 -= 5;
} else if (dragonOwner == 2) { 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); d2.add(c1);
d1.remove(c1); d1.remove(c1);
this.scorePlayer1 -= 5; this.scorePlayer2 += 3;
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);
} }
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()) { //Checkt ob eine der beiden karten ein wizzard ist und der andere ein ork
//Fireelf ist stärker } 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")))) {
if (dragonOwner == 1) { System.out.println("Eine wizzard Andere ist ein ork");
d2.add(c1); Card wizzard = null;
d1.remove(c1); Card ork = null;
this.scorePlayer2 += 3; int wizzardOwner = 0;
this.scorePlayer1 -= 5; if (c1.getCardType().name().toUpperCase().equals("WIZZARD")) {
} else if (dragonOwner == 2) { 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); d1.add(c2);
d2.remove(c2); d2.remove(c2);
this.scorePlayer2 -= 5; this.scorePlayer1 += 3;
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 "+dragonOwner+" gewinnt!\nWizzard ist stärker! Drache: " + dragon.getDamage() + " vs FireElves: " + fireelf.getDamage() + "\nPlayer 1 score: " + scorePlayer1 + "\nPlayer 2 score: "+ scorePlayer2);
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 drache den elf ned angreifen kann //Sonst nix tun, weil der ork dem wizzard keinen schaden machen kann
}else{ } else {
if(c1.getDamage() > c2.getDamage()){ //PURE MONSTER
if (c1.getDamage() > c2.getDamage()) {
d1.add(c2); d1.add(c2);
d2.remove(c2); d2.remove(c2);
this.scorePlayer1 += 3; this.scorePlayer1 += 3;
this.scorePlayer2 -= 5; 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); 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()){ } else if (c1.getDamage() < c2.getDamage()) {
d2.add(c1); d2.add(c1);
d1.remove(c1); d1.remove(c1);
this.scorePlayer2 += 3; this.scorePlayer2 += 3;
this.scorePlayer1 -= 5; 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); 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;
//Checkt ob eine der beiden karten ein wizzard ist und der andere ein ork if (c1.getCardType().name().toUpperCase().equals("KNIGHT") || c2.getCardType().name().toUpperCase().equals("KNIGHT")) {
} 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")))){ //Mixed mit "Spezialeffekt" KNIGHT
System.out.println("Eine wizzard Andere ist ein ork"); System.out.println("Spell und knight");
Card wizzard = null; Card knight = null, other = null;
Card ork = null; int knightOwner = 0;
int wizzardOwner = 0; if (c1.getCardType().name().toUpperCase().equals("KNIGHT")) {
if(c1.getCardType().name().toUpperCase().equals("WIZZARD")){ knight = c1;
wizzardOwner = 1; other = c2;
wizzard = c1; knightOwner = 1;
ork = c2; } else if (c2.getCardType().name().toUpperCase().equals("KNIGHT")) {
}else if(c1.getCardType().name().toUpperCase().equals("WIZZARD")){ knight = c2;
wizzardOwner = 2; other = c1;
wizzard = c2; knightOwner = 2;
ork = c1; }
} double damageKnight = -1, damageOther = -1;
if(wizzard.getDamage() > ork.getDamage()){ if (other.getElementTyp().name().toUpperCase().equals("WATER")) {
if(wizzardOwner == 1){ //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); d1.add(c2);
d2.remove(c2); d2.remove(c2);
this.scorePlayer1 += 3; this.scorePlayer1 += 3;
this.scorePlayer2 -= 5; this.scorePlayer2 -= 5;
}else if (wizzardOwner == 2){ 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); d2.add(c1);
d1.remove(c1); d1.remove(c1);
this.scorePlayer2 += 3; this.scorePlayer2 += 3;
this.scorePlayer1 -= 5; 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);
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 { } else {
System.out.println("Damage konnte nicht berechnet werden"); ////PURE SPELL & mixed mit elementen
return false; 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;
}
} }
} }
} }

View File

@ -410,42 +410,34 @@ public class Response {
if(new DBConnection().addBattleLog(openBattle.getId()+"", openBattle.getPlayer1().getName(), openBattle.getPlayer2().getName(), openBattle.getScorePlayer1()+"", openBattle.getScorePlayer2() +"")){ if(new DBConnection().addBattleLog(openBattle.getId()+"", openBattle.getPlayer1().getName(), openBattle.getPlayer2().getName(), openBattle.getScorePlayer1()+"", openBattle.getScorePlayer2() +"")){
if(new DBConnection().delDeck(openBattle.getPlayer1().getCredentials().getUsername()) && new DBConnection().delDeck(openBattle.getPlayer2().getCredentials().getUsername())) { if(new DBConnection().delDeck(openBattle.getPlayer1().getCredentials().getUsername()) && new DBConnection().delDeck(openBattle.getPlayer2().getCredentials().getUsername())) {
//DEL OLD DECK CARDS //DEL OLD DECK CARDS
ArrayList<String> oldDeck1 = new ArrayList<String>();
for (Card ca: openBattle.getDeckPlayer1Init().getCards()){ for (Card ca: openBattle.getDeckPlayer1Init().getCards()){
if(!new DBConnection().delUserCard(openBattle.getPlayer1().getCredentials().getUsername(), ca.getName())){ oldDeck1.add(ca.getName());
sendResponse("Error Deleting user card1: " + ca.getName(), "500");
}
} }
ArrayList<String> oldDeck2 = new ArrayList<String>();
for (Card ca: openBattle.getDeckPlayer2Init().getCards()){ for (Card ca: openBattle.getDeckPlayer2Init().getCards()){
if(!new DBConnection().delUserCard(openBattle.getPlayer2().getCredentials().getUsername(), ca.getName())){ oldDeck2.add(ca.getName());
sendResponse("Error Deleting user card2: " + ca.getName(), "500");
}
} }
//DEL NEW CARDS IF EXIST //DEL NEW CARDS IF EXIST
Cards player1cards = new DBConnection().getCards(openBattle.getPlayer1().getCredentials().getUsername()); Cards player1cards = new DBConnection().getCards(openBattle.getPlayer1().getCredentials().getUsername());
ArrayList<String> player1CardsList = new ArrayList<String>(); for(Card ca:openBattle.getDeckPlayer1().getCards()){
for(Card ca:player1cards.getCards()){ oldDeck1.add(ca.getName());
player1CardsList.add(ca.getName());
} }
if(player1cards.getCards() != null && !player1cards.getCards().isEmpty()) { if(player1cards.getCards() != null && !player1cards.getCards().isEmpty()) {
for (Card ca : openBattle.getDeckPlayer1().getCards()) { for (String ca : oldDeck1) {
if (player1CardsList.contains(ca.getName())){ if(!new DBConnection().delUserCard(openBattle.getPlayer1().getCredentials().getUsername(), ca)){
if(!new DBConnection().delUserCard(openBattle.getPlayer1().getCredentials().getUsername(), ca.getName())){ sendResponse("Error Deleting user card1: " + ca, "500");
sendResponse("Error Deleting user card1: " + ca.getName(), "500");
}
} }
} }
} }
Cards player2cards = new DBConnection().getCards(openBattle.getPlayer2().getCredentials().getUsername()); Cards player2cards = new DBConnection().getCards(openBattle.getPlayer2().getCredentials().getUsername());
ArrayList<String> player2CardsList = new ArrayList<String>(); for(Card ca:openBattle.getDeckPlayer2().getCards()){
for(Card ca:player2cards.getCards()){ oldDeck2.add(ca.getName());
player2CardsList.add(ca.getName());
} }
if(player2cards.getCards() != null && !player2cards.getCards().isEmpty()) { if(player2cards.getCards() != null && !player2cards.getCards().isEmpty()) {
for (Card ca : openBattle.getDeckPlayer2().getCards()) { for (String ca : oldDeck2) {
if (player2CardsList.contains(ca.getName())){ if(!new DBConnection().delUserCard(openBattle.getPlayer2().getCredentials().getUsername(), ca)){
if(!new DBConnection().delUserCard(openBattle.getPlayer2().getCredentials().getUsername(), ca.getName())){ sendResponse("Error Deleting user card2: " + ca, "500");
sendResponse("Error Deleting user card2: " + ca.getName(), "500");
}
} }
} }
} }