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,12 +73,19 @@ public class Battle {
deckPlayer1.setCards(d2);
//Runden
int maxroundcount = 100;
for(int i = 0; d1.size()>i && d2.size()>i && i<maxroundcount; i++) {
System.out.println("Runde: " + i);
Card c1 = d1.get(i);
Card c2 = d2.get(i);
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");
@ -409,6 +416,7 @@ public class Battle {
}
}
}
}
this.deckPlayer1 = new Cards(d1);
this.deckPlayer2 = new Cards(d2);
}else{

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().delDeck(openBattle.getPlayer1().getCredentials().getUsername()) && new DBConnection().delDeck(openBattle.getPlayer2().getCredentials().getUsername())) {
//DEL OLD DECK CARDS
ArrayList<String> oldDeck1 = new ArrayList<String>();
for (Card ca: openBattle.getDeckPlayer1Init().getCards()){
if(!new DBConnection().delUserCard(openBattle.getPlayer1().getCredentials().getUsername(), ca.getName())){
sendResponse("Error Deleting user card1: " + ca.getName(), "500");
}
oldDeck1.add(ca.getName());
}
ArrayList<String> oldDeck2 = new ArrayList<String>();
for (Card ca: openBattle.getDeckPlayer2Init().getCards()){
if(!new DBConnection().delUserCard(openBattle.getPlayer2().getCredentials().getUsername(), ca.getName())){
sendResponse("Error Deleting user card2: " + ca.getName(), "500");
}
oldDeck2.add(ca.getName());
}
//DEL NEW CARDS IF EXIST
Cards player1cards = new DBConnection().getCards(openBattle.getPlayer1().getCredentials().getUsername());
ArrayList<String> player1CardsList = new ArrayList<String>();
for(Card ca:player1cards.getCards()){
player1CardsList.add(ca.getName());
for(Card ca:openBattle.getDeckPlayer1().getCards()){
oldDeck1.add(ca.getName());
}
if(player1cards.getCards() != null && !player1cards.getCards().isEmpty()) {
for (Card ca : openBattle.getDeckPlayer1().getCards()) {
if (player1CardsList.contains(ca.getName())){
if(!new DBConnection().delUserCard(openBattle.getPlayer1().getCredentials().getUsername(), ca.getName())){
sendResponse("Error Deleting user card1: " + ca.getName(), "500");
}
for (String ca : oldDeck1) {
if(!new DBConnection().delUserCard(openBattle.getPlayer1().getCredentials().getUsername(), ca)){
sendResponse("Error Deleting user card1: " + ca, "500");
}
}
}
Cards player2cards = new DBConnection().getCards(openBattle.getPlayer2().getCredentials().getUsername());
ArrayList<String> player2CardsList = new ArrayList<String>();
for(Card ca:player2cards.getCards()){
player2CardsList.add(ca.getName());
for(Card ca:openBattle.getDeckPlayer2().getCards()){
oldDeck2.add(ca.getName());
}
if(player2cards.getCards() != null && !player2cards.getCards().isEmpty()) {
for (Card ca : openBattle.getDeckPlayer2().getCards()) {
if (player2CardsList.contains(ca.getName())){
if(!new DBConnection().delUserCard(openBattle.getPlayer2().getCredentials().getUsername(), ca.getName())){
sendResponse("Error Deleting user card2: " + ca.getName(), "500");
}
for (String ca : oldDeck2) {
if(!new DBConnection().delUserCard(openBattle.getPlayer2().getCredentials().getUsername(), ca)){
sendResponse("Error Deleting user card2: " + ca, "500");
}
}
}